77 Commits

Author SHA1 Message Date
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
enelson1001
8e312529b9
Add RMT receiver (#104)
* Add RMT receiver

* Changed line 891 to rmt_item32_t,
Changed line 835 to carrier_rm

* rmt.rs - changed line 891 to rmt_item32_t
rmt.rs - changed line 835 to carrier_rm

* Changed rmt channel implementation

* wrong rx_config_t field name

* More cleanup from rebase

* Fix cargo fmt check errors

* guess #1 to fix errors

* Try to fix clippy error

* Can't use log change to println
Change gpio pins for esp32-c3

* old update to esp-idf-hal newer one coming

* Fix format errors

* Update TxRmtDriver and RxRmtDriver

* Fix compile errors

* fix rmt_morse_code.rs error

* Fix format failure

* Fix more errors

* Fix examples

* Change PulsePair durationX type
 - use u16 instead of PulseTicks

Co-authored-by: enelson1001 <ednelson5080@gmail>
2022-11-12 13:01:37 +02:00
ivmarkov
fcbba08fe3 Symmetry with SPI 2022-11-12 12:56:54 +02:00
Frederick Vollbrecht
13ba61fb0b
RFC: Multi CS Spi Implementation (#150)
* initial draft

* working alternative without using i32 id's

* EspSpiDevice + SpiDriverMaster / no global statics

* start splitting implementation in spi & spi_pool

* impl SpiDevice for EspSpiDevice

* spi2_pool draft (spi with software based cs)

* pre master fetch up

* Driver accepts Optional DMA channel + fetch master

* replaced: std with core, mutex with hal's cs

* replaced HashMap with Array

* merged spi2 into spi

* clean up

* replace std with core

* updated loopback example,  spi takes dma directly

* moved criticalsection guard out of spi to spi_pool

* added paragraph to the release.md

* rm fn to add / rm device from bus or update config

* rm stored config from EspSpiDevice

* fmt'd

* grammer + changelog update

* implements inverted chipselect for spi.rs #119

* device with optional cs + guarded soft_cs wrapper

* fmt'd

* add pre / post cs delay functionality for wrapper

* no bus.finish for dev with no cs. partial fix #99

* spi driver renaming

* updated naming + locking with &mut SpiDeviceDriver

* updated naming + locking with &mut SpiDeviceDriver

* clean up

* updated CHANGELOG
2022-11-12 08:54:16 +02:00
monacoprinsen
8cd8c8c207
spi/adc_st7789_example (#125)
* spi_st7789_example

* added adc example

* added ADC example

* spi and adc examples

* updated adc_st7789 example

* removed st7789 adc example

* adc up to date

* clippy and fmt

* added dependencies

* adjusted path to assets

* changed adc pin

* added compile flags

* path
2022-11-08 18:27:37 +02:00
ivmarkov
d6370068ef Move all peripheral generics into the constructors 2022-11-01 10:00:24 +02:00
Ronen Ulanovsky
db54a533b1 Fixup riscv-ulp-hal delay and examples 2022-10-07 20:53:26 +03:00