Skip to content

Commit e33c013

Browse files
Stop gating the AES peripheral
ST seems to have randomly sprinkled the AES peripheral across their STM32L0 MCUs, so manually gating access to it would require declaring dozens of Cargo features. Instead, just always enable it and add a note telling the user to check the datasheet.
1 parent 519d729 commit e33c013

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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.

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub use crate::pac as stm32;
2121
mod bb;
2222

2323
pub mod adc;
24-
#[cfg(any(feature = "stm32l062", feature = "stm32l082"))]
2524
pub mod aes;
2625
pub mod delay;
2726
pub mod dma;

0 commit comments

Comments
 (0)