Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notes for esp32c3 & embassy #834

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions esp32c3-hal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Please refer to the documentation for more information.
- [The Rust Programming Language](https://doc.rust-lang.org/book/)
- [The Embedded Rust Book](https://docs.rust-embedded.org/book/index.html)
- [The Rust on ESP Book](https://esp-rs.github.io/book/)
- [Embassy-rs Support](examples/README-embassy.md)

## Getting Started

Expand All @@ -35,6 +36,8 @@ The compilation target for this device is officially supported by the mainline R
rustup target add riscv32imc-unknown-none-elf
```

##

## License

Licensed under either of:
Expand Down
27 changes: 27 additions & 0 deletions esp32c3-hal/examples/README-embassy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

## Embassy Examples

* 😁 Decision Point1: choose systick vs timg0
- systick is for ARM cortex-m, the esp-hal provides a simple 24-bit clear on write decrementing wrap-on-zero counter for os-scheduling sed for basic countdown timer, interrpt generation on reaching zero. Better for ARM, etc. compatibility.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did you get this from?

I'd suggest familiarizing yourself with the ESP32 lineup and their peripherals. I don't think any ARM-based ESP32 exists, the C3 certainly isn't ARM. The SysTimer peripheral, that this feature coopts as the timebase is a 52 bit timer peripheral present in most ESP32s (it's there at least in the S2, S3, C3, and maybe more).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bugadani - see cunninghams law.

I'm attempting to sift through the code and understand it, write up documentation with my guesses and hopefully get them corrected either in github or matrix.

I assumed (incorrectly) the systick was put in to provide compatibility for embassy-rs which seems stm32 centric, that's just what I was able to find/infer from searching & asking chatgpt. the documentation in this area is sparse.

I was trying to say that systick might be a better choice than timg0 if multiple architectures are important - because apparently I must choose one, and only one timer with no explanation why one is better or different than the other.

```
cargo run --example embassy_hello_world --features "embassy","embassy-time-systick"
```


- timg0 is a peripheral esp32-c3 / espressif specific, has more features compared to systick, configurable frequency, has input capture, output compare, can trigger other peripherals or DMA, Suitable for more complex timing requirements like waveform generation, event timing, pulse counting, etc. there is also a timg1
```
cargo run --example embassy_hello_world --features "embassy","embassy-time-timg0"
```

### examples/embassy_hello_world.rs

examples/embassy_i2c.rs
examples/embassy_i2s_read.rs
examples/embassy_i2s_sound.rs
examples/embassy_rmt_rx.rs
examples/embassy_rmt_tx.rs
examples/embassy_serial.rs
examples/embassy_spi.rs
examples/embassy_wait.rs