diff options
| author | Milton Eduardo Sosa <31409391+snorkman88@users.noreply.github.com> | 2024-06-26 19:35:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-26 17:35:48 +0000 |
| commit | 624f643a976fc0676750de9c22d789115cba21c1 (patch) | |
| tree | 8431872969ec320d36a8f8f6f074cacab1de980c /examples/stm32f411_adc_and_mpsc_channel/README.md | |
| parent | 35891f4559cb2ec90128530ebd0ea74a65421b7a (diff) | |
Add example for STM32F411 with HW & SW tasks communicating via MPSC channel (#953)
* Add example with HW & SW tasks communicating via MPSC channel
* example: f411-adc-mpcsc: nit: typos
* example: f411-adc-mpsc: prefer text over picture
---------
Co-authored-by: Milton Eduardo Sosa <milton@Miltons-MacBook-Pro.local>
Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
Diffstat (limited to 'examples/stm32f411_adc_and_mpsc_channel/README.md')
| -rw-r--r-- | examples/stm32f411_adc_and_mpsc_channel/README.md | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/examples/stm32f411_adc_and_mpsc_channel/README.md b/examples/stm32f411_adc_and_mpsc_channel/README.md new file mode 100644 index 0000000..d7dc6f3 --- /dev/null +++ b/examples/stm32f411_adc_and_mpsc_channel/README.md @@ -0,0 +1,46 @@ +# STM32F411CEU6 ADC example +This example is a continuation of the **stm32f411_adc**. +In this variant, there are 3 tasks (1 HW & 2 SW) involved and communication between them by means of an MPSC channel. + +In the `#[init]` before spawning any task, an MPSC channel is created and split in its two parts. +Immediately after separating the `Receiver` and `Sender` the software task `printer_actor` is spawned and receives the `Receiver` end of the channel and starts listening. + +Then two clones of the `Sender` type are created. The first one is stored as Local resource for the HW task and the second, is passed as an argument when the `pinger` software task is spawned. + +## Hardware task bound to EXTI0: `gpio_interrupt_handler` +This task, + - Decreases the value of __delayval__ by 200 + - Takes a new sample from the ADC input connected on pin `PA1` + - Sends a message of type `Message::PotentiometerValue` to the printer task + - Clears the interrupt_pending_bit + +## Software task: `printer_actor` +This task makes use of the unused interrupt __SPI1__ as a dispatcher. Since it is an async fn, it ia constantly awaiting for incoming messages from other actors. +Depending on the type of message received, it prints something different. + +## Software task: `pinger` +This is just a simple task that sends ping every 25000 millis and uses __SPI2__ as a dispatcher. + +## How-to + +### Build +Run `cargo build --release` to compile the code. If you run it for the first time, it will take some time to download and compile dependencies. + +### Run +Install `probe-rs` and configure it using the [debugging extension for VScode](https://probe.rs/docs/tools/debugger/). + +The output should look like this: + +``` +INFO Printer actor received a PING from software task +INFO Current delay value 1900 +INFO Printer actor received a new PotentiometerValue: 607 from hardware task. + +INFO Current delay value 1800 +INFO Printer actor received a new PotentiometerValue: 1011 from hardware task. + +INFO Current delay value 1700 +INFO Printer actor received a new PotentiometerValue: 819 from hardware task. + +INFO Printer actor received a PING from software task +``` |
