163 Commits

Author SHA1 Message Date
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
Jesse Braham
d3969c3130 New releases for all HAL packages 2023-02-21 07:43:44 -08:00
bjoernQ
f385a7dfd2 Make sure to re-export xtensa-lx-rt 2023-02-13 10:09:20 +01: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
Scott Mabin
2b2df2dbbd
Preemptively add cfg's needed in upcoming releases for s2 (#371) 2023-01-31 11:21:07 +00: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
Jesse Braham
d03c267084 New releases for all HAL packages 2023-01-26 08:51:24 -08:00
mhead
586276fd34 aes accelerator implementation 2023-01-24 10:04:57 -08:00
Jesse Braham
832f9ef4d4
Refactor the clock module, provide ROM functions via linker scripts (#353)
* Refactor `clock` and `clocks_ll` into a common module

* Add a ROM function linker script to each HAL and provide some functions

* Use the provided ROM functions instead of transmuting addresses

* Fix CI workflow for ESP32-S2
2023-01-23 07:12:33 -08:00
Jesse Braham
d29c4b1dcf
Update a number of dependencies to get RISC-V HALs building again (#350)
* Update `riscv`, `riscv-rt` dependencies, plus PACs for RISC-V chips

* Update `riscv-atomic-emulation-trap` package

* Update the `embassy-executor` dev dependency to a newer version
2023-01-18 14:08:30 -08:00
liebman
ac206af656
pulse counter implementation (#328)
* start of pulse counter implementation

* implement interrupts
implement pcnt for esp32, esp32s2, and esp32s3

* implement pcnt for esp32s2

* fix esp32 PCNT signal names

* update PCNT register/fields for cleaned up PAC

* implement events/get_events (choosing what events interrupt)

* added pcnt example: simple encoder configuration

* restrict pcnt::channel::Channel::new() to super

* PcntPin -> PcntSignal
added range checks for thresholds and limits

* PcntSource is a better name I think

* handle error for PCNT Unit configure() in example

* update pac versions for status register change

* cargo fmt

* cargo fmt (examples)

* PcntSource now only stores the source id.
add a critical section to protect the ctrl & isr_en registers

* cargo fmt
2023-01-17 17:04:22 +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
bjoernQ
dc8963c0a8 Support ESP32-C2 with 26MHz Xtal 2022-12-13 05:15:10 -08: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
Jesse Braham
03d94a0ba2 New releases for all HALs 2022-12-12 01:29:49 -08: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
bjoernQ
4ab05e8923 Pass trap frame to CPU interrupt handlers (Xtensa) 2022-12-06 02:07:49 -08: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
Sergio Gasquez
9ef3a29e58 feat: 📝 Update install sections 2022-11-24 08:30:57 -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
Jesse Braham
096ff3439d
New releases for all HALs (#265)
* Update all dependencies to their latest versions

* Bump version numbers
2022-11-17 09:13:41 -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
icedrocket
b52670a3e9 doc: add #[doc(inline)] to esp-hal-common re-exports 2022-11-08 18:26:00 +09:00
bjoernQ
a876d8d344 Support USB-DEVICE on ESP32-S3 and ESP32-S2 2022-11-02 07:14:50 -07:00
bjoernQ
3e4710b822 Add DMA support for ESP32-S2 2022-10-25 07:38:45 -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
bjoernQ
2afa38b240 ESP32-S2: add wifi sections and fix linker script 2022-09-19 09:14:22 +02:00
Jesse Braham
ee7e9bd0a1 Bump version numbers and update dependencies 2022-09-13 21:01:08 +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
Juraj Sadel
f11a23dddb Make it impossible to create multiple instances of LEDC 2022-09-06 11:37:05 +02:00
har7an
8b9fd8b7a0
embedded-hal SpiDevice on all esp32 variants (#106)
* WIP: common/spi: Implement `SpiDevice`

to get shared access to an SPI bus directly via the HAL.

* WIP: common/spi: add SpiBusDevice::new

to create instances via a function call.

* esp32/examples: Add example for spi device trait

* common/spi: Finish "SpiDevice" implementation

for esp32. Abandons the approach of having the user pass in some generic
mutex in favor of creating the Mutex as part of the API so it isn't
exposed to the user in the first place.

* common/spi: Add more thorough docs

* esp32/examples: Fix example for eh1 "SpiDevice"

* common/spi: Implement `SpiDevice` for xtensa arch

and move the code into a submodule that is fenced with conditional
compilation directives.

* esp32/examples: Update spi device example

to the changed APIs for the timers and clocks, and add more transmission
tests to the example code.

* common/spi: Create devices from buscontroller

directly, instead of offering only the `new` method.

* common/spi: Finish `SpiBusDevice` trait

from embedded-hal 1.0.0-alpha.8.

* esp32: Update `SpiBusDevice` usage example.

* common/spi: Fix mutex types for xtensa32 esp

because the esp32/esp32s3 can use `SpinLockMutex`, whereas the esp32s2
has access only to `CriticalSectionMutex`.

* common/spi: Implement `SpiBusDevice` for riscv

based esp32c3.

* general: Add examples for spi device loopback

to all esp variants.

* common: Use esp_backtrace in spi_eh1_device examples

* common/spi: Update module documentation.

* common/spi: Use `critical_section::Mutex`

to unify locking across all esp variants.

* esp32c3-hal: Fix spi device example

* esp32c3/examples: Fix typo in used spi pins

Co-authored-by: Jesse Braham <jessebraham@users.noreply.github.com>

Co-authored-by: Jesse Braham <jessebraham@users.noreply.github.com>
2022-08-30 06:55:53 -07:00
Juraj Sadel
9911a1e359 Replace all float calculations with fixed ones 2022-08-30 13:43:48 +02:00
Jesse Braham
6f20358124
Update the Cargo manifests and top-level README (#168)
* Add the `rust-version` key to each Cargo manifest

* Normalize dependencies and features in each Cargo manifest

* Enable all features in CI when checking examples

* Update the top-level README
2022-08-25 09:20:05 -07:00
Scott Mabin
b30886cce6
Periodic system timer & esp32s2 fixes & edge interrupt fixes (#167)
* Add Periodic mode to SYSTIMER

* Deduplicate shared code in SYSTIMER

* esp32s2 edge mode systimer interrupt

- Make systimer interrupts edge mode
- fix examples for s3 & s2

* Fix TPS for esp32s2, clean up examples
2022-08-25 07:13:56 -07:00
Scott Mabin
be184a552d
critical_section implementations & esp_backtrace (#151)
* CS impl

* use CS Mutex in C3 examples

* use CS Mutex in S2 examples

* Update esp32 example

* run fmt

* Update S3 examples

* Remove uses of unsafe where no longer required

* use esp_backtrace in examples

* fix import & fmt once more

* Bump MSRV to 1.60.0

Co-authored-by: Jesse Braham <jesse@beta7.io>
2022-08-22 20:02:28 +01:00
bjoernQ
b9f59c436c Rename RESERVE_DRAM to RESERVE_CACHES, revert change of reserved_for_boot_seg 2022-08-22 15:42:12 +02:00
Björn Quentin
520f8d6f41
Update esp32s2-hal/ld/link-esp32s2.x
Co-authored-by: Gustavo Henrique Nihei <38959758+gustavonihei@users.noreply.github.com>
2022-08-22 15:25:09 +02:00
Björn Quentin
92d618a8e5
Update esp32s2-hal/ld/memory.x
Co-authored-by: Gustavo Henrique Nihei <38959758+gustavonihei@users.noreply.github.com>
2022-08-22 15:25:04 +02:00
bjoernQ
468d4a90c5 Fix IRAM/DRAM overlap for ESP32-S2 2022-08-22 11:29:33 +02:00