Skip to content

Commit

Permalink
remove embedded-hal 0.2 from prelude, rename hals
Browse files Browse the repository at this point in the history
embedded-hal 1.0 renamed from embedded-hal-one to embedded-hal
embedded-hal 0.2 renamed from embedded-hal to embedded-hal-old, still
re-exported as hal-02
  • Loading branch information
techmccat committed Aug 5, 2024
1 parent 3c6d61e commit 4915e78
Show file tree
Hide file tree
Showing 31 changed files with 202 additions and 141 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ default-features = false
features = ["const-fn"]
version = "0.2.5"

[dependencies.embedded-hal]
[dependencies.embedded-hal-old]
package = "embedded-hal"
features = ["unproven"]
version = "0.2.4"
version = "0.2.7"

[dependencies.embedded-hal-one]
[dependencies.embedded-hal]
version = "1.0.0"
package = "embedded-hal"

[dependencies.embedded-dma]
version = "0.1.2"
Expand Down Expand Up @@ -95,7 +95,7 @@ stm32g4a1 = ["stm32g4/stm32g4a1"]
log-itm = ["cortex-m-log/itm"]
log-rtt = []
log-semihost = ["cortex-m-log/semihosting"]
defmt-logging = ["defmt", "nb/defmt-0-3", "embedded-hal-one/defmt-03", "embedded-io/defmt-03"]
defmt-logging = ["defmt", "nb/defmt-0-3", "embedded-hal/defmt-03", "embedded-io/defmt-03"]

[profile.dev]
codegen-units = 1
Expand Down
13 changes: 9 additions & 4 deletions examples/adc-continious-dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
#![no_main]

mod utils;
use utils::logger::info;

