2024-04-04 11:35:41 +02:00
|
|
|
### ESP32-C3 RTIC template
|
|
|
|
This crate showcases a simple RTIC application for the ESP32-C3.
|
|
|
|
|
|
|
|
## Prerequisites
|
|
|
|
|
|
|
|
# Nightly Rust
|
|
|
|
The ESP32-C3 HAL requires a nightly build of Rust.
|
|
|
|
Following the example of the (Espressif no_std book)[https://docs.esp-rs.org/no_std-training/02_2_software.html], we use this specific build:
|
|
|
|
```rustup toolchain install nightly-2023-11-14 --component rust-src --target riscv32imc-unknown-none-elf```
|
|
|
|
|
|
|
|
# Espressif toolchain
|
|
|
|
|
|
|
|
This crate uses the most convenient option in ``cargo-espflash`` and ``espflash``
|
|
|
|
```cargo install cargo-espflash espflash```
|
|
|
|
|
|
|
|
## Running the crate
|
|
|
|
|
2024-09-29 06:21:14 +02:00
|
|
|
Uncomment the
|
|
|
|
|
|
|
|
```runner = "espflash flash --monitor"```
|
|
|
|
|
|
|
|
line in ``.cargo/config.toml``
|
|
|
|
|
|
|
|
and comment out (or remove)
|
|
|
|
|
|
|
|
```runner = "./runner.sh"```
|
|
|
|
|
|
|
|
Now, running
|
|
|
|
|
2024-04-04 11:35:41 +02:00
|
|
|
```cargo run --example sw_and_hw --features=riscv-esp32c3-backend (--release)```
|
|
|
|
|
2024-09-29 06:21:14 +02:00
|
|
|
in the root of this crate should do the trick.
|
2024-04-04 11:35:41 +02:00
|
|
|
|
|
|
|
# Expected behavior
|
2024-09-29 06:21:14 +02:00
|
|
|
The example ``sw_and_hw``
|
2024-04-04 11:35:41 +02:00
|
|
|
- Prints ``init``
|
|
|
|
- Enters a high prio task
|
|
|
|
- During the execution of the high prio task, the button should be non-functional
|
|
|
|
- Pends a low prio task
|
|
|
|
- Exits the high prio task
|
|
|
|
- Enters the low prio task
|
|
|
|
- During the execution of the low prio task, the button should be functional.
|
|
|
|
- Exits the low prio task
|
|
|
|
- Prints ``idle``
|
|
|
|
|
2024-09-29 06:21:14 +02:00
|
|
|
The example ``monotonic``
|
|
|
|
- Prints ``init``
|
|
|
|
- Spawns the ``foo``, ``bar``, ``baz`` tasks (because of hardware interrupt latency dispatch, the order here may vary).
|
|
|
|
- Each task prints ``hello from $TASK`` on entry
|
|
|
|
- The tasks wait for 1, 2, 3 seconds respectively
|
|
|
|
- Once the wait period is over, each task exits printing ``bye from $TASK`` (now in the proper order).
|