efm32g840_pac/lcd/
ctrl.rs

1#[doc = "Register `CTRL` reader"]
2pub struct R(crate::R<CTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CTRL` writer"]
17pub struct W(crate::W<CTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CTRL_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<CTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `EN` reader - LCD Enable"]
38pub type EN_R = crate::BitReader<bool>;
39#[doc = "Field `EN` writer - LCD Enable"]
40pub type EN_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 0>;
41#[doc = "Update Data Control\n\nValue on reset: 0"]
42#[derive(Clone, Copy, Debug, PartialEq)]
43#[repr(u8)]
44pub enum UDCTRL_A {
45    #[doc = "0: The data transfer is controlled by SW. Transfer is performed as soon as possible"]
46    REGULAR = 0,
47    #[doc = "1: The data transfer is done at the next event triggered by the Frame Counter"]
48    FCEVENT = 1,
49    #[doc = "2: The data transfer is done continuously at every LCD frame start"]
50    FRAMESTART = 2,
51}
52impl From<UDCTRL_A> for u8 {
53    #[inline(always)]
54    fn from(variant: UDCTRL_A) -> Self {
55        variant as _
56    }
57}
58#[doc = "Field `UDCTRL` reader - Update Data Control"]
59pub type UDCTRL_R = crate::FieldReader<u8, UDCTRL_A>;
60impl UDCTRL_R {
61    #[doc = "Get enumerated values variant"]
62    #[inline(always)]
63    pub fn variant(&self) -> Option<UDCTRL_A> {
64        match self.bits {
65            0 => Some(UDCTRL_A::REGULAR),
66            1 => Some(UDCTRL_A::FCEVENT),
67            2 => Some(UDCTRL_A::FRAMESTART),
68            _ => None,
69        }
70    }
71    #[doc = "Checks if the value of the field is `REGULAR`"]
72    #[inline(always)]
73    pub fn is_regular(&self) -> bool {
74        *self == UDCTRL_A::REGULAR
75    }
76    #[doc = "Checks if the value of the field is `FCEVENT`"]
77    #[inline(always)]
78    pub fn is_fcevent(&self) -> bool {
79        *self == UDCTRL_A::FCEVENT
80    }
81    #[doc = "Checks if the value of the field is `FRAMESTART`"]
82    #[inline(always)]
83    pub fn is_framestart(&self) -> bool {
84        *self == UDCTRL_A::FRAMESTART
85    }
86}
87#[doc = "Field `UDCTRL` writer - Update Data Control"]
88pub type UDCTRL_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, UDCTRL_A, 2, 1>;
89impl<'a> UDCTRL_W<'a> {
90    #[doc = "The data transfer is controlled by SW. Transfer is performed as soon as possible"]
91    #[inline(always)]
92    pub fn regular(self) -> &'a mut W {
93        self.variant(UDCTRL_A::REGULAR)
94    }
95    #[doc = "The data transfer is done at the next event triggered by the Frame Counter"]
96    #[inline(always)]
97    pub fn fcevent(self) -> &'a mut W {
98        self.variant(UDCTRL_A::FCEVENT)
99    }
100    #[doc = "The data transfer is done continuously at every LCD frame start"]
101    #[inline(always)]
102    pub fn framestart(self) -> &'a mut W {
103        self.variant(UDCTRL_A::FRAMESTART)
104    }
105}
106impl R {
107    #[doc = "Bit 0 - LCD Enable"]
108    #[inline(always)]
109    pub fn en(&self) -> EN_R {
110        EN_R::new((self.bits & 1) != 0)
111    }
112    #[doc = "Bits 1:2 - Update Data Control"]
113    #[inline(always)]
114    pub fn udctrl(&self) -> UDCTRL_R {
115        UDCTRL_R::new(((self.bits >> 1) & 3) as u8)
116    }
117}
118impl W {
119    #[doc = "Bit 0 - LCD Enable"]
120    #[inline(always)]
121    pub fn en(&mut self) -> EN_W {
122        EN_W::new(self)
123    }
124    #[doc = "Bits 1:2 - Update Data Control"]
125    #[inline(always)]
126    pub fn udctrl(&mut self) -> UDCTRL_W {
127        UDCTRL_W::new(self)
128    }
129    #[doc = "Writes raw bits to the register."]
130    #[inline(always)]
131    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
132        self.0.bits(bits);
133        self
134    }
135}
136#[doc = "Control Register\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 [ctrl](index.html) module"]
137pub struct CTRL_SPEC;
138impl crate::RegisterSpec for CTRL_SPEC {
139    type Ux = u32;
140}
141#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
142impl crate::Readable for CTRL_SPEC {
143    type Reader = R;
144}
145#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
146impl crate::Writable for CTRL_SPEC {
147    type Writer = W;
148}
149#[doc = "`reset()` method sets CTRL to value 0"]
150impl crate::Resettable for CTRL_SPEC {
151    #[inline(always)]
152    fn reset_value() -> Self::Ux {
153        0
154    }
155}