bl616_pac/uart/
rs485_transmit.rs1#[doc = "Register `rs485_transmit` reader"]
2pub struct R(crate::R<RS485_TRANSMIT_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<RS485_TRANSMIT_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<RS485_TRANSMIT_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<RS485_TRANSMIT_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `rs485_transmit` writer"]
17pub struct W(crate::W<RS485_TRANSMIT_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<RS485_TRANSMIT_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<RS485_TRANSMIT_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<RS485_TRANSMIT_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `function` reader - RS-485 transceiver mode enable"]
38pub type FUNCTION_R = crate::BitReader<FUNCTION_A>;
39#[doc = "RS-485 transceiver mode enable\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum FUNCTION_A {
42 #[doc = "1: Enable RS-485 transceiver mode\n\n The peripheral is connected to RS-485 transceiver, and RTS signal output becomes Driver Enable (DE) signal."]
43 ENABLE = 1,
44 #[doc = "0: Disable RS-485 transceiver mode\n\n The peripheral operates as normal UART."]
45 DISABLE = 0,
46}
47impl From<FUNCTION_A> for bool {
48 #[inline(always)]
49 fn from(variant: FUNCTION_A) -> Self {
50 variant as u8 != 0
51 }
52}
53impl FUNCTION_R {
54 #[doc = "Get enumerated values variant"]
55 #[inline(always)]
56 pub fn variant(&self) -> FUNCTION_A {
57 match self.bits {
58 true => FUNCTION_A::ENABLE,
59 false => FUNCTION_A::DISABLE,
60 }
61 }
62 #[doc = "Checks if the value of the field is `ENABLE`"]
63 #[inline(always)]
64 pub fn is_enable(&self) -> bool {
65 *self == FUNCTION_A::ENABLE
66 }
67 #[doc = "Checks if the value of the field is `DISABLE`"]
68 #[inline(always)]
69 pub fn is_disable(&self) -> bool {
70 *self == FUNCTION_A::DISABLE
71 }
72}
73#[doc = "Field `function` writer - RS-485 transceiver mode enable"]
74pub type FUNCTION_W<'a, const O: u8> =
75 crate::BitWriter<'a, u32, RS485_TRANSMIT_SPEC, FUNCTION_A, O>;
76impl<'a, const O: u8> FUNCTION_W<'a, O> {
77 #[doc = "Enable RS-485 transceiver mode\n\n The peripheral is connected to RS-485 transceiver, and RTS signal output becomes Driver Enable (DE) signal."]
78 #[inline(always)]
79 pub fn enable(self) -> &'a mut W {
80 self.variant(FUNCTION_A::ENABLE)
81 }
82 #[doc = "Disable RS-485 transceiver mode\n\n The peripheral operates as normal UART."]
83 #[inline(always)]
84 pub fn disable(self) -> &'a mut W {
85 self.variant(FUNCTION_A::DISABLE)
86 }
87}
88#[doc = "Field `polarity` reader - RS-485 pin polarity of Driver Enable (DE) pin"]
89pub type POLARITY_R = crate::BitReader<POLARITY_A>;
90#[doc = "RS-485 pin polarity of Driver Enable (DE) pin\n\nValue on reset: 1"]
91#[derive(Clone, Copy, Debug, PartialEq, Eq)]
92pub enum POLARITY_A {
93 #[doc = "1: Driver Enable (DE) pin is active high"]
94 ACTIVE_HIGH = 1,
95 #[doc = "0: Driver Enable (DE) pin is active low"]
96 ACTIVE_LOW = 0,
97}
98impl From<POLARITY_A> for bool {
99 #[inline(always)]
100 fn from(variant: POLARITY_A) -> Self {
101 variant as u8 != 0
102 }
103}
104impl POLARITY_R {
105 #[doc = "Get enumerated values variant"]
106 #[inline(always)]
107 pub fn variant(&self) -> POLARITY_A {
108 match self.bits {
109 true => POLARITY_A::ACTIVE_HIGH,
110 false => POLARITY_A::ACTIVE_LOW,
111 }
112 }
113 #[doc = "Checks if the value of the field is `ACTIVE_HIGH`"]
114 #[inline(always)]
115 pub fn is_active_high(&self) -> bool {
116 *self == POLARITY_A::ACTIVE_HIGH
117 }
118 #[doc = "Checks if the value of the field is `ACTIVE_LOW`"]
119 #[inline(always)]
120 pub fn is_active_low(&self) -> bool {
121 *self == POLARITY_A::ACTIVE_LOW
122 }
123}
124#[doc = "Field `polarity` writer - RS-485 pin polarity of Driver Enable (DE) pin"]
125pub type POLARITY_W<'a, const O: u8> =
126 crate::BitWriter<'a, u32, RS485_TRANSMIT_SPEC, POLARITY_A, O>;
127impl<'a, const O: u8> POLARITY_W<'a, O> {
128 #[doc = "Driver Enable (DE) pin is active high"]
129 #[inline(always)]
130 pub fn active_high(self) -> &'a mut W {
131 self.variant(POLARITY_A::ACTIVE_HIGH)
132 }
133 #[doc = "Driver Enable (DE) pin is active low"]
134 #[inline(always)]
135 pub fn active_low(self) -> &'a mut W {
136 self.variant(POLARITY_A::ACTIVE_LOW)
137 }
138}
139impl R {
140 #[doc = "Bit 0 - RS-485 transceiver mode enable"]
141 #[inline(always)]
142 pub fn function(&self) -> FUNCTION_R {
143 FUNCTION_R::new((self.bits & 1) != 0)
144 }
145 #[doc = "Bit 1 - RS-485 pin polarity of Driver Enable (DE) pin"]
146 #[inline(always)]
147 pub fn polarity(&self) -> POLARITY_R {
148 POLARITY_R::new(((self.bits >> 1) & 1) != 0)
149 }
150}
151impl W {
152 #[doc = "Bit 0 - RS-485 transceiver mode enable"]
153 #[inline(always)]
154 #[must_use]
155 pub fn function(&mut self) -> FUNCTION_W<0> {
156 FUNCTION_W::new(self)
157 }
158 #[doc = "Bit 1 - RS-485 pin polarity of Driver Enable (DE) pin"]
159 #[inline(always)]
160 #[must_use]
161 pub fn polarity(&mut self) -> POLARITY_W<1> {
162 POLARITY_W::new(self)
163 }
164 #[doc = "Writes raw bits to the register."]
165 #[inline(always)]
166 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
167 self.0.bits(bits);
168 self
169 }
170}
171#[doc = "RS-485 mode transmit configuration\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 [rs485_transmit](index.html) module"]
172pub struct RS485_TRANSMIT_SPEC;
173impl crate::RegisterSpec for RS485_TRANSMIT_SPEC {
174 type Ux = u32;
175}
176#[doc = "`read()` method returns [rs485_transmit::R](R) reader structure"]
177impl crate::Readable for RS485_TRANSMIT_SPEC {
178 type Reader = R;
179}
180#[doc = "`write(|w| ..)` method takes [rs485_transmit::W](W) writer structure"]
181impl crate::Writable for RS485_TRANSMIT_SPEC {
182 type Writer = W;
183 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
184 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
185}
186#[doc = "`reset()` method sets rs485_transmit to value 0x02"]
187impl crate::Resettable for RS485_TRANSMIT_SPEC {
188 const RESET_VALUE: Self::Ux = 0x02;
189}