|
ArvernOS
|
#include <stdbool.h>#include <stdint.h>Macros | |
| #define | SERIAL_COM1 0x3F8 |
| #define | SERIAL_LINE_ENABLE_DLAB 0x80 |
| #define | SERIAL_SPEED_115200 1 |
| 115200 bauds. | |
| #define | SERIAL_SPEED_57600 2 |
| 57600 bauds. | |
| #define | SERIAL_SPEED_38400 3 |
| 38400 bauds. | |
Functions | |
| void | serial_init (uint16_t com, uint16_t speed) |
| void | serial_print (uint16_t com, const char *str) |
| void | serial_write (uint16_t com, char c) |
| char | serial_read (uint16_t com) |
| bool | serial_is_waiting (uint16_t com) |
| #define SERIAL_COM1 0x3F8 |
All the I/O ports are calculated relative to the data port. This is because all serial ports (COM1, COM2, COM3, COM4) have their ports in the same order, but they start at different values.
| #define SERIAL_LINE_ENABLE_DLAB 0x80 |
Tells the serial port to expect first the highest 8 bits on the data port, then the lowest 8 bits will follow.
| void serial_init | ( | uint16_t | com, |
| uint16_t | speed ) |
Initializes the serial driver.
| com | a serial port number |
| speed | the serial speed to use |
| bool serial_is_waiting | ( | uint16_t | com | ) |
Tells whether a character is waiting in the serial port receive queue.
| com | a serial port number |
| void serial_print | ( | uint16_t | com, |
| const char * | str ) |
Prints a string to the serial port.
| com | a serial port number |
| str | the string to print to the serial port |
| char serial_read | ( | uint16_t | com | ) |
Reads a character from the serial port. This function blocks until a character is available.
| com | a serial port number |
| void serial_write | ( | uint16_t | com, |
| char | c ) |
Prints a character to the serial port.
| com | a serial port number |
| c | the character to print to the serial port |