diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f41a9c2..38b2694 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build and Test check jobs: builds: name: Build checks - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 strategy: matrix: mode: ["", "--release"] diff --git a/Cargo.toml b/Cargo.toml index 6e8abe5..7e8998e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,11 +8,18 @@ documentation = "https://docs.rs/ws2812-pio" repository = "https://github.com/rp-rs/ws2812-pio-rs/" [dependencies] +cfg-if = "1.0" embedded-hal = "0.2.5" fugit = "0.3.5" -rp2040-hal = "0.11" pio = "0.2.0" smart-leds-trait = "0.3" smart-leds-trait-0-2 = { package = "smart-leds-trait", version = "0.2.1" } nb = "1.0.0" cortex-m = "0.7.3" +rp2040-hal = { version = "0.11.0", optional = true } +rp235x-hal = { version = "0.2.0", optional = true } + +[features] +default = ["rp2040"] +rp2040 = ["dep:rp2040-hal"] +rp235x = ["dep:rp235x-hal"] diff --git a/src/lib.rs b/src/lib.rs index 75ad292..5bbba9f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,10 +15,24 @@ use embedded_hal::timer::CountDown; use fugit::{ExtU32, HertzU32, MicrosDurationU32}; -use rp2040_hal::{ + +use cfg_if::cfg_if; + +cfg_if! { + if #[cfg(feature = "rp2040")] { + use rp2040_hal as hal; + } else if #[cfg(feature = "rp235x")] { + use rp235x_hal as hal; + } else { + compile_error!("Either 'rp2040' or 'rp235x' feature must be enabled."); + } +} + +use hal::{ gpio::AnyPin, pio::{PIOExt, StateMachineIndex, Tx, UninitStateMachine, PIO}, }; + use smart_leds_trait::SmartLedsWrite; use smart_leds_trait_0_2::SmartLedsWrite as SmartLedsWrite02; @@ -33,9 +47,9 @@ use smart_leds_trait_0_2::SmartLedsWrite as SmartLedsWrite02; /// /// Typical usage example: ///```ignore -/// use rp2040_hal::clocks::init_clocks_and_plls; +/// use hal::clocks::init_clocks_and_plls; /// let clocks = init_clocks_and_plls(...); -/// let pins = rp2040_hal::gpio::pin::bank0::Pins::new(...); +/// let pins = hal::gpio::pin::bank0::Pins::new(...); /// /// let (mut pio, sm0, _, _, _) = pac.PIO0.split(&mut pac.RESETS); /// let mut ws = Ws2812Direct::new( @@ -54,6 +68,7 @@ use smart_leds_trait_0_2::SmartLedsWrite as SmartLedsWrite02; /// delay_for_at_least_60_microseconds(); /// }; ///``` + pub struct Ws2812Direct
where
I: AnyPin
where
C: CountDown,
@@ -268,7 +284,6 @@ where
Self { driver, cd }
}
}
-
impl SmartLedsWrite for Ws2812
where
C: CountDown,
@@ -293,7 +308,6 @@ where
SmartLedsWrite::write(&mut self.driver, iterator)
}
}
-
impl SmartLedsWrite02 for Ws2812
where
C: CountDown,