stm32f3xx_hal_v2/flash.rs
1//! Flash memory
2
3use crate::pac::{flash, FLASH};
4
5/// Extension trait to constrain the FLASH peripheral
6pub trait FlashExt {
7 /// Constrains the FLASH peripheral to play nicely with the other abstractions
8 fn constrain(self) -> Parts;
9}
10
11impl FlashExt for FLASH {
12 fn constrain(self) -> Parts {
13 Parts {
14 acr: ACR { _0: () },
15 }
16 }
17}
18
19/// Constrained FLASH peripheral
20pub struct Parts {
21 /// Opaque ACR register
22 pub acr: ACR,
23}
24
25/// Opaque ACR register
26pub struct ACR {
27 _0: (),
28}
29
30impl ACR {
31 pub(crate) fn acr(&mut self) -> &flash::ACR {
32 // NOTE(unsafe) this proxy grants exclusive access to this register
33 unsafe { &(*FLASH::ptr()).acr }
34 }
35}