nrf52840_pac/uarte0/
config.rs

1#[doc = "Register `CONFIG` reader"]
2pub struct R(crate::R<CONFIG_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CONFIG_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CONFIG_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CONFIG_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CONFIG` writer"]
17pub struct W(crate::W<CONFIG_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CONFIG_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<CONFIG_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CONFIG_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `HWFC` reader - Hardware flow control"]
38pub type HWFC_R = crate::BitReader<HWFC_A>;
39#[doc = "Hardware flow control\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41pub enum HWFC_A {
42    #[doc = "0: Disabled"]
43    DISABLED = 0,
44    #[doc = "1: Enabled"]
45    ENABLED = 1,
46}
47impl From<HWFC_A> for bool {
48    #[inline(always)]
49    fn from(variant: HWFC_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl HWFC_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> HWFC_A {
57        match self.bits {
58            false => HWFC_A::DISABLED,
59            true => HWFC_A::ENABLED,
60        }
61    }
62    #[doc = "Checks if the value of the field is `DISABLED`"]
63    #[inline(always)]
64    pub fn is_disabled(&self) -> bool {
65        *self == HWFC_A::DISABLED
66    }
67    #[doc = "Checks if the value of the field is `ENABLED`"]
68    #[inline(always)]
69    pub fn is_enabled(&self) -> bool {
70        *self == HWFC_A::ENABLED
71    }
72}
73#[doc = "Field `HWFC` writer - Hardware flow control"]
74pub type HWFC_W<'a, const O: u8> = crate::BitWriter<'a, u32, CONFIG_SPEC, HWFC_A, O>;
75impl<'a, const O: u8> HWFC_W<'a, O> {
76    #[doc = "Disabled"]
77    #[inline(always)]
78    pub fn disabled(self) -> &'a mut W {
79        self.variant(HWFC_A::DISABLED)
80    }
81    #[doc = "Enabled"]
82    #[inline(always)]
83    pub fn enabled(self) -> &'a mut W {
84        self.variant(HWFC_A::ENABLED)
85    }
86}
87#[doc = "Field `PARITY` reader - Parity"]
88pub type PARITY_R = crate::FieldReader<u8, PARITY_A>;
89#[doc = "Parity\n\nValue on reset: 0"]
90#[derive(Clone, Copy, Debug, PartialEq)]
91#[repr(u8)]
92pub enum PARITY_A {
93    #[doc = "0: Exclude parity bit"]
94    EXCLUDED = 0,
95    #[doc = "7: Include even parity bit"]
96    INCLUDED = 7,
97}
98impl From<PARITY_A> for u8 {
99    #[inline(always)]
100    fn from(variant: PARITY_A) -> Self {
101        variant as _
102    }
103}
104impl PARITY_R {
105    #[doc = "Get enumerated values variant"]
106    #[inline(always)]
107    pub fn variant(&self) -> Option<PARITY_A> {
108        match self.bits {
109            0 => Some(PARITY_A::EXCLUDED),
110            7 => Some(PARITY_A::INCLUDED),
111            _ => None,
112        }
113    }
114    #[doc = "Checks if the value of the field is `EXCLUDED`"]
115    #[inline(always)]
116    pub fn is_excluded(&self) -> bool {
117        *self == PARITY_A::EXCLUDED
118    }
119    #[doc = "Checks if the value of the field is `INCLUDED`"]
120    #[inline(always)]
121    pub fn is_included(&self) -> bool {
122        *self == PARITY_A::INCLUDED
123    }
124}
125#[doc = "Field `PARITY` writer - Parity"]
126pub type PARITY_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CONFIG_SPEC, u8, PARITY_A, 3, O>;
127impl<'a, const O: u8> PARITY_W<'a, O> {
128    #[doc = "Exclude parity bit"]
129    #[inline(always)]
130    pub fn excluded(self) -> &'a mut W {
131        self.variant(PARITY_A::EXCLUDED)
132    }
133    #[doc = "Include even parity bit"]
134    #[inline(always)]
135    pub fn included(self) -> &'a mut W {
136        self.variant(PARITY_A::INCLUDED)
137    }
138}
139#[doc = "Field `STOP` reader - Stop bits"]
140pub type STOP_R = crate::BitReader<STOP_A>;
141#[doc = "Stop bits\n\nValue on reset: 0"]
142#[derive(Clone, Copy, Debug, PartialEq)]
143pub enum STOP_A {
144    #[doc = "0: One stop bit"]
145    ONE = 0,
146    #[doc = "1: Two stop bits"]
147    TWO = 1,
148}
149impl From<STOP_A> for bool {
150    #[inline(always)]
151    fn from(variant: STOP_A) -> Self {
152        variant as u8 != 0
153    }
154}
155impl STOP_R {
156    #[doc = "Get enumerated values variant"]
157    #[inline(always)]
158    pub fn variant(&self) -> STOP_A {
159        match self.bits {
160            false => STOP_A::ONE,
161            true => STOP_A::TWO,
162        }
163    }
164    #[doc = "Checks if the value of the field is `ONE`"]
165    #[inline(always)]
166    pub fn is_one(&self) -> bool {
167        *self == STOP_A::ONE
168    }
169    #[doc = "Checks if the value of the field is `TWO`"]
170    #[inline(always)]
171    pub fn is_two(&self) -> bool {
172        *self == STOP_A::TWO
173    }
174}
175#[doc = "Field `STOP` writer - Stop bits"]
176pub type STOP_W<'a, const O: u8> = crate::BitWriter<'a, u32, CONFIG_SPEC, STOP_A, O>;
177impl<'a, const O: u8> STOP_W<'a, O> {
178    #[doc = "One stop bit"]
179    #[inline(always)]
180    pub fn one(self) -> &'a mut W {
181        self.variant(STOP_A::ONE)
182    }
183    #[doc = "Two stop bits"]
184    #[inline(always)]
185    pub fn two(self) -> &'a mut W {
186        self.variant(STOP_A::TWO)
187    }
188}
189impl R {
190    #[doc = "Bit 0 - Hardware flow control"]
191    #[inline(always)]
192    pub fn hwfc(&self) -> HWFC_R {
193        HWFC_R::new((self.bits & 1) != 0)
194    }
195    #[doc = "Bits 1:3 - Parity"]
196    #[inline(always)]
197    pub fn parity(&self) -> PARITY_R {
198        PARITY_R::new(((self.bits >> 1) & 7) as u8)
199    }
200    #[doc = "Bit 4 - Stop bits"]
201    #[inline(always)]
202    pub fn stop(&self) -> STOP_R {
203        STOP_R::new(((self.bits >> 4) & 1) != 0)
204    }
205}
206impl W {
207    #[doc = "Bit 0 - Hardware flow control"]
208    #[inline(always)]
209    pub fn hwfc(&mut self) -> HWFC_W<0> {
210        HWFC_W::new(self)
211    }
212    #[doc = "Bits 1:3 - Parity"]
213    #[inline(always)]
214    pub fn parity(&mut self) -> PARITY_W<1> {
215        PARITY_W::new(self)
216    }
217    #[doc = "Bit 4 - Stop bits"]
218    #[inline(always)]
219    pub fn stop(&mut self) -> STOP_W<4> {
220        STOP_W::new(self)
221    }
222    #[doc = "Writes raw bits to the register."]
223    #[inline(always)]
224    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
225        self.0.bits(bits);
226        self
227    }
228}
229#[doc = "Configuration of parity and hardware flow control\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 [config](index.html) module"]
230pub struct CONFIG_SPEC;
231impl crate::RegisterSpec for CONFIG_SPEC {
232    type Ux = u32;
233}
234#[doc = "`read()` method returns [config::R](R) reader structure"]
235impl crate::Readable for CONFIG_SPEC {
236    type Reader = R;
237}
238#[doc = "`write(|w| ..)` method takes [config::W](W) writer structure"]
239impl crate::Writable for CONFIG_SPEC {
240    type Writer = W;
241}
242#[doc = "`reset()` method sets CONFIG to value 0"]
243impl crate::Resettable for CONFIG_SPEC {
244    #[inline(always)]
245    fn reset_value() -> Self::Ux {
246        0
247    }
248}