Struct stm32wlxx_hal::aes::AesWrapClk
source · pub struct AesWrapClk { /* private fields */ }
Expand description
Wrapper around Aes
for safely disabling the peripheral clock.
Implementations§
source§impl AesWrapClk
impl AesWrapClk
sourcepub fn with_clk<F>(&mut self, rcc: &mut RCC, f: F) -> Result<(), Error>where
F: FnOnce(&mut Aes) -> Result<(), Error>,
pub fn with_clk<F>(&mut self, rcc: &mut RCC, f: F) -> Result<(), Error>where F: FnOnce(&mut Aes) -> Result<(), Error>,
Run a function that accepts the AES driver as an argument,
enabling the peripheral clock with enable_clock
before calling the
function, and disabling the peripheral clock with disable_clock
after calling the function.
This is useful for saving power in applications that need to access the AES peripheral infrequently.
Power Savings
From DS13105 Rev 9:
- Range 1: 2.50 μA/MHz
- Range 2: 2.13 μA/MHz
- LPRun and LPSleep: 1.80 μA/MHz
Example
use stm32wlxx_hal::{
aes::{Aes, AesWrapClk},
pac,
};
let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
// safety:
// * no need to reset because the AES memory-mapped IO has not been accessed since power-on
// * the wrapper will handle enabling clocks
let mut aeswrap: AesWrapClk = unsafe { Aes::new_no_init(dp.AES) }.into();
const KEY: [u32; 4] = [0; 4];
let mut text: [u32; 4] = [0xf34481ec, 0x3cc627ba, 0xcd5dc3fb, 0x08f273e6];
aeswrap.with_clk(&mut dp.RCC, |aes| aes.encrypt_ecb_inplace(&KEY, &mut text))?;
Trait Implementations§
source§impl Debug for AesWrapClk
impl Debug for AesWrapClk
Auto Trait Implementations§
impl RefUnwindSafe for AesWrapClk
impl Send for AesWrapClk
impl !Sync for AesWrapClk
impl Unpin for AesWrapClk
impl UnwindSafe for AesWrapClk
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more