Dokumentation

Serial interface. More...

#include <machine/serial.h>

+ Inheritance diagram for Serial:

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.
 
bool receiveInterrupt (bool enable)
 Activate or deactivate interrupts on data reception.
 

Protected Attributes

const ComPort port
 Selected COM port.
 

Detailed Description

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.

See also
PC8250A Data Sheet (Registers on page 11)
PC16550D Data Sheet (Successor, for optional FIFO buffer, page 16)

Member Enumeration Documentation

COM-Port.

The serial interface and its hardware addresses. Modern desktop PCs have, at most, a single, physical COM-port (COM1)

Enumerator
COM1 
COM2 
COM3 
COM4 

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 

Number of data bits per character.

Enumerator
DATA_5BIT 
DATA_6BIT 
DATA_7BIT 
DATA_8BIT 

Number of stop bits per character.

Enumerator
STOP_1BIT 
STOP_1_5BIT 
STOP_2BIT 

parity bit

Enumerator
PARITY_NONE 
PARITY_ODD 
PARITY_EVEN 
PARITY_MARK 
PARITY_SPACE 

Constructor & Destructor Documentation

Serial::Serial ( ComPort  port = COM1,
BaudRate  baud_rate = BAUD_115200,
DataBits  data_bits = DATA_8BIT,
StopBits  stop_bits = STOP_1BIT,
Parity  parity = PARITY_NONE 
)
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.

Member Function Documentation

int Serial::read ( bool  blocking = true)

Read one byte from the serial interface.

Parameters
blockingIf set, read() blocks until one byte was read
Returns
Value read from serial interface (or -1 if non-blocking and no data ready)
int Serial::write ( char  out,
bool  blocking = true 
)

Write one byte to the serial interface.

Parameters
outByte to be written
blockingIf set, write() blocks until the byte was written
Returns
Byte written (or -1 if writing byte failed)
bool Serial::receiveInterrupt ( bool  enable)

Activate or deactivate interrupts on data reception.

Calling this function reconfigures the respective register and flushes the receive buffer.

Parameters
enableIf true, interrupts will be enabled, otherwise disabled.
Returns
Previous interrupt state.

Member Data Documentation

const ComPort Serial::port
protected

Selected COM port.


The documentation for this class was generated from the following files: