Serial Port
Classes | Defines | Functions | Variables
Arduino/libraries/SerialPort/SerialPort.h File Reference

Serial Port class. More...

#include <avr/io.h>
#include <avr/pgmspace.h>
#include <Arduino.h>

Go to the source code of this file.

Classes

class  SerialPort< PortNumber, RxBufSize, TxBufSize >
 Class for avr hardware USART ports. More...
class  SerialRingBuffer
 Ring buffer for RX and TX data. More...
class  UsartRegister
 Addresses of USART registers. More...

Defines

#define ALLOW_LARGE_BUFFERS   1
#define BUFFERED_RX   1
#define BUFFERED_TX   1
#define ENABLE_RX_ERROR_CHECKING   1
#define SERIAL_PORT_VERSION   20130222
#define USE_NEW_SERIAL   SerialPort<0, 63, 63> NewSerial
#define USE_NEW_SERIAL1   SerialPort<1, 63, 63> NewSerial1
#define USE_NEW_SERIAL2   SerialPort<2, 63, 63> NewSerial2
#define USE_NEW_SERIAL3   SerialPort<3, 63, 63> NewSerial3
#define USE_WRITE_OVERRIDES   1

Functions

uint8_t badPortNumber (void)
uint8_t badRxBufSize (void)
uint8_t badTxBufSize (void)

Variables

uint8_t rxErrorBits []
SerialRingBuffer rxRingBuf []
static const uint8_t SP_1_STOP_BIT = 0
static const uint8_t SP_2_STOP_BIT = M_USBS
static const uint8_t SP_5_BIT_CHAR = 0
static const uint8_t SP_6_BIT_CHAR = M_UCSZ0
static const uint8_t SP_7_BIT_CHAR = M_UCSZ1
static const uint8_t SP_8_BIT_CHAR = M_UCSZ0 | M_UCSZ1
static const uint8_t SP_EVEN_PARITY = M_UPM1
static const uint8_t SP_FRAMING_ERROR = M_FE
static const uint8_t SP_NO_PARITY = 0
static const uint8_t SP_ODD_PARITY = M_UPM0 | M_UPM1
static const uint8_t SP_OPT_MASK = M_USBS | M_UPM0 | M_UPM1 |M_UCSZ0 | M_UCSZ1
static const uint8_t SP_PARITY_ERROR = M_UPE
static const uint8_t SP_RX_BUF_OVERRUN = 1
static const uint8_t SP_RX_DATA_OVERRUN = M_DOR
static const uint8_t SP_UCSRA_ERROR_MASK = M_FE | M_DOR | M_UPE
SerialRingBuffer txRingBuf []
static const UsartRegister usart []

Detailed Description

Serial Port class.

Definition in file SerialPort.h.


Define Documentation

#define ALLOW_LARGE_BUFFERS   1

Set ALLOW_LARGE_BUFFERS to zero to limit buffer sizes to 254 bytes.

ALLOW_LARGE_BUFFERS controls whether uint16_t or uint8_t will be used for buffer indices.

Definition at line 36 of file SerialPort.h.

#define BUFFERED_RX   1

Set BUFFERED_RX zero to save flash and RAM if no RX buffering is used.

RxBufSize must be zero in all SerialPort constructors if BUFFERED_RX is zero.

Definition at line 52 of file SerialPort.h.

#define BUFFERED_TX   1

Set BUFFERED_TX zero to save flash and RAM if no TX buffering is used.

TxBufSize must be zero in all SerialPort constructors if BUFFERED_TX is zero.

Definition at line 60 of file SerialPort.h.

#define ENABLE_RX_ERROR_CHECKING   1

Set ENABLE_RX_ERROR_CHECKING zero to disable RX error checking.

Definition at line 65 of file SerialPort.h.

#define SERIAL_PORT_VERSION   20130222

SerialPort version YYYYMMDD

Definition at line 28 of file SerialPort.h.

#define USE_NEW_SERIAL   SerialPort<0, 63, 63> NewSerial

Define NewSerial with buffering like Arduino 1.0.

Definition at line 69 of file SerialPort.h.

#define USE_NEW_SERIAL1   SerialPort<1, 63, 63> NewSerial1

