A collection of small examples built with stm32f4xx_hal
. I also have another example collection for stm32f3xx_hal
.
You will find the follwoings in examples
:
timer_interrupt_1.rs
: Timer interrupt flips abool
. A LED gets flipped based on the bool in the main.timer_interrupt_2.rs
: Timer interrupt toggles a LED.gpio_interrupt_1.rs
: GPIO interrupts with one button.gpio_interrupt_2.rs
: GPIO interrupts with two buttons 1.gpio_interrupt_3.rs
: GPIO interrupts with two buttons 2.serial_1.rs
: Serial Echo.serial_interrupt_1.rs
: Serial Echo with interrupt.timer_counter_1.rs
: Pulse width reading with a timer. (Maxbotix Ultrasonic sensors demo)adc_1.rs
: ADC reading and PWM output example.adc_interrupt_1.rs
: ADC EOC End of Conversion Interrupt. An interrupt version ofadc_1.rs
.adc_interrupt_2.rs
: ADC External trigger. Injected Conversion Mode.rtfm_1.rs
: Real-Time Interrupt-driven Concurrency (RTIC) framework + BBQueue (SPSC, lockless, no_std, thread safe, queue) example.rtfm_2.rs
: Real-Time Interrupt-driven Concurrency (RTIC) framework example. LED toggle with Timer interrupt.rtfm_3.rs
: Real-Time Interrupt-driven Concurrency (RTIC) framework example. Software task scheduling + UART interrupt.
I am planning to add more.
Note I wrote these for Nucleo-F429ZI board which has a STM32F429 microcontroller. If you use a different microcontroller, you need to adjust the settings accordingly.
- Clone this repo.
$ git clone https://github.com/lonesometraveler/stm32f4xx-examples.git
-
If necessary, set a default target in
.cargo/config
and edit the memory region info inmemory.x
. -
Build the examples.
$ cargo build --examples
The config file for Cortex-Debug extension for VS Code is in .vscode
folder. If your board is Nucleo-F429ZI and you plan to use JLink, it's pretty much ready to go. Just specify an executable in .vscode/launch.json
.