1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
//! API for analog control (ANACTRL) - always on // use core::marker::PhantomData; // use crate::typestates::Fro96MHzEnabledToken; // use crate::{ raw,}; // UM says: // NOTE: The clock to analog controller module is enabled during boot time // by the boot loader and it should always stay enabled // // So for safety, should enforce it's enabled crate::wrap_always_on_peripheral!(Anactrl, ANACTRL); impl Anactrl { // pub(crate) fn latch_fro_to_usbfs_sof(&mut self) { // // "If this bit is set and the USB peripheral is enabled into full-speed // // device mode, the USB block will provide FRO clock adjustments to // // lock it to the host clock using the SOF packets." // self.raw.fro192m_ctrl.modify(|_, w| w.usbclkadj().set_bit()); // // TODO: do we need any stabilisation? e.g. // // "USBMODCHG If it reads as 1 when reading the DAC_TRIM field and // // USBCLKADJ=1, it should be re-read until it is 0." // // <-- this is mentioned in the UM, but missing in the PAC. // } pub fn is_12mhzclk_enabled(&self) -> bool { self.raw.fro192m_ctrl.read().ena_12mhzclk().is_enable() } /// Supposedly, this is needed for Flash, hence enabled by default pub fn is_48mhzclk_enabled(&self) -> bool { self.raw.fro192m_ctrl.read().ena_48mhzclk().is_enable() } /// UM says not enabled by default, empiricially seems it is pub fn is_96mhzclk_enabled(&self) -> bool { // ewww this hard-faults if 12MHz clock is main clock?! self.raw.fro192m_ctrl.read().ena_96mhzclk().is_enable() && self.raw.fro192m_status.read().clk_valid().is_clkout() } // pub(crate) fn enable_96mhzclk(&self) { // self.raw.fro192m_ctrl.modify(|_, w| w.ena_96mhzclk().enable()); // } // pub fn fro96mhz_enabled_token(&self) -> Option<Fro96MHzEnabledToken> { // if self.is_96mhzclk_enabled() { // Some(Fro96MHzEnabledToken{__: PhantomData}) // } else { // None // } // } }