avr_device/devices/atmega4809/bod/
ctrlb.rs

1#[doc = "Register `CTRLB` reader"]
2pub struct R(crate::R<CTRLB_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CTRLB_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CTRLB_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CTRLB_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CTRLB` writer"]
17pub struct W(crate::W<CTRLB_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CTRLB_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<CTRLB_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CTRLB_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `LVL` reader - Bod level"]
38pub type LVL_R = crate::FieldReader<u8, LVL_A>;
39#[doc = "Bod level\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum LVL_A {
43    #[doc = "0: 1.8 V"]
44    BODLEVEL0 = 0,
45    #[doc = "2: 2.6 V"]
46    BODLEVEL2 = 2,
47    #[doc = "7: 4.2 V"]
48    BODLEVEL7 = 7,
49}
50impl From<LVL_A> for u8 {
51    #[inline(always)]
52    fn from(variant: LVL_A) -> Self {
53        variant as _
54    }
55}
56impl LVL_R {
57    #[doc = "Get enumerated values variant"]
58    #[inline(always)]
59    pub fn variant(&self) -> Option<LVL_A> {
60        match self.bits {
61            0 => Some(LVL_A::BODLEVEL0),
62            2 => Some(LVL_A::BODLEVEL2),
63            7 => Some(LVL_A::BODLEVEL7),
64            _ => None,
65        }
66    }
67    #[doc = "Checks if the value of the field is `BODLEVEL0`"]
68    #[inline(always)]
69    pub fn is_bodlevel0(&self) -> bool {
70        *self == LVL_A::BODLEVEL0
71    }
72    #[doc = "Checks if the value of the field is `BODLEVEL2`"]
73    #[inline(always)]
74    pub fn is_bodlevel2(&self) -> bool {
75        *self == LVL_A::BODLEVEL2
76    }
77    #[doc = "Checks if the value of the field is `BODLEVEL7`"]
78    #[inline(always)]
79    pub fn is_bodlevel7(&self) -> bool {
80        *self == LVL_A::BODLEVEL7
81    }
82}
83impl R {
84    #[doc = "Bits 0:2 - Bod level"]
85    #[inline(always)]
86    pub fn lvl(&self) -> LVL_R {
87        LVL_R::new(self.bits & 7)
88    }
89}
90impl W {
91    #[doc = "Writes raw bits to the register."]
92    #[inline(always)]
93    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
94        self.0.bits(bits);
95        self
96    }
97}
98#[doc = "Control B\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ctrlb](index.html) module"]
99pub struct CTRLB_SPEC;
100impl crate::RegisterSpec for CTRLB_SPEC {
101    type Ux = u8;
102}
103#[doc = "`read()` method returns [ctrlb::R](R) reader structure"]
104impl crate::Readable for CTRLB_SPEC {
105    type Reader = R;
106}
107#[doc = "`write(|w| ..)` method takes [ctrlb::W](W) writer structure"]
108impl crate::Writable for CTRLB_SPEC {
109    type Writer = W;
110    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
111    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
112}
113#[doc = "`reset()` method sets CTRLB to value 0"]
114impl crate::Resettable for CTRLB_SPEC {
115    const RESET_VALUE: Self::Ux = 0;
116}