709 Commits

Author SHA1 Message Date
ivmarkov
1aaa928b50 Update CI to latest nightly 2023-09-02 11:40:55 +00:00
ivmarkov
e5845492a3 Better display output; rx should be InputPin 2023-08-31 07:18:43 +00:00
ivmarkov
15a06306cd h2 and c6 have a single ADC unit 2023-08-28 11:38:27 +00:00
Dominic Fischer
cfe5086854
SPI: Queue up multiple transactions in interrupt mode (#291)
* Move _keep_cs_active to separate function

* Make spi_transmit(_async) accept an iterator

* Pass iterators to spi_transmit(_async)

* Add queueing support to spi_transmit

* Add queueing support to spi_transmit_async

* Clippy workaround

* Array init trick
2023-08-27 15:38:58 +03:00
ivmarkov
b49cc8b861
Mention re-export of esp-idf-sys 2023-08-27 15:17:29 +03:00
ivmarkov
b97a2975a3 Clippy 2023-08-27 08:04:26 +00:00
ivmarkov
8cc193aa35
TWAI driver async hack; examples cleanup (#292)
* Hacky async TWAI driver

* Async TWAI: Custom priority and pin to core

* Async TWAI: Proper configuration of alerts

* Do not refer to esp-idf-sys as it is not an explicit dependency anymore
2023-08-27 10:47:18 +03:00
ivmarkov
b92764159a Compat with ESP IDF master 2023-08-23 06:49:42 +00:00
ivmarkov
29c466c941 #284 2023-08-22 19:22:07 +00:00
ivmarkov
a326603190 #284 2023-08-22 16:50:47 +00:00
ivmarkov
b61a2b11c7 #284 2023-08-22 12:52:05 +00:00
ivmarkov
9fc2e8c61e
Async drivers (#279)
* Continuous mode ADC

* GPIO: Switch to the common notification; remove alloc req for async

* (WIP) async SPI

* Notification callbacks in async SPI

* SPI: Lower the code repetition

* Fix the build

* I2S pre-async simplification

* Async methods for I2S

* SPI: Wait for the transaction to complete on drop

* More flexibility in PinDriver::wait_for

* Remove the gargantuan mutex for now

* Arrays supported as ADC channels

* Fix timeouts

* ADC: measurement shape

* Fix the dependencies

* Fix CI

* ADC: cont config

* ADC: better atten API; fix delays

* ADC: Raw handle access

* I2S: Make config more symmetric with the other drivers

* I2S: Remove unnecessary generics

* Improve the semantics of read/write vrt partial r/w

* Review feedback

* Clippy

* Shorten static array initializers

* Do not glob-import all of esp-idf-sys

* SPI: make notifications non-static

* SPI: Remove the async fetch() hack; extend async support

* Fix the CI

* SPI: Restore WriteIter impl

* Bugfix: tx/rx handles mismatch

* I2S: Utility methods to write the whole buffer

* I2S Bugfix: wrong translation to native format

* More ergonomic API for TickType

* unsubscribe during reset will fail if ISR service is not enabled yet

* Typo

* Same defaults

* No need for unsafe here

Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>

* Assert that ESP_ERR_TIMEOUT should never happen

* Safe variant of completion

* ADC: wrong timeout conversion

* Proof of posession of i2s0/spi3 for esp32/esp32s2

* write_async only available on ESP IDF 5+

* Option to transmute the adc buffer to pcm

* ADC: only expose PCM conversion where it is possible (esp32/esp32s2)

* ADC: Fix channel chaining

* ADC: fix the CI

* ADC: Nullify everything

* ADC: as_pcm32 for riscv and esp32s3

* ADC: as_pcm32 for riscv and esp32s3

* ADC: read_raw

* I2S: Proper driver shutdown

* ADC: Fix clippy and compile errors on ESP-IDF 4

* Compat with ESP-IDF master

---------

Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>
2023-08-22 15:39:02 +03:00
ivmarkov
58b652ff15 Option to configure rx/tx fifo sizes and queue size 2023-08-08 17:24:25 +00:00
ivmarkov
24543de78e Option to configure rx/tx fifo sizes and queue size 2023-08-08 17:09:29 +00:00
ivmarkov
29806afcd3 Clippy 2023-08-02 05:51:42 +00:00
ivmarkov
9a8f51e6b4 Clippy 2023-07-22 06:19:13 +00:00
Frederick Vollbrecht
a5dc68adcf
🚸 add simple timer example with task notify (#277)
* 🚸 add simple timer example with task notify

* use println do avoid log dev-dep

* remove esp-idf-svc dep on logging
2023-07-05 21:54:06 +03:00
Øyvind Myrstad Netland
c0534b9428
adds example for i2c between master and slave I2C on same device (#274) 2023-07-05 21:50:32 +03:00
Johan Olby
f3c37ab402
Map ULP wakeup to WakeupReason::ULP (#276)
Extend the WakeupReason::ULP to match both COCPU and ULP (fsm) wakeups.
2023-07-04 18:22:30 +03:00
Jonathan Herbert
6258d043af
Add From Implementations Between Level and PinState (#273)
* Add From Implementations Between Level and PinState

* Fix Formatting And Reorder Match Cases
2023-07-03 20:01:52 +03:00
David Cuthbert
8e0ddd7457
pconfig does not need to be mut. (#272)
This fixes a clippy issue from rust-analyzer that's been sitting in
VSCode's problems pane for a while.
2023-07-03 12:17:36 +03:00
ivmarkov
30c3c86efb Fix build for ESP IDF master 2023-06-27 15:36:12 +00:00
ivmarkov
cb535a9afd Update the README with build information and better description 2023-06-27 10:54:24 +00:00
ivmarkov
114dcc2641 Update the README with build information and better description 2023-06-27 10:30:10 +00:00
ivmarkov
30a75d078d Update the README with build information and better description 2023-06-27 10:29:15 +00:00
Øyvind Myrstad Netland
afef9efb90
Update README.md (#271)
Update instructions for building examples
2023-06-27 13:10:52 +03:00
David Cuthbert
e3616e723a
Ergonomic changes for I2S callbacks. (#269)
* Ergonomic changes for I2S callbacks.

This makes a few changes suggested in the last bit of
https://github.com/esp-rs/esp-idf-hal/pull/232:

* Trait functions take impl FnMut instead of Box<dyn FnMut>.
* Callback bookkeeping is no longer static (like the GPIO callbacks);
  instead, it's stored with the channel.
* Added rx/tx_unsubscribe() methods to the channels.

Also, fixed the naming of the I2sRxEvent/I2sTxEvent enums to be more
inline with the brevity of Rust in general:
* DataReceived -> RxDone
* ReceiveOverflow -> RxOverflow
* DataTransmitted -> TxDone
* TransmitOverflow -> TxOverflow

* Fix no-std, no-alloc builds.
Fix leak introduced by changing the UnsafeCallback Box<Box<...>> to
a *mut Box<...> (which isn't dropped automatically).
2023-06-26 20:18:38 +03:00
ivmarkov
3ab97a27a2 sdkconfig.defaults is not found 2023-06-23 17:06:03 +00:00
ivmarkov
7332707618
Try to downgrade the ESP-RS toolchain so that CI runs fine on xtensa 2023-06-23 09:24:35 +03:00
ivmarkov
2c1bd7103a
Try to download the toolchain so that CI runs fine on xtensa 2023-06-23 09:04:51 +03:00
David Cuthbert
de7dee4799
Implement I2S (#232)
* Basic structure of the I2S driver.

This does not yet work, but outlines the approach I'm taking to bind
the Rust HAL layer to the ESP-IDF SDK 5.0.

* Fix issues with AtomicBool ordering.

* Add StdClockConfig::from_sample_rate ctor.

This is equivalent to the I2S_STD_CLK_DEFAULT_CONFIG macro, but
much cleaner.

* Add #[inline(always)] where appropriate.

* Add open_tx_channel method.

* Add constructors for StdSlotConfig.

* Add drop impl for I2sDriver.

* Add event handler interface.

I'm not entirely certain I'm happy with this interface. In particular,
there's virtual dispatch involved, and it's called in the context of
an ISR. This shouldn't be a problem, but it would be nice to be able
to avoid it. That might not be possible.

* Fix generics issues with I2S.

This fixes generics issues found with the I2S driver found in
actual use. This requires the changes to esp-idf-sys in
https://github.com/esp-rs/esp-idf-sys/pull/187 to use.

* Pass callback handlers by reference.

This removes some unsafe pointer handling that was previously being
used as a direct transliteration of the equivalent C code.

* Add allow(unused) annotations for PCM/PDM.

These structures will be used when PCM and PDM support is implemented.

* Remove bindings.h.

* Refactoring based on PR comments.

This moves standard mode to its own driver. The channel structs are
no longer separate from the driver; instead, the driver implements
I2sRxChannel and/or I2sTxChannel depending on a generic it takes,
which can be I2sRxSupported and/or I2sTxSupported.

Alas, the separate I2sStdDriverInternal struct is still there. This is
required because it has to be pinned in memory to serve as callback
data for the interrupt handler, while I2sStdDriver can be moved
around as Rust pleases.

Stubs configs have been created for PCM and PDM modes.

* Fix pin usage in doc examples.

* Make traits more ergonomic.

This moves default implementations for I2sRxChannel and I2sTxChannel
into the traits themselves where it makes sense, and will make it
easier to implement the PDM and TDM modes.

This also moves I2sStd{Rx,Tx}Callback into I2s{Rx,Tx}Callback and
removes lifetimes associated with them. It turns out that attempting
to use the lifetimes in any callback implementations suffered from
the self-referential lifetime problem, where the lifetime of the
callback and the lifetime of the driver are the same. Now the driver
owns the callback instead.

* Add notes about bugs with callbacks.

The callback implementation in ESP-IDF appears to be broken. The
DMA buffers need to be released to i2s_dma_rx/tx_callback at some
point, but it is impossible to do this since the message queue is
hidden behind the opaque i2s_chan_handle_t type.

* Comment fix.

* Move channel to main i2s.rs.

This moves the channel implementation (which turns out to be
generic) to the main i2s.rs file in preparation for PDM and TDM mode
implementation.

* Add pulse density modulation support for I2S.

This driver is more complex than the standard mode driver since not
support for PDM mode is not universal across the ESP32 line.
In particular, the ESP32S2 does not support PDM mode at all, and the
ESP32C3 only supports PDM transmission.

* Add TDM mode support for I2S.

This adds time-division multiplexing (TDM) for the I2S peripheral.
Note that this is only supported on ESP32C3 and ESP32S3 devices.

* Remove unnecessary pub(super) from config.

This removes unnecessary pub(super) modifiers from various I2S
standard mode config struct fields.

* Compiling for v4.4.x and v5.0.x.

I have not yet tested the v4.4 version, or the PDM/TDM modes on either
version; I need to get some hardware together for this.

* Add drop impl for v4.

* Remove whitespace at EOL

* Derive Default for TdmSlotMask.

This eliminates a clippy error about impl Default being able to be
derived.

* Fix preload_data in v5.1.

This fixes the preload_data default impl on the I2sRxChannel trait
to conform to the C signature.

* Add bclk_div to TdmClkConfig on v5.1.

The ESP-IDF v5.1 driver adds a new field, bclk_div, to the
i2s_tdm_clk_config_t structure that has a default value (8) but can
be overridden by users in case transmits are lagging in target mode.

* Allow multiple PDM RX pins.

Also ran cargo fmt.

* Wrap new_rx_multi in v5.1 cfg.

* Enable no_std builds.

This removes the use of Box when building for no_std at the cost of
static allocations that are incurred whether the I2S driver is used or
not. This is 16 bytes/channel, 32 bytes per I2S device.

* A few cfg fixes for clippy.

* Make unsafe decls match for create_rx/tx.

This isn't strictly necessary in alloc mode, but it makes the code
easier to use.

* Add missing field in clone().

* Actually put comm_fmt in clone().

* Don't create pools on v4.4.

Channels aren't used, so pools aren't needed (and the types aren't
valid).

* Derive Debug, Default.

Add Debug derivations where missing.
Add Default derivations to enums now that MSRV supports them.

* Make callbacks functions.

This makes the rx/tx callbacks into functions instead of traits
per @ivmarkov's recommendations. This helps with a number of ergonomic
issues with the code (particularly around channels and lifetimes).

* Remove PCM compression support.

This mode was only supported in the v4 driver series, and not all that
well at that. This doesn't appear to be a standard I2S operating mode
anyway.

* I2S_PORT_COUNT, UnsafeCallback unused in 4.4.

* Remove duplicate cfg block.

* Use core::slice instead of std::slice.
2023-06-23 08:50:58 +03:00
Mikael Lund
091128a282
Refactor Rgb struct (#265)
* Refactor Rgb struct

Moves hsv convertion into
an associated function and further
implements From<Rgb> for u32.

* Update rmt_neopixel.rs

* Replace if-else with pattern matching
2023-06-22 18:31:54 +03:00
Jordan Halase
c03ec8199b
Fix typos in rom::crc docs (#267) 2023-06-22 18:31:29 +03:00
Sergio Gasquez Arcos
c8e54a7a5e
Create issue_handler.yml 2023-06-22 13:34:01 +02:00
ivmarkov
f2359698f0 New release v0.41.2 2023-06-21 13:24:28 +00:00
Michael Heinrichs
5a0e459a38
Do not set the single shot flag in the can frame (#263) 2023-06-18 16:15:28 +03:00
Jordan Halase
bf4a5afc5f
Add safe abstractions to CRC functions in ESP ROM (#261)
* Add safe abstractions to CRC functions in ESP ROM

* Do not include ROM functions if esp-ulp-hal is enabled

* Run cargo fmt and clippy
2023-06-12 08:49:26 +03:00
Frederick Vollbrecht
ec7dafa1b9
🐛 use same error for all e-hal 0.2 trait impls (#260) 2023-06-07 17:32:17 +03:00
Harry Stern
8c3f90ddca
Add support for WakeupReason from Ext0 events (#259)
See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/sleep_modes.html#external-wakeup-ext0
for more information on ext0 vs ext1
2023-06-05 13:51:50 +03:00
ivmarkov
2ab4c709f1 #258 2023-06-03 10:44:55 +00:00
Gustavo Batistela
c68856c4e4
Fix UART docs (#252)
* Fix module import in UART docs

* Fix example in UART docs

---------

Co-authored-by: Gustavo Batistela <gustavo.alcala@tarvos.ag>
2023-05-23 15:51:05 +01:00
ivmarkov
b8e43ffbc7 New release v0.41.1 2023-05-21 17:15:18 +00:00
ivmarkov
279f0f458d Make Clippy happy 2023-05-21 17:06:42 +00:00
ivmarkov
fc9857c8a7 Quick temp fix for #250 2023-05-21 17:03:27 +00:00
ivmarkov
c21d8c09f2 PAtching no longer necessary 2023-05-13 17:27:23 +00:00
ivmarkov
8059a2d14c New release v0.41.0 2023-05-13 15:34:30 +00:00
ivmarkov
f2f5b830f6 Interrupt flags 2023-05-13 11:07:58 +00:00
ivmarkov
ba9cc4246a Interrupt flags 2023-05-13 10:07:38 +00:00
ivmarkov
01d35f3973 Matrix link 2023-05-12 23:37:52 +00:00
ivmarkov
08bd33aff2 Constants not available with CMake minimal builds 2023-05-12 23:37:45 +00:00