mirror of
https://github.com/janishutz/eth-summaries.git
synced 2026-03-14 23:10:03 +01:00
[SPCA] devices
This commit is contained in:
14
semester3/spca/code-examples/03_hw/00_driver.c
Normal file
14
semester3/spca/code-examples/03_hw/00_driver.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#define UART_BASE 0x3f8 // Registers specified by
|
||||
#define UART_THR (UART_BASE + 0) // the device
|
||||
#define UART_RBR (UART_BASE + 0)
|
||||
#define UART_LSR (UART_BASE + 5)
|
||||
|
||||
void serial_putc(char c) {
|
||||
while( (inb(UART_LSR) & 0x20)== 0); // Wait until FIFO can hold more chars
|
||||
outb(UART_THR, c); // Write character to FIFO
|
||||
}
|
||||
|
||||
char serial_getc() {
|
||||
while( (inb(UART_LSR) & 0x01) == 0); // Wait until there is a char to read
|
||||
return inb(UART_RBR); // Read from the receive FIFO
|
||||
}
|
||||
Reference in New Issue
Block a user