GitOS
Operating system exercise
Loading...
Searching...
No Matches
serial.h File Reference
#include <stdint.h>

Go to the source code of this file.

Macros

#define COM1   0x3f8
 

Functions

int ser_Init (uint16_t port, uint16_t divisor)
 Initializes specified Serial port.
 
void ser_PrintChar (uint16_t port, char c)
 Prints single character to Serial port.
 
void ser_PrintString (uint16_t port, const char *str)
 Prints string to specified Serial port.
 
int ser_Received (uint16_t port)
 Checks if port has unread value.
 
char ser_ReadChar (uint16_t port)
 Reads single character from Serial port.
 

Macro Definition Documentation

◆ COM1

#define COM1   0x3f8

Function Documentation

◆ ser_Init()

int ser_Init ( uint16_t  port,
uint16_t  divisor 
)

Initializes specified Serial port.

Parameters
portSerial port address pointer
divisor0-65535 divisor for 115200 base speed
Returns
int Status

References ALL_OK, EIO, outb(), ser_PrintChar(), ser_ReadChar(), and ser_Received().

◆ ser_PrintChar()

void ser_PrintChar ( uint16_t  port,
char  c 
)

Prints single character to Serial port.

Parameters
portSerial port pointer
cCharacter to write

References outb(), and ser_TransmitEmpty().

◆ ser_PrintString()

void ser_PrintString ( uint16_t  port,
const char *  str 
)

Prints string to specified Serial port.

Parameters
portSerial port pointer
strString to write

References ser_PrintChar(), and strlen().

◆ ser_ReadChar()

char ser_ReadChar ( uint16_t  port)

Reads single character from Serial port.

Parameters
portSerial port pointer
Returns
char Read character

References inb().

◆ ser_Received()

int ser_Received ( uint16_t  port)

Checks if port has unread value.

Parameters
portSerial port pointer
Returns
int 1 if can read

References inb().