ArvernOS
Loading...
Searching...
No Matches
serial.h File Reference
#include <stdbool.h>
#include <stdint.h>
Include dependency graph for serial.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)

Macro Definition Documentation

◆ SERIAL_COM1

#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.

◆ SERIAL_LINE_ENABLE_DLAB

#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.

Function Documentation

◆ serial_init()

void serial_init ( uint16_t com,
uint16_t speed )

Initializes the serial driver.

Parameters
coma serial port number
speedthe serial speed to use

◆ serial_is_waiting()

bool serial_is_waiting ( uint16_t com)

Tells whether a character is waiting in the serial port receive queue.

Parameters
coma serial port number
Returns
whether a character is available

◆ serial_print()

void serial_print ( uint16_t com,
const char * str )

Prints a string to the serial port.

Parameters
coma serial port number
strthe string to print to the serial port

◆ serial_read()

char serial_read ( uint16_t com)

Reads a character from the serial port. This function blocks until a character is available.

Parameters
coma serial port number
Returns
the character

◆ serial_write()

void serial_write ( uint16_t com,
char c )

Prints a character to the serial port.

Parameters
coma serial port number
cthe character to print to the serial port