use crate::hal::{
adc::{
config,
config::{Continuous, Dma as AdcDma, SampleTime, Sequence},
AdcClaim, ClockSource, Temperature, Vref,
},
delay::SYSTDelayExt,
time::ExtU32,
timer::Timer,
delay::DelayFromCountDownTimer,
dma::{config::DmaConfig, stream::DMAExt, TransferExt},
gpio::GpioExt,
pwr::PwrExt,
Expand All @@ -20,7 +23,6 @@ use crate::hal::{
use stm32g4xx_hal as hal;

use cortex_m_rt::entry;
use utils::logger::info;

#[entry]
fn main() -> ! {
Expand All @@ -29,7 +31,7 @@ fn main() -> ! {
info!("start");

let dp = Peripherals::take().unwrap();
let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
// let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");

info!("rcc");
let rcc = dp.RCC.constrain();
Expand All @@ -47,7 +49,10 @@ fn main() -> ! {
let pa0 = gpioa.pa0.into_analog();

info!("Setup Adc1");
let mut delay = cp.SYST.delay(&rcc.clocks);
// let mut delay = cp.SYST.delay(&rcc.clocks);
let mut delay = DelayFromCountDownTimer::new(
Timer::new(dp.TIM6, &rcc.clocks).start_count_down(100u32.millis()),
);
let mut adc = dp
.ADC1
.claim(ClockSource::SystemClock, &rcc, &mut delay, true);
Expand Down
11 changes: 8 additions & 3 deletions examples/adc-continious.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use crate::hal::{
config::{Continuous, Resolution, SampleTime, Sequence},
AdcClaim, ClockSource, Temperature, Vref,
},
delay::SYSTDelayExt,
time::ExtU32,
timer::Timer,
delay::DelayFromCountDownTimer,
gpio::GpioExt,
pwr::PwrExt,
rcc::{Config, RccExt},
Expand All @@ -29,7 +31,7 @@ fn main() -> ! {
info!("start");

let dp = Peripherals::take().unwrap();
let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
// let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");

info!("rcc");

Expand All @@ -42,7 +44,10 @@ fn main() -> ! {
let pa0 = gpioa.pa0.into_analog();

info!("Setup Adc1");
let mut delay = cp.SYST.delay(&rcc.clocks);
// let mut delay = cp.SYST.delay(&rcc.clocks);
let mut delay = DelayFromCountDownTimer::new(
Timer::new(dp.TIM6, &rcc.clocks).start_count_down(100u32.millis()),
);
let mut adc = dp
.ADC1
.claim(ClockSource::SystemClock, &rcc, &mut delay, true);
Expand Down
13 changes: 9 additions & 4 deletions examples/adc-one-shot-dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use crate::hal::{
config::{Continuous, Dma as AdcDma, Resolution, SampleTime, Sequence},
AdcClaim, ClockSource, Temperature,
},
delay::SYSTDelayExt,
time::ExtU32,
timer::Timer,
delay::DelayFromCountDownTimer,
dma::{config::DmaConfig, stream::DMAExt, TransferExt},
gpio::GpioExt,
pwr::PwrExt,
Expand All @@ -17,10 +19,10 @@ use crate::hal::{
};
use stm32g4xx_hal as hal;

use log::info;

#[macro_use]
mod utils;
use utils::logger::info;

#[entry]
fn main() -> ! {
Expand All @@ -29,7 +31,7 @@ fn main() -> ! {
info!("start");

let dp = Peripherals::take().unwrap();
let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
// let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");

info!("rcc");

Expand All @@ -48,7 +50,10 @@ fn main() -> ! {
let pa0 = gpioa.pa0.into_analog();

info!("Setup Adc1");
let mut delay = cp.SYST.delay(&rcc.clocks);
// let mut delay = cp.SYST.delay(&rcc.clocks);
let mut delay = DelayFromCountDownTimer::new(
Timer::new(dp.TIM6, &rcc.clocks).start_count_down(100u32.millis()),
);
let mut adc = dp
.ADC1
.claim(ClockSource::SystemClock, &rcc, &mut delay, true);
Expand Down
14 changes: 9 additions & 5 deletions examples/adc-one-shot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

use crate::hal::{
adc::{config::SampleTime, AdcClaim},
delay::SYSTDelayExt,
time::ExtU32,
timer::Timer,
delay::DelayFromCountDownTimer,
pwr::PwrExt,
rcc::Config,
stm32::Peripherals,
Expand All @@ -13,10 +15,9 @@ use stm32g4xx_hal as hal;

use cortex_m_rt::entry;

use log::info;

#[macro_use]
mod utils;
use utils::logger::info;

#[entry]
fn main() -> ! {
Expand All @@ -25,7 +26,7 @@ fn main() -> ! {
info!("start");

let dp = Peripherals::take().unwrap();
let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
// let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");

info!("rcc");

Expand All @@ -34,7 +35,10 @@ fn main() -> ! {
let mut rcc = rcc.freeze(Config::hsi(), pwr);

info!("Setup Adc1");
let mut delay = cp.SYST.delay(&rcc.clocks);
// let mut delay = cp.SYST.delay(&rcc.clocks);
let mut delay = DelayFromCountDownTimer::new(
Timer::new(dp.TIM6, &rcc.clocks).start_count_down(100u32.millis()),
);
let mut adc = dp.ADC2.claim_and_configure(
stm32g4xx_hal::adc::ClockSource::SystemClock,
&rcc,
Expand Down
4 changes: 2 additions & 2 deletions examples/blinky_delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use hal::stm32;
use hal::time::ExtU32;
use hal::timer::Timer;
use stm32g4xx_hal as hal;
use embedded_hal_one::delay::DelayNs;
use embedded_hal::delay::DelayNs;

use cortex_m_rt::entry;
use utils::logger::info;
Expand Down Expand Up @@ -48,6 +48,6 @@ fn main() -> ! {
info!("Toggle");
led.toggle().unwrap();
info!("TIM2 delay");
DelayNs::delay_ms(&mut delay_tim2, 1000);
delay_tim2.delay_ms(1000);
}
}
2 changes: 1 addition & 1 deletion examples/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use core::cell::RefCell;
use core::sync::atomic::{AtomicBool, Ordering};
use cortex_m::{asm::wfi, interrupt::Mutex};
use cortex_m_rt::entry;
use embedded_hal::digital::v2::OutputPin;
use embedded_hal::digital::OutputPin;

type ButtonPin = gpioc::PC13<Input<PullDown>>;

Expand Down
5 changes: 2 additions & 3 deletions examples/can-echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ use core::num::{NonZeroU16, NonZeroU8};

use cortex_m_rt::entry;

use log::info;

#[macro_use]
mod utils;
use utils::logger::info;

#[entry]
fn main() -> ! {
Expand Down Expand Up @@ -116,7 +115,7 @@ fn main() -> ! {
bit_rate_switching: false,
marker: None,
};
info!("Initial Header: {:#X?}", &header);
info!("Initial Header: {:#?}", &header);

info!("Transmit initial message");
block!(can.transmit(header, &buffer)).unwrap();
Expand Down
15 changes: 10 additions & 5 deletions examples/comp_w_dac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,25 @@ fn main() -> ! {
#[cfg(feature = "stm32g474")]
#[entry]
fn main() -> ! {
use embedded_hal::Direction;
use embedded_hal_old::Direction;
use stm32g4xx_hal as hal;
use hal::comparator::{self, ComparatorExt, ComparatorSplit};
use hal::dac::{Dac1IntSig1, DacExt, DacOut};
use hal::delay::SYSTDelayExt;
use hal::delay::DelayFromCountDownTimer;
use hal::time::ExtU32;
use hal::timer::Timer;
use hal::gpio::GpioExt;
use hal::rcc::RccExt;
use hal::stm32;
use stm32g4xx_hal as hal;

let dp = stm32::Peripherals::take().expect("cannot take peripherals");
let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
// let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");

let mut rcc = dp.RCC.constrain();
let mut delay = cp.SYST.delay(&rcc.clocks);
// let mut delay = cp.SYST.delay(&rcc.clocks);
let mut delay = DelayFromCountDownTimer::new(
Timer::new(dp.TIM6, &rcc.clocks).start_count_down(100u32.millis()),
);

let gpioa = dp.GPIOA.split(&mut rcc);

Expand Down
14 changes: 10 additions & 4 deletions examples/dac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
#![no_main]
#![no_std]

use embedded_hal::Direction;
use embedded_hal_old::Direction;
use hal::dac::{DacExt, DacOut, GeneratorConfig};
use hal::delay::SYSTDelayExt;
use hal::gpio::GpioExt;
use hal::rcc::RccExt;
use hal::time::ExtU32;
use hal::timer::Timer;
use hal::delay::DelayFromCountDownTimer;
use stm32g4xx_hal as hal;
mod utils;
extern crate cortex_m_rt as rt;
Expand All @@ -23,10 +25,14 @@ use rt::entry;
#[entry]
fn main() -> ! {
let dp = stm32::Peripherals::take().expect("cannot take peripherals");
let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");
// let cp = cortex_m::Peripherals::take().expect("cannot take core peripherals");

let mut rcc = dp.RCC.constrain();
let mut delay = cp.SYST.delay(&rcc.clocks);
// cortex-m doesn't yet support hal-1 DelayNs on systick (PR #504)
// let mut delay = cp.SYST.delay(&rcc.clocks);
let mut delay = DelayFromCountDownTimer::new(
Timer::new(dp.TIM6, &rcc.clocks).start_count_down(100u32.millis()),
);

let gpioa = dp.GPIOA.split(&mut rcc);
let (dac1ch1, dac1ch2) = dp.DAC1.constrain((gpioa.pa4, gpioa.pa5), &mut rcc);
Expand Down
4 changes: 2 additions & 2 deletions examples/i2c-bme680.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use bme680::*;
use core::time::Duration;
use embedded_hal::blocking::delay::DelayMs;
use embedded_hal::delay::DelayNs;
use hal::delay::DelayFromCountDownTimer;
use hal::i2c::Config;
use hal::prelude::*;
Expand All @@ -15,10 +15,10 @@ use hal::timer::Timer;
use stm32g4xx_hal as hal;

use cortex_m_rt::entry;
use log::info;

#[macro_use]
mod utils;
use utils::logger::info;

#[entry]
fn main() -> ! {
Expand Down
2 changes: 1 addition & 1 deletion examples/i2c-mpu6050.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use hal::time::{ExtU32, RateExtU32};
use stm32g4xx_hal as hal;

use cortex_m_rt::entry;
use log::info;
use mpu6050::*;

#[macro_use]
mod utils;
use utils::logger::info;

#[entry]
fn main() -> ! {
Expand Down
2 changes: 1 addition & 1 deletion examples/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn main() -> ! {

let buf: [u8; 1] = [0];
loop {
match i2c.write(0x3c, &buf) {
match i2c.write(0x3Cu8, &buf) {
Ok(_) => info!("ok"),
Err(err) => info!("error: {:?}", err),
}
Expand Down
Loading

0 comments on commit 4915e78

Please sign in to comment.