From 9cc2b5568942fb84214abacd05d4940339f57a8b Mon Sep 17 00:00:00 2001 From: Michael Guerrier <68760212+Token-Thinker@users.noreply.github.com> Date: Fri, 27 Dec 2024 15:21:02 -0500 Subject: [PATCH] update esp-hal to 0.22.0 --- esp-hal-smartled/Cargo.toml | 10 ++------ esp-hal-smartled/examples/hello_rgb.rs | 14 +++++------ esp-hal-smartled/src/lib.rs | 35 +++++++++++++++----------- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/esp-hal-smartled/Cargo.toml b/esp-hal-smartled/Cargo.toml index 18cee65..dd14c53 100644 --- a/esp-hal-smartled/Cargo.toml +++ b/esp-hal-smartled/Cargo.toml @@ -14,7 +14,7 @@ targets = ["riscv32imac-unknown-none-elf"] [dependencies] defmt = { version = "0.3.8", optional = true } document-features = "0.2.10" -esp-hal = "0.20.0" +esp-hal = "0.22.0" fugit = "0.3.7" smart-leds-trait = "0.3.0" @@ -25,7 +25,7 @@ esp-backtrace = { version = "0.14.1", features = [ "panic-handler", "println", ] } -esp-println = "0.11.0" +esp-println = "0.12.0" smart-leds = "0.4.0" [features] @@ -45,9 +45,3 @@ esp32h2 = ["esp-backtrace/esp32h2", "esp-hal/esp32h2", "esp-println/esp32h2"] esp32s2 = ["esp-backtrace/esp32s2", "esp-hal/esp32s2", "esp-println/esp32s2"] ## Target the ESP32-S3. esp32s3 = ["esp-backtrace/esp32s3", "esp-hal/esp32s3", "esp-println/esp32s3"] - -# TODO: Remove patches prior to next release -[patch.crates-io] -esp-backtrace = { git = "https://github.com/esp-rs/esp-hal", rev = "d44affc" } -esp-hal = { git = "https://github.com/esp-rs/esp-hal", rev = "d44affc" } -esp-println = { git = "https://github.com/esp-rs/esp-hal", rev = "d44affc" } diff --git a/esp-hal-smartled/examples/hello_rgb.rs b/esp-hal-smartled/examples/hello_rgb.rs index fe15d90..481d093 100644 --- a/esp-hal-smartled/examples/hello_rgb.rs +++ b/esp-hal-smartled/examples/hello_rgb.rs @@ -23,7 +23,7 @@ #![no_main] use esp_backtrace as _; -use esp_hal::{delay::Delay, gpio::Io, prelude::*, rmt::Rmt}; +use esp_hal::{delay::Delay, prelude::*, rmt::Rmt}; use esp_hal_smartled::{smartLedBuffer, SmartLedsAdapter}; use smart_leds::{ brightness, gamma, @@ -35,21 +35,19 @@ use smart_leds::{ fn main() -> ! { let peripherals = esp_hal::init(esp_hal::Config::default()); - let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); - // Each devkit uses a unique GPIO for the RGB LED, so in order to support // all chips we must unfortunately use `#[cfg]`s: cfg_if::cfg_if! { if #[cfg(feature = "esp32")] { - let led_pin = io.pins.gpio33; + let led_pin = peripherals.GPIO33; } else if #[cfg(feature = "esp32c3")] { - let led_pin = io.pins.gpio8; + let led_pin = peripherals.GPIO8; } else if #[cfg(any(feature = "esp32c6", feature = "esp32h2"))] { - let led_pin = io.pins.gpio8; + let led_pin = peripherals.GPIO8; } else if #[cfg(feature = "esp32s2")] { - let led_pin = io.pins.gpio18; + let led_pin = peripherals.GPIO18; } else if #[cfg(feature = "esp32s3")] { - let led_pin = io.pins.gpio48; + let led_pin = peripherals.GPIO48; } } diff --git a/esp-hal-smartled/src/lib.rs b/esp-hal-smartled/src/lib.rs index 3b8ec16..9b1e288 100644 --- a/esp-hal-smartled/src/lib.rs +++ b/esp-hal-smartled/src/lib.rs @@ -11,11 +11,10 @@ //! ## Example //! //! ```rust,ignore -//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); //! let rmt = Rmt::new(peripherals.RMT, 80.MHz(), None).unwrap(); //! //! let rmt_buffer = smartLedBuffer!(1); -//! let mut led = SmartLedsAdapter::new(rmt.channel0, io.pins.gpio2, rmt_buffer); +//! let mut led = SmartLedsAdapter::new(rmt.channel0, peripherals.GPIO2, rmt_buffer); //! ``` //! //! ## Feature Flags @@ -51,6 +50,12 @@ pub enum LedAdapterError { TransmissionError(RmtError), } +impl From for LedAdapterError { + fn from(e: RmtError) -> Self { + LedAdapterError::TransmissionError(e) + } +} + /// Macro to allocate a buffer sized for a specific number of LEDs to be /// addressed. /// @@ -113,18 +118,18 @@ where channel: Some(channel), rmt_buffer, pulses: ( - u32::from(PulseCode { - level1: true, - length1: ((SK68XX_T0H_NS * src_clock) / 1000) as u16, - level2: false, - length2: ((SK68XX_T0L_NS * src_clock) / 1000) as u16, - }), - u32::from(PulseCode { - level1: true, - length1: ((SK68XX_T1H_NS * src_clock) / 1000) as u16, - level2: false, - length2: ((SK68XX_T1L_NS * src_clock) / 1000) as u16, - }), + PulseCode::new ( + true, + ((SK68XX_T0H_NS * src_clock) / 1000) as u16, + false, + ((SK68XX_T0L_NS * src_clock) / 1000) as u16, + ), + PulseCode::new ( + true, + ((SK68XX_T1H_NS * src_clock) / 1000) as u16, + false, + ((SK68XX_T1L_NS * src_clock) / 1000) as u16, + ), ), } } @@ -188,7 +193,7 @@ where // Perform the actual RMT operation. We use the u32 values here right away. let channel = self.channel.take().unwrap(); - match channel.transmit(&self.rmt_buffer).wait() { + match channel.transmit(&self.rmt_buffer)?.wait() { Ok(chan) => { self.channel = Some(chan); Ok(())