bl61x_pac/glb/
uart_signal_0.rs

1#[doc = "Register `uart_signal_0` reader"]
2pub type R = crate::R<UART_SIGNAL_0_SPEC>;
3#[doc = "Register `uart_signal_0` writer"]
4pub type W = crate::W<UART_SIGNAL_0_SPEC>;
5#[doc = "Field `function_0(0-7)` reader - Select peripheral function for UART signal %s"]
6pub type FUNCTION_0_R = crate::FieldReader<FUNCTION_A>;
7#[doc = "Select peripheral function for UART signal %s\n\nValue on reset: 0"]
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9#[repr(u8)]
10pub enum FUNCTION_A {
11    #[doc = "0: UART0 Request-to-Send flow control"]
12    UART0_RTS = 0,
13    #[doc = "1: UART0 Clear-to-Send flow control"]
14    UART0_CTS = 1,
15    #[doc = "2: UART0 transmit data"]
16    UART0_TXD = 2,
17    #[doc = "3: UART0 receive data"]
18    UART0_RXD = 3,
19    #[doc = "4: UART1 Request-to-Send flow control"]
20    UART1_RTS = 4,
21    #[doc = "5: UART1 Clear-to-Send flow control"]
22    UART1_CTS = 5,
23    #[doc = "6: UART1 transmit data"]
24    UART1_TXD = 6,
25    #[doc = "7: UART1 receive data"]
26    UART1_RXD = 7,
27}
28impl From<FUNCTION_A> for u8 {
29    #[inline(always)]
30    fn from(variant: FUNCTION_A) -> Self {
31        variant as _
32    }
33}
34impl crate::FieldSpec for FUNCTION_A {
35    type Ux = u8;
36}
37impl FUNCTION_0_R {
38    #[doc = "Get enumerated values variant"]
39    #[inline(always)]
40    pub const fn variant(&self) -> Option<FUNCTION_A> {
41        match self.bits {
42            0 => Some(FUNCTION_A::UART0_RTS),
43            1 => Some(FUNCTION_A::UART0_CTS),
44            2 => Some(FUNCTION_A::UART0_TXD),
45            3 => Some(FUNCTION_A::UART0_RXD),
46            4 => Some(FUNCTION_A::UART1_RTS),
47            5 => Some(FUNCTION_A::UART1_CTS),
48            6 => Some(FUNCTION_A::UART1_TXD),
49            7 => Some(FUNCTION_A::UART1_RXD),
50            _ => None,
51        }
52    }
53    #[doc = "UART0 Request-to-Send flow control"]
54    #[inline(always)]
55    pub fn is_uart0_rts(&self) -> bool {
56        *self == FUNCTION_A::UART0_RTS
57    }
58    #[doc = "UART0 Clear-to-Send flow control"]
59    #[inline(always)]
60    pub fn is_uart0_cts(&self) -> bool {
61        *self == FUNCTION_A::UART0_CTS
62    }
63    #[doc = "UART0 transmit data"]
64    #[inline(always)]
65    pub fn is_uart0_txd(&self) -> bool {
66        *self == FUNCTION_A::UART0_TXD
67    }
68    #[doc = "UART0 receive data"]
69    #[inline(always)]
70    pub fn is_uart0_rxd(&self) -> bool {
71        *self == FUNCTION_A::UART0_RXD
72    }
73    #[doc = "UART1 Request-to-Send flow control"]
74    #[inline(always)]
75    pub fn is_uart1_rts(&self) -> bool {
76        *self == FUNCTION_A::UART1_RTS
77    }
78    #[doc = "UART1 Clear-to-Send flow control"]
79    #[inline(always)]
80    pub fn is_uart1_cts(&self) -> bool {
81        *self == FUNCTION_A::UART1_CTS
82    }
83    #[doc = "UART1 transmit data"]
84    #[inline(always)]
85    pub fn is_uart1_txd(&self) -> bool {
86        *self == FUNCTION_A::UART1_TXD
87    }
88    #[doc = "UART1 receive data"]
89    #[inline(always)]
90    pub fn is_uart1_rxd(&self) -> bool {
91        *self == FUNCTION_A::UART1_RXD
92    }
93}
94#[doc = "Field `function_0(0-7)` writer - Select peripheral function for UART signal %s"]
95pub type FUNCTION_0_W<'a, REG> = crate::FieldWriter<'a, REG, 8, FUNCTION_A>;
96impl<'a, REG> FUNCTION_0_W<'a, REG>
97where
98    REG: crate::Writable + crate::RegisterSpec,
99    REG::Ux: From<u8>,
100{
101    #[doc = "UART0 Request-to-Send flow control"]
102    #[inline(always)]
103    pub fn uart0_rts(self) -> &'a mut crate::W<REG> {
104        self.variant(FUNCTION_A::UART0_RTS)
105    }
106    #[doc = "UART0 Clear-to-Send flow control"]
107    #[inline(always)]
108    pub fn uart0_cts(self) -> &'a mut crate::W<REG> {
109        self.variant(FUNCTION_A::UART0_CTS)
110    }
111    #[doc = "UART0 transmit data"]
112    #[inline(always)]
113    pub fn uart0_txd(self) -> &'a mut crate::W<REG> {
114        self.variant(FUNCTION_A::UART0_TXD)
115    }
116    #[doc = "UART0 receive data"]
117    #[inline(always)]
118    pub fn uart0_rxd(self) -> &'a mut crate::W<REG> {
119        self.variant(FUNCTION_A::UART0_RXD)
120    }
121    #[doc = "UART1 Request-to-Send flow control"]
122    #[inline(always)]
123    pub fn uart1_rts(self) -> &'a mut crate::W<REG> {
124        self.variant(FUNCTION_A::UART1_RTS)
125    }
126    #[doc = "UART1 Clear-to-Send flow control"]
127    #[inline(always)]
128    pub fn uart1_cts(self) -> &'a mut crate::W<REG> {
129        self.variant(FUNCTION_A::UART1_CTS)
130    }
131    #[doc = "UART1 transmit data"]
132    #[inline(always)]
133    pub fn uart1_txd(self) -> &'a mut crate::W<REG> {
134        self.variant(FUNCTION_A::UART1_TXD)
135    }
136    #[doc = "UART1 receive data"]
137    #[inline(always)]
138    pub fn uart1_rxd(self) -> &'a mut crate::W<REG> {
139        self.variant(FUNCTION_A::UART1_RXD)
140    }
141}
142impl R {
143    #[doc = "Select peripheral function for UART signal (0-7)"]
144    #[doc = ""]
145    #[doc = "NOTE: `n` is number of field in register. `n == 0` corresponds to `function_00` field"]
146    #[inline(always)]
147    pub fn function_0(&self, n: u8) -> FUNCTION_0_R {
148        #[allow(clippy::no_effect)]
149        [(); 8][n as usize];
150        FUNCTION_0_R::new(((self.bits >> (n * 4)) & 0xff) as u8)
151    }
152    #[doc = "Iterator for array of:"]
153    #[doc = "Select peripheral function for UART signal (0-7)"]
154    #[inline(always)]
155    pub fn function_0_iter(&self) -> impl Iterator<Item = FUNCTION_0_R> + '_ {
156        (0..8).map(move |n| FUNCTION_0_R::new(((self.bits >> (n * 4)) & 0xff) as u8))
157    }
158    #[doc = "Bits 0:7 - Select peripheral function for UART signal 0"]
159    #[inline(always)]
160    pub fn function_00(&self) -> FUNCTION_0_R {
161        FUNCTION_0_R::new((self.bits & 0xff) as u8)
162    }
163    #[doc = "Bits 4:11 - Select peripheral function for UART signal 1"]
164    #[inline(always)]
165    pub fn function_01(&self) -> FUNCTION_0_R {
166        FUNCTION_0_R::new(((self.bits >> 4) & 0xff) as u8)
167    }
168    #[doc = "Bits 8:15 - Select peripheral function for UART signal 2"]
169    #[inline(always)]
170    pub fn function_02(&self) -> FUNCTION_0_R {
171        FUNCTION_0_R::new(((self.bits >> 8) & 0xff) as u8)
172    }
173    #[doc = "Bits 12:19 - Select peripheral function for UART signal 3"]
174    #[inline(always)]
175    pub fn function_03(&self) -> FUNCTION_0_R {
176        FUNCTION_0_R::new(((self.bits >> 12) & 0xff) as u8)
177    }
178    #[doc = "Bits 16:23 - Select peripheral function for UART signal 4"]
179    #[inline(always)]
180    pub fn function_04(&self) -> FUNCTION_0_R {
181        FUNCTION_0_R::new(((self.bits >> 16) & 0xff) as u8)
182    }
183    #[doc = "Bits 20:27 - Select peripheral function for UART signal 5"]
184    #[inline(always)]
185    pub fn function_05(&self) -> FUNCTION_0_R {
186        FUNCTION_0_R::new(((self.bits >> 20) & 0xff) as u8)
187    }
188    #[doc = "Bits 24:31 - Select peripheral function for UART signal 6"]
189    #[inline(always)]
190    pub fn function_06(&self) -> FUNCTION_0_R {
191        FUNCTION_0_R::new(((self.bits >> 24) & 0xff) as u8)
192    }
193    #[doc = "Bits 28:35 - Select peripheral function for UART signal 7"]
194    #[inline(always)]
195    pub fn function_07(&self) -> FUNCTION_0_R {
196        FUNCTION_0_R::new(((self.bits >> 28) & 0xff) as u8)
197    }
198}
199impl W {
200    #[doc = "Select peripheral function for UART signal (0-7)"]
201    #[doc = ""]
202    #[doc = "NOTE: `n` is number of field in register. `n == 0` corresponds to `function_00` field"]
203    #[inline(always)]
204    #[must_use]
205    pub fn function_0(&mut self, n: u8) -> FUNCTION_0_W<UART_SIGNAL_0_SPEC> {
206        #[allow(clippy::no_effect)]
207        [(); 8][n as usize];
208        FUNCTION_0_W::new(self, n * 4)
209    }
210    #[doc = "Bits 0:7 - Select peripheral function for UART signal 0"]
211    #[inline(always)]
212    #[must_use]
213    pub fn function_00(&mut self) -> FUNCTION_0_W<UART_SIGNAL_0_SPEC> {
214        FUNCTION_0_W::new(self, 0)
215    }
216    #[doc = "Bits 4:11 - Select peripheral function for UART signal 1"]
217    #[inline(always)]
218    #[must_use]
219    pub fn function_01(&mut self) -> FUNCTION_0_W<UART_SIGNAL_0_SPEC> {
220        FUNCTION_0_W::new(self, 4)
221    }
222    #[doc = "Bits 8:15 - Select peripheral function for UART signal 2"]
223    #[inline(always)]
224    #[must_use]
225    pub fn function_02(&mut self) -> FUNCTION_0_W<UART_SIGNAL_0_SPEC> {
226        FUNCTION_0_W::new(self, 8)
227    }
228    #[doc = "Bits 12:19 - Select peripheral function for UART signal 3"]
229    #[inline(always)]
230    #[must_use]
231    pub fn function_03(&mut self) -> FUNCTION_0_W<UART_SIGNAL_0_SPEC> {
232        FUNCTION_0_W::new(self, 12)
233    }
234    #[doc = "Bits 16:23 - Select peripheral function for UART signal 4"]
235    #[inline(always)]
236    #[must_use]
237    pub fn function_04(&mut self) -> FUNCTION_0_W<UART_SIGNAL_0_SPEC> {
238        FUNCTION_0_W::new(self, 16)
239    }
240    #[doc = "Bits 20:27 - Select peripheral function for UART signal 5"]
241    #[inline(always)]
242    #[must_use]
243    pub fn function_05(&mut self) -> FUNCTION_0_W<UART_SIGNAL_0_SPEC> {
244        FUNCTION_0_W::new(self, 20)
245    }
246    #[doc = "Bits 24:31 - Select peripheral function for UART signal 6"]
247    #[inline(always)]
248    #[must_use]
249    pub fn function_06(&mut self) -> FUNCTION_0_W<UART_SIGNAL_0_SPEC> {
250        FUNCTION_0_W::new(self, 24)
251    }
252    #[doc = "Bits 28:35 - Select peripheral function for UART signal 7"]
253    #[inline(always)]
254    #[must_use]
255    pub fn function_07(&mut self) -> FUNCTION_0_W<UART_SIGNAL_0_SPEC> {
256        FUNCTION_0_W::new(self, 28)
257    }
258    #[doc = r" Writes raw bits to the register."]
259    #[doc = r""]
260    #[doc = r" # Safety"]
261    #[doc = r""]
262    #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
263    #[inline(always)]
264    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
265        self.bits = bits;
266        self
267    }
268}
269#[doc = "Universal Asynchronous Receiver/Transmitter signal configuration 0\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`uart_signal_0::R`](R).  You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`uart_signal_0::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
270pub struct UART_SIGNAL_0_SPEC;
271impl crate::RegisterSpec for UART_SIGNAL_0_SPEC {
272    type Ux = u32;
273}
274#[doc = "`read()` method returns [`uart_signal_0::R`](R) reader structure"]
275impl crate::Readable for UART_SIGNAL_0_SPEC {}
276#[doc = "`write(|w| ..)` method takes [`uart_signal_0::W`](W) writer structure"]
277impl crate::Writable for UART_SIGNAL_0_SPEC {
278    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
279    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
280}
281#[doc = "`reset()` method sets uart_signal_0 to value 0"]
282impl crate::Resettable for UART_SIGNAL_0_SPEC {
283    const RESET_VALUE: Self::Ux = 0;
284}