bl61x_pac/uart/
rs485_transmit.rs

1#[doc = "Register `rs485_transmit` reader"]
2pub type R = crate::R<RS485_TRANSMIT_SPEC>;
3#[doc = "Register `rs485_transmit` writer"]
4pub type W = crate::W<RS485_TRANSMIT_SPEC>;
5#[doc = "Field `function` reader - RS-485 transceiver mode enable"]
6pub type FUNCTION_R = crate::BitReader<FUNCTION_A>;
7#[doc = "RS-485 transceiver mode enable\n\nValue on reset: 0"]
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9pub enum FUNCTION_A {
10    #[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."]
11    ENABLE = 1,
12    #[doc = "0: Disable RS-485 transceiver mode\n\n The peripheral operates as normal UART."]
13    DISABLE = 0,
14}
15impl From<FUNCTION_A> for bool {
16    #[inline(always)]
17    fn from(variant: FUNCTION_A) -> Self {
18        variant as u8 != 0
19    }
20}
21impl FUNCTION_R {
22    #[doc = "Get enumerated values variant"]
23    #[inline(always)]
24    pub const fn variant(&self) -> FUNCTION_A {
25        match self.bits {
26            true => FUNCTION_A::ENABLE,
27            false => FUNCTION_A::DISABLE,
28        }
29    }
30    #[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."]
31    #[inline(always)]
32    pub fn is_enable(&self) -> bool {
33        *self == FUNCTION_A::ENABLE
34    }
35    #[doc = "Disable RS-485 transceiver mode\n\n The peripheral operates as normal UART."]
36    #[inline(always)]
37    pub fn is_disable(&self) -> bool {
38        *self == FUNCTION_A::DISABLE
39    }
40}
41#[doc = "Field `function` writer - RS-485 transceiver mode enable"]
42pub type FUNCTION_W<'a, REG> = crate::BitWriter<'a, REG, FUNCTION_A>;
43impl<'a, REG> FUNCTION_W<'a, REG>
44where
45    REG: crate::Writable + crate::RegisterSpec,
46{
47    #[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."]
48    #[inline(always)]
49    pub fn enable(self) -> &'a mut crate::W<REG> {
50        self.variant(FUNCTION_A::ENABLE)
51    }
52    #[doc = "Disable RS-485 transceiver mode\n\n The peripheral operates as normal UART."]
53    #[inline(always)]
54    pub fn disable(self) -> &'a mut crate::W<REG> {
55        self.variant(FUNCTION_A::DISABLE)
56    }
57}
58#[doc = "Field `polarity` reader - RS-485 pin polarity of Driver Enable (DE) pin"]
59pub type POLARITY_R = crate::BitReader<POLARITY_A>;
60#[doc = "RS-485 pin polarity of Driver Enable (DE) pin\n\nValue on reset: 1"]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62pub enum POLARITY_A {
63    #[doc = "1: Driver Enable (DE) pin is active high"]
64    ACTIVE_HIGH = 1,
65    #[doc = "0: Driver Enable (DE) pin is active low"]
66    ACTIVE_LOW = 0,
67}
68impl From<POLARITY_A> for bool {
69    #[inline(always)]
70    fn from(variant: POLARITY_A) -> Self {
71        variant as u8 != 0
72    }
73}
74impl POLARITY_R {
75    #[doc = "Get enumerated values variant"]
76    #[inline(always)]
77    pub const fn variant(&self) -> POLARITY_A {
78        match self.bits {
79            true => POLARITY_A::ACTIVE_HIGH,
80            false => POLARITY_A::ACTIVE_LOW,
81        }
82    }
83    #[doc = "Driver Enable (DE) pin is active high"]
84    #[inline(always)]
85    pub fn is_active_high(&self) -> bool {
86        *self == POLARITY_A::ACTIVE_HIGH
87    }
88    #[doc = "Driver Enable (DE) pin is active low"]
89    #[inline(always)]
90    pub fn is_active_low(&self) -> bool {
91        *self == POLARITY_A::ACTIVE_LOW
92    }
93}
94#[doc = "Field `polarity` writer - RS-485 pin polarity of Driver Enable (DE) pin"]
95pub type POLARITY_W<'a, REG> = crate::BitWriter<'a, REG, POLARITY_A>;
96impl<'a, REG> POLARITY_W<'a, REG>
97where
98    REG: crate::Writable + crate::RegisterSpec,
99{
100    #[doc = "Driver Enable (DE) pin is active high"]
101    #[inline(always)]
102    pub fn active_high(self) -> &'a mut crate::W<REG> {
103        self.variant(POLARITY_A::ACTIVE_HIGH)
104    }
105    #[doc = "Driver Enable (DE) pin is active low"]
106    #[inline(always)]
107    pub fn active_low(self) -> &'a mut crate::W<REG> {
108        self.variant(POLARITY_A::ACTIVE_LOW)
109    }
110}
111impl R {
112    #[doc = "Bit 0 - RS-485 transceiver mode enable"]
113    #[inline(always)]
114    pub fn function(&self) -> FUNCTION_R {
115        FUNCTION_R::new((self.bits & 1) != 0)
116    }
117    #[doc = "Bit 1 - RS-485 pin polarity of Driver Enable (DE) pin"]
118    #[inline(always)]
119    pub fn polarity(&self) -> POLARITY_R {
120        POLARITY_R::new(((self.bits >> 1) & 1) != 0)
121    }
122}
123impl W {
124    #[doc = "Bit 0 - RS-485 transceiver mode enable"]
125    #[inline(always)]
126    #[must_use]
127    pub fn function(&mut self) -> FUNCTION_W<RS485_TRANSMIT_SPEC> {
128        FUNCTION_W::new(self, 0)
129    }
130    #[doc = "Bit 1 - RS-485 pin polarity of Driver Enable (DE) pin"]
131    #[inline(always)]
132    #[must_use]
133    pub fn polarity(&mut self) -> POLARITY_W<RS485_TRANSMIT_SPEC> {
134        POLARITY_W::new(self, 1)
135    }
136    #[doc = r" Writes raw bits to the register."]
137    #[doc = r""]
138    #[doc = r" # Safety"]
139    #[doc = r""]
140    #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
141    #[inline(always)]
142    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
143        self.bits = bits;
144        self
145    }
146}
147#[doc = "RS-485 mode transmit configuration\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`rs485_transmit::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 [`rs485_transmit::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
148pub struct RS485_TRANSMIT_SPEC;
149impl crate::RegisterSpec for RS485_TRANSMIT_SPEC {
150    type Ux = u32;
151}
152#[doc = "`read()` method returns [`rs485_transmit::R`](R) reader structure"]
153impl crate::Readable for RS485_TRANSMIT_SPEC {}
154#[doc = "`write(|w| ..)` method takes [`rs485_transmit::W`](W) writer structure"]
155impl crate::Writable for RS485_TRANSMIT_SPEC {
156    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
157    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
158}
159#[doc = "`reset()` method sets rs485_transmit to value 0x02"]
160impl crate::Resettable for RS485_TRANSMIT_SPEC {
161    const RESET_VALUE: Self::Ux = 0x02;
162}