bl61x_pac/uart/
rs485_transmit.rs

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