Skip to content

Commit 0332e38

Browse files
authored
Merge pull request #51 from jonas-schievink/update-stm32l0
Update to stm32l0 0.9.0
2 parents 0e036eb + e402882 commit 0332e38

File tree

17 files changed

+100
-178
lines changed

17 files changed

+100
-178
lines changed

Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ version = "0.4.0"
2727
features = ["stm32l0x2", "rt", "stm32-usbd"]
2828

2929
[dependencies]
30+
stm32l0 = "0.9.0"
3031
as-slice = "0.1.0"
3132
embedded-hal = { version = "0.2.3", features = ["unproven"] }
3233
cortex-m = {version = "0.6.1", features = ["const-fn"] }
@@ -37,9 +38,6 @@ cast = { version = "0.2.2", default-features = false }
3738
nb = "0.1.2"
3839
stm32-usbd = { version = "0.5.0", features = ["ram_access_2x16"], optional = true }
3940

40-
[dependencies.stm32l0]
41-
version = "0.8.0"
42-
4341
[dev-dependencies]
4442
aligned = "0.3.1"
4543
heapless = "0.5.0"

examples/button_irq.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ fn main() -> ! {
3939
// Configure PB2 as input.
4040
let button = gpiob.pb2.into_pull_up_input();
4141

42-
#[cfg(feature = "stm32l0x1")]
4342
let mut syscfg = SYSCFG::new(dp.SYSCFG, &mut rcc);
44-
#[cfg(any(feature = "stm32l0x2", feature = "stm32l0x3"))]
45-
let mut syscfg = SYSCFG::new(dp.SYSCFG_COMP, &mut rcc);
4643

4744
// Configure the external interrupt on the falling edge for the pin 0.
4845
let exti = dp.EXTI;

examples/button_irq_rtfm.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ const APP: () = {
2828
// Configure PB2 as input.
2929
let button = gpiob.pb2.into_pull_up_input();
3030

31-
#[cfg(feature = "stm32l0x1")]
3231
let mut syscfg = SYSCFG::new(device.SYSCFG, &mut rcc);
33-
#[cfg(any(feature = "stm32l0x2", feature = "stm32l0x3"))]
34-
let mut syscfg = SYSCFG::new(device.SYSCFG_COMP, &mut rcc);
3532

3633
// Configure the external interrupt on the falling edge for the pin 0.
3734
let exti = device.EXTI;

examples/exti_wakeup.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ fn main() -> ! {
2929
let button = gpiob.pb2.into_floating_input();
3030
let mut led = gpiob.pb6.into_push_pull_output();
3131

32-
#[cfg(feature = "stm32l0x1")]
3332
let mut syscfg = SYSCFG::new(dp.SYSCFG, &mut rcc);
34-
#[cfg(any(feature = "stm32l0x2", feature = "stm32l0x3"))]
35-
let mut syscfg = SYSCFG::new(dp.SYSCFG_COMP, &mut rcc);
3633

3734
exti.listen(
3835
&mut syscfg,

examples/pwr.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ fn main() -> ! {
4444

4545
let mut led = gpiob.pb2.into_push_pull_output().downgrade();
4646

47-
#[cfg(feature = "stm32l0x1")]
4847
let mut syscfg = SYSCFG::new(dp.SYSCFG, &mut rcc);
49-
#[cfg(any(feature = "stm32l0x2", feature = "stm32l0x3"))]
50-
let mut syscfg = SYSCFG::new(dp.SYSCFG_COMP, &mut rcc);
5148

5249
let instant = Instant::new()
5350
.set_year(19)

examples/rng.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() -> ! {
1414
let dp = pac::Peripherals::take().unwrap();
1515

1616
let mut rcc = dp.RCC.freeze(Config::hsi16());
17-
let mut syscfg = SYSCFG::new(dp.SYSCFG_COMP, &mut rcc);
17+
let mut syscfg = SYSCFG::new(dp.SYSCFG, &mut rcc);
1818

1919
// constructor initializes 48 MHz clock that RNG requires
2020
// Initialize 48 MHz clock and RNG
@@ -31,4 +31,4 @@ fn main() -> ! {
3131
// can save some power by disabling until next random number needed
3232
rng.disable();
3333
}
34-
}
34+
}

examples/rtc_wakeup.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ fn main() -> ! {
3232
let mut exti = dp.EXTI;
3333
let mut pwr = PWR::new(dp.PWR, &mut rcc);
3434

35-
#[cfg(feature = "stm32l0x1")]
3635
let mut syscfg = SYSCFG::new(dp.SYSCFG, &mut rcc);
37-
#[cfg(any(feature = "stm32l0x2", feature = "stm32l0x3"))]
38-
let mut syscfg = SYSCFG::new(dp.SYSCFG_COMP, &mut rcc);
3936

4037
let instant = Instant::new()
4138
.set_year(19)

src/adc.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,12 @@ impl Adc {
110110
while self.rb.cr.read().aden().bit_is_set() {}
111111
}
112112

113-
#[cfg(feature = "stm32l0x1")]
114113
fn write_smpr(&mut self) {
115114
self.rb
116115
.smpr
117116
.modify(|_, w| w.smp().bits(self.sample_time as u8));
118117
}
119118

120-
#[cfg(any(feature = "stm32l0x2", feature = "stm32l0x3"))]
121-
fn write_smpr(&mut self) {
122-
self.rb
123-
.smpr
124-
// Safe, because `self.sample_time` is of type `SampleTime`, which
125-
// defines only valid values.
126-
.modify(|_, w| unsafe { w.smpr().bits(self.sample_time as u8) });
127-
}
128-
129119
pub fn release(self) -> ADC {
130120
self.rb
131121
}
@@ -156,8 +146,7 @@ where
156146
//
157147
// The `bits` method is not unsafe on STM32L0x1, so we need to
158148
// suppress the warning there.
159-
#[cfg_attr(feature = "stm32l0x1", allow(unused_unsafe))]
160-
let w = unsafe { w.res().bits(self.precision as u8) };
149+
let w = w.res().bits(self.precision as u8);
161150
w.align().bit(self.align == Align::Left)
162151
});
163152

src/aes.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
//! Interface to the AES peripheral
1+
//! Interface to the AES peripheral.
2+
//!
3+
//! Note that the AES peripheral is only available on some MCUs in the L0/L1/L2
4+
//! families. Check the datasheet for more information.
25
//!
36
//! See STM32L0x2 reference manual, chapter 18.
47
@@ -88,7 +91,7 @@ impl AES {
8891

8992
// Configure for stream of bytes
9093
// Safe, as we write a valid byte pattern.
91-
unsafe { w.datatype().bits(0b10) };
94+
w.datatype().bits(0b10);
9295

9396
// Enable peripheral
9497
w.en().set_bit()
@@ -524,7 +527,7 @@ impl Mode for CTR {
524527
fn derive_key(aes: &aes::RegisterBlock) {
525528
// Select key derivation mode. This is safe, as we're writing a valid bit
526529
// pattern.
527-
unsafe { aes.cr.modify(|_, w| w.mode().bits(0b01)) };
530+
aes.cr.modify(|_, w| w.mode().bits(0b01));
528531

529532
// Enable the peripheral. It will be automatically disabled again once the
530533
// key has been derived.

0 commit comments

Comments
 (0)