Define NewSerial1 with buffering like Arduino 1.0.

Definition at line 71 of file SerialPort.h.

#define USE_NEW_SERIAL2   SerialPort<2, 63, 63> NewSerial2

Define NewSerial2 with buffering like Arduino 1.0.

Definition at line 73 of file SerialPort.h.

#define USE_NEW_SERIAL3   SerialPort<3, 63, 63> NewSerial3

Define NewSerial3 with buffering like Arduino 1.0.

Definition at line 75 of file SerialPort.h.

#define USE_WRITE_OVERRIDES   1

Set USE_WRITE_OVERRIDES to zero to use the Arduino Print version of write(const char*) and write(const uint8_t*, size_t).

This will save some flash but is much slower.

Definition at line 44 of file SerialPort.h.


Function Documentation

uint8_t badPortNumber ( void  )

Cause error message for bad port number.

Returns:
Never returns since it is never called.
uint8_t badRxBufSize ( void  )

Cause error message for bad port number.

Returns:
Never returns since it is never called.
uint8_t badTxBufSize ( void  )

Cause error message for bad port number.

Returns:
Never returns since it is never called.

Variable Documentation

uint8_t rxErrorBits[]

RX error bits.

RX ring buffers.

const uint8_t SP_1_STOP_BIT = 0 [static]

Use one stop bit.

Definition at line 161 of file SerialPort.h.

const uint8_t SP_2_STOP_BIT = M_USBS [static]

Use two stop bits.

Definition at line 163 of file SerialPort.h.

const uint8_t SP_5_BIT_CHAR = 0 [static]

Use 5-bit character size.

Definition at line 173 of file SerialPort.h.

const uint8_t SP_6_BIT_CHAR = M_UCSZ0 [static]

Use 6-bit character size.

Definition at line 175 of file SerialPort.h.

const uint8_t SP_7_BIT_CHAR = M_UCSZ1 [static]

Use 7-bit character size.

Definition at line 177 of file SerialPort.h.

const uint8_t SP_8_BIT_CHAR = M_UCSZ0 | M_UCSZ1 [static]

Use 8-bit character size.

Definition at line 179 of file SerialPort.h.

const uint8_t SP_EVEN_PARITY = M_UPM1 [static]

Use even parity.

Definition at line 168 of file SerialPort.h.

const uint8_t SP_FRAMING_ERROR = M_FE [static]

USART framing error bit.

Definition at line 184 of file SerialPort.h.

const uint8_t SP_NO_PARITY = 0 [static]

No parity bit.

Definition at line 166 of file SerialPort.h.

const uint8_t SP_ODD_PARITY = M_UPM0 | M_UPM1 [static]

Use odd parity.

Definition at line 170 of file SerialPort.h.

const uint8_t SP_OPT_MASK = M_USBS | M_UPM0 | M_UPM1 |M_UCSZ0 | M_UCSZ1 [static]

Mask for all options bits.

Definition at line 181 of file SerialPort.h.

const uint8_t SP_PARITY_ERROR = M_UPE [static]

USART parity error bit.

Definition at line 188 of file SerialPort.h.

const uint8_t SP_RX_BUF_OVERRUN = 1 [static]

RX ring buffer full overrun.

Definition at line 192 of file SerialPort.h.

const uint8_t SP_RX_DATA_OVERRUN = M_DOR [static]

USART RX data overrun error bit.

Definition at line 186 of file SerialPort.h.

const uint8_t SP_UCSRA_ERROR_MASK = M_FE | M_DOR | M_UPE [static]

Mask for all error bits in UCSRA.

Definition at line 190 of file SerialPort.h.

TX ring buffers.

const UsartRegister usart[] [static]
Initial value:
 {




  
  {0, 0, 0, 0, 0, 0},




  
  {0, 0, 0, 0, 0, 0},




  
  {0, 0, 0, 0, 0, 0},




  
  {0, 0, 0, 0, 0, 0}

}

Pointers to USART registers. This static const array allows the compiler to generate very efficient code if the array index is a constant.

Definition at line 214 of file SerialPort.h.

 All Classes Files Functions Variables Typedefs Defines