Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update embedded-hal to 1.0 #73

Merged
merged 11 commits into from
Jan 26, 2024
Next Next commit
refactor: Import embedded-hal 0.2 as embedded-hal-0-2
  • Loading branch information
chrysn committed Jan 26, 2024
commit b743979b6119541571ab48e25099372d881c65a9
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ license = "MIT OR Apache-2.0"


[dependencies]
embedded-hal = { version = "0.2.4", features = ["unproven"] }
embedded-hal-0-2 = { package = "embedded-hal", version = "0.2.4", features = ["unproven"] }
switch-hal = "0.4.0"
nb = "0.1.1"
riot-sys = "0.7.8"
Expand Down
4 changes: 2 additions & 2 deletions src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ pub struct ADC {
pub resolution: riot_sys::adc_res_t,
}

impl embedded_hal::adc::Channel<ADC> for ADCLine {
impl embedded_hal_0_2::adc::Channel<ADC> for ADCLine {
type ID = riot_sys::adc_t;
fn channel() -> Self::ID {
unimplemented!("See https://github.com/rust-embedded/embedded-hal/issues/110")
}
}

impl embedded_hal::adc::OneShot<ADC, i32, ADCLine> for ADC {
impl embedded_hal_0_2::adc::OneShot<ADC, i32, ADCLine> for ADC {
type Error = Never;

fn read(&mut self, pin: &mut ADCLine) -> nb::Result<i32, Never> {
Expand Down
4 changes: 2 additions & 2 deletions src/gpio.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! Access to [RIOT's GPIO pins](http://doc.riot-os.org/group__drivers__periph__gpio.html)
//!
//! The various configured GPIO types ([InputGPIO], [OutputGPIO], [InOutGPIO]) can be used through
//! the [embedded_hal::digital::v2] traits.
//! the [embedded_hal_0_2::digital::v2] traits.

use riot_sys::{gpio_clear, gpio_mode_t, gpio_read, gpio_set, gpio_t, gpio_toggle};

use embedded_hal::digital::v2::{InputPin, OutputPin, ToggleableOutputPin};
use embedded_hal_0_2::digital::v2::{InputPin, OutputPin, ToggleableOutputPin};

use crate::error::NegativeErrorExt;
use crate::Never;
Expand Down
4 changes: 2 additions & 2 deletions src/i2c.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Controlling the I²C bus

use embedded_hal::blocking;
use embedded_hal_0_2::blocking;
use riot_sys::i2c_t;

/// An I²C master backed by RIOT's [I2C implementation]
///
/// [I2C implementation]: http://doc.riot-os.org/group__drivers__periph__i2c.html
///
/// Actual transactions on this are performed through the [embedded_hal::blocking::i2c] traits
/// Actual transactions on this are performed through the [mbedded_hal_0_2::blocking::i2c] traits
/// implemented by this.
#[derive(Debug)]
pub struct I2CDevice {
Expand Down
10 changes: 5 additions & 5 deletions src/led.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ impl<const I: u8> switch_hal::OutputSwitch for LED<I> {
type Error = Never;

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

fn off(&mut self) -> Result<(), Self::Error> {
use embedded_hal::digital::v2::OutputPin;
use embedded_hal_0_2::digital::v2::OutputPin;
self.set_low()
}
}
Expand All @@ -37,11 +37,11 @@ impl<const I: u8> switch_hal::ToggleableOutputSwitch for LED<I> {
type Error = Never;

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

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

fn set_high(&mut self) -> Result<(), Never> {
Expand Down Expand Up @@ -81,7 +81,7 @@ impl<const I: u8> embedded_hal::digital::v2::OutputPin for LED<I> {
}
}

impl<const I: u8> embedded_hal::digital::v2::ToggleableOutputPin for LED<I> {
impl<const I: u8> embedded_hal_0_2::digital::v2::ToggleableOutputPin for LED<I> {
type Error = Never;

fn toggle(&mut self) -> Result<(), Never> {
Expand Down
2 changes: 1 addition & 1 deletion src/microbit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::Never;

/// The 5x5 LED matrix of the micro:bit boards
///
/// Use the [embedded_hal] mechanisms to paint on them.
/// Use the [embedded_graphics] mechanisms to paint on them.
pub struct LEDs {
_private: (),
}
Expand Down
2 changes: 1 addition & 1 deletion src/spi.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::Never;
use embedded_hal::blocking;
use embedded_hal_0_2::blocking;
use riot_sys::{
spi_acquire,
spi_clk_t,
Expand Down
4 changes: 2 additions & 2 deletions src/ztimer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ impl Clock<1000000> {
}
}

impl embedded_hal::blocking::delay::DelayMs<u32> for Clock<1000> {
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::blocking::delay::DelayUs<u32> for Clock<1000000> {
impl embedded_hal_0_2::blocking::delay::DelayUs<u32> for Clock<1000000> {
fn delay_us(&mut self, us: u32) {
self.sleep_ticks(us);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/gpio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use riot_wrappers::gpio::{InputMode, OutputMode, GPIO};
use riot_wrappers::println;
use riot_wrappers::riot_main;

use embedded_hal::digital::v2::{InputPin, OutputPin, PinState};
use embedded_hal_0_2::digital::v2::{InputPin, OutputPin, PinState};

riot_main!(main);

Expand Down