1*37fdb2f5SManos Pitsidianakis // Copyright 2024, Linaro Limited 2*37fdb2f5SManos Pitsidianakis // Author(s): Manos Pitsidianakis <manos.pitsidianakis@linaro.org> 3*37fdb2f5SManos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later 4*37fdb2f5SManos Pitsidianakis // 5*37fdb2f5SManos Pitsidianakis // PL011 QEMU Device Model 6*37fdb2f5SManos Pitsidianakis // 7*37fdb2f5SManos Pitsidianakis // This library implements a device model for the PrimeCell® UART (PL011) 8*37fdb2f5SManos Pitsidianakis // device in QEMU. 9*37fdb2f5SManos Pitsidianakis // 10*37fdb2f5SManos Pitsidianakis #![doc = include_str!("../README.md")] 11*37fdb2f5SManos Pitsidianakis //! # Library crate 12*37fdb2f5SManos Pitsidianakis //! 13*37fdb2f5SManos Pitsidianakis //! See [`PL011State`](crate::device::PL011State) for the device model type and 14*37fdb2f5SManos Pitsidianakis //! the [`registers`] module for register types. 15*37fdb2f5SManos Pitsidianakis 16*37fdb2f5SManos Pitsidianakis #![deny( 17*37fdb2f5SManos Pitsidianakis rustdoc::broken_intra_doc_links, 18*37fdb2f5SManos Pitsidianakis rustdoc::redundant_explicit_links, 19*37fdb2f5SManos Pitsidianakis clippy::correctness, 20*37fdb2f5SManos Pitsidianakis clippy::suspicious, 21*37fdb2f5SManos Pitsidianakis clippy::complexity, 22*37fdb2f5SManos Pitsidianakis clippy::perf, 23*37fdb2f5SManos Pitsidianakis clippy::cargo, 24*37fdb2f5SManos Pitsidianakis clippy::nursery, 25*37fdb2f5SManos Pitsidianakis clippy::style, 26*37fdb2f5SManos Pitsidianakis // restriction group 27*37fdb2f5SManos Pitsidianakis clippy::dbg_macro, 28*37fdb2f5SManos Pitsidianakis clippy::as_underscore, 29*37fdb2f5SManos Pitsidianakis clippy::assertions_on_result_states, 30*37fdb2f5SManos Pitsidianakis // pedantic group 31*37fdb2f5SManos Pitsidianakis clippy::doc_markdown, 32*37fdb2f5SManos Pitsidianakis clippy::borrow_as_ptr, 33*37fdb2f5SManos Pitsidianakis clippy::cast_lossless, 34*37fdb2f5SManos Pitsidianakis clippy::option_if_let_else, 35*37fdb2f5SManos Pitsidianakis clippy::missing_const_for_fn, 36*37fdb2f5SManos Pitsidianakis clippy::cognitive_complexity, 37*37fdb2f5SManos Pitsidianakis clippy::missing_safety_doc, 38*37fdb2f5SManos Pitsidianakis )] 39*37fdb2f5SManos Pitsidianakis 40*37fdb2f5SManos Pitsidianakis extern crate bilge; 41*37fdb2f5SManos Pitsidianakis extern crate bilge_impl; 42*37fdb2f5SManos Pitsidianakis extern crate qemu_api; 43*37fdb2f5SManos Pitsidianakis 44*37fdb2f5SManos Pitsidianakis pub mod device; 45*37fdb2f5SManos Pitsidianakis pub mod device_class; 46*37fdb2f5SManos Pitsidianakis pub mod memory_ops; 47*37fdb2f5SManos Pitsidianakis 48*37fdb2f5SManos Pitsidianakis pub const TYPE_PL011: &::core::ffi::CStr = c"pl011"; 49*37fdb2f5SManos Pitsidianakis 50*37fdb2f5SManos Pitsidianakis /// Offset of each register from the base memory address of the device. 51*37fdb2f5SManos Pitsidianakis /// 52*37fdb2f5SManos Pitsidianakis /// # Source 53*37fdb2f5SManos Pitsidianakis /// ARM DDI 0183G, Table 3-1 p.3-3 54*37fdb2f5SManos Pitsidianakis #[doc(alias = "offset")] 55*37fdb2f5SManos Pitsidianakis #[allow(non_camel_case_types)] 56*37fdb2f5SManos Pitsidianakis #[repr(u64)] 57*37fdb2f5SManos Pitsidianakis #[derive(Debug)] 58*37fdb2f5SManos Pitsidianakis pub enum RegisterOffset { 59*37fdb2f5SManos Pitsidianakis /// Data Register 60*37fdb2f5SManos Pitsidianakis /// 61*37fdb2f5SManos Pitsidianakis /// A write to this register initiates the actual data transmission 62*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTDR")] 63*37fdb2f5SManos Pitsidianakis DR = 0x000, 64*37fdb2f5SManos Pitsidianakis /// Receive Status Register or Error Clear Register 65*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTRSR")] 66*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTECR")] 67*37fdb2f5SManos Pitsidianakis RSR = 0x004, 68*37fdb2f5SManos Pitsidianakis /// Flag Register 69*37fdb2f5SManos Pitsidianakis /// 70*37fdb2f5SManos Pitsidianakis /// A read of this register shows if transmission is complete 71*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTFR")] 72*37fdb2f5SManos Pitsidianakis FR = 0x018, 73*37fdb2f5SManos Pitsidianakis /// Fractional Baud Rate Register 74*37fdb2f5SManos Pitsidianakis /// 75*37fdb2f5SManos Pitsidianakis /// responsible for baud rate speed 76*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTFBRD")] 77*37fdb2f5SManos Pitsidianakis FBRD = 0x028, 78*37fdb2f5SManos Pitsidianakis /// `IrDA` Low-Power Counter Register 79*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTILPR")] 80*37fdb2f5SManos Pitsidianakis ILPR = 0x020, 81*37fdb2f5SManos Pitsidianakis /// Integer Baud Rate Register 82*37fdb2f5SManos Pitsidianakis /// 83*37fdb2f5SManos Pitsidianakis /// Responsible for baud rate speed 84*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTIBRD")] 85*37fdb2f5SManos Pitsidianakis IBRD = 0x024, 86*37fdb2f5SManos Pitsidianakis /// line control register (data frame format) 87*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTLCR_H")] 88*37fdb2f5SManos Pitsidianakis LCR_H = 0x02C, 89*37fdb2f5SManos Pitsidianakis /// Toggle UART, transmission or reception 90*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTCR")] 91*37fdb2f5SManos Pitsidianakis CR = 0x030, 92*37fdb2f5SManos Pitsidianakis /// Interrupt FIFO Level Select Register 93*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTIFLS")] 94*37fdb2f5SManos Pitsidianakis FLS = 0x034, 95*37fdb2f5SManos Pitsidianakis /// Interrupt Mask Set/Clear Register 96*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTIMSC")] 97*37fdb2f5SManos Pitsidianakis IMSC = 0x038, 98*37fdb2f5SManos Pitsidianakis /// Raw Interrupt Status Register 99*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTRIS")] 100*37fdb2f5SManos Pitsidianakis RIS = 0x03C, 101*37fdb2f5SManos Pitsidianakis /// Masked Interrupt Status Register 102*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTMIS")] 103*37fdb2f5SManos Pitsidianakis MIS = 0x040, 104*37fdb2f5SManos Pitsidianakis /// Interrupt Clear Register 105*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTICR")] 106*37fdb2f5SManos Pitsidianakis ICR = 0x044, 107*37fdb2f5SManos Pitsidianakis /// DMA control Register 108*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTDMACR")] 109*37fdb2f5SManos Pitsidianakis DMACR = 0x048, 110*37fdb2f5SManos Pitsidianakis ///// Reserved, offsets `0x04C` to `0x07C`. 111*37fdb2f5SManos Pitsidianakis //Reserved = 0x04C, 112*37fdb2f5SManos Pitsidianakis } 113*37fdb2f5SManos Pitsidianakis 114*37fdb2f5SManos Pitsidianakis impl core::convert::TryFrom<u64> for RegisterOffset { 115*37fdb2f5SManos Pitsidianakis type Error = u64; 116*37fdb2f5SManos Pitsidianakis 117*37fdb2f5SManos Pitsidianakis fn try_from(value: u64) -> Result<Self, Self::Error> { 118*37fdb2f5SManos Pitsidianakis macro_rules! case { 119*37fdb2f5SManos Pitsidianakis ($($discriminant:ident),*$(,)*) => { 120*37fdb2f5SManos Pitsidianakis /* check that matching on all macro arguments compiles, which means we are not 121*37fdb2f5SManos Pitsidianakis * missing any enum value; if the type definition ever changes this will stop 122*37fdb2f5SManos Pitsidianakis * compiling. 123*37fdb2f5SManos Pitsidianakis */ 124*37fdb2f5SManos Pitsidianakis const fn _assert_exhaustive(val: RegisterOffset) { 125*37fdb2f5SManos Pitsidianakis match val { 126*37fdb2f5SManos Pitsidianakis $(RegisterOffset::$discriminant => (),)* 127*37fdb2f5SManos Pitsidianakis } 128*37fdb2f5SManos Pitsidianakis } 129*37fdb2f5SManos Pitsidianakis 130*37fdb2f5SManos Pitsidianakis match value { 131*37fdb2f5SManos Pitsidianakis $(x if x == Self::$discriminant as u64 => Ok(Self::$discriminant),)* 132*37fdb2f5SManos Pitsidianakis _ => Err(value), 133*37fdb2f5SManos Pitsidianakis } 134*37fdb2f5SManos Pitsidianakis } 135*37fdb2f5SManos Pitsidianakis } 136*37fdb2f5SManos Pitsidianakis case! { DR, RSR, FR, FBRD, ILPR, IBRD, LCR_H, CR, FLS, IMSC, RIS, MIS, ICR, DMACR } 137*37fdb2f5SManos Pitsidianakis } 138*37fdb2f5SManos Pitsidianakis } 139*37fdb2f5SManos Pitsidianakis 140*37fdb2f5SManos Pitsidianakis pub mod registers { 141*37fdb2f5SManos Pitsidianakis //! Device registers exposed as typed structs which are backed by arbitrary 142*37fdb2f5SManos Pitsidianakis //! integer bitmaps. [`Data`], [`Control`], [`LineControl`], etc. 143*37fdb2f5SManos Pitsidianakis //! 144*37fdb2f5SManos Pitsidianakis //! All PL011 registers are essentially 32-bit wide, but are typed here as 145*37fdb2f5SManos Pitsidianakis //! bitmaps with only the necessary width. That is, if a struct bitmap 146*37fdb2f5SManos Pitsidianakis //! in this module is for example 16 bits long, it should be conceived 147*37fdb2f5SManos Pitsidianakis //! as a 32-bit register where the unmentioned higher bits are always 148*37fdb2f5SManos Pitsidianakis //! unused thus treated as zero when read or written. 149*37fdb2f5SManos Pitsidianakis use bilge::prelude::*; 150*37fdb2f5SManos Pitsidianakis 151*37fdb2f5SManos Pitsidianakis // TODO: FIFO Mode has different semantics 152*37fdb2f5SManos Pitsidianakis /// Data Register, `UARTDR` 153*37fdb2f5SManos Pitsidianakis /// 154*37fdb2f5SManos Pitsidianakis /// The `UARTDR` register is the data register. 155*37fdb2f5SManos Pitsidianakis /// 156*37fdb2f5SManos Pitsidianakis /// For words to be transmitted: 157*37fdb2f5SManos Pitsidianakis /// 158*37fdb2f5SManos Pitsidianakis /// - if the FIFOs are enabled, data written to this location is pushed onto 159*37fdb2f5SManos Pitsidianakis /// the transmit 160*37fdb2f5SManos Pitsidianakis /// FIFO 161*37fdb2f5SManos Pitsidianakis /// - if the FIFOs are not enabled, data is stored in the transmitter 162*37fdb2f5SManos Pitsidianakis /// holding register (the 163*37fdb2f5SManos Pitsidianakis /// bottom word of the transmit FIFO). 164*37fdb2f5SManos Pitsidianakis /// 165*37fdb2f5SManos Pitsidianakis /// The write operation initiates transmission from the UART. The data is 166*37fdb2f5SManos Pitsidianakis /// prefixed with a start bit, appended with the appropriate parity bit 167*37fdb2f5SManos Pitsidianakis /// (if parity is enabled), and a stop bit. The resultant word is then 168*37fdb2f5SManos Pitsidianakis /// transmitted. 169*37fdb2f5SManos Pitsidianakis /// 170*37fdb2f5SManos Pitsidianakis /// For received words: 171*37fdb2f5SManos Pitsidianakis /// 172*37fdb2f5SManos Pitsidianakis /// - if the FIFOs are enabled, the data byte and the 4-bit status (break, 173*37fdb2f5SManos Pitsidianakis /// frame, parity, 174*37fdb2f5SManos Pitsidianakis /// and overrun) is pushed onto the 12-bit wide receive FIFO 175*37fdb2f5SManos Pitsidianakis /// - if the FIFOs are not enabled, the data byte and status are stored in 176*37fdb2f5SManos Pitsidianakis /// the receiving 177*37fdb2f5SManos Pitsidianakis /// holding register (the bottom word of the receive FIFO). 178*37fdb2f5SManos Pitsidianakis /// 179*37fdb2f5SManos Pitsidianakis /// The received data byte is read by performing reads from the `UARTDR` 180*37fdb2f5SManos Pitsidianakis /// register along with the corresponding status information. The status 181*37fdb2f5SManos Pitsidianakis /// information can also be read by a read of the `UARTRSR/UARTECR` 182*37fdb2f5SManos Pitsidianakis /// register. 183*37fdb2f5SManos Pitsidianakis /// 184*37fdb2f5SManos Pitsidianakis /// # Note 185*37fdb2f5SManos Pitsidianakis /// 186*37fdb2f5SManos Pitsidianakis /// You must disable the UART before any of the control registers are 187*37fdb2f5SManos Pitsidianakis /// reprogrammed. When the UART is disabled in the middle of 188*37fdb2f5SManos Pitsidianakis /// transmission or reception, it completes the current character before 189*37fdb2f5SManos Pitsidianakis /// stopping. 190*37fdb2f5SManos Pitsidianakis /// 191*37fdb2f5SManos Pitsidianakis /// # Source 192*37fdb2f5SManos Pitsidianakis /// ARM DDI 0183G 3.3.1 Data Register, UARTDR 193*37fdb2f5SManos Pitsidianakis #[bitsize(16)] 194*37fdb2f5SManos Pitsidianakis #[derive(Clone, Copy, DebugBits, FromBits)] 195*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTDR")] 196*37fdb2f5SManos Pitsidianakis pub struct Data { 197*37fdb2f5SManos Pitsidianakis _reserved: u4, 198*37fdb2f5SManos Pitsidianakis pub data: u8, 199*37fdb2f5SManos Pitsidianakis pub framing_error: bool, 200*37fdb2f5SManos Pitsidianakis pub parity_error: bool, 201*37fdb2f5SManos Pitsidianakis pub break_error: bool, 202*37fdb2f5SManos Pitsidianakis pub overrun_error: bool, 203*37fdb2f5SManos Pitsidianakis } 204*37fdb2f5SManos Pitsidianakis 205*37fdb2f5SManos Pitsidianakis // TODO: FIFO Mode has different semantics 206*37fdb2f5SManos Pitsidianakis /// Receive Status Register / Error Clear Register, `UARTRSR/UARTECR` 207*37fdb2f5SManos Pitsidianakis /// 208*37fdb2f5SManos Pitsidianakis /// The UARTRSR/UARTECR register is the receive status register/error clear 209*37fdb2f5SManos Pitsidianakis /// register. Receive status can also be read from the `UARTRSR` 210*37fdb2f5SManos Pitsidianakis /// register. If the status is read from this register, then the status 211*37fdb2f5SManos Pitsidianakis /// information for break, framing and parity corresponds to the 212*37fdb2f5SManos Pitsidianakis /// data character read from the [Data register](Data), `UARTDR` prior to 213*37fdb2f5SManos Pitsidianakis /// reading the UARTRSR register. The status information for overrun is 214*37fdb2f5SManos Pitsidianakis /// set immediately when an overrun condition occurs. 215*37fdb2f5SManos Pitsidianakis /// 216*37fdb2f5SManos Pitsidianakis /// 217*37fdb2f5SManos Pitsidianakis /// # Note 218*37fdb2f5SManos Pitsidianakis /// The received data character must be read first from the [Data 219*37fdb2f5SManos Pitsidianakis /// Register](Data), `UARTDR` before reading the error status associated 220*37fdb2f5SManos Pitsidianakis /// with that data character from the `UARTRSR` register. This read 221*37fdb2f5SManos Pitsidianakis /// sequence cannot be reversed, because the `UARTRSR` register is 222*37fdb2f5SManos Pitsidianakis /// updated only when a read occurs from the `UARTDR` register. However, 223*37fdb2f5SManos Pitsidianakis /// the status information can also be obtained by reading the `UARTDR` 224*37fdb2f5SManos Pitsidianakis /// register 225*37fdb2f5SManos Pitsidianakis /// 226*37fdb2f5SManos Pitsidianakis /// # Source 227*37fdb2f5SManos Pitsidianakis /// ARM DDI 0183G 3.3.2 Receive Status Register/Error Clear Register, 228*37fdb2f5SManos Pitsidianakis /// UARTRSR/UARTECR 229*37fdb2f5SManos Pitsidianakis #[bitsize(8)] 230*37fdb2f5SManos Pitsidianakis #[derive(Clone, Copy, DebugBits, FromBits)] 231*37fdb2f5SManos Pitsidianakis pub struct ReceiveStatusErrorClear { 232*37fdb2f5SManos Pitsidianakis pub framing_error: bool, 233*37fdb2f5SManos Pitsidianakis pub parity_error: bool, 234*37fdb2f5SManos Pitsidianakis pub break_error: bool, 235*37fdb2f5SManos Pitsidianakis pub overrun_error: bool, 236*37fdb2f5SManos Pitsidianakis _reserved_unpredictable: u4, 237*37fdb2f5SManos Pitsidianakis } 238*37fdb2f5SManos Pitsidianakis 239*37fdb2f5SManos Pitsidianakis impl ReceiveStatusErrorClear { 240*37fdb2f5SManos Pitsidianakis pub fn reset(&mut self) { 241*37fdb2f5SManos Pitsidianakis // All the bits are cleared to 0 on reset. 242*37fdb2f5SManos Pitsidianakis *self = 0.into(); 243*37fdb2f5SManos Pitsidianakis } 244*37fdb2f5SManos Pitsidianakis } 245*37fdb2f5SManos Pitsidianakis 246*37fdb2f5SManos Pitsidianakis impl Default for ReceiveStatusErrorClear { 247*37fdb2f5SManos Pitsidianakis fn default() -> Self { 248*37fdb2f5SManos Pitsidianakis 0.into() 249*37fdb2f5SManos Pitsidianakis } 250*37fdb2f5SManos Pitsidianakis } 251*37fdb2f5SManos Pitsidianakis 252*37fdb2f5SManos Pitsidianakis #[bitsize(16)] 253*37fdb2f5SManos Pitsidianakis #[derive(Clone, Copy, DebugBits, FromBits)] 254*37fdb2f5SManos Pitsidianakis /// Flag Register, `UARTFR` 255*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTFR")] 256*37fdb2f5SManos Pitsidianakis pub struct Flags { 257*37fdb2f5SManos Pitsidianakis /// CTS Clear to send. This bit is the complement of the UART clear to 258*37fdb2f5SManos Pitsidianakis /// send, `nUARTCTS`, modem status input. That is, the bit is 1 259*37fdb2f5SManos Pitsidianakis /// when `nUARTCTS` is LOW. 260*37fdb2f5SManos Pitsidianakis pub clear_to_send: bool, 261*37fdb2f5SManos Pitsidianakis /// DSR Data set ready. This bit is the complement of the UART data set 262*37fdb2f5SManos Pitsidianakis /// ready, `nUARTDSR`, modem status input. That is, the bit is 1 when 263*37fdb2f5SManos Pitsidianakis /// `nUARTDSR` is LOW. 264*37fdb2f5SManos Pitsidianakis pub data_set_ready: bool, 265*37fdb2f5SManos Pitsidianakis /// DCD Data carrier detect. This bit is the complement of the UART data 266*37fdb2f5SManos Pitsidianakis /// carrier detect, `nUARTDCD`, modem status input. That is, the bit is 267*37fdb2f5SManos Pitsidianakis /// 1 when `nUARTDCD` is LOW. 268*37fdb2f5SManos Pitsidianakis pub data_carrier_detect: bool, 269*37fdb2f5SManos Pitsidianakis /// BUSY UART busy. If this bit is set to 1, the UART is busy 270*37fdb2f5SManos Pitsidianakis /// transmitting data. This bit remains set until the complete 271*37fdb2f5SManos Pitsidianakis /// byte, including all the stop bits, has been sent from the 272*37fdb2f5SManos Pitsidianakis /// shift register. This bit is set as soon as the transmit FIFO 273*37fdb2f5SManos Pitsidianakis /// becomes non-empty, regardless of whether the UART is enabled 274*37fdb2f5SManos Pitsidianakis /// or not. 275*37fdb2f5SManos Pitsidianakis pub busy: bool, 276*37fdb2f5SManos Pitsidianakis /// RXFE Receive FIFO empty. The meaning of this bit depends on the 277*37fdb2f5SManos Pitsidianakis /// state of the FEN bit in the UARTLCR_H register. If the FIFO 278*37fdb2f5SManos Pitsidianakis /// is disabled, this bit is set when the receive holding 279*37fdb2f5SManos Pitsidianakis /// register is empty. If the FIFO is enabled, the RXFE bit is 280*37fdb2f5SManos Pitsidianakis /// set when the receive FIFO is empty. 281*37fdb2f5SManos Pitsidianakis pub receive_fifo_empty: bool, 282*37fdb2f5SManos Pitsidianakis /// TXFF Transmit FIFO full. The meaning of this bit depends on the 283*37fdb2f5SManos Pitsidianakis /// state of the FEN bit in the UARTLCR_H register. If the FIFO 284*37fdb2f5SManos Pitsidianakis /// is disabled, this bit is set when the transmit holding 285*37fdb2f5SManos Pitsidianakis /// register is full. If the FIFO is enabled, the TXFF bit is 286*37fdb2f5SManos Pitsidianakis /// set when the transmit FIFO is full. 287*37fdb2f5SManos Pitsidianakis pub transmit_fifo_full: bool, 288*37fdb2f5SManos Pitsidianakis /// RXFF Receive FIFO full. The meaning of this bit depends on the state 289*37fdb2f5SManos Pitsidianakis /// of the FEN bit in the UARTLCR_H register. If the FIFO is 290*37fdb2f5SManos Pitsidianakis /// disabled, this bit is set when the receive holding register 291*37fdb2f5SManos Pitsidianakis /// is full. If the FIFO is enabled, the RXFF bit is set when 292*37fdb2f5SManos Pitsidianakis /// the receive FIFO is full. 293*37fdb2f5SManos Pitsidianakis pub receive_fifo_full: bool, 294*37fdb2f5SManos Pitsidianakis /// Transmit FIFO empty. The meaning of this bit depends on the state of 295*37fdb2f5SManos Pitsidianakis /// the FEN bit in the [Line Control register](LineControl), 296*37fdb2f5SManos Pitsidianakis /// `UARTLCR_H`. If the FIFO is disabled, this bit is set when the 297*37fdb2f5SManos Pitsidianakis /// transmit holding register is empty. If the FIFO is enabled, 298*37fdb2f5SManos Pitsidianakis /// the TXFE bit is set when the transmit FIFO is empty. This 299*37fdb2f5SManos Pitsidianakis /// bit does not indicate if there is data in the transmit shift 300*37fdb2f5SManos Pitsidianakis /// register. 301*37fdb2f5SManos Pitsidianakis pub transmit_fifo_empty: bool, 302*37fdb2f5SManos Pitsidianakis /// `RI`, is `true` when `nUARTRI` is `LOW`. 303*37fdb2f5SManos Pitsidianakis pub ring_indicator: bool, 304*37fdb2f5SManos Pitsidianakis _reserved_zero_no_modify: u7, 305*37fdb2f5SManos Pitsidianakis } 306*37fdb2f5SManos Pitsidianakis 307*37fdb2f5SManos Pitsidianakis impl Flags { 308*37fdb2f5SManos Pitsidianakis pub fn reset(&mut self) { 309*37fdb2f5SManos Pitsidianakis // After reset TXFF, RXFF, and BUSY are 0, and TXFE and RXFE are 1 310*37fdb2f5SManos Pitsidianakis self.set_receive_fifo_full(false); 311*37fdb2f5SManos Pitsidianakis self.set_transmit_fifo_full(false); 312*37fdb2f5SManos Pitsidianakis self.set_busy(false); 313*37fdb2f5SManos Pitsidianakis self.set_receive_fifo_empty(true); 314*37fdb2f5SManos Pitsidianakis self.set_transmit_fifo_empty(true); 315*37fdb2f5SManos Pitsidianakis } 316*37fdb2f5SManos Pitsidianakis } 317*37fdb2f5SManos Pitsidianakis 318*37fdb2f5SManos Pitsidianakis impl Default for Flags { 319*37fdb2f5SManos Pitsidianakis fn default() -> Self { 320*37fdb2f5SManos Pitsidianakis let mut ret: Self = 0.into(); 321*37fdb2f5SManos Pitsidianakis ret.reset(); 322*37fdb2f5SManos Pitsidianakis ret 323*37fdb2f5SManos Pitsidianakis } 324*37fdb2f5SManos Pitsidianakis } 325*37fdb2f5SManos Pitsidianakis 326*37fdb2f5SManos Pitsidianakis #[bitsize(16)] 327*37fdb2f5SManos Pitsidianakis #[derive(Clone, Copy, DebugBits, FromBits)] 328*37fdb2f5SManos Pitsidianakis /// Line Control Register, `UARTLCR_H` 329*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTLCR_H")] 330*37fdb2f5SManos Pitsidianakis pub struct LineControl { 331*37fdb2f5SManos Pitsidianakis /// 15:8 - Reserved, do not modify, read as zero. 332*37fdb2f5SManos Pitsidianakis _reserved_zero_no_modify: u8, 333*37fdb2f5SManos Pitsidianakis /// 7 SPS Stick parity select. 334*37fdb2f5SManos Pitsidianakis /// 0 = stick parity is disabled 335*37fdb2f5SManos Pitsidianakis /// 1 = either: 336*37fdb2f5SManos Pitsidianakis /// • if the EPS bit is 0 then the parity bit is transmitted and checked 337*37fdb2f5SManos Pitsidianakis /// as a 1 • if the EPS bit is 1 then the parity bit is 338*37fdb2f5SManos Pitsidianakis /// transmitted and checked as a 0. This bit has no effect when 339*37fdb2f5SManos Pitsidianakis /// the PEN bit disables parity checking and generation. See Table 3-11 340*37fdb2f5SManos Pitsidianakis /// on page 3-14 for the parity truth table. 341*37fdb2f5SManos Pitsidianakis pub sticky_parity: bool, 342*37fdb2f5SManos Pitsidianakis /// WLEN Word length. These bits indicate the number of data bits 343*37fdb2f5SManos Pitsidianakis /// transmitted or received in a frame as follows: b11 = 8 bits 344*37fdb2f5SManos Pitsidianakis /// b10 = 7 bits 345*37fdb2f5SManos Pitsidianakis /// b01 = 6 bits 346*37fdb2f5SManos Pitsidianakis /// b00 = 5 bits. 347*37fdb2f5SManos Pitsidianakis pub word_length: WordLength, 348*37fdb2f5SManos Pitsidianakis /// FEN Enable FIFOs: 349*37fdb2f5SManos Pitsidianakis /// 0 = FIFOs are disabled (character mode) that is, the FIFOs become 350*37fdb2f5SManos Pitsidianakis /// 1-byte-deep holding registers 1 = transmit and receive FIFO 351*37fdb2f5SManos Pitsidianakis /// buffers are enabled (FIFO mode). 352*37fdb2f5SManos Pitsidianakis pub fifos_enabled: Mode, 353*37fdb2f5SManos Pitsidianakis /// 3 STP2 Two stop bits select. If this bit is set to 1, two stop bits 354*37fdb2f5SManos Pitsidianakis /// are transmitted at the end of the frame. The receive 355*37fdb2f5SManos Pitsidianakis /// logic does not check for two stop bits being received. 356*37fdb2f5SManos Pitsidianakis pub two_stops_bits: bool, 357*37fdb2f5SManos Pitsidianakis /// EPS Even parity select. Controls the type of parity the UART uses 358*37fdb2f5SManos Pitsidianakis /// during transmission and reception: 359*37fdb2f5SManos Pitsidianakis /// - 0 = odd parity. The UART generates or checks for an odd number of 360*37fdb2f5SManos Pitsidianakis /// 1s in the data and parity bits. 361*37fdb2f5SManos Pitsidianakis /// - 1 = even parity. The UART generates or checks for an even number 362*37fdb2f5SManos Pitsidianakis /// of 1s in the data and parity bits. 363*37fdb2f5SManos Pitsidianakis /// This bit has no effect when the `PEN` bit disables parity checking 364*37fdb2f5SManos Pitsidianakis /// and generation. See Table 3-11 on page 3-14 for the parity 365*37fdb2f5SManos Pitsidianakis /// truth table. 366*37fdb2f5SManos Pitsidianakis pub parity: Parity, 367*37fdb2f5SManos Pitsidianakis /// 1 PEN Parity enable: 368*37fdb2f5SManos Pitsidianakis /// 369*37fdb2f5SManos Pitsidianakis /// - 0 = parity is disabled and no parity bit added to the data frame 370*37fdb2f5SManos Pitsidianakis /// - 1 = parity checking and generation is enabled. 371*37fdb2f5SManos Pitsidianakis /// 372*37fdb2f5SManos Pitsidianakis /// See Table 3-11 on page 3-14 for the parity truth table. 373*37fdb2f5SManos Pitsidianakis pub parity_enabled: bool, 374*37fdb2f5SManos Pitsidianakis /// BRK Send break. 375*37fdb2f5SManos Pitsidianakis /// 376*37fdb2f5SManos Pitsidianakis /// If this bit is set to `1`, a low-level is continually output on the 377*37fdb2f5SManos Pitsidianakis /// `UARTTXD` output, after completing transmission of the 378*37fdb2f5SManos Pitsidianakis /// current character. For the proper execution of the break command, 379*37fdb2f5SManos Pitsidianakis /// the software must set this bit for at least two complete 380*37fdb2f5SManos Pitsidianakis /// frames. For normal use, this bit must be cleared to `0`. 381*37fdb2f5SManos Pitsidianakis pub send_break: bool, 382*37fdb2f5SManos Pitsidianakis } 383*37fdb2f5SManos Pitsidianakis 384*37fdb2f5SManos Pitsidianakis impl LineControl { 385*37fdb2f5SManos Pitsidianakis pub fn reset(&mut self) { 386*37fdb2f5SManos Pitsidianakis // All the bits are cleared to 0 when reset. 387*37fdb2f5SManos Pitsidianakis *self = 0.into(); 388*37fdb2f5SManos Pitsidianakis } 389*37fdb2f5SManos Pitsidianakis } 390*37fdb2f5SManos Pitsidianakis 391*37fdb2f5SManos Pitsidianakis impl Default for LineControl { 392*37fdb2f5SManos Pitsidianakis fn default() -> Self { 393*37fdb2f5SManos Pitsidianakis 0.into() 394*37fdb2f5SManos Pitsidianakis } 395*37fdb2f5SManos Pitsidianakis } 396*37fdb2f5SManos Pitsidianakis 397*37fdb2f5SManos Pitsidianakis #[bitsize(1)] 398*37fdb2f5SManos Pitsidianakis #[derive(Clone, Copy, Debug, Eq, FromBits, PartialEq)] 399*37fdb2f5SManos Pitsidianakis /// `EPS` "Even parity select", field of [Line Control 400*37fdb2f5SManos Pitsidianakis /// register](LineControl). 401*37fdb2f5SManos Pitsidianakis pub enum Parity { 402*37fdb2f5SManos Pitsidianakis /// - 0 = odd parity. The UART generates or checks for an odd number of 403*37fdb2f5SManos Pitsidianakis /// 1s in the data and parity bits. 404*37fdb2f5SManos Pitsidianakis Odd = 0, 405*37fdb2f5SManos Pitsidianakis /// - 1 = even parity. The UART generates or checks for an even number 406*37fdb2f5SManos Pitsidianakis /// of 1s in the data and parity bits. 407*37fdb2f5SManos Pitsidianakis Even = 1, 408*37fdb2f5SManos Pitsidianakis } 409*37fdb2f5SManos Pitsidianakis 410*37fdb2f5SManos Pitsidianakis #[bitsize(1)] 411*37fdb2f5SManos Pitsidianakis #[derive(Clone, Copy, Debug, Eq, FromBits, PartialEq)] 412*37fdb2f5SManos Pitsidianakis /// `FEN` "Enable FIFOs" or Device mode, field of [Line Control 413*37fdb2f5SManos Pitsidianakis /// register](LineControl). 414*37fdb2f5SManos Pitsidianakis pub enum Mode { 415*37fdb2f5SManos Pitsidianakis /// 0 = FIFOs are disabled (character mode) that is, the FIFOs become 416*37fdb2f5SManos Pitsidianakis /// 1-byte-deep holding registers 417*37fdb2f5SManos Pitsidianakis Character = 0, 418*37fdb2f5SManos Pitsidianakis /// 1 = transmit and receive FIFO buffers are enabled (FIFO mode). 419*37fdb2f5SManos Pitsidianakis FIFO = 1, 420*37fdb2f5SManos Pitsidianakis } 421*37fdb2f5SManos Pitsidianakis 422*37fdb2f5SManos Pitsidianakis impl From<Mode> for bool { 423*37fdb2f5SManos Pitsidianakis fn from(val: Mode) -> Self { 424*37fdb2f5SManos Pitsidianakis matches!(val, Mode::FIFO) 425*37fdb2f5SManos Pitsidianakis } 426*37fdb2f5SManos Pitsidianakis } 427*37fdb2f5SManos Pitsidianakis 428*37fdb2f5SManos Pitsidianakis #[bitsize(2)] 429*37fdb2f5SManos Pitsidianakis #[derive(Clone, Copy, Debug, Eq, FromBits, PartialEq)] 430*37fdb2f5SManos Pitsidianakis /// `WLEN` Word length, field of [Line Control register](LineControl). 431*37fdb2f5SManos Pitsidianakis /// 432*37fdb2f5SManos Pitsidianakis /// These bits indicate the number of data bits transmitted or received in a 433*37fdb2f5SManos Pitsidianakis /// frame as follows: 434*37fdb2f5SManos Pitsidianakis pub enum WordLength { 435*37fdb2f5SManos Pitsidianakis /// b11 = 8 bits 436*37fdb2f5SManos Pitsidianakis _8Bits = 0b11, 437*37fdb2f5SManos Pitsidianakis /// b10 = 7 bits 438*37fdb2f5SManos Pitsidianakis _7Bits = 0b10, 439*37fdb2f5SManos Pitsidianakis /// b01 = 6 bits 440*37fdb2f5SManos Pitsidianakis _6Bits = 0b01, 441*37fdb2f5SManos Pitsidianakis /// b00 = 5 bits. 442*37fdb2f5SManos Pitsidianakis _5Bits = 0b00, 443*37fdb2f5SManos Pitsidianakis } 444*37fdb2f5SManos Pitsidianakis 445*37fdb2f5SManos Pitsidianakis /// Control Register, `UARTCR` 446*37fdb2f5SManos Pitsidianakis /// 447*37fdb2f5SManos Pitsidianakis /// The `UARTCR` register is the control register. All the bits are cleared 448*37fdb2f5SManos Pitsidianakis /// to `0` on reset except for bits `9` and `8` that are set to `1`. 449*37fdb2f5SManos Pitsidianakis /// 450*37fdb2f5SManos Pitsidianakis /// # Source 451*37fdb2f5SManos Pitsidianakis /// ARM DDI 0183G, 3.3.8 Control Register, `UARTCR`, Table 3-12 452*37fdb2f5SManos Pitsidianakis #[bitsize(16)] 453*37fdb2f5SManos Pitsidianakis #[doc(alias = "UARTCR")] 454*37fdb2f5SManos Pitsidianakis #[derive(Clone, Copy, DebugBits, FromBits)] 455*37fdb2f5SManos Pitsidianakis pub struct Control { 456*37fdb2f5SManos Pitsidianakis /// `UARTEN` UART enable: 0 = UART is disabled. If the UART is disabled 457*37fdb2f5SManos Pitsidianakis /// in the middle of transmission or reception, it completes the current 458*37fdb2f5SManos Pitsidianakis /// character before stopping. 1 = the UART is enabled. Data 459*37fdb2f5SManos Pitsidianakis /// transmission and reception occurs for either UART signals or SIR 460*37fdb2f5SManos Pitsidianakis /// signals depending on the setting of the SIREN bit. 461*37fdb2f5SManos Pitsidianakis pub enable_uart: bool, 462*37fdb2f5SManos Pitsidianakis /// `SIREN` `SIR` enable: 0 = IrDA SIR ENDEC is disabled. `nSIROUT` 463*37fdb2f5SManos Pitsidianakis /// remains LOW (no light pulse generated), and signal transitions on 464*37fdb2f5SManos Pitsidianakis /// SIRIN have no effect. 1 = IrDA SIR ENDEC is enabled. Data is 465*37fdb2f5SManos Pitsidianakis /// transmitted and received on nSIROUT and SIRIN. UARTTXD remains HIGH, 466*37fdb2f5SManos Pitsidianakis /// in the marking state. Signal transitions on UARTRXD or modem status 467*37fdb2f5SManos Pitsidianakis /// inputs have no effect. This bit has no effect if the UARTEN bit 468*37fdb2f5SManos Pitsidianakis /// disables the UART. 469*37fdb2f5SManos Pitsidianakis pub enable_sir: bool, 470*37fdb2f5SManos Pitsidianakis /// `SIRLP` SIR low-power IrDA mode. This bit selects the IrDA encoding 471*37fdb2f5SManos Pitsidianakis /// mode. If this bit is cleared to 0, low-level bits are transmitted as 472*37fdb2f5SManos Pitsidianakis /// an active high pulse with a width of 3/ 16th of the bit period. If 473*37fdb2f5SManos Pitsidianakis /// this bit is set to 1, low-level bits are transmitted with a pulse 474*37fdb2f5SManos Pitsidianakis /// width that is 3 times the period of the IrLPBaud16 input signal, 475*37fdb2f5SManos Pitsidianakis /// regardless of the selected bit rate. Setting this bit uses less 476*37fdb2f5SManos Pitsidianakis /// power, but might reduce transmission distances. 477*37fdb2f5SManos Pitsidianakis pub sir_lowpower_irda_mode: u1, 478*37fdb2f5SManos Pitsidianakis /// Reserved, do not modify, read as zero. 479*37fdb2f5SManos Pitsidianakis _reserved_zero_no_modify: u4, 480*37fdb2f5SManos Pitsidianakis /// `LBE` Loopback enable. If this bit is set to 1 and the SIREN bit is 481*37fdb2f5SManos Pitsidianakis /// set to 1 and the SIRTEST bit in the Test Control register, UARTTCR 482*37fdb2f5SManos Pitsidianakis /// on page 4-5 is set to 1, then the nSIROUT path is inverted, and fed 483*37fdb2f5SManos Pitsidianakis /// through to the SIRIN path. The SIRTEST bit in the test register must 484*37fdb2f5SManos Pitsidianakis /// be set to 1 to override the normal half-duplex SIR operation. This 485*37fdb2f5SManos Pitsidianakis /// must be the requirement for accessing the test registers during 486*37fdb2f5SManos Pitsidianakis /// normal operation, and SIRTEST must be cleared to 0 when loopback 487*37fdb2f5SManos Pitsidianakis /// testing is finished. This feature reduces the amount of external 488*37fdb2f5SManos Pitsidianakis /// coupling required during system test. If this bit is set to 1, and 489*37fdb2f5SManos Pitsidianakis /// the SIRTEST bit is set to 0, the UARTTXD path is fed through to the 490*37fdb2f5SManos Pitsidianakis /// UARTRXD path. In either SIR mode or UART mode, when this bit is set, 491*37fdb2f5SManos Pitsidianakis /// the modem outputs are also fed through to the modem inputs. This bit 492*37fdb2f5SManos Pitsidianakis /// is cleared to 0 on reset, to disable loopback. 493*37fdb2f5SManos Pitsidianakis pub enable_loopback: bool, 494*37fdb2f5SManos Pitsidianakis /// `TXE` Transmit enable. If this bit is set to 1, the transmit section 495*37fdb2f5SManos Pitsidianakis /// of the UART is enabled. Data transmission occurs for either UART 496*37fdb2f5SManos Pitsidianakis /// signals, or SIR signals depending on the setting of the SIREN bit. 497*37fdb2f5SManos Pitsidianakis /// When the UART is disabled in the middle of transmission, it 498*37fdb2f5SManos Pitsidianakis /// completes the current character before stopping. 499*37fdb2f5SManos Pitsidianakis pub enable_transmit: bool, 500*37fdb2f5SManos Pitsidianakis /// `RXE` Receive enable. If this bit is set to 1, the receive section 501*37fdb2f5SManos Pitsidianakis /// of the UART is enabled. Data reception occurs for either UART 502*37fdb2f5SManos Pitsidianakis /// signals or SIR signals depending on the setting of the SIREN bit. 503*37fdb2f5SManos Pitsidianakis /// When the UART is disabled in the middle of reception, it completes 504*37fdb2f5SManos Pitsidianakis /// the current character before stopping. 505*37fdb2f5SManos Pitsidianakis pub enable_receive: bool, 506*37fdb2f5SManos Pitsidianakis /// `DTR` Data transmit ready. This bit is the complement of the UART 507*37fdb2f5SManos Pitsidianakis /// data transmit ready, `nUARTDTR`, modem status output. That is, when 508*37fdb2f5SManos Pitsidianakis /// the bit is programmed to a 1 then `nUARTDTR` is LOW. 509*37fdb2f5SManos Pitsidianakis pub data_transmit_ready: bool, 510*37fdb2f5SManos Pitsidianakis /// `RTS` Request to send. This bit is the complement of the UART 511*37fdb2f5SManos Pitsidianakis /// request to send, `nUARTRTS`, modem status output. That is, when the 512*37fdb2f5SManos Pitsidianakis /// bit is programmed to a 1 then `nUARTRTS` is LOW. 513*37fdb2f5SManos Pitsidianakis pub request_to_send: bool, 514*37fdb2f5SManos Pitsidianakis /// `Out1` This bit is the complement of the UART Out1 (`nUARTOut1`) 515*37fdb2f5SManos Pitsidianakis /// modem status output. That is, when the bit is programmed to a 1 the 516*37fdb2f5SManos Pitsidianakis /// output is 0. For DTE this can be used as Data Carrier Detect (DCD). 517*37fdb2f5SManos Pitsidianakis pub out_1: bool, 518*37fdb2f5SManos Pitsidianakis /// `Out2` This bit is the complement of the UART Out2 (`nUARTOut2`) 519*37fdb2f5SManos Pitsidianakis /// modem status output. That is, when the bit is programmed to a 1, the 520*37fdb2f5SManos Pitsidianakis /// output is 0. For DTE this can be used as Ring Indicator (RI). 521*37fdb2f5SManos Pitsidianakis pub out_2: bool, 522*37fdb2f5SManos Pitsidianakis /// `RTSEn` RTS hardware flow control enable. If this bit is set to 1, 523*37fdb2f5SManos Pitsidianakis /// RTS hardware flow control is enabled. Data is only requested when 524*37fdb2f5SManos Pitsidianakis /// there is space in the receive FIFO for it to be received. 525*37fdb2f5SManos Pitsidianakis pub rts_hardware_flow_control_enable: bool, 526*37fdb2f5SManos Pitsidianakis /// `CTSEn` CTS hardware flow control enable. If this bit is set to 1, 527*37fdb2f5SManos Pitsidianakis /// CTS hardware flow control is enabled. Data is only transmitted when 528*37fdb2f5SManos Pitsidianakis /// the `nUARTCTS` signal is asserted. 529*37fdb2f5SManos Pitsidianakis pub cts_hardware_flow_control_enable: bool, 530*37fdb2f5SManos Pitsidianakis } 531*37fdb2f5SManos Pitsidianakis 532*37fdb2f5SManos Pitsidianakis impl Control { 533*37fdb2f5SManos Pitsidianakis pub fn reset(&mut self) { 534*37fdb2f5SManos Pitsidianakis *self = 0.into(); 535*37fdb2f5SManos Pitsidianakis self.set_enable_receive(true); 536*37fdb2f5SManos Pitsidianakis self.set_enable_transmit(true); 537*37fdb2f5SManos Pitsidianakis } 538*37fdb2f5SManos Pitsidianakis } 539*37fdb2f5SManos Pitsidianakis 540*37fdb2f5SManos Pitsidianakis impl Default for Control { 541*37fdb2f5SManos Pitsidianakis fn default() -> Self { 542*37fdb2f5SManos Pitsidianakis let mut ret: Self = 0.into(); 543*37fdb2f5SManos Pitsidianakis ret.reset(); 544*37fdb2f5SManos Pitsidianakis ret 545*37fdb2f5SManos Pitsidianakis } 546*37fdb2f5SManos Pitsidianakis } 547*37fdb2f5SManos Pitsidianakis 548*37fdb2f5SManos Pitsidianakis /// Interrupt status bits in UARTRIS, UARTMIS, UARTIMSC 549*37fdb2f5SManos Pitsidianakis pub const INT_OE: u32 = 1 << 10; 550*37fdb2f5SManos Pitsidianakis pub const INT_BE: u32 = 1 << 9; 551*37fdb2f5SManos Pitsidianakis pub const INT_PE: u32 = 1 << 8; 552*37fdb2f5SManos Pitsidianakis pub const INT_FE: u32 = 1 << 7; 553*37fdb2f5SManos Pitsidianakis pub const INT_RT: u32 = 1 << 6; 554*37fdb2f5SManos Pitsidianakis pub const INT_TX: u32 = 1 << 5; 555*37fdb2f5SManos Pitsidianakis pub const INT_RX: u32 = 1 << 4; 556*37fdb2f5SManos Pitsidianakis pub const INT_DSR: u32 = 1 << 3; 557*37fdb2f5SManos Pitsidianakis pub const INT_DCD: u32 = 1 << 2; 558*37fdb2f5SManos Pitsidianakis pub const INT_CTS: u32 = 1 << 1; 559*37fdb2f5SManos Pitsidianakis pub const INT_RI: u32 = 1 << 0; 560*37fdb2f5SManos Pitsidianakis pub const INT_E: u32 = INT_OE | INT_BE | INT_PE | INT_FE; 561*37fdb2f5SManos Pitsidianakis pub const INT_MS: u32 = INT_RI | INT_DSR | INT_DCD | INT_CTS; 562*37fdb2f5SManos Pitsidianakis 563*37fdb2f5SManos Pitsidianakis #[repr(u32)] 564*37fdb2f5SManos Pitsidianakis pub enum Interrupt { 565*37fdb2f5SManos Pitsidianakis OE = 1 << 10, 566*37fdb2f5SManos Pitsidianakis BE = 1 << 9, 567*37fdb2f5SManos Pitsidianakis PE = 1 << 8, 568*37fdb2f5SManos Pitsidianakis FE = 1 << 7, 569*37fdb2f5SManos Pitsidianakis RT = 1 << 6, 570*37fdb2f5SManos Pitsidianakis TX = 1 << 5, 571*37fdb2f5SManos Pitsidianakis RX = 1 << 4, 572*37fdb2f5SManos Pitsidianakis DSR = 1 << 3, 573*37fdb2f5SManos Pitsidianakis DCD = 1 << 2, 574*37fdb2f5SManos Pitsidianakis CTS = 1 << 1, 575*37fdb2f5SManos Pitsidianakis RI = 1 << 0, 576*37fdb2f5SManos Pitsidianakis } 577*37fdb2f5SManos Pitsidianakis 578*37fdb2f5SManos Pitsidianakis impl Interrupt { 579*37fdb2f5SManos Pitsidianakis pub const E: u32 = INT_OE | INT_BE | INT_PE | INT_FE; 580*37fdb2f5SManos Pitsidianakis pub const MS: u32 = INT_RI | INT_DSR | INT_DCD | INT_CTS; 581*37fdb2f5SManos Pitsidianakis } 582*37fdb2f5SManos Pitsidianakis } 583*37fdb2f5SManos Pitsidianakis 584*37fdb2f5SManos Pitsidianakis // TODO: You must disable the UART before any of the control registers are 585*37fdb2f5SManos Pitsidianakis // reprogrammed. When the UART is disabled in the middle of transmission or 586*37fdb2f5SManos Pitsidianakis // reception, it completes the current character before stopping 587