efm32pg12_pac/cmu/
hfperpresc.rs

1#[doc = "Reader of register HFPERPRESC"]
2pub type R = crate::R<u32, super::HFPERPRESC>;
3#[doc = "Writer for register HFPERPRESC"]
4pub type W = crate::W<u32, super::HFPERPRESC>;
5#[doc = "Register HFPERPRESC `reset()`'s with value 0"]
6impl crate::ResetValue for super::HFPERPRESC {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "HFPERCLK Prescaler\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u16)]
16pub enum PRESC_A {
17    #[doc = "0: `0`"]
18    NODIVISION = 0,
19}
20impl From<PRESC_A> for u16 {
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<u16, PRESC_A>;
28impl PRESC_R {
29    #[doc = r"Get enumerated values variant"]
30    #[inline(always)]
31    pub fn variant(&self) -> crate::Variant<u16, 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: u16) -> &'a mut W {
62        self.w.bits = (self.w.bits & !(0x01ff << 8)) | (((value as u32) & 0x01ff) << 8);
63        self.w
64    }
65}
66impl R {
67    #[doc = "Bits 8:16 - HFPERCLK Prescaler"]
68    #[inline(always)]
69    pub fn presc(&self) -> PRESC_R {
70        PRESC_R::new(((self.bits >> 8) & 0x01ff) as u16)
71    }
72}
73impl W {
74    #[doc = "Bits 8:16 - HFPERCLK Prescaler"]
75    #[inline(always)]
76    pub fn presc(&mut self) -> PRESC_W {
77        PRESC_W { w: self }
78    }
79}