stm32f3xx_hal/flash.rs
1//! # Flash memory
2//!
3//! Abstractions of the internal flash module.
4
5use crate::pac::{flash, FLASH};
6
7impl crate::private::Sealed for FLASH {}
8
9/// Extension trait to constrain the [`FLASH`] peripheral
10#[allow(clippy::module_name_repetitions)]
11pub trait FlashExt: crate::private::Sealed {
12 /// Constrains the [`FLASH`] peripheral.
13 ///
14 /// Consumes the [`pac::FLASH`] peripheral and converts it to a [`HAL`] internal type
15 /// constraining it's public access surface to fit the design of the [`HAL`].
16 ///
17 /// [`pac::FLASH`]: `crate::pac::FLASH`
18 /// [`HAL`]: `crate`
19 fn constrain(self) -> Parts;
20}
21
22impl FlashExt for FLASH {
23 fn constrain(self) -> Parts {
24 Parts {
25 acr: ACR { _0: () },
26 }
27 }
28}
29
30/// Constrained FLASH peripheral
31pub struct Parts {
32 /// Opaque ACR register
33 pub acr: ACR,
34}
35
36/// Opaque ACR register
37pub struct ACR {
38 _0: (),
39}
40
41impl ACR {
42 #[allow(clippy::unused_self)]
43 pub(crate) fn acr(&mut self) -> &flash::ACR {
44 // SAFETY: This proxy grants exclusive access to this register
45 unsafe { &(*FLASH::ptr()).acr }
46 }
47}