77 Commits

Author SHA1 Message Date
Jesse Braham
9cb8f7e941
Miscellaneous pre-release fixes (#883)
* Temporarily disable async `SYSTIMER` implementation, remove mention from `CHANGELOG.md`

* Remove a couple files which are not required

* Fix warning for `sha` examples

* Fix warning for non-C3 devices

* s/interrupt_clear/clear_interrupt/
2023-10-31 06:50:54 -07:00
jneem
ff80b69183
Provide ADC values in mV instead of requiring the user to scale them (#836)
* Provide ADC values in mV instead of requiring the user to scale them

* Changelog

* Try converting poly calibration also

* Update changelog and comments

* Fix example
2023-10-30 10:16:45 -07:00
Scott Mabin
94a07da47b
Fix Async UART (#871)
* Fix Async UART

The uart handler was `writing` to the enable register instead of
`modify`, which meant any wake would see the cleared enabled bit and
think the event had occurred. This wasn't seen before the split of uart
because it was only possible to listen to one thing at a time.

This PR also removes the ReadBufferFull error in favour of returning the
max bytes in the buffer.

The serial examples has been updated to actually have some cross task
communication.

* changelog

* fix dev deps
2023-10-25 10:25:25 -07:00
Jesse Braham
33bfe80d95
Prelude improvements/fixes (#860)
* Move SPI-related traits into their own preludes in the `spi` module

* Remove the `embedded-hal-async` trait re-exports and the `eh1` module from the prelude

* Update `CHANGELOG.md`
2023-10-20 06:56:17 -07:00
Jesse Braham
f81dc50748
Refactor the spi and spi_slave modules into a common spi module (#843)
* Refactor the `spi` and `spi_slave` modules into a single `spi` module

* Update import paths in examples as needed

* Extract some common types from `spi::master` into the root `spi` module

* Fix imports in examples (again)

* Documentation fixes/improvements

* Remove unnecessary re-exports

* Update `CHANGELOG.md`
2023-10-11 11:38:38 -07:00
Björn Quentin
a0ebdf0399
embassy #[main] convenience for RISC-V / Xtensa (#841) 2023-10-11 12:10:14 +01:00
Bryan Kadzban
0aa0232f1b
SPI slave support (#580)
* Duplicate spi to spi_slave

* Restore spi

* Add barebones SPI slave mode, DMA only.

This setup allows registering buffers for future transactions the master
does (lowering cs, toggling sclk, and raising cs again). The transfer
struct returned from the registration API will complete its wait() or
return true from is_done() after cs has been raised.

Copied from spi.rs, so most of the changes are deleting code that
handles e.g. segmented transfers or synchronous operations.

Fix non-c3 devices' builds

* Limit spi_slave to non-pdma devices

* SPI slave DMA example

Ensure the API "feels" right.

Since there's no way to route GPIOs to other peripherals, we choose four
other wires and bit-bang SPI for the master side, relying on the person
running the example to connect the bus.  This way we ensure the slave
code works, since we created the master ourselves.

Also, it's not really possible to use a second ESP device as the master
anyway: all the digital lines have glitches on startup, and those
glitches cause the slave's DMA engine to skip descriptors (it thinks
they're intended CS indicators); this causes it to lose data.

Then, fix the bitbang master (recording the progression here)

- When bitbanging, iterate the bits by "for _ in 0..8", instead of the
  broken "for _ in [0..8]".  The latter only runs the iteration once,
  since there's only one list given ... and because the code uses _
  instead of a real loop variable, type checking didn't save us.
- When bitbanging, send the bits out (and read them in) MSB first, since
  that's actually how we have the slave configured.

* Add changelog entry

* Split DMA prepare_transfer into two fns.

The first does everything but write to the start bit and check for an
error. The second does those. We need 2 fns because the  SPI slave needs
to start the transfer only after resetting the various afifo hardware
components (if it starts the transfer before, the first 8 bytes will be
lost when that reset happens).

Use the split fns everywhere.

Also split flush().  It needs to be pollable, so split it into one fn that
polls and one that waits until the poll returns clear. Also call the poll
fn from the is_done() fn, so we don't trample in-progress transfers.

* Make example code fill rx buffer before transfer

This way we can tell if it's ever touching certain bytes - 0xff is never
added to the master transmit buffer.

While I'm changing this, make the slave tx buffer never contain 0xff
either (go from 254 to 0).

---------

Co-authored-by: Jesse Braham <jessebraham@users.noreply.github.com>
2023-10-10 09:00:18 -07:00
Dániel Buga
44e968f7a8
Make sure examples can actually build with defmt enabled, build some examples in CI (#810)
* Make sure examples can build with defmt

* Remove duplicate example checks

* Fix examples

* Add changelog entry

* Actually build some examples with defmt feature enabled

* Add the defmt linker script in each package's build script
2023-10-05 12:13:09 -07:00
Scott Mabin
db409ffe7b
Unify the system peripheral (#832)
* Unify the system peripheral

Whilst the PCR, SYSTEM and DPORT peripherals are different, we currently
use them all in the same way. This PR unifies the peripheral name in the
hal to `SYSTEM`. The idea is that they all do the same sort of thing, so
we can collect them under the same name, and later down the line we can
being to expose differences under an extended API.

The benifits to this are imo quite big, the examples now are all identical,
which makes things easier for esp-wifi, and paves a path towards the
multichip hal.

Why not do this in the PAC? Imo the pac should be as close to the
hardware as possible, and the HAL is where we should abstractions such
as this.

* changelog
2023-09-29 08:14:50 -07:00
Björn Quentin
547f6db6ce
Add SYSTIMER ETM (#828)
* Add SYSTIMER ETM

* Remove logger-init from examples
2023-09-28 11:59:50 +02:00
Juraj Sadel
ca4e1b3a26
(G)DMA AES working mode support (#821)
* Add (G)DMA AES initial support

* Modify AES examples to the driver changes

* Add DMA examples(tests)

* fmt

* changelog

* review changes

* typo
2023-09-27 09:08:14 -07:00
Kirill Mikhailov
24c5e8cb79
Adding async support for RSA peripheral (#790)
* Adding async support for RSA peripheral

* Add esp32 support (doesn't work properly yet)

* Xtensa chips are supported (except of esp32)

Add modular multiplication for esp32

Adding a CHANGELOG entry

Rebase issue fix

* Code cleanup

* Add `.await` on `RsaFuture::new()` calls

* Refactor and rebase

Made `read_results` functions to be `async`, got rid of `nb` usage

* Change API methods naming + refactor `start_step2` method

* Adjust example to the API change + documentation

* Code cleaning + refactoring

Update examples
2023-09-27 09:03:06 -07:00
Jesse Braham
0064766ef2
No longer publicly expose the PeripheralClockControl struct (#817)
* No longer publicly expose the `PeripheralClockControl` struct

* Update examples as needed to get things building again

* Update CHANGELOG.md

* Address review feedback, fix a warning

* Use a critical section for all devices other than the ESP32-C6/H2, as they modify multiple registers

* Rebase and update `etm` driver to fix build errors
2023-09-26 09:07:57 -07:00
Björn Quentin
774d5c4f21
Add ETM, Add GPIO ETM (#819)
* Add ETM, Add GPIO ETM

* Add CHANGELOG.md entry
2023-09-26 12:56:09 +02:00
Jesse Braham
b91b3b1b77
Implement embedded_hal_async::delay::DelayUs trait for SYSTIMER alarms (#812)
* Implement `embedded_hal_async::delay::DelayUs` trait for `SYSTIMER` alarms

* Update CHANGELOG.md

* Address review feedback
2023-09-25 07:33:47 -07:00
Scott Mabin
eeb2d1db6f
Fix UART to handle CPU/APB clock changes (#808)
* Ensure that uart is configured to account for clock changes, not just boot defaults

* fix examples

* changelog

---------

Co-authored-by: Jesse Braham <jessebraham@users.noreply.github.com>
2023-09-21 09:06:56 -07:00
Björn Quentin
24edf7bdc4
Async PARL_IO support (#807)
* Async PARL_IO support

* Add CHANGELOG.md entry
2023-09-21 17:34:53 +02:00
Björn Quentin
434a32763c
Async I2S support (#801)
* Async I2S support

* Add CHANGELOG.md entry
2023-09-20 22:23:50 +00:00
Georges
107732b111
Add support for splitting esp32 uart into TX and RX (#754)
* Add support for splitting esp32 uart into TX and RX

* Keeps existing API for uart, but wraps it in Tx and Rx sub-types
* Adds split() method similar to embassy-rs nRF/stm32/rp for getting indepdendent TX and RX
parts
* Implements e-h traits for TX and RX types
* Add esp32s3 example

* finish implementing

* rebase examples

* declare new examples

* fix fmt

* rebase on 0.12.0

* fix fmt

* fix fmt

* merge embassy_serial_split example with embassy_serial

* fix changelog

* fix changelog
2023-09-20 13:19:34 +01:00
Juraj Sadel
856f0d1881
ECC peripheral support for ESP32C2, ESP32C6, and ESP32H2 (#785)
* Add ECC driver for ESP32C2 and ESP32C6

* Add ECC example for ESP32C2 and ESP32C6

* Add and modify dependencies

* ESP32H2: Add ECC driver support

* ESP32H2: Add ECC example

* ESP32C2 and ESP32C6: clean examples

* changelog

* refactor: remove enable_interrupt() and clear_interrupt()

* refactor: remove ugly if/else logic for padding
2023-09-19 05:24:32 -07:00
Björn Quentin
a0e5737a22
Macro to load LP core code (#779)
* Macro to load LP core code

* Fix imports, add CHANGELOG.md entry

* Avoid code warning

* Omit path from function signature

* More error checking

* Clippy fix

* Include the ELF used by the lp_core_basic example

* Make object dependency optional

* Use 1.65 for RISCV MSRV check

* Use RUSTC_BOOTSTRAP for RISCV MSRV check

* Remove the pre-compiled LP core example

* Pin toml_edit in esp32c6-lp-hal-procmacro
2023-09-14 12:16:12 +02:00
Björn Quentin
a642ee40da
Async RMT (#787)
* Async RMT

* Add CHANGELOG item

* Pin toml_edit transitive dependency
2023-09-13 09:02:36 +02:00
Jesse Braham
d12a3dbac5
Update all examples to remove unnecessary disabling of watchdogs (#768)
* Update `esp32-hal` examples

* Update `esp32c2-hal` examples

* Update `esp32c3-hal` examples

* Update `esp32c6-hal` examples

* Update `esp32h2-hal` examples

* Update `esp32s2-hal` examples

* Update `esp32s3-hal` examples

* Fix the `ram.rs` examples
2023-08-31 07:17:12 -07:00
Jesse Braham
4dd9fbdb7b
Disable all watchdog timers at startup by default (#763)
* Rework watchdog timer drivers to allow enabling/disabling and feeding without traits

* Disable all watchdogs prior to `main` using the `__post_init` hook

* Update all watchdog-related examples

* Update CHANGELOG

* Address review comment
2023-08-30 08:54:01 -07:00
Björn Quentin
9a894879a7
PARL_IO RX for ESP32-C6 / H2 (#760)
* PARL_IO RX for ESP32-C6 / H2

* Add PARL_IO RX to README.md

* Remove logger-init from PARL_IO_RX examples
2023-08-29 18:48:37 +02:00
Dániel Buga
e082d47a87
Multicore-aware executors (#723)
* Implement multicore-aware executors

* Add examples

* Use pre-defined config to import SystemPeripheral

* Use static_cell::make_static
2023-08-28 10:05:42 -07:00
Anthony Grondin
91b9b51426
feat(hmac): Add HMAC driver for hardware acceleration (#755)
* feat(hmac): Add HMAC driver for hardware acceleration

Driver code taken from: a9807ae67d

* fix build for target without hmac support.
2023-08-28 08:54:41 +02:00
Björn Quentin
95a1255c3b
PARL_IO TX driver (#733)
* PARL_IO TX driver

* Update CHANGELOG.md

* Update esp-hal-common/src/dma/mod.rs

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

---------

Co-authored-by: Jesse Braham <jessebraham@users.noreply.github.com>
2023-08-23 10:32:13 -07:00
Jesse Braham
7fce6e32f2
Update to 1.0.0-rc.1 version of embedded-hal-* crates (#747)
* Update a bunch of dependencies

* Implement `embedded-io` and `embedded-io-async` traits for USB Serial JTAG

* Implement `embedded-io` and `embedded-io-async` traits for UART

* Fix `embassy_serial` examples

* Update CHANGELOG

* Address review comments
2023-08-22 14:53:41 +01:00
onsdagens
d6d5e0c86b
Adding direct vector table hooking support for RISC-V's (#621)
* direct vectoring support added

* provide minimal handlers for hooking the vector table directly

* changed direct vectoring interrupt enable interface to map to CPU interrupt

* direct vectoring interrupt nesting

* removed unused dependency

* added tentative c2 and c6 support for direct vector table hooking

* added direct vectoring examples

* added direct vectoring examples

* updated changelog

* added direct vectoring to CI

* Added H2 support and example, moved helpers to esp-hal-common

* Added H2 direct vectoring example to CI

* Removed remnants of removed feature

* C6 and H2 examples fixed

* C6 and H2 examples fixed

* C6 and H2 examples fixed

* Comment fixed

* Added preemption flag to RT

---------

Co-authored-by: Scott Mabin <scott@mabez.dev>
2023-08-01 16:28:40 +01:00
Jesse Braham
00fac71b68
Update the PACs and resolve breaking changes, simplify rmt driver (#695)
* Update to latest (unreleased) versions of PACs

* Update `SDMCC` peripheral to `SDHOST` for ESP32

* Fix `USB_DEVICE` interrupts

* Fix references to various renamed GPIO fields for ESP32-S2

* Update and re-organize the `rmt` driver

* Update CHANGELOG
2023-07-27 23:16:39 +01:00
Jesse Braham
a95f6efb35
Update esp-hal-smartled to use the new rmt driver, remove old pulse_control driver (#694)
* Remove the old `pulse_control` driver

* Update `esp-hal-smartled` to use the new `rmt` driver instead

* Update the `hello_rgb` example for each chip

* Update CHANGELOG
2023-07-27 16:07:15 +01:00
Alex Johnson
debe2b8004
fixed async read w/o at_cmd (#652)
* fixed async read w/o at_cmd

* configurtion checks  for async `read`

* remove fifo thrhd check
2023-07-25 12:19:59 +01:00
Björn Quentin
170d590b67
Make in-progress DMA transfers potentially fallible (#665) 2023-07-22 20:14:57 +01:00
Björn Quentin
213dde9304
Add a new RMT driver (#653)
* Add a new RMT driver

* Add CHANGELOG entry

* Fix typos
2023-07-19 10:54:52 -07:00
Björn Quentin
f7831be7ae
Add basic LP_IO support (#639)
* Add basic LP_IO support

* Add CHANGELOG.md entry

* Fix after rebase
2023-07-07 10:08:52 +02:00
Dániel Buga
b1e8c6e818
Some minor cleanup (#642)
* Fix typo

* Don't require importing paste

* Clean up warnings

* Clean up Clippy warnings
2023-07-05 11:09:04 -07:00
Kayo Phoenix
74438fcec5
ADC raw values calibration (#555)
* adc_cal: c2: Add efuse functions for reading calibration

* adc_cal: c3: Add efuse functions for reading calibration

* adc_cal: c6: Add efuse functions for reading calibration

* adc_cal: Add extra traits to support calibration

- `AdcCalScheme<ADCI>` implemented for each calibration scheme (basic, linear, curved)
- `AdcCalEfuse` implemented for each ADC unit to get calibration data from efuse bits

* adc_cal: Add basic ADC calibration scheme

Basic calibration is related to setting some initial bias value to ADC unit.
Such values usually is stored in efuse bit fields but also can be measured
in runtime by connecting ADC input to ground internally.

* adc_cal: Add line fitting ADC calibration scheme

This scheme also includes basic calibration and implements gain correction based
on reference point.

Reference point is a pair of reference voltage and corresponding mean raw ADC
value. Such raw values usually is stored in efuse bit fields for each supported
attenuation.

Possibly it also can be measured in runtime by connecting ADC to reference
voltage internally.

* adc_cal: Add curve fitting ADC calibration scheme

This scheme also includes basic and linear and implements final polynomial error
correction.

* adc_cal: riscv: Add ADC calibration implementation for riscv chips

* adc_cal: c2: Add calibrated ADC reading example

This example uses line fitting calibration scheme by default.
It periodically prints both raw measured value and computed millivolts.

* adc_cal: c3: Add calibrated ADC reading example

This example uses curve fitting calibration scheme by default.
It periodically prints both raw measured value and computed millivolts.

* adc_cal: c6: Add calibrated ADC reading example

This example uses curve fitting calibration scheme by default.
It periodically prints both raw measured value and computed millivolts.

* adc_cal: riscv: Add changelog entry for ADC calibration
2023-07-04 10:14:27 -07:00
Björn Quentin
996da27f30
Bare-bones support to run code on ULP-RV/LP core (#631)
* Bare-bones support to run code on ULP-RV/LP core

* Add CHANGELOG.md entry
2023-07-03 16:15:34 +02:00
Hannah Kolbeck
a86c2ac310
Clean up a stray comment in rtc_time examples (#630)
Co-authored-by: Hannah Kolbeck <hskolbeck@gmail.com>
2023-06-30 12:30:05 +01:00
Jesse Braham
6869f8c783 Update embedded-graphics and ssd1306, address breaking changes 2023-06-28 09:47:43 -07:00
Dániel Buga
2371c30542
Simplify user-facing DMA channel types (#626)
* Introduce a trait for DMA channels

This trait is then used to hold types related to the particular DMA channel. This change allows us to simplify user-facing types.

* Remove private type from I2s

* Remove redundant spi3 example, update examples

* Merge markdown sections

* Add changelog entry
2023-06-28 13:03:49 +01:00
Alex Johnson
bce7210b01
Async serial uart read (#620)
* implement embassy async uart read

* Add embassy async read support for uart

* changes based on review

* fix CI failures

* change review #2

* fixed re-opened PR number

* changes review no.3

---------

Co-authored-by: Scott Mabin <scott@mabez.dev>
2023-06-26 16:56:32 +01:00
Jordan Halase
a562863cde
Add MD5 functionality from ESP ROM (#618)
* Add ROM MD5 definitions in linker and devices

* Add initial MD5 support

* Implement traits and add comments to MD5 module

* Add MD5 example to ESP32-C3

* Test MD5 context on the quick brown fox

* Implemenr From<Context> for Digest

* Add MD5 to the rest of the examples

* Add docs for MD5

* Remove #[repr(transparent)] from md5::Digest

* Update CHANGELOG.md
2023-06-26 09:01:34 +02:00
Jesse Braham
5af8b6387a
Clean up re-exports and make small improvements to documentation (#607)
* Create issue_handler.yml

* No longer re-export `embedded-hal`, hide exported macros in documentation

* Add simple package-level documentation for each HAL package

* Clean up/simplify re-exports

* Fix the examples that I broke

* Ensure top-level modules/types/functions have doc comments

* Update CHANGELOG

* Re-export the `soc::psram` module where available

---------

Co-authored-by: Sergio Gasquez Arcos <sergio.gasquez@gmail.com>
2023-06-22 06:46:50 -07:00
Sergio Gasquez Arcos
310809a5bf
Update documentation (#606)
* docs: 📝 Update documentation

* docs: 🐛 Fix typo
2023-06-21 04:03:15 -07:00
Sergio Gasquez Arcos
e3b77418c4
ESP32H2: Improve examples documentation (#598)
* style: 🎨 Improve print format

* docs: 📝 Update advanced_serial documentation

* docs: 📝 Update examples documentation
2023-06-19 07:14:12 -07:00
Jordan Halase
f22cd7370d
Add CRC functionality from ESP ROM (#587)
* Add ESP ROM CRC and fallbacks to HAL

* Cargo fmt

* Add CRC examples

* Cargo fmt

* Cargo fmt and clippy (all)

* Update CHANGELOG.md
2023-06-14 05:40:51 -07:00
Jesse Braham
a92c46f309 Correct a number of comments in various examples 2023-05-25 06:02:15 -07:00
Bryan Kadzban
a6835d9cec Add examples for polling DMA transfers.
Only in the SPI case, but the I2S case has the same API so this should
be fine.
2023-05-25 06:37:09 +00:00