nrf52840_pac/uart0/
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 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 parity bit"]
134    #[inline(always)]
135    pub fn included(self) -> &'a mut W {
136        self.variant(PARITY_A::INCLUDED)
137    }
138}
139impl R {
140    #[doc = "Bit 0 - Hardware flow control"]
141    #[inline(always)]
142    pub fn hwfc(&self) -> HWFC_R {
143        HWFC_R::new((self.bits & 1) != 0)
144    }
145    #[doc = "Bits 1:3 - Parity"]
146    #[inline(always)]
147    pub fn parity(&self) -> PARITY_R {
148        PARITY_R::new(((self.bits >> 1) & 7) as u8)
149    }
150}
151impl W {
152    #[doc = "Bit 0 - Hardware flow control"]
153    #[inline(always)]
154    pub fn hwfc(&mut self) -> HWFC_W<0> {
155        HWFC_W::new(self)
156    }
157    #[doc = "Bits 1:3 - Parity"]
158    #[inline(always)]
159    pub fn parity(&mut self) -> PARITY_W<1> {
160        PARITY_W::new(self)
161    }
162    #[doc = "Writes raw bits to the register."]
163    #[inline(always)]
164    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
165        self.0.bits(bits);
166        self
167    }
168}
169#[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"]
170pub struct CONFIG_SPEC;
171impl crate::RegisterSpec for CONFIG_SPEC {
172    type Ux = u32;
173}
174#[doc = "`read()` method returns [config::R](R) reader structure"]
175impl crate::Readable for CONFIG_SPEC {
176    type Reader = R;
177}
178#[doc = "`write(|w| ..)` method takes [config::W](W) writer structure"]
179impl crate::Writable for CONFIG_SPEC {
180    type Writer = W;
181}
182#[doc = "`reset()` method sets CONFIG to value 0"]
183impl crate::Resettable for CONFIG_SPEC {
184    #[inline(always)]
185    fn reset_value() -> Self::Ux {
186        0
187    }
188}