#include <UART.hh>
Basic UART device handler with external buffering. IOStream devices may be piped with the IOBuffer class. The UART class requires an input- and output IOBuffer instance.
Definition at line 59 of file UART.hh.
Serial formats; DATA + PARITY + STOP.
Enumerator |
---|
DATA5 |
|
DATA6 |
|
DATA7 |
|
DATA8 |
|
NO_PARITY |
|
EVEN_PARITY |
|
ODD_PARITY |
|
STOP1 |
|
STOP2 |
|
Definition at line 46 of file Serial.hh.
Construct serial port handler for given UART.
- Parameters
-
[in] | port | number. |
[in] | ibuf | input stream buffer. |
[in] | obuf | output stream buffer. |
Definition at line 71 of file UART.hh.
virtual int UART::available |
( |
| ) |
|
|
inlinevirtual |
Number of bytes available in input buffer.
- Returns
- bytes.
Reimplemented from IOStream::Device.
Definition at line 87 of file UART.hh.
Powerup and start UART for given baudrate and format. Returns true(1) if successful otherwise false(0).
- Parameters
-
[in] | baudrate | serial bitrate (default 9600). |
[in] | format | serial frame format (default async, 8data, 2stop bit) |
- Returns
- true(1) if successful otherwise false(0)
Implements Serial.
Definition at line 45 of file UART.cpp.
void IOStream::Device::blocking |
( |
| ) |
|
|
inlineinherited |
virtual void UART::empty |
( |
| ) |
|
|
inlinevirtual |
Stop and powerdown UART device driver. Returns true(1) if successful otherwise false(0).
- Returns
- true(1) if successful otherwise false(0)
Reimplemented from Serial.
Definition at line 69 of file UART.cpp.
void IOStream::Device::eol |
( |
Mode |
mode | ) |
|
|
inlineinherited |
Set end of line mode.
- Parameters
-
Definition at line 103 of file IOStream.hh.
Mode IOStream::Device::eol |
( |
| ) |
const |
|
inlineinherited |
Get end of line mode.
- Returns
- mode.
Definition at line 112 of file IOStream.hh.
Flush device output buffer and wait for device to become idle and all character transmitted.
- Returns
- zero(0) or negative error code.
Reimplemented from IOStream::Device.
Definition at line 130 of file UART.cpp.
virtual int UART::getchar |
( |
| ) |
|
|
inlinevirtual |
Read character from serial port input buffer. Returns character if successful otherwise a negative error code (EOF(-1)).
- Returns
- character or EOF(-1).
Reimplemented from IOStream::Device.
Definition at line 139 of file UART.hh.
char * IOStream::Device::gets |
( |
char * |
s, |
|
|
size_t |
count |
|
) |
| |
|
virtualinherited |
Read string terminated by new-line or until size into given string buffer. Returns pointer to string or NULL if empty line.
- Parameters
-
[in] | s | string buffer to read into. |
[in] | count | max number of bytes to read. |
- Returns
- string pointer or NULL.
Definition at line 118 of file IOStream_Device.cpp.
bool IOStream::Device::is_blocking |
( |
| ) |
const |
|
inlineinherited |
Is blocking mode?
- Returns
- bool.
Definition at line 94 of file IOStream.hh.
void IOStream::Device::non_blocking |
( |
| ) |
|
|
inlineinherited |
Set non-blocking mode.
Definition at line 77 of file IOStream.hh.
void UART::on_rx_interrupt |
( |
| ) |
|
|
protectedvirtual |
Common UART receive interrupt handler.
Definition at line 221 of file UART.cpp.
virtual void UART::on_tx_interrupt |
( |
| ) |
|
|
inlineprotectedvirtual |
Common UART transmit completed interrupt handler.
Reimplemented in RS485.
Definition at line 266 of file UART.hh.
void UART::on_udre_interrupt |
( |
| ) |
|
|
protectedvirtual |
Common UART data register empty (transmit) interrupt handler.
Reimplemented in RS485.
Definition at line 208 of file UART.cpp.
virtual int UART::peekchar |
( |
| ) |
|
|
inlinevirtual |
Peek at next character from serial port input buffer. Returns character if successful otherwise a negative error code (EOF(-1)).
- Returns
- character or EOF(-1).
Reimplemented from IOStream::Device.
Definition at line 117 of file UART.hh.
virtual int UART::peekchar |
( |
char |
c | ) |
|
|
inlinevirtual |
Peek for given character from serial port input buffer.
- Parameters
-
[in] | c | character to peek for. |
- Returns
- available or EOF(-1).
Reimplemented from IOStream::Device.
Definition at line 128 of file UART.hh.
int UART::putchar |
( |
char |
c | ) |
|
|
virtual |
Write character to serial port output buffer. Returns character if successful otherwise a negative error code (EOF(-1)).
- Parameters
-
- Returns
- character written or EOF(-1).
Reimplemented from IOStream::Device.
Reimplemented in RS485.
Definition at line 95 of file UART.cpp.
int IOStream::Device::puts |
( |
const char * |
s | ) |
|
|
virtualinherited |
Write null terminated string to device. Terminating null is not written.
- Parameters
-
- Returns
- zero(0) or negative error code.
Definition at line 43 of file IOStream_Device.cpp.
int IOStream::Device::puts |
( |
str_P |
s | ) |
|
|
virtualinherited |
Write null terminated string from program memory to device. Terminating null is not written.
- Parameters
-
[in] | s | string in program memory to write. |
- Returns
- zero(0) or negative error code.
Definition at line 54 of file IOStream_Device.cpp.
int IOStream::Device::read |
( |
void * |
buf, |
|
|
size_t |
size |
|
) |
| |
|
virtualinherited |
int IOStream::Device::read |
( |
iovec_t * |
vec | ) |
|
|
virtualinherited |
Read data to given buffers in null terminated io vector.
- Parameters
-
[in] | vec | io vector with buffers to read into. |
- Returns
- number of bytes read or EOF(-1).
Definition at line 157 of file IOStream_Device.cpp.
virtual int UART::room |
( |
| ) |
|
|
inlinevirtual |
Number of bytes room in output buffer.
- Returns
- bytes.
Reimplemented from IOStream::Device.
Definition at line 97 of file UART.hh.
volatile uint16_t* UART::UBRRn |
( |
| ) |
const |
|
inlineprotected |
Return pointer to UART Baud Rate Register (UBRRn).
- Returns
- UBRRn register pointer.
Definition at line 236 of file UART.hh.
volatile uint8_t* UART::UCSRnA |
( |
| ) |
const |
|
inlineprotected |
Return pointer to UART Control and Status Register A (UCSRnA).
- Returns
- UCSRAn register pointer.
Definition at line 209 of file UART.hh.
volatile uint8_t* UART::UCSRnB |
( |
| ) |
const |
|
inlineprotected |
Return pointer to UART Control and Status Register B (UCSRnB).
- Returns
- UCSRnB register pointer.
Definition at line 218 of file UART.hh.
volatile uint8_t* UART::UCSRnC |
( |
| ) |
const |
|
inlineprotected |
Return pointer to UART Control and Status Register C (UCSRnC).
- Returns
- UCSRnC register pointer.
Definition at line 227 of file UART.hh.
volatile uint8_t* UART::UDRn |
( |
| ) |
const |
|
inlineprotected |
Return pointer to UART I/O Data Register (UDRn).
- Returns
- UDRn register pointer.
Definition at line 245 of file UART.hh.
int IOStream::Device::write |
( |
const void * |
buf, |
|
|
size_t |
size |
|
) |
| |
|
virtualinherited |
int IOStream::Device::write |
( |
const iovec_t * |
vec | ) |
|
|
virtualinherited |
Write data from buffers in null terminated io vector.
- Parameters
-
[in] | vec | io vector with buffers to write. |
- Returns
- number of bytes written or EOF(-1).
Definition at line 87 of file IOStream_Device.cpp.
int IOStream::Device::write_P |
( |
const void * |
buf, |
|
|
size_t |
size |
|
) |
| |
|
virtualinherited |
Write data from buffer in program memory with given size to device.
- Parameters
-
[in] | buf | buffer to write. |
[in] | size | number of bytes to write. |
- Returns
- number of bytes written or EOF(-1).
Reimplemented in CFFS::File, Socket, and CC3000::Driver.
Definition at line 76 of file IOStream_Device.cpp.
const uint32_t Serial::DEFAULT_BAUDRATE = 9600L |
|
staticinherited |
Default baudrate.
Definition at line 43 of file Serial.hh.
Default serial format.
Definition at line 59 of file Serial.hh.
bool IOStream::Device::m_blocking |
|
protectedinherited |
Mode IOStream::Device::m_eol |
|
protectedinherited |
Input Buffer/Device.
Definition at line 195 of file UART.hh.
Flag idle mode.
Definition at line 197 of file UART.hh.
Output Buffer/Device.
Definition at line 196 of file UART.hh.
volatile uint8_t* const UART::m_sfr |
|
protected |
Special Function Register Pointer.
Definition at line 194 of file UART.hh.
Default buffer size for standard UART0 (at 9600 baud).
Definition at line 62 of file UART.hh.
Serial port references. Only uart0 is predefined (reference to global uart). Others as installed by constructor when created in application.
Definition at line 203 of file UART.hh.
The documentation for this class was generated from the following files: