83 Commits

Author SHA1 Message Date
hyx0329
e20ef5c92f
Add an example of using interrupt directly without async (#474) 2024-09-09 18:16:26 +03:00
DaneSlattery
aa0e257ffe
RMT Onewire Peripheral (#454)
* 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>
2024-08-10 16:11:38 +03:00
Jorge Muñoz
74ffea5c0c
Fixes #443: Add new ResetReason enum items (#444)
* Fixes #443: Add new ResetReason enum items

* Fix examples/reset_reason.rs comments

* Add forgotten 5.1.3 version to conditions

* Add forgotten 5.1.3 version to more conditions
2024-07-02 16:17:48 +02:00
ivmarkov
f20b9f71a5 Replace with 2024-06-16 07:50:15 +00:00
ivmarkov
16823abd7d Protect the legacy example; do not make the oneshot_legacy mod an API (yet) 2024-06-16 07:35:35 +00:00
ivmarkov
e3e8a37807 Hide the new ADC oneshot driver behind a feature flag 2024-06-16 07:35:35 +00:00
adam-53-r
0360fc8d0a
Fixed one character typo. (#381) 2024-02-20 14:18:13 +00:00
David Sheets
5657073293
RMT symbols and musical buzzer example bugfix for ESP32 (#354)
* rmt: wrap rmt_item32_t in a newtype

This makes it much easier to use `TxRmtDriver::start_iter` and
`TxRmtDriver::start_iter_blocking` (#113).

* examples/rmt_musical_buzzer: fix for ESP32

Possibly broken by #97, possibly never worked. The ESP-IDF repo
specifically excludes the ESP32 from the RMT musical buzzer demo
because its RMT unit lacks hardware looping. Before this change, the
demo would simply hang when trying to play the second note possibly
because the ESP32 RMT unit does not support asynchronous stopping.

As an added bonus, this example is now much easier to modify to
experiment with 1-bit chiptune synthesis by making every symbol
(cycle) accessible in the ISR iterator.

* rmt: remove Pulse::into_rmt_item in favor of Symbol::new

Also, factor Pulse pairs into function arguments for ease of use.
2024-01-31 15:39:29 +02:00
ivmarkov
e79df5a873 Get rid of the riscv-ulp-hal feature 2024-01-18 20:12:27 +00:00
ivmarkov
05140a3056 The crate now does build with cargo --all-features 2024-01-05 16:26:26 +00:00
ivmarkov
455cf15dc6 Fix CI 2023-11-22 06:14:39 +00:00
ivmarkov
6eeeae1018 Use better pins for esp32 2023-10-16 19:27:53 +00:00
ivmarkov
bb92e2a47e Async examples 2023-10-14 07:36:30 +00:00
ivmarkov
092055b967 Bugfixing; async timer example 2023-10-09 18:55:44 +00:00
ivmarkov
ebeef0fcc8
All executors (#315)
* 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
2023-10-06 22:01:20 +03:00
ivmarkov
4df6030eb8 fix CI 2023-09-19 08:56:21 +00:00
ivmarkov
53a48597d8 fix CI 2023-09-19 06:49:47 +00:00
ivmarkov
356f9f8218 Fix CI 2023-09-18 06:12:09 +00:00
liebman
95dfc2f9f7
Adc oneshot driver (#302)
* esp-idf v5 Adc oneshot driver

* cargo fmt

* added example & cargo fmt

* fix clippy issues

* more clippy's

* even more clippy's

* handle most review comments

* AdcChannelDriver: remove ADC annotation - use T::Adc
AdcChannelDriver: remove Sync implementation
examples: update adc_oneshot

* cargo fmt
remove AdcChannelDriver::channel

* implement e-hal 0.2 Adc OneShot trait
2023-09-18 06:59:54 +03:00
ivmarkov
d7ca04fb27 Option to notify a task without yield 2023-09-14 08:05:50 +00:00
ivmarkov
2cb816c6d4 Split the notification mechanism from the executor module 2023-09-08 17:20:00 +00:00
ivmarkov
bed45e741e
Upgrade to e-hal 1.0-rc1 (#295)
* 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
2023-09-06 09:36:48 +03: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
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
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
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
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
ivmarkov
ba9cc4246a Interrupt flags 2023-05-13 10:07:38 +00:00
Frederick Vollbrecht
b739c46b12
Embedded-Hal PR - incoorparate e-hal master changes in spi / i2c / gpio / delay (#224)
* 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
2023-05-08 20:59:45 +03:00
Sergio Gasquez Arcos
061a234ba9
Update ledc examples names (#214)
* style: 🎨 Rename ledc examples to be consistent

* docs: 📝 Update rust-board name
2023-03-08 07:43:02 +02:00
liebman
72c0aacf74
PCNT implementation for v4 esp-idf api (will work for on v5 with v4 api) (#157)
* 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>
2023-02-21 09:07:45 +02:00
Danilo Bargen
d477d54e2b
General purpose delay provider (#210)
* Move delay implementations to dedicated subdirectory

* Add general purpose delay provider
2023-02-20 15:45:41 +02:00
Adam Mashrique
28a3aad231
Correct endianness of RMT signal in neopixel example (#195)
* Correct endianness of RMT signal

Bits were sent reversed, which worked for 0xff but not at smaller values to dim the LED. Also added rainbow example using a hsv function.

* cargo fmt

* Removed logger and fixed delays
2023-01-14 12:49:55 +02:00
Raphael Höser
bf13eee9a2
#180 ledcdriver redundand timer config (#188)
* fix: #180 Remove redundant info in LedcDriver::new

This is an implementation of one of the possible solutions to the issue.

Signed-off-by: Raphael Höser <raphael@hoeser.info>

* Remove speed_mode method from LedcTimerDriver as it's not needed.

* Fix rustfmt issues

Signed-off-by: Raphael Höser <raphael@hoeser.info>
2022-12-12 09:35:36 +00:00
Ivan Markov
81a7e3d84c clippy 2022-12-04 16:21:28 +00:00
Ronen Ulanovsky
bc465611c8
do some clippy/Cargo.toml housekeeping, update st7789 example to use a non-deprecated driver (#169) 2022-11-19 15:11:41 +02:00
Ronen Ulanovsky
3f532d7224
Overhaul UART to support single wire transmitters/receivers (#164)
* overhaul UART to support single wire trasimitters/receivers

* add missing methods for uart transmitter/receiver

* fix `uart_config_t`'s `source_clk` being part of a union in `esp-idf v4.x`

* add `esp32c2`'s `PLL F40M` `APB` clock

* revert `uart_wait_tx_done` to timeout of 0

* fix incorrect order in `uart_driver_install`, `rx_buffer` shou always exceed `UART_FIFO_SIZE`

* Refactor `Owner` enum

* Fix double drop on `into_split`

* Add missing `count` methods for the UART drivers, change their return to be able to fit the maximum allowed value, don't run `drop` on temporary internal borrows, update example
2022-11-19 15:10:43 +02:00
ivmarkov
5f7122a2f6 Fix rmt receiver 2022-11-14 23:15:22 +02:00
ivmarkov
7f801159ab Allocate enough stack space 2022-11-14 07:58:50 +02:00
ivmarkov
5667be95ac Fix examples 2022-11-12 16:25:38 +02:00
ivmarkov
2cffd68b48 Fix a typo 2022-11-12 15:51:21 +02:00
ivmarkov
c181e60451 Fix example 2022-11-12 15:47:33 +02:00
ivmarkov
163715ee19 Fix example 2022-11-12 15:26:07 +02:00
ivmarkov
9979b7e385 Fix example 2022-11-12 15:07:02 +02:00
ivmarkov
555dfafec6 Fix the SPI example 2022-11-12 14:26:10 +02:00
ivmarkov
bea4411b7f Add necessary import 2022-11-12 14:16:48 +02:00
ivmarkov
48834fb1ae Make the TX and RX side more coherent 2022-11-12 14:08:26 +02:00
ivmarkov
35609be6b6 Convenience methods and types for the single SPI device case 2022-11-12 13:48:23 +02:00
ivmarkov
a78dc8c86d Fix the RMT driver 2022-11-12 13:30:32 +02:00