Skip to content

Commit 79867ef

Browse files
usbalbinAdinAcktechmccat
authored
Merge from main (#173)
* Export pac as pac (#156) * rm remaining fdcan files (#160) * defmt format for rcc clocks (#163) * export PwrExt in prelude (#164) * e-hal-v1 (#172) * Implement SpiBus from embedded-hal 1 * i2c: implement embedded-hal traits * gpio: implement embedded-hal 1 digital traits * pwm: implement SetDutyCycle from embedded-hal 1 * delay: temporary DelayNs impl (μs-resolution) * serial: implement embedded-io traits for UART * bump hal-1, remove ToggleableOutputPin impls * remove embedded-hal 0.2 from prelude, rename hals 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 * pwm: use set_duty_cycle_percent in example * run cargo fmt * remove unused dependencies I had added them by accident for an example that didn't end up in the PR * time: fix duration variable names, add doc * docs: fix cargo doc warnings * Try to make syst delay work as before * Cleanup examples --------- Co-authored-by: techmccat <[email protected]> --------- Co-authored-by: AdinAck <[email protected]> Co-authored-by: techmccat <[email protected]>
1 parent e8ac42d commit 79867ef

32 files changed

+862
-301
lines changed

Cargo.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ repository = "https://github.com/stm32-rs/stm32g4xx-hal"
1212
version = "0.0.2"
1313

1414
[dependencies]
15-
nb = "0.1.1"
15+
nb = "1"
1616
#stm32g4 = { git = "https://github.com/stm32-rs/stm32-rs-nightlies" } #"0.15.1"
1717
stm32g4 = { version = "0.19.0", package = "stm32g4-staging" }
1818
paste = "1.0"
@@ -22,6 +22,7 @@ static_assertions = "1.1"
2222
fugit = "0.3.7"
2323
stm32-usbd = { version = "0.7.0", optional = true }
2424
fixed = { version = "1.28.0", optional = true }
25+
embedded-io = "0.6"
2526

2627
[dependencies.cortex-m]
2728
version = "0.7.7"
@@ -39,9 +40,13 @@ default-features = false
3940
features = ["const-fn"]
4041
version = "0.2.5"
4142

42-
[dependencies.embedded-hal]
43+
[dependencies.embedded-hal-old]
44+
package = "embedded-hal"
4345
features = ["unproven"]
44-
version = "0.2.4"
46+
version = "0.2.7"
47+
48+
[dependencies.embedded-hal]
49+
version = "1.0.0"
4550

4651
[dependencies.embedded-dma]
4752
version = "0.1.2"
@@ -94,7 +99,7 @@ stm32g4a1 = ["stm32g4/stm32g4a1"]
9499
log-itm = ["cortex-m-log/itm"]
95100
log-rtt = []
96101
log-semihost = ["cortex-m-log/semihosting"]
97-
defmt = ["dep:defmt", "fugit/defmt"]
102+
defmt = ["dep:defmt", "fugit/defmt", "nb/defmt-0-3", "embedded-hal/defmt-03", "embedded-io/defmt-03"]
98103
cordic = ["dep:fixed"]
99104

100105
[profile.dev]

examples/adc-continious-dma.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![no_main]
33

44
mod utils;
5+
use utils::logger::info;
56

67
use crate::hal::{
78
adc::{
@@ -20,7 +21,6 @@ use crate::hal::{
2021
use stm32g4xx_hal as hal;
2122

2223
use cortex_m_rt::entry;
23-
use utils::logger::info;
2424

2525
#[entry]
2626
fn main() -> ! {
@@ -48,6 +48,7 @@ fn main() -> ! {
4848

4949
info!("Setup Adc1");
5050
let mut delay = cp.SYST.delay(&rcc.clocks);
51+
5152
let mut adc = dp
5253
.ADC1
5354
.claim(ClockSource::SystemClock, &rcc, &mut delay, true);

examples/adc-one-shot-dma.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ use crate::hal::{
1717
};
1818
use stm32g4xx_hal as hal;
1919

20-
use log::info;
21-
2220
#[macro_use]
2321
mod utils;
22+
use utils::logger::info;
2423

2524
#[entry]
2625
fn main() -> ! {
@@ -49,6 +48,7 @@ fn main() -> ! {
4948

5049
info!("Setup Adc1");
5150
let mut delay = cp.SYST.delay(&rcc.clocks);
51+
5252
let mut adc = dp
5353
.ADC1
5454
.claim(ClockSource::SystemClock, &rcc, &mut delay, true);

examples/adc-one-shot.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
use crate::hal::{
55
adc::{config::SampleTime, AdcClaim},
6-
delay::SYSTDelayExt,
76
pwr::PwrExt,
87
rcc::Config,
98
stm32::Peripherals,
@@ -13,10 +12,9 @@ use stm32g4xx_hal as hal;
1312

1413
use cortex_m_rt::entry;
1514

16-
use log::info;
17-
1815
#[macro_use]
1916
mod utils;
17+
use utils::logger::info;
2018

2119
#[entry]
2220
fn main() -> ! {

examples/blinky_delay.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![no_main]
44
#![no_std]
55

6-
use hal::delay::DelayFromCountDownTimer;
76
use hal::prelude::*;
87
use hal::pwr::PwrExt;
98
use hal::rcc::Config;
@@ -37,7 +36,7 @@ fn main() -> ! {
3736

3837
info!("Init Timer2 delay");
3938
let timer2 = Timer::new(dp.TIM2, &rcc.clocks);
40-
let mut delay_tim2 = DelayFromCountDownTimer::new(timer2.start_count_down(100.millis()));
39+
let mut delay_tim2 = timer2.start_count_down(100.millis()).delay();
4140

4241
loop {
4342
info!("Toggle");
@@ -47,6 +46,6 @@ fn main() -> ! {
4746
info!("Toggle");
4847
led.toggle().unwrap();
4948
info!("TIM2 delay");
50-
delay_tim2.delay_ms(1000_u16);
49+
delay_tim2.delay_ms(1000);
5150
}
5251
}

examples/button.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use core::cell::RefCell;
1414
use core::sync::atomic::{AtomicBool, Ordering};
1515
use cortex_m::{asm::wfi, interrupt::Mutex};
1616
use cortex_m_rt::entry;
17-
use embedded_hal::digital::v2::OutputPin;
17+
use embedded_hal::digital::OutputPin;
1818

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

examples/can-echo.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ use core::num::{NonZeroU16, NonZeroU8};
2222

2323
use cortex_m_rt::entry;
2424

25-
use log::info;
26-
2725
#[macro_use]
2826
mod utils;
27+
use utils::logger::info;
2928

3029
#[entry]
3130
fn main() -> ! {
@@ -116,7 +115,7 @@ fn main() -> ! {
116115
bit_rate_switching: false,
117116
marker: None,
118117
};
119-
info!("Initial Header: {:#X?}", &header);
118+
info!("Initial Header: {:#?}", &header);
120119

121120
info!("Transmit initial message");
122121
block!(can.transmit(header, &buffer)).unwrap();

examples/comp_w_dac.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use rt::entry;
1010

1111
#[entry]
1212
fn main() -> ! {
13-
use embedded_hal::Direction;
1413
use hal::comparator::{self, ComparatorExt, ComparatorSplit};
1514
use hal::dac::{Dac1IntSig1, DacExt, DacOut};
1615
use hal::delay::SYSTDelayExt;
@@ -49,6 +48,11 @@ fn main() -> ! {
4948
comp.output_pin(led2);
5049
let _comp1 = comp.enable().lock();
5150

51+
enum Direction {
52+
Upcounting,
53+
Downcounting,
54+
}
55+
5256
let mut dir = Direction::Upcounting;
5357
let mut val = 0;
5458

examples/dac.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#![no_main]
99
#![no_std]
1010

11-
use embedded_hal::Direction;
1211
use hal::dac::{DacExt, DacOut, GeneratorConfig};
1312
use hal::delay::SYSTDelayExt;
1413
use hal::gpio::GpioExt;
@@ -37,6 +36,11 @@ fn main() -> ! {
3736
// dac_generator will have its value set automatically from its internal noise generator
3837
let mut dac_generator = dac1ch2.enable_generator(GeneratorConfig::noise(11));
3938

39+
enum Direction {
40+
Upcounting,
41+
Downcounting,
42+
}
43+
4044
let mut dir = Direction::Upcounting;
4145
let mut val = 0;
4246

examples/i2c-bme680.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
use bme680::*;
77
use core::time::Duration;
8-
use embedded_hal::blocking::delay::DelayMs;
8+
use embedded_hal::delay::DelayNs;
99
use hal::delay::DelayFromCountDownTimer;
1010
use hal::i2c::Config;
1111
use hal::prelude::*;
@@ -15,10 +15,10 @@ use hal::timer::Timer;
1515
use stm32g4xx_hal as hal;
1616

1717
use cortex_m_rt::entry;
18-
use log::info;
1918

2019
#[macro_use]
2120
mod utils;
21+
use utils::logger::info;
2222

2323
#[entry]
2424
fn main() -> ! {

0 commit comments

Comments
 (0)