pub type R = crate::R<PLLCKSELRrs>;
pub type W = crate::W<PLLCKSELRrs>;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum PLLSRC {
Hsi = 0,
Csi = 1,
Hse = 2,
None = 3,
}
impl From<PLLSRC> for u8 {
#[inline(always)]
fn from(variant: PLLSRC) -> Self {
variant as _
}
}
impl crate::FieldSpec for PLLSRC {
type Ux = u8;
}
impl crate::IsEnum for PLLSRC {}
pub type PLLSRC_R = crate::FieldReader<PLLSRC>;
impl PLLSRC_R {
#[inline(always)]
pub const fn variant(&self) -> PLLSRC {
match self.bits {
0 => PLLSRC::Hsi,
1 => PLLSRC::Csi,
2 => PLLSRC::Hse,
3 => PLLSRC::None,
_ => unreachable!(),
}
}
#[inline(always)]
pub fn is_hsi(&self) -> bool {
*self == PLLSRC::Hsi
}
#[inline(always)]
pub fn is_csi(&self) -> bool {
*self == PLLSRC::Csi
}
#[inline(always)]
pub fn is_hse(&self) -> bool {
*self == PLLSRC::Hse
}
#[inline(always)]
pub fn is_none(&self) -> bool {
*self == PLLSRC::None
}
}
pub type PLLSRC_W<'a, REG> = crate::FieldWriter<'a, REG, 2, PLLSRC, crate::Safe>;
impl<'a, REG> PLLSRC_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
REG::Ux: From<u8>,
{
#[inline(always)]
pub fn hsi(self) -> &'a mut crate::W<REG> {
self.variant(PLLSRC::Hsi)
}
#[inline(always)]
pub fn csi(self) -> &'a mut crate::W<REG> {
self.variant(PLLSRC::Csi)
}
#[inline(always)]
pub fn hse(self) -> &'a mut crate::W<REG> {
self.variant(PLLSRC::Hse)
}
#[inline(always)]
pub fn none(self) -> &'a mut crate::W<REG> {
self.variant(PLLSRC::None)
}
}
pub type DIVM1_R = crate::FieldReader;
pub type DIVM1_W<'a, REG> = crate::FieldWriter<'a, REG, 6, u8, crate::Safe>;
pub type DIVM2_R = crate::FieldReader;
pub type DIVM2_W<'a, REG> = crate::FieldWriter<'a, REG, 6, u8, crate::Safe>;
pub type DIVM3_R = crate::FieldReader;
pub type DIVM3_W<'a, REG> = crate::FieldWriter<'a, REG, 6, u8, crate::Safe>;
impl R {
#[inline(always)]
pub fn pllsrc(&self) -> PLLSRC_R {
PLLSRC_R::new((self.bits & 3) as u8)
}
#[inline(always)]
pub fn divm1(&self) -> DIVM1_R {
DIVM1_R::new(((self.bits >> 4) & 0x3f) as u8)
}
#[inline(always)]
pub fn divm2(&self) -> DIVM2_R {
DIVM2_R::new(((self.bits >> 12) & 0x3f) as u8)
}
#[inline(always)]
pub fn divm3(&self) -> DIVM3_R {
DIVM3_R::new(((self.bits >> 20) & 0x3f) as u8)
}
}
impl core::fmt::Debug for R {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("PLLCKSELR")
.field("pllsrc", &self.pllsrc())
.field("divm1", &self.divm1())
.field("divm2", &self.divm2())
.field("divm3", &self.divm3())
.finish()
}
}
impl W {
#[inline(always)]
pub fn pllsrc(&mut self) -> PLLSRC_W<PLLCKSELRrs> {
PLLSRC_W::new(self, 0)
}
#[inline(always)]
pub fn divm1(&mut self) -> DIVM1_W<PLLCKSELRrs> {
DIVM1_W::new(self, 4)
}
#[inline(always)]
pub fn divm2(&mut self) -> DIVM2_W<PLLCKSELRrs> {
DIVM2_W::new(self, 12)
}
#[inline(always)]
pub fn divm3(&mut self) -> DIVM3_W<PLLCKSELRrs> {
DIVM3_W::new(self, 20)
}
}
pub struct PLLCKSELRrs;
impl crate::RegisterSpec for PLLCKSELRrs {
type Ux = u32;
}
impl crate::Readable for PLLCKSELRrs {}
impl crate::Writable for PLLCKSELRrs {
type Safety = crate::Unsafe;
}
impl crate::Resettable for PLLCKSELRrs {
const RESET_VALUE: u32 = 0x0202_0200;
}