GitOS
Operating system exercise
|
#include "serial.h"
#include <stddef.h>
#include "../../common/io.h"
#include "../../common/string.h"
#include "../../common/status.h"
Macros | |
#define | ERROR_I(value) (int)(value) |
Functions | |
int | ser_Init (uint16_t port, uint16_t divisor) |
Initializes specified Serial port. | |
int | ser_TransmitEmpty (uint16_t port) |
Checks if Transmitter holding register is empty (can write) | |
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. | |
#define ERROR_I | ( | value | ) | (int)(value) |
int ser_Init | ( | uint16_t | port, |
uint16_t | divisor | ||
) |
Initializes specified Serial port.
port | Serial port address pointer |
divisor | 0-65535 divisor for 115200 base speed |
References ALL_OK, EIO, outb(), ser_PrintChar(), ser_ReadChar(), and ser_Received().
void ser_PrintChar | ( | uint16_t | port, |
char | c | ||
) |
Prints single character to Serial port.
port | Serial port pointer |
c | Character to write |
References outb(), and ser_TransmitEmpty().
void ser_PrintString | ( | uint16_t | port, |
const char * | str | ||
) |
Prints string to specified Serial port.
port | Serial port pointer |
str | String to write |
References ser_PrintChar(), and strlen().
char ser_ReadChar | ( | uint16_t | port | ) |
Reads single character from Serial port.
port | Serial port pointer |
References inb().
int ser_Received | ( | uint16_t | port | ) |
Checks if port has unread value.
port | Serial port pointer |
References inb().
int ser_TransmitEmpty | ( | uint16_t | port | ) |
Checks if Transmitter holding register is empty (can write)
port | Serial port pointer |
References inb().