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