You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clients should not need to access registers directly; if they need
functionality which is not currently exposed then it should be added to
this crate.
Also removed register access methods, as they didn't really add anything.
/// > Offset: +0 . The Transmit and Receive buffers are related, and often even use the very same memory. This is also one of the areas where later versions of the 8250 chip have a significant impact, as the later models incorporate some internal buffering of the data within the chip before it gets transmitted as serial data. The base 8250 chip can only receive one byte at a time, while later chips like the 16550 chip will hold up to 16 bytes either to transmit or to receive (sometimes both... depending on the manufacturer) before you have to wait for the character to be sent. This can be useful in multi-tasking environments where you have a computer doing many things, and it may be a couple of milliseconds before you get back to dealing with serial data flow.
221
-
/// >
222
-
/// > These registers really are the "heart" of serial data communication, and how data is transferred from your software to another computer and how it gets data from other devices. Reading and Writing to these registers is simply a matter of accessing the Port I/O address for the respective UART.
223
-
/// >
224
-
/// > If the receive buffer is occupied or the FIFO is full, the incoming data is discarded and the Receiver Line Status interrupt is written to the IIR register. The Overrun Error bit is also set in the Line Status Register.
225
-
#[inline]
226
-
pubfnwrite_thr(&self,value:u8){
227
-
self.thr_rbr_dll.set(value)
228
-
}
229
-
230
-
/// read RBR (offset + 0)
231
-
///
232
-
/// Read Receiver Buffer to get data
233
-
#[inline]
234
-
pubfnread_rbr(&self) -> u8{
235
-
self.thr_rbr_dll.get()
236
-
}
237
-
238
-
/// read DLL (offset + 0)
239
-
///
240
-
/// get divisor latch low byte in the register
241
-
///
242
-
/// > ## Divisor Latch Bytes
243
-
/// >
244
-
/// > Offset: +0 and +1 . The Divisor Latch Bytes are what control the baud rate of the modem. As you might guess from the name of this register, it is used as a divisor to determine what baud rate that the chip is going to be transmitting at.
245
-
///
246
-
/// Used clock 1.8432 MHz as example, first divide 16 and get 115200. Then use the formula to get divisor latch value:
247
-
///
248
-
/// *DivisorLatchValue = 115200 / BaudRate*
249
-
///
250
-
/// This gives the following table:
251
-
///
252
-
/// | Baud Rate | Divisor (in decimal) | Divisor Latch High Byte | Divisor Latch Low Byte |
/// Returns `None` when data is not ready (RBR\[0\] != 1)
57
59
pubfnread_byte(&self) -> Option<u8>{
58
60
ifself.is_data_ready(){
59
-
Some(self.reg.read_rbr())
61
+
Some(self.reg.thr_rbr_dll.get())
60
62
}else{
61
63
None
62
64
}
@@ -66,16 +68,43 @@ impl<'a> MmioUart8250<'a> {
66
68
///
67
69
/// TODO: This currently ignores errors.
68
70
pubfnwrite_byte(&self,byte:u8){
69
-
self.reg.write_thr(byte);
71
+
self.reg.thr_rbr_dll.set(byte);
70
72
}
71
73
72
-
/// Set divisor latch according to clock and baud_rate, then set DLAB to false
74
+
/// Sets DLAB to true, sets divisor latch according to clock and baud_rate, then sets DLAB to
75
+
/// false.
76
+
///
77
+
/// > ## Divisor Latch Bytes
78
+
/// >
79
+
/// > Offset: +0 and +1 . The Divisor Latch Bytes are what control the baud rate of the modem. As you might guess from the name of this register, it is used as a divisor to determine what baud rate that the chip is going to be transmitting at.
80
+
///
81
+
/// Used clock 1.8432 MHz as example, first divide 16 and get 115200. Then use the formula to get divisor latch value:
82
+
///
83
+
/// *DivisorLatchValue = 115200 / BaudRate*
84
+
///
85
+
/// This gives the following table:
86
+
///
87
+
/// | Baud Rate | Divisor (in decimal) | Divisor Latch High Byte | Divisor Latch Low Byte |
0 commit comments