Skip to content
Snippets Groups Projects
Select Git revision
  • 2bb508529ff07f0a55e1742d444cd3b713f76233
  • master default
2 results

flash.rs

Blame
  • Forked from Per Lindgren / stm32f4-hal
    Source project has a limited visibility.
    flash.rs 713 B
    //! Flash memory
    
    use stm32f4x::{flash, FLASH};
    
    /// Extension trait to constrain the FLASH peripheral
    pub trait FlashExt {
        /// Constrains the FLASH peripheral to play nicely with the other abstractions
        fn constrain(self) -> Parts;
    }
    
    impl FlashExt for FLASH {
        fn constrain(self) -> Parts {
            Parts {
                acr: ACR { _0: () },
            }
        }
    }
    
    /// Constrained FLASH peripheral
    pub struct Parts {
        /// Opaque ACR register
        pub acr: ACR,
    }
    
    /// Opaque ACR register
    pub struct ACR {
        _0: (),
    }
    
    impl ACR {
        pub(crate) fn acr(&mut self) -> &flash::ACR {
            // NOTE(unsafe) this proxy grants exclusive access to this register
            unsafe { &(*FLASH::ptr()).acr }
        }
    }