Skip to content

Rust Microcontroller experiments using the Embassy framework

License

Notifications You must be signed in to change notification settings

SillyFreak/embassy-experiments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Embassy Experiments

This repo contains example programs for the STM32F3 Discovery board - which uses the STM32F303VC MCU - utilizing the Embassy embedded Rust framework.

Prerequisites

To run these programs, you'll need a nightly rust toolchain for the thumbv7em-none-eabihf target:

rustup install nightly
rustup target add thumbv7em-none-eabihf

In addition, cargo run will try to flash the discovery board using probe-rs, so you'll need that as well. Alternatively, you can only cargo build the programs and flash them via other means, or adapt the runner option in .cargo/config.toml.

Also, you will naturally need an STM32F3 Discovery board.

Usage

Several programs are contained in src/bin/. For example, to run the hello.rs program, execute this command:

cargo run --release --bin hello

The programs are based on and inspired by Embassy's stm32f3 and stm32f4 examples.

These programs work:

  • hello: prints "Hello World!" to the debugging interface, that's it. See this example

  • blinky: blinks the eight LEDs of the discovery board at different frequencies, by multiplexing eight independent tasks. See this example

  • button: waits for button presses and releases using interrupts and controls an LED accordingly. See this example

  • pwm: controls an LED's brightness by varying its duty cycle. See this example

  • adc: reads a voltage from one of the ADC capable pins periodically. Raw ADC values (0-4095) are shown, no voltage calibration is performed. See this example

    This example has been fixed by anothersteven2. See their repo for a more complete example with voltage calibration and temperature reading.

  • channel: uses a Channel to communicate between two async tasks. If the receiver interval is larger than the sender interval, this will demonstrate backpressure.

  • signal: uses a Signal to communicate between two async tasks. If the receiver interval is larger than the sender interval, this will demonstrate overwriting without backpressure.

  • spi: uses SPI (and GPIO) to control an ADXL345 accelerometer (the hardware choice is because I had it laying around). SCLK .. PB3, SDI .. PB5, SDO .. PB4, nCS .. PD6.

These don't:

  • uart: when TX and RX (PE0, PE1) are connected, should echo the UART output. However, no data is received and printed (I have not yet explicitly tested if the data is sent correctly). See this example

About

Rust Microcontroller experiments using the Embassy framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages