StuBS
|
Serial interface. More...
#include <machine/serial.h>
Public Types | |
enum | ComPort { COM1 = 0x3f8 , COM2 = 0x2f8 , COM3 = 0x3e8 , COM4 = 0x2e8 } |
COM-Port. More... | |
enum | BaudRate { BAUD_300 = 384 , BAUD_600 = 192 , BAUD_1200 = 96 , BAUD_2400 = 48 , BAUD_4800 = 24 , BAUD_9600 = 12 , BAUD_19200 = 6 , BAUD_38400 = 3 , BAUD_57600 = 2 , BAUD_115200 = 1 } |
Transmission speed. More... | |
enum | DataBits { DATA_5BIT = 0 , DATA_6BIT = 1 , DATA_7BIT = 2 , DATA_8BIT = 3 } |
Number of data bits per character. More... | |
enum | StopBits { STOP_1BIT = 0 , STOP_1_5BIT = 4 , STOP_2BIT = 4 } |
Number of stop bits per character. More... | |
enum | Parity { PARITY_NONE = 0 , PARITY_ODD = 8 , PARITY_EVEN = 24 , PARITY_MARK = 40 , PARITY_SPACE = 56 } |
parity bit More... | |
Public Member Functions | |
Serial (ComPort port=COM1, BaudRate baud_rate=BAUD_115200, DataBits data_bits=DATA_8BIT, StopBits stop_bits=STOP_1BIT, Parity parity=PARITY_NONE) | |
Constructor. | |
int | read (bool blocking=true) |
Read one byte from the serial interface. | |
int | write (char out, bool blocking=true) |
Write one byte to the serial interface. | |
Protected Attributes | |
const ComPort | port |
Selected COM port. | |
Private Member Functions | |
char | readReg (RegisterIndex reg) |
Read value from register. | |
void | writeReg (RegisterIndex reg, char out) |
Write value to register. | |
Serial interface.
This class provides a serial interface (COM1 - COM4) for communication with the outside world.
The first IBM PC used the external chip 8250 UART, whereas, in today's systems, this functionality is commonly integrated into the southbridge, but remained compatible.
enum Serial::ComPort |
enum Serial::BaudRate |
Transmission speed.
The unit Baud describes the transmission speed in number of symbols per seconds. 1 Baud therefore equals the transmission of 1 symbol per second. The possible Baud rates are whole-number dividers of the clock frequency of 115200 Hz..
Enumerator | |
---|---|
BAUD_300 | |
BAUD_600 | |
BAUD_1200 | |
BAUD_2400 | |
BAUD_4800 | |
BAUD_9600 | |
BAUD_19200 | |
BAUD_38400 | |
BAUD_57600 | |
BAUD_115200 |
enum Serial::DataBits |
enum Serial::StopBits |
enum Serial::Parity |
|
private |
register index
|
private |
Mask for the respective register.
|
explicit |
Constructor.
Creates a Serial object that encapsulates the used COM port, as well as the parameters used for the serial connection. Default values are 8N1
(8 bit, no parity bit, one stop bit) with 115200 Baud using COM1.
|
private |
Read value from register.
reg | Register index |
|
private |
int Serial::read | ( | bool | blocking = true | ) |
int Serial::write | ( | char | out, |
bool | blocking = true |
||
) |
|
protected |
Selected COM port.