* 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
* 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
* 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>
* 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).
* 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.
* 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