Skip to content

Commit

Permalink
eh-1.0.0: support both e-h v1.0 and e-h v0.2 for key traits
Browse files Browse the repository at this point in the history
  • Loading branch information
richardeoin committed Mar 3, 2024
1 parent 038349f commit 5cfff1d
Show file tree
Hide file tree
Showing 29 changed files with 39 additions and 31 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
fugit = "0.3.5"
embedded-hal = { version = "1.0" }
embedded-hal-02 = { package = "embedded-hal", version = "0.2.7", features = ["unproven"] }
embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
embedded-dma = "0.2.0"
embedded-io = "0.6.1"
cortex-m = { version = "^0.7.7", features = ["critical-section-single-core"] }
Expand Down
6 changes: 4 additions & 2 deletions examples/blinky-stm32h747i-disco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use cortex_m_rt::entry;
use stm32h7xx_hal::{pac, prelude::*};

use embedded_hal_1::delay::DelayNs; // this example uses embedded-hal v1.0

use log::info;

#[macro_use]
Expand Down Expand Up @@ -53,13 +55,13 @@ fn main() -> ! {
led2.set_low();
led3.set_high();
led4.set_low();
delay.delay_ms(500_u16);
delay.delay_ms(500);

led1.set_low();
led2.set_high();
led3.set_low();
led4.set_high();
delay.delay_ms(500_u16);
delay.delay_ms(500);
}
}
}
2 changes: 1 addition & 1 deletion examples/blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use cortex_m_rt::entry;
#[macro_use]
mod utilities;

use embedded_hal::delay::DelayNs;
use embedded_hal_1::delay::DelayNs; // this example uses embedded-hal v1.0
use stm32h7xx_hal::{pac, prelude::*};

use log::info;
Expand Down
2 changes: 1 addition & 1 deletion examples/blinky_random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#![no_std]

use cortex_m_rt::entry;
use embedded_hal::delay::DelayNs;
use embedded_hal_1::delay::DelayNs; // this example uses embedded-hal v1.0
use stm32h7xx_hal::{pac, prelude::*};

#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion examples/blinky_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod utilities;
extern crate nb;

use cortex_m_rt::entry;
use embedded_hal::delay::DelayNs;
use embedded_hal_1::delay::DelayNs; // this example uses embedded-hal v1.0
use stm32h7xx_hal::{pac, prelude::*};

