-
Notifications
You must be signed in to change notification settings - Fork 0
Celve edited this page Jan 21, 2024
·
2 revisions
In the initialization of UART, we do these things in sequence:
- Set maximum speed of 38.4K for LSB.
- Set maximum speed of 38.4K for MSB.
- Set data word length to 8 bits.
- Enable FIFO, clear TX/RX queues and set interrupt watermark at 14 bytes.
- Mark data terminal ready, signal request to send and enable auxilliary output.
- Enable UART interrupts.
All these operations are linked to code in kernel/src/drivers/uart.rs
.
When there is a read request, we first check whether there is data in the read buffer. Otherwise, the process sleeps until an external interrupt is triggered. After that, it would wake up, read the data from the buffer, and return it to the caller.
Because the FIFO is enabled in the intialization, therefore a write buffer is not implemented.
Due to the practicality, we spin when there is no enough space in the queue until it's available. No interrupt is introduced here.