An experiment to make a PWM controller in embedded Rust for the STM32F407 Discovery board.
A release build is preferred for the optimizations. Run
cargo build --release
Note that the build may not fit in the processor if the debug config is used.
Setup OpenOCD and run
openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -l /tmp/openocd.log
To run with semihosting,
gdb-multiarch -q target/thumbv7em-none-eabihf/release/stm32f4-hello --command=.gdbinit
and run c
to continue.
This project is a chance for me to learn more about embedded Rust. Here are some helpful resources
- Embedded Rust Page high-level overview of embedded rust.
- STM32F4xx HAL Docs an abstracted interface to use STM32F4xx features and devices.
- STM32F4xx HAL Examples playing with these examples are a good place to start.
- RTIC Book RTIC framework for programming with hardware interrupts.
- heapless embedded-friendly data structures that don't require dynamic memory allocation.
- light-cli heapless CLI parser. I used this to make a simple CLI to control the device over serial TTL.
- micromath embedded-friendly math functions library. I used this for LUT generation.
- STM32F407 Reference Manual complete information of how to use the processor and its peripheral devices. I referred to it when learning how to configure DMA for USART. I also use it for debugging, looking up what the status registers mean.
- STM32F4 Discovery Board Manual reference for external devices that come with the development board. I referred to this when finding which GPIO blocks are connected to the LEDs. I also discovered that one pin gave filtered results because it was connected to a bypass cap.
- UART using DMA useful for understanding serial using DMA and the tradeoffs of the various configurations.