No description
Find a file
2024-05-02 16:07:19 -07:00
.cargo blinks the user LED on the Nucleo board. 2024-05-02 16:07:19 -07:00
src blinks the user LED on the Nucleo board. 2024-05-02 16:07:19 -07:00
.gitignore blinks the user LED on the Nucleo board. 2024-05-02 16:07:19 -07:00
build.rs blinks the user LED on the Nucleo board. 2024-05-02 16:07:19 -07:00
Cargo.toml blinks the user LED on the Nucleo board. 2024-05-02 16:07:19 -07:00
memory.x blinks the user LED on the Nucleo board. 2024-05-02 16:07:19 -07:00
openocd.cfg blinks the user LED on the Nucleo board. 2024-05-02 16:07:19 -07:00
openocd.gdb blinks the user LED on the Nucleo board. 2024-05-02 16:07:19 -07:00
README.md blinks the user LED on the Nucleo board. 2024-05-02 16:07:19 -07:00

TinFOC: a Rust-y Field-Oriented Control crate for STM32 MCUs

A crate that provides an FOC motor controller using STM32 Cortex microcontrollers.

Dependencies

The MCU I'm using is the STM32F302R8, and I'm using the [X-Nuclean IHM07M1] BLDC motor controller shield board that provides the actual power to the motor.

This requires the thumbv7em-none-eabihf Rust target:

rustup target add thumbv7em-none-eabihf

In order to connect to the microcontroller with a debugger (say, to load the program) on Ubuntu linux, you'll need to:

sudo apt install openocd gdb-multiarch

Running on hardware

Assuming you've plugged your board into your computer via USB:

  1. build TinFOC with cargo build
  2. connect to the board with openocd &
  3. start gdb: gdb-multiarch -q target/thumbv7em-none-eabihf/debug/tinfoc
  4. inside gdb, attach to openocd: target remote :3333
  5. inside gdb, load the program into the MCU's flash: load

Assuming that was successful, you can then enter continue in the gdb console, which will run the program on the hardware; you should see the LD2 LED start blinking green, on and off, every 2 seconds. If you disconnect the board from power and then reconnect, it will automatically run the program.

There are no doubt other ways to flash the board, and I'll update here when I adjust my flow; I'm a newb when it comes to this stuff.