* add BlockingIoDriver to make stdin/out/err calls blocking
* gate sys imports
* use at least enumset 1.1.4 to make EnumSet::empty() a const fn
* add missing trait impl
* fix wrong macro usage
* fix macro
* Remove all VFS code in prep to move it to esp_idf_svc::io::vfs
---------
Co-authored-by: Frederick Vollbrecht <frederick@vollbrecht.cc>
* Add first version of temp sensor driver
Code is very rudimentary and still suspect to change.
Notably, error handling is not implemented yet.
* Change cfg attribute to not any
* Rename TemperatureSensor to TemperatureSensorDriver
* Switch to `core::ptr`
* Add error handling
* Build the internal temperature sensor only on supported targets
* Fix the derives in TemperatureSensorConfig, TemperatureSensorClockSource
* Implement From<TemperatureSensorConfig> for temperature_sensor_config_t
* Use right clocks for temperature sensor depending on target
* Rename config and move it into own module
* Provide const new constructor for temperature sensor config
* Change config argument to be a reference
* Rename TemperatureSensor to TempSensor
* Avoid cloning config in temp driver constructor
* Add back derived Copy trait for TempSensorClockSource
* Add non_exhaustive option to TempSensorConfig
* Add temp sensor peripheral
* Cause panic if uninstalling the temp driver fails
* Implement Send for TempSensorDriver
* Make use of esp_idf_soc_temp_sensor_supported
* Add an example for temperature_sensor
---------
Co-authored-by: Luca Barbato <lu_zero@gentoo.org>
* commit test 1
test commit 2
next device
asd
* try example, haven't built yet
* Add feature flags for legacy RMT examples
Remove references to the ds18b20 specific device.
Add a feature flag `rmt-legacy` that, when enabled, will build the
original rmt modules from v4 of the esp-idf. When disabled, the v5
rmt interface can be used for one wire applications.
Implement the Iterator trait for a device search and use the Iterator
in the example.
* Add more feature guards to examples compile
* Add alternative main functions for examples
* Use std threading
* Add std to thread sleep
* use std duration
* correct use for legacy rmt component
* Remove local bindings and use the esp-idf-sys master
* fix a typo
* Remove esp-idf component inclusion
* Update gitignore
* Fix examples
* mut-ex out the example compilation
* add implementation for temperature readings
* Conditional compile
* esp4.4 compile
* Changes to cargo and config
* Remove OWDevice and simplify API
* Remove phantomdata that is not required
* adjust lifetimes for single search at a time
* Keep RMT peripheral and add channel to onewire
Moves the RMT driver into a private `driver` module, which will only be compiled in rmt-legacy mode.
Also reduce the number of cfg feature flags in examples by wrapping the implementation in a module.
* modularise examples
* Fix for CI
* update example name to make it pop
---------
Co-authored-by: Dane Slattery <dane@polarmonitoring.com>
Co-authored-by: DaneSlattery <dane_s@umantec.net>
* SD Card driver; SD Card host drivers (SPI and SDMMC)
* fmt
* fix typo
* Fix riscv32 build
* Better names for the GPIO matrix constructors
* Fix CI for esp32s3 and esp32p4
* Fix CI for esp32s3 and esp32p4
* SD-MMC finally works
* Address feedback from code review
* Support for all async executors
* Make all Notifiucation primitives a public API
* Address a small typo
* Address a small typo
* Fix CI
* Tighten the notify APIs by not taking 0s
* Fix CI
* Fix changelog
* Fix changelog
* Fix the examples
* edge-executor support moved to edge-executor
* wake-from-isr feature for edge-executor
* Fix CI
* Bugfixing
* Clippy
* Fix mono mode slot mask.
This changes the slot mask configuration in standard mode for
non ESP32/ESP32-S3 chips to use left-channel only mode. This behavior
differs from the ESP-IDF SDK, which appears to be in error due when
a preprocessor macro was renamed.
* Improve I2S documentation.
* Run cargo fmt.
* Fix clippy issues on 4.4.
* Fix another instance of dma_desc for 4.4.
* Add missing doc() attr.
* Upgrade to e-hal 1.0-rc1
* e-hal is no longer alpha
* Fix for ESP IDF < 5
* Unite all delay impls in a single module
* Model delays between transactions
* SPI: Make queueing it a bit more readable
* SPI: Plug delays
* Shorten the threshold for the Delay provider
* Clippy
* Fix the examples
* SPI: Detect last transaction in the presence of delays
* SPI: Introduce CsPin
* SPI: Introduce CsPin
* SPI: Mark delays with TODO
* Clippy
* SPI: Rename CsPin to CsCtl
* Transfer_transaction not necessary
* 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>
* 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.
* embedded-hal::delay no longer returns Error
* embedded_hal::digital add generic GpioError
* spi: init work: from closure to Operation pattern
* first full implementation
* i2c: remove iter fn droped by e-hal master
* make ci work by temp. refere to e-hal master
* more ci fix
* make clippy happy
* more ci fighting
* gpio: cursed repair of ulp_processor
* fmt
* spi: repair example + get rid of generic's
* dep: change to new e-hal release
* fix e-hal 0.2 comp & fix bus
* fmt
* clippy
* remove debug artifacts
* test ci with e-hal-nb-alpha.1
* e-hal-nb to alpha.2
* modified comments
* impl e-hal delay to general purpose provider
* use embedded_hal_error macro for riscv-ulp-hal
* typo
* impl pwm alpha10
* fixed wrong return error on async gpio
* duplicated impl error macro for ulp
* Start work on async
* Fix trailing whitespace in lib.rs
cargo fmt seems to be having an issue with this according to the checks.
* Fix clippy errors, remove useless enable_interrupt call
* Make embedded-hal-async optional
* Remove extra comment in lib.rs
* Rename wait_async to wait_asynch
* Use atomic wakers
* Reduce size of unsafe blocks
* Update for review comments
* Missed a few cfg(nightly)'s
* Remove unused import
* address review comments
---------
Co-authored-by: Scott Mabin <scott@mabez.dev>
* WIP - PCNT implementation for idf v4
* use from core not std
pass pins as PeripheralRef
store PinDriver in PcntPin
* try a allocate/deallocate stratagy for PCNT UNITS (like esp-idf v5)
* update pcnt example
* WIP - PCNT implementation for idf v4
* use from core not std
pass pins as PeripheralRef
store PinDriver in PcntPin
* try a allocate/deallocate stratagy for PCNT UNITS (like esp-idf v5)
* update pcnt example
* use Arc/Mutex for PcntPin so Pnct can be Send
* update pcnt encoder example
* add partial esp-idf 5 pulse_cnt support (no watches/events)
requires update in esp-idf-sys to choose implementation
uses pcnt on esp-idf 4
uses pulse_cnt by default on esp-idf 5
* fix pcnt compilation on esp-idf 4
* implement interrupt service
* added some documentation
* fix subscribe - trampoline did not work with captured values.
update example to support either
* no need to initialize logging in example
* use esp_idf_sys::*
* Implement From not Into
* switch from bitflags to enumset
* typo
* switch #[doc] to /// style
* gate uses of Box with alloc feature and use alloc::boxed::Box
* rename to PcntDriver and make Pcnt Peripherals
* use `impl Peripheral<P = impl InputPin>` instead of `AnyInputPin`
* small cleanup
* rename config() -> channel_config()
implement defaults on PcntChannelConfig
* some cleanup on idf v5 pulse_ctr
* no need for PcntChanConfig, just use flags
* use comment style documentation not `#[doc=""]`
* small tweak to pnct example
* review fixes (the easy ones)
* added deps for the pcnt example (dev-dependencies)
* cargo fmt
* pub const fn new for PcntChanFlags
* pub const fn new for PcntUnitFlags
* fix compilation for esp-idf 4
* pass in all pins in PcntDriver::new
use PinIndex to specify pins to a channel
* remove unused lifetime
* use a simple macro to convert Option<> pin to a pin number
* cargo fmt
* remove V5 for now
fix #cfg's for when/where pcnt is available
* fix #cfg's for when/where pcnt is available
* fix #cfg's for when/where pcnt is available
* gate access to ISR_HANDLERS in drop with `alloc`
no need for `not(feature = "riscv-ulp-hal")` as pcnt is not included for `riscv-ulp-hal`
* cargo fmt / clippy
* stub out the pcnt example on an unsuported device
* - drop esp-idf-svc from dev-deps (compile error on esp-idf 5)
- use println!() instead of log::info!() in pcnt example
* fix ocnt example compile for riscv32imc-esp-espidf
---------
Co-authored-by: Chris Liebman <chris.l@taboola.com>
Primarily useful because this gives me a readable `Debug` impl for the
reset reason. There may be a way to have `esp-idf-sys` generate some
more reasonable code as an alternative.
Use only ISR terminology
Remove unused imports
Simplify subscription code
timer subscription callbacks
No need for e-hal timer error
More meaningful timer periph names for esp32c3
embassy-time driver