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
2022-02-05 18:57:46 +02:00
2022-01-19 21:35:44 +02:00
2022-05-02 15:45:49 +03:00
2022-12-14 08:04:52 +02:00
2022-12-13 12:06:44 +02:00
2021-08-31 21:21:41 +03:00
2021-08-31 21:21:41 +03:00
2022-11-22 17:42:44 +02:00

An embedded-hal implementation for ESP32[-XX] + ESP-IDF

CI crates.io Documentation

  • This crate is intended for usage in ESP32[-XX] embedded projects that utilize and link with the ESP-IDF SDK.
  • For embedded projects that don't need Rust STD support, WiFi or BLE (and thus don't link with the ESP-IDF SDK), please check esp-hal.

For more information, check out:

Hardware Notes

Each chip has a number of GPIO pins which are generally used by the SPI0 and SPI1 peripherals in order to connect external PSRAM and/or SPI Flash memory. The datasheets explicitly state that these are not recommended for use, however this crate includes them anyways for completeness.

Please refer to the table below to determine the pins which are not recommended for use for your chip.

Chip GPIOs
ESP32 6 - 11, 16 - 17
ESP32-C3 12 - 17
ESP32-S2 26 - 32
ESP32-S3 26 - 32, 33 - 37*

* When using Octal Flash and/or Octal PSRAM

Examples

The examples could be built and flashed conveniently with cargo-espflash. To run ledc-simple on an ESP32-C3:

$ cargo espflash --release --target riscv32imc-esp-espidf --example ledc-simple --monitor /dev/ttyUSB0

In order to run the examples on other chips you will most likely need to adapt at least the used pins.

Description
embedded-hal implementation for Rust on ESP32 and ESP-IDF
Readme 20 MiB
Languages
Rust 100%