use crate::ral::{self, ccm::CCM};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u32)]
pub enum Selection {
Pll2 = 0,
Pll3Pfd3 = 1,
Pll2Pfd3 = 2,
Pll6 = 3,
}
#[inline(always)]
pub fn set_selection(ccm: &mut CCM, selection: Selection) {
ral::modify_reg!(ral::ccm, ccm, CBCMR, PRE_PERIPH_CLK_SEL: selection as u32);
}
#[inline(always)]
pub fn selection(ccm: &CCM) -> Selection {
use Selection::*;
match ral::read_reg!(ral::ccm, ccm, CBCMR, PRE_PERIPH_CLK_SEL) {
0 => Pll2,
1 => Pll3Pfd3,
2 => Pll2Pfd3,
3 => Pll6,
_ => unreachable!(),
}
}