efm32pg12_pac/cmu/
hfexppresc.rs

1#[doc = "Reader of register HFEXPPRESC"]
2pub type R = crate::R<u32, super::HFEXPPRESC>;
3#[doc = "Writer for register HFEXPPRESC"]
4pub type W = crate::W<u32, super::HFEXPPRESC>;
5#[doc = "Register HFEXPPRESC `reset()`'s with value 0"]
6impl crate::ResetValue for super::HFEXPPRESC {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "HFEXPCLK Prescaler\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum PRESC_A {
17    #[doc = "0: `0`"]
18    NODIVISION = 0,
19}
20impl From<PRESC_A> for u8 {
21    #[inline(always)]
22    fn from(variant: PRESC_A) -> Self {
23        variant as _
24    }
25}
26#[doc = "Reader of field `PRESC`"]
27pub type PRESC_R = crate::R<u8, PRESC_A>;
28impl PRESC_R {
29    #[doc = r"Get enumerated values variant"]
30    #[inline(always)]
31    pub fn variant(&self) -> crate::Variant<u8, PRESC_A> {
32        use crate::Variant::*;
33        match self.bits {
34            0 => Val(PRESC_A::NODIVISION),
35            i => Res(i),
36        }
37    }
38    #[doc = "Checks if the value of the field is `NODIVISION`"]
39    #[inline(always)]
40    pub fn is_nodivision(&self) -> bool {
41        *self == PRESC_A::NODIVISION
42    }
43}
44#[doc = "Write proxy for field `PRESC`"]
45pub struct PRESC_W<'a> {
46    w: &'a mut W,
47}
48impl<'a> PRESC_W<'a> {
49    #[doc = r"Writes `variant` to the field"]
50    #[inline(always)]
51    pub fn variant(self, variant: PRESC_A) -> &'a mut W {
52        unsafe { self.bits(variant.into()) }
53    }
54    #[doc = "`0`"]
55    #[inline(always)]
56    pub fn nodivision(self) -> &'a mut W {
57        self.variant(PRESC_A::NODIVISION)
58    }
59    #[doc = r"Writes raw bits to the field"]
60    #[inline(always)]
61    pub unsafe fn bits(self, value: u8) -> &'a mut W {
62        self.w.bits = (self.w.bits & !(0x1f << 8)) | (((value as u32) & 0x1f) << 8);
63        self.w
64    }
65}
66impl R {
67    #[doc = "Bits 8:12 - HFEXPCLK Prescaler"]
68    #[inline(always)]
69    pub fn presc(&self) -> PRESC_R {
70        PRESC_R::new(((self.bits >> 8) & 0x1f) as u8)
71    }
72}
73impl W {
74    #[doc = "Bits 8:12 - HFEXPCLK Prescaler"]
75    #[inline(always)]
76    pub fn presc(&mut self) -> PRESC_W {
77        PRESC_W { w: self }
78    }
79}