use log::info;
Expand Down
2 changes: 1 addition & 1 deletion examples/can-echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::hal::{
rcc,
rcc::rec,
};
use embedded_hal::delay::DelayNs;
use embedded_hal_1::delay::DelayNs; // this example uses embedded-hal v1.0
use fdcan::{
config::NominalBitTiming,
filter::{StandardFilter, StandardFilterSlot},
Expand Down
2 changes: 1 addition & 1 deletion examples/can-fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::hal::{
rcc,
rcc::rec,
};
use embedded_hal::delay::DelayNs;
use embedded_hal_1::delay::DelayNs; // this example uses embedded-hal v1.0
use fdcan::{
config::{DataBitTiming, FrameTransmissionConfig, NominalBitTiming},
filter::{StandardFilter, StandardFilterSlot},
Expand Down
2 changes: 2 additions & 0 deletions examples/display-dsi-command-teartest-stm32h747i-disco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ use log::info;
use otm8009a::Otm8009AConfig;
use stm32h7xx_hal::dsi::{ColorCoding, DsiChannel, DsiConfig, DsiPllConfig};

use embedded_hal_1::delay::DelayNs; // this example uses embedded-hal v1.0

extern crate cortex_m;
extern crate cortex_m_rt as rt;
use cortex_m_rt::{entry, exception};
Expand Down
2 changes: 2 additions & 0 deletions examples/display-dsi-video-stm32h747i-disco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ use log::info;
use otm8009a::Otm8009AConfig;
use stm32h7xx_hal::dsi::{ColorCoding, DsiChannel, DsiConfig, DsiPllConfig};

use embedded_hal_1::delay::DelayNs; // this example uses embedded-hal v1.0

extern crate cortex_m;
extern crate cortex_m_rt as rt;
use cortex_m_rt::{entry, exception};
Expand Down
2 changes: 2 additions & 0 deletions examples/display-dsi-video-teartest-stm32h747i-disco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ extern crate cortex_m;
extern crate cortex_m_rt as rt;
use cortex_m_rt::{entry, exception};

use embedded_hal_1::delay::DelayNs; // this example uses embedded-hal v1.0

use crate::utilities_display::display_target::BufferedDisplay;
use stm32h7xx_hal::gpio::Speed;
use stm32h7xx_hal::ltdc;
Expand Down
2 changes: 1 addition & 1 deletion examples/embedded-graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern crate cortex_m_rt as rt;
use core::sync::atomic::{AtomicU32, Ordering};
use cortex_m_rt::{entry, exception};

use embedded_hal::delay::DelayNs;
use embedded_hal_1::delay::DelayNs; // this example uses embedded-hal v1.0
use stm32h7xx_hal::gpio::Speed;
use stm32h7xx_hal::rcc::CoreClocks;
use stm32h7xx_hal::{ltdc, xspi};
Expand Down
2 changes: 1 addition & 1 deletion examples/gpio_with_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#![no_std]

use cortex_m_rt::entry;
use embedded_hal::delay::DelayNs;
use embedded_hal_1::delay::DelayNs; // this example uses embedded-hal v1.0
use stm32h7xx_hal::{pac, prelude::*};

use log::info;
Expand Down
2 changes: 1 addition & 1 deletion examples/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use cortex_m_rt::entry;
#[macro_use]
mod utilities;

use embedded_hal::i2c::*;
use embedded_hal_1::i2c::*; // this example uses embedded-hal v1.0
use stm32h7xx_hal::{pac, prelude::*};

use log::info;
Expand Down
2 changes: 1 addition & 1 deletion examples/i2c4_bdma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use cortex_m_rt::entry;
#[macro_use]
mod utilities;

use embedded_hal::i2c::*;
use embedded_hal_1::i2c::*; // this example uses embedded-hal v1.0
use stm32h7xx_hal::dma::{
bdma::{BdmaConfig, StreamsTuple},
PeripheralToMemory, Transfer,
Expand Down
2 changes: 1 addition & 1 deletion examples/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use cortex_m::asm;
use cortex_m_rt::entry;

use embedded_hal::pwm::*;
use embedded_hal_1::pwm::*; // this example uses embedded-hal v1.0
use stm32h7xx_hal::{pac, prelude::*};

#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion examples/pwm_advanced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mod utilities;
use stm32h7xx_hal::pwm::{FaultMonitor, Polarity};
use stm32h7xx_hal::{pac, prelude::*};

use embedded_hal::pwm::*;
use embedded_hal_1::pwm::*; // this example uses embedded-hal v1.0

use log::info;

Expand Down
2 changes: 1 addition & 1 deletion examples/pwm_lptim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use cortex_m_rt::entry;
#[macro_use]
mod utilities;

use embedded_hal::pwm::*;
use embedded_hal_1::pwm::*; // this example uses embedded-hal v1.0
use stm32h7xx_hal::{pac, prelude::*, rcc::rec};

use log::info;
Expand Down
2 changes: 1 addition & 1 deletion examples/reset_reason.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use cortex_m_rt::entry;
#[macro_use]
mod utilities;

use embedded_hal::delay::DelayNs;
use embedded_hal_1::delay::DelayNs; // this example uses embedded-hal v1.0
use stm32h7xx_hal::{pac, prelude::*, rcc::ResetReason};

use log::info;
Expand Down
2 changes: 1 addition & 1 deletion examples/sdmmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
mod utilities;

use cortex_m_rt::entry;
use embedded_hal::delay::DelayNs;
use embedded_hal_1::delay::DelayNs; // this example uses embedded-hal v1.0
use stm32h7xx_hal::gpio::Speed;
use stm32h7xx_hal::sdmmc::{SdCard, Sdmmc};
use stm32h7xx_hal::{pac, prelude::*};
Expand Down
2 changes: 1 addition & 1 deletion examples/sdmmc_fat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![no_std]

use {
embedded_hal::delay::DelayNs,
embedded_hal_1::delay::DelayNs, // this example uses embedded-hal v1.0 // this example uses embedded-hal v1.0
embedded_sdmmc::{Controller, Mode, VolumeIdx},
stm32h7xx_hal::sdmmc::{SdCard, Sdmmc},
stm32h7xx_hal::{pac, prelude::*, rcc},
Expand Down
2 changes: 1 addition & 1 deletion examples/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cortex_m_rt::entry;
#[macro_use]
mod utilities;

use embedded_hal::spi::*;
use embedded_hal_1::spi::*; // this example uses embedded-hal v1.0
use nb::block;
use stm32h7xx_hal::{pac, prelude::*, spi};

Expand Down
2 changes: 1 addition & 1 deletion examples/spi_hardware_cs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use cortex_m_rt::entry;
#[macro_use]
mod utilities;

use embedded_hal::spi::*;
use embedded_hal_1::spi::*; // this example uses embedded-hal v1.0
use nb::block;
use stm32h7xx_hal::{pac, prelude::*, spi};

Expand Down
2 changes: 1 addition & 1 deletion examples/spi_send_frames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use cortex_m_rt::entry;
mod utilities;
use core::num::NonZeroU16;

use embedded_hal::spi::*;
use embedded_hal_1::spi::*; // this example uses embedded-hal v1.0
use stm32h7xx_hal::{pac, prelude::*, spi};

use log::info;
Expand Down
2 changes: 1 addition & 1 deletion examples/temperature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use cortex_m_rt::entry;
#[macro_use]
mod utilities;

use embedded_hal::delay::DelayNs;
use embedded_hal_1::delay::DelayNs; // this example uses embedded-hal v1.0
use stm32h7xx_hal::{
adc,
delay::Delay,
Expand Down
2 changes: 1 addition & 1 deletion examples/usb_phy_serial_interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use {
core::cell::RefCell,
core::mem::MaybeUninit,
cortex_m::interrupt::{free as interrupt_free, Mutex},
embedded_hal::delay::DelayNs,
embedded_hal_1::delay::DelayNs, // this example uses embedded-hal v1.0
stm32h7xx_hal::{
interrupt, pac,
prelude::*,
Expand Down
5 changes: 2 additions & 3 deletions src/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

use cortex_m::peripheral::syst::SystClkSource;
use cortex_m::peripheral::SYST;
use embedded_hal::delay::DelayNs;
use void::Void;

use crate::block;
Expand Down Expand Up @@ -206,7 +205,7 @@ impl Delay {
}
}

impl DelayNs for Delay {
impl embedded_hal_1::delay::DelayNs for Delay {
fn delay_ns(&mut self, ns: u32) {
// With c_ck up to 480e6, 1 cycle is always > 2ns

Expand Down Expand Up @@ -310,7 +309,7 @@ macro_rules! impl_delay_from_count_down_timer {
}
}

impl DelayNs for DelayFromCountDownTimer<$TIMX> {
impl embedded_hal_1::delay::DelayNs for DelayFromCountDownTimer<$TIMX> {
fn delay_ns(&mut self, ns: u32) {
// TODO(): This delay is 1000x longer than the intended duration!
self.delay_us_internal(ns);
Expand Down
2 changes: 1 addition & 1 deletion src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub use dynamic::{Dynamic, DynamicPin};
mod hal_02;
mod hal_1;

pub use embedded_hal::digital::PinState;
pub use embedded_hal_1::digital::PinState;

use core::fmt;

Expand Down
6 changes: 3 additions & 3 deletions src/gpio/hal_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use super::{
PartiallyErasedPin, Pin,
};

use embedded_hal::digital::{ErrorKind, ErrorType};
use embedded_hal::digital::{InputPin, OutputPin, StatefulOutputPin};
use embedded_hal_1::digital::{ErrorKind, ErrorType};
use embedded_hal_1::digital::{InputPin, OutputPin, StatefulOutputPin};

/// Error type for GPIO
#[derive(Clone, Copy, Debug, PartialEq)]
Expand All @@ -15,7 +15,7 @@ pub enum GpioError {
/// Error
Other,
}
impl embedded_hal::digital::Error for GpioError {
impl embedded_hal_1::digital::Error for GpioError {
fn kind(&self) -> ErrorKind {
ErrorKind::Other
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ compile_error!(
"
);

pub use embedded_hal as hal;
pub use embedded_hal_1 as hal;
pub mod traits;

pub use nb;
Expand Down

0 comments on commit 5cfff1d

Please sign in to comment.