99 Commits

Author SHA1 Message Date
Sergio Gasquez Arcos
b90ea68931
Improve examples documentation (#533)
* docs: 📝 Doccument embassy I2C example

* docs: 📝 Improve documentation of embassy SPI example

* docs: 📝 Doccument AES and RSA example

* docs: 📝 Update changelog
2023-05-12 13:46:56 +02:00
Jesse Braham
b43516682e
Add async support to the I2C driver (#519)
* Small refactor to extract functions for setting up reads/writes

* Implement async capabilities for `I2C` driver

* Add async I2C examples for each supported chip

* Update CHANGELOG
2023-05-10 10:38:16 -07:00
liebman
905c0af154
implement fetching the RTC timer value in milliseconds and mircroseconds (#476)
* implement fetching the rtc timer value in miliseconds and mircroseconds

* fmt cleanup

* add rtc_time examples

* get_time_raw/esp32: delay 1us between time update checks like esp-idf

* cargo fmt
2023-05-08 07:59:37 -07:00
Scott Mabin
1731169112
Async serial write (#510)
* Initial async_{write|flush} implementations

- ESP32C3 + UART0 example

* Support UART1 & UART2

* Add examples for all chips

* reduce number of wakers depending on uart count
2023-05-05 09:05:15 -07:00
onsdagens
fe84e74151
Adding priority based interrupt preemption (#448)
* Software interrupt support added, not sure if the code is good

* Added support for remaining SW interrupts

* Added support for remaining SW interrupts

* Added support for remaining SW interrupts

* Added support for esp32c2, esp32s2, esp32s3

* Added support for esp32c2, esp32s2, esp32s3

* Added support for esp32c2, esp32s2, esp32s3

* Added support for esp32c2, esp32s2, esp32s3

* Software interrupt example for esp32c3

* Added support for esp32c2, esp32s2, esp32s3

* Software interrupt example for esp32c3

* prio based preemption only, vector table reverted

* prio based preemption only, vector table reverted

* fixed a rare bug causing misaligned memory accesses

* fixed a rare bug causing misaligned memory accesses

* fixed a rare bug causing misaligned memory accesses

* fixed rare bug causing misaligned memory access when emulating atomics

* fixed a rare bug causing misaligned memory accesses

* fixed a rare bug causing misaligned memory accesses

* broke something

* broke something

* fixed alignment bug

* Tentative: added support for interrupt preemption without involving the rt

* Added feature enabling priority based interrupt preemption

* Fixed failed merge

* Tagged preemption helpers with inline always

* Disable interrupts before restoring context to avoid ruining it

* Fix max priority edge case

* Fix broken merge

* Added examples for the remaining RISC-V ESPs

* Update esp-hal-common/src/interrupt/riscv.rs

Co-authored-by: sethp <seth.pellegrino@gmail.com>

* Update esp32c2-hal/examples/interrupt_preemption.rs

Co-authored-by: sethp <seth.pellegrino@gmail.com>

* Update esp-hal-common/src/interrupt/riscv.rs

Co-authored-by: sethp <seth.pellegrino@gmail.com>

* Example comments courtesy of @sethp

* Reverted irrelevant changes, raised high prio interrupt to max prio

* Rolling back an irrelevant change

* Rolling back an irrelevant change

* Update esp-hal-common/src/interrupt/riscv.rs

Co-authored-by: Scott Mabin <scott@mabez.dev>

* Update esp-hal-common/src/interrupt/riscv.rs

Co-authored-by: Scott Mabin <scott@mabez.dev>

* Moved imports to avoid warnings, moved functions to ram, moved interrupt disable to before prio threshold is restored

* Added preemption for the ESP32C6

* Moved helper functions into the relevant modules, changed threshold for ESP32C6 to machine mode one

* ESP32C6 Threshold register changed to machine mode one, corrected threshold set.

---------

Co-authored-by: sethp <seth.pellegrino@gmail.com>
Co-authored-by: Scott Mabin <scott@mabez.dev>
2023-05-05 11:40:54 +01:00
Jesse Braham
6fdc1ea5de
Implement embedded_hal_nb::serial::* traits for UsbSerialJtag (#498)
* Implement `embedded-hal-nb` serial traits for `UsbSerialJtag`

* Fix warnings in `usb_serial_jtag` examples
2023-05-02 12:14:15 +01:00
Jesse Braham
304e0116d7 Remove unnecessary generic from UsbSerialJtag driver 2023-04-24 09:19:49 -07:00
Björn Quentin
e01a569c69
Merge pull request #474 from BryanKadzban/add-open-drain
Let users configure the LEDC output_pin as open-drain
2023-04-20 17:00:33 +02:00
Björn Quentin
ab79b142f7
Add DEBUG-ASSIST functionality (#484)
* Add DEBUG-ASSIST functionality

* Reformat `lib.rs`

* Reformat ESP32-C2 example
2023-04-20 07:38:55 -07:00
onsdagens
a0a47a4add Fixed comments 2023-04-18 13:48:01 +02:00
onsdagens
613136a5ef Fixed comments 2023-04-18 13:20:00 +02:00
Bryan Kadzban
9d85bc2ffe Fix ledc example to specify a push-pull output 2023-04-16 20:37:27 -07:00
onsdagens
3d3b71924b Added software interrupt API, examples for all of the MCUs 2023-04-14 18:53:49 +02:00
sreehari prasad
9ff3837537
rsa peripheral support (#467) 2023-04-11 11:58:10 +01:00
Juraj Sadel
40bf086a0c
Add PeripheralClockControl argument to timg, wdt, sha, usb-serial-jtag and uart constructors (#463)
* PeripheralClockControl timer

* Add PeripheralClockControl to timg, wdt, sha, usb-serial-jtag and uart

* ESP32 updated examples

* ESP32C2 updated examples

* ESP32C3 updated examples

* ESP32S2 updated examples

* ESP32S3 updated examples

* ESP32C6 updated examples

* cargo fmt
2023-03-31 09:51:34 +02:00
bjoernQ
ba75b151c3 Fix embassy_spi example 2023-03-22 09:06:37 +01:00
bjoernQ
6c7875afef Half-duplex SPI 2023-03-21 15:44:16 +01:00
Juraj Sadel
2e97c7b5c9 Disable SWDT in sha, systimer and aes C2/C3/C6 examples 2023-03-15 07:20:13 -07:00
Jesse Braham
a0b72bdfa5 Use latest PACs and make required changes 2023-03-14 06:23:58 -07:00
Jesse Braham
5747ddee14
Extract the esp-hal-smartled package (#429)
* Extract the `esp-hal-smartled` package

This (finally) eliminates the `esp_hal_common::utils` module!

* Remove all references to the old `smartled` feature from CI
2023-03-10 10:36:07 +00:00
Jesse Braham
39b4db0cf9 Add examples for the RNG peripheral for all supported devices 2023-02-28 07:58:38 -08:00
Jesse Braham
984b7fc042
Refactor chip-specific code into esp_hal_common::soc module (#412)
* Create an `soc` module with a submodule for each chip, move `peripherals` in

* Move the `cpu_control` module into `soc`

* Move the `efuse` module into `soc`

* Refactor type definitions from `gpio` module into `soc`

* Put all embassy-related files in a common directory

* Change visibility of `GpioPin` constructor
2023-02-28 07:49:41 -08:00
Björn Quentin
4e88e48bbe
Remove unnecessary rt crate dependencies (#391)
* Remove unnecessary `rt` crate dependencies

* Bump versions, update to latest released dependencies
2023-02-10 07:24:12 -08:00
Björn Quentin
ab9aeb2443 AnyPin 2023-02-08 14:31:54 +01:00
Scott Mabin
3f7181fece
Async SPI (#385)
* ground work for async dma (gdma only atm)

* Add async DMA (GDMA) - esp32c3/esp32c2

* Add Async SPI impl for esp32c3/c2

* Remove private modules from DMA

* add async spi example for esp32c3

* Switch to assoc wakers instead of a static array

* add support for esp32/esp32s2

* add support for esp32s3

* run fmt

* add c2 example, fix CI

* Remove redundant comments
2023-02-08 11:02:03 +00:00
Jesse Braham
c0eaa91a6f Fix examples after a bad rebase 2023-01-27 11:06:29 -08:00
Jesse Braham
cf270700e7
Use the new esp-riscv-rt package for RISC-V HALs (#365)
* Update PACs and modify `esp-hal-common` to use new `esp-riscv-rt` package

* Update `esp32c2-hal` and `esp32c3-hal` to use `esp-riscv-rt` as well

* Update all RISC-V examples to use `esp-riscv-rt`

* Update RISC-V trap frame handling according to review feedback
2023-01-27 10:49:38 -08:00
Scott Mabin
0eac22eba1
Async: GPIO (#333)
* Add `is_listening` to `Pin` trait

* Add `Wait` impl for Gpio Input

* Add GPIO wait example for C3

* Ensure correct bank is accessed in interrupt

* Add esp32c2 wait example

* Add esp32s3 wait example

* Add esp32s2 wait example

* Add esp32 wait example

* Run fmt

* Add example to cargo tomls

* Add top level docs for embassy examples

* Mention the higher MSRV for async in the README

---------

Co-authored-by: Jesse Braham <jesse@beta7.io>
2023-01-27 10:44:08 -08:00
mhead
586276fd34 aes accelerator implementation 2023-01-24 10:04:57 -08:00
Alex Bohm
1f6803776c
Initial TWAI Driver Implementation (#192)
* wip: initial implementation of transmission only.

* Moved TWAI to its own directory and added initial reception of packets.

* Added extended id transmit and receive.

* Added maybe better code for making packet filters.

* Fixed bug with ids and improved methods of copying data to the peripheral.

* Added some guards against Bus Off

* Added reception of remote frames.

* Clean up of comments, etc

* Updated TWAI naming and cleaned up example a bit.

* Updated bitselector to include better unpacking methods.

* Add embedded-can and limit initial TWAI implementation to esp32c3.

* Added embedded-can to esp32c3 twai example.

* Switched twai filter to using bytestrings.

Co-authored-by: dimi <dimi.polonski@gmail.com>

* Implemented new() for twai filters.

* Clean up TWAI docs and example.

* Fix filter constructors and add examples.

* pre driver PeripheralRef update.

* PeripheralRef/twai

* Format comments with nightly rustfmt.

* Add gpio PeripheralRef and use volatile for direct register access.

Co-authored-by: dimi <dimi.polonski@gmail.com>
2022-12-22 00:54:06 +00:00
Scott Mabin
452fde2c12
Peripheral ref/gpio (#323)
* Implement Peripheral for all GPIO pins

* Update i2c & i2s to use the new gpio peripherals ref

* gpio pref: usb

* gpio pref: pulse control (RMT)

* gpio pref: spi

* gpio pref: uart

* gpio pref: ledc

* gpio pref: mcpwm

* fixup smartleds to use new pulse controller traits

* dump msrv

* bump rust-version in cargo tomls
2022-12-19 14:40:29 +00:00
Jesse Braham
220f812625
Peripheral ref/sha (#312)
* Add SHA to list of peripherals to be created

* Refactor SHA peripheral to use PeripheralRef

* Update SHA examples to get them building again
2022-12-14 12:19:53 +00:00
Scott Mabin
248fb356f8
PeripheralRef init: uart (#272)
* Add the peripheral module plus some helper macros in preparation

* peripheral macro

* Add peripheral generation macro

* Fixes after rebase

* Update the signature of Peripherals::take

* syncronise hello world example

* fmt the entire repo

Co-authored-by: Jesse Braham <jesse@beta7.io>
2022-12-12 14:45:33 +00:00
Scott Mabin
0000d46ac5 Embassy init updates:
- Rename timg feature to timg0 to better refect which TG is being used
- Use the time_driver::TimerType in the signature of init to fix #268
- Update examples
- Fix CI features
- Add timg0 cfg to build.rs
2022-12-08 06:36:42 -08:00
Josh Weberruss
bc39cdae86 Add Rx and interrupts to UsbSerialJtag
Add non-blocking Write
2022-12-01 22:02:47 +11:00
Björn Quentin
bc4e180a1a
Merge pull request #280 from bjoernQ/gpio-refactoring
GPIO module refactoring
2022-11-30 08:15:13 +01:00
dimi
7a51433944 remove i2c::SetupError and make i2c::I2C::new infallible 2022-11-29 14:19:45 +01:00
bjoernQ
878bbc4c0c GPIO module refactoring 2022-11-29 12:03:04 +01:00
C2D
59d02f5f6e
Add SHA accelerator implementation (#257)
* Add untested basic SHA for esp-sX/cX chips

* Fix ptr type inconsistency for S2

* Add ESP32 impl & fix process_buffer latch issue

* Add debug example for SHA accelerator

* Clean up no-op buffer prints

* Test vector parity (on esp32s3)

* Checkpoint for converting to alignment helper

* Finish refactoring & additional parity tests on esp32s3

* Remove core_intrinsics requirement for now

* Fix case where (src.len() % 4) == 3

* Finish sha2 example with performance comparison (12-61x speedup)

* Refactor ESP32 to alignment helper & Clean up example

* Prevent out-of-bounds reads in ESP32 version

* Revert Cargo debug changes

* Remove cargo config.toml

* Clean up example

* Remove common/rust-toolchain & ignore in future

* Might as well use actual size_of const

* Remove SHA512/SHA384 for C2/C3

* Directly import nb::block! to remove unused import warning & fix c2 feature detect

* Remove stray newlines

* Fix esp32c2 having SHA256

* ESP32 also has SHA384

* Remove comments that don't have a purpose

* Clean up example & finish() handling

* Add examples & add ESP32 free()

* Update C2/C3 examples to show accurate algorithm used

* Fix busy check for ESP32

* Remove outdated TODO comment

* Update PAC for ESP3 and (actually) fix busy check

* Refactor ESP32 version to reduce search space

* Add debug printlns to sha example & clean up comments

* Fix ESP32 version, finally

Co-authored-by: ferris <ferris@devdroplets.com>
Co-authored-by: Jesse Braham <jesse@beta7.io>
2022-11-28 14:20:31 -08:00
icedrocket
177d278223
Add more trait re-exports to prelude module (#260)
* Add more trait re-exports to prelude module

* Don't expose usb_serial_jtag module

* Add missing system module re-exports
2022-11-23 07:24:47 -08:00
bjoernQ
4afa8fda92 Preliminary I2S Implementation 2022-11-17 08:24:43 -08:00
Scott Mabin
9064177e99
Initial embassy support (#225)
* wip: timg embassy driver

- read_raw on timg renamed to now()
- timg initialized and stored in static for use in the embassy driver
- timg sets alarm value
- untested whether alarms actually trigger

* TIMG timer driver for esp32, esp32s3

- Adds the timg timer block as a time driver for embassy
- Not enabled on the C3 as it only has one timer block, better to use
  systimer
- s2 example added but can't build due to atomic requirements in
  futures-core

* Add S2 atomic support with emulation, fixup embassy support for the S2

* Move executor & static-cell to dev deps. Make eha optional

* Add c2 support, run fmt

* Update to crates.io embassy releases

* Update eha

* update timg time driver to new trait

* Remove exception feature of esp-backtrace and use the user handler for backtracing

* Add async testing workflow

* Update systick example

* Fix S2 examples

* Update xtensa-toolchain

* set rustflags for s2 target

* Disable systick for esp32s2 until we can fix the noted issues

* review improvements

- Fix intr prio array being off by one
- emabssy time prio interrupt set to max prio
- use cfg instead of feature for systick detection

* Update example time delays
2022-11-09 08:04:38 -08:00
Björn Quentin
8bdf11b287
I2C Driver Refactoring (#233)
* I2C Driver Refactoring

* Improve I2C error handling and robustness
2022-11-09 06:34:55 -08:00
Juraj Sadel
f6ba237e76
ADC: Refactor, join S2 and S3 together and C2 and C3 as well (#245)
* ADC: Refactor, join S2 and S3 together and C2 and C3 as well

* S3: Update PAC version
2022-11-02 10:38:03 -07:00
Björn Quentin
9744d12484
SPI-DMA for ESP32 (#216)
* SPI-DMA for ESP32

* MSRV Fix
2022-10-20 09:12:31 -07:00
bjoernQ
9cb24bb79f Basic DMA for ESP32-C3 2022-10-13 10:14:51 -07:00
Jesse Braham
5054681ba3 Update to newest embedded-hal alpha and add embedded-hal-nb 2022-09-29 16:07:49 +02:00
Jesse Braham
d885054fd2 Use esp_println in favour of the Serial peripheral wherever possible 2022-09-28 13:09:06 -07:00
Juraj Sadel
0f9fdb7c15 RMT: Shouldn't be possible to assign pins multiple times into channel 2022-09-20 12:33:17 +02:00
Juraj Sadel
3ebfbc44c3 ADC: Add compile time check for using unconfigured PIN, add AdcPin wrapper around PIN 2022-09-13 08:41:04 +02:00