Skip to content

Commit

Permalink
Drop support for embedded-hal 0.2 except where 1.0 has no traits for …
Browse files Browse the repository at this point in the history
…it (ADC)

SPI is not dropped either because the 1.0 trait includes acquisition in
the trait (which makes it not trivial to port).

Closes: #65
  • Loading branch information
chrysn committed Aug 19, 2024
1 parent 2b73c1d commit b688639
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 222 deletions.
73 changes: 0 additions & 73 deletions src/gpio/impl_0_2.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/gpio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! the [embedded_hal::digital::v2] traits. As recommended for infallible types, they also
//! provide identically named direct methods, which (for input pins) also work on shared reference.
mod impl_0_2;
mod impl_1;

use riot_sys::{gpio_clear, gpio_mode_t, gpio_read, gpio_set, gpio_t, gpio_toggle, gpio_write};
Expand Down
106 changes: 0 additions & 106 deletions src/i2c/impl_0_2.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/i2c/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Controlling the I²C bus
pub mod impl_0_2;
pub mod impl_1;

use riot_sys::i2c_t;
Expand Down
32 changes: 3 additions & 29 deletions src/led.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ use core::convert::Infallible;
/// The preferred interface for turning a LED on and off is [switch_hal::OutputSwitch].
///
/// LEDs are accessible safely; any not implemented on a board are silently ignored.
///
/// LEDs are wrapped into embedded-hal 0.2 GPIOs for compatibility reasons (but that integration is
/// discontinued with embedded-hal 1.0); GPIO is interpreted such that "high" is having the LED on,
/// and "low" is off.
pub struct LED<const I: u8>(());

impl<const I: u8> LED<I> {
Expand All @@ -24,28 +20,6 @@ impl<const I: u8> switch_hal::OutputSwitch for LED<I> {
type Error = Infallible;

fn on(&mut self) -> Result<(), Self::Error> {
use embedded_hal_0_2::digital::v2::OutputPin;
self.set_high()
}

fn off(&mut self) -> Result<(), Self::Error> {
use embedded_hal_0_2::digital::v2::OutputPin;
self.set_low()
}
}

impl<const I: u8> switch_hal::ToggleableOutputSwitch for LED<I> {
type Error = Infallible;

fn toggle(&mut self) -> Result<(), Self::Error> {
<Self as embedded_hal_0_2::digital::v2::ToggleableOutputPin>::toggle(self)
}
}

impl<const I: u8> embedded_hal_0_2::digital::v2::OutputPin for LED<I> {
type Error = Infallible;

fn set_high(&mut self) -> Result<(), Infallible> {
// unsafe: RIOT's LED functions can be called any time (and no-op on undefined LEDs)
unsafe {
match I {
Expand All @@ -63,7 +37,7 @@ impl<const I: u8> embedded_hal_0_2::digital::v2::OutputPin for LED<I> {
Ok(())
}

fn set_low(&mut self) -> Result<(), Infallible> {
fn off(&mut self) -> Result<(), Self::Error> {
// unsafe: RIOT's LED functions can be called any time (and no-op on undefined LEDs)
unsafe {
match I {
Expand All @@ -82,10 +56,10 @@ impl<const I: u8> embedded_hal_0_2::digital::v2::OutputPin for LED<I> {
}
}

impl<const I: u8> embedded_hal_0_2::digital::v2::ToggleableOutputPin for LED<I> {
impl<const I: u8> switch_hal::ToggleableOutputSwitch for LED<I> {
type Error = Infallible;

fn toggle(&mut self) -> Result<(), Infallible> {
fn toggle(&mut self) -> Result<(), Self::Error> {
// unsafe: RIOT's LED functions can be called any time (and no-op on undefined LEDs)
unsafe {
match I {
Expand Down
12 changes: 0 additions & 12 deletions src/ztimer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,6 @@ impl Clock<1000000> {
}
}

impl embedded_hal_0_2::blocking::delay::DelayMs<u32> for Clock<1000> {
fn delay_ms(&mut self, ms: u32) {
self.sleep_ticks(ms.into());
}
}

impl embedded_hal_0_2::blocking::delay::DelayUs<u32> for Clock<1000000> {
fn delay_us(&mut self, us: u32) {
self.sleep_ticks(us);
}
}

#[cfg(all(feature = "embedded-hal-async", riot_module_ztimer_usec))]
/// Struct that provides the [embedded_hal_async::delay::DelayNs] trait
///
Expand Down

0 comments on commit b688639

Please sign in to comment.