COSA
An Object-Oriented Platform for Arduino Programming
|
#include <UART.hh>
Classes | |
class | RXPinChangeInterrupt |
Public Types | |
enum | { DATA5 = 0, DATA6 = _BV(UCSZ00), DATA7 = _BV(UCSZ01), DATA8 = _BV(UCSZ01) | _BV(UCSZ00), NO_PARITY = 0, EVEN_PARITY = _BV(UPM01), ODD_PARITY = _BV(UPM01) | _BV(UPM00), STOP1 = 0, STOP2 = _BV(USBS0) } |
Public Member Functions | |
UART (Board::DigitalPin tx, Board::InterruptPin rx, IOStream::Device *ibuf) | |
virtual int | available () |
virtual int | peekchar () |
virtual int | peekchar (char c) |
virtual int | getchar () |
virtual void | empty () |
virtual bool | begin (uint32_t baudrate=DEFAULT_BAUDRATE, uint8_t format=DEFAULT_FORMAT) |
virtual bool | end () |
virtual int | putchar (char c) |
virtual void | powerup () |
virtual void | powerdown () |
void | non_blocking () |
void | blocking () |
bool | is_blocking () const |
void | eol (Mode mode) |
Mode | eol () const |
virtual int | room () |
virtual int | puts (const char *s) |
virtual int | puts (str_P s) |
virtual int | write (const void *buf, size_t size) |
virtual int | write (const iovec_t *vec) |
virtual int | write_P (const void *buf, size_t size) |
virtual char * | gets (char *s, size_t count) |
virtual int | read (void *buf, size_t size) |
virtual int | read (iovec_t *vec) |
virtual int | flush () |
Static Public Attributes | |
static const uint8_t | RX_BUFFER_MAX = COSA_SOFT_UART_RX_BUFFER_MAX |
static const uint8_t | TX_BUFFER_MAX = COSA_SOFT_UART_TX_BUFFER_MAX |
static const uint32_t | DEFAULT_BAUDRATE = 9600L |
static const uint8_t | DEFAULT_FORMAT = DATA8 + NO_PARITY + STOP2 |
Protected Attributes | |
RXPinChangeInterrupt | m_rx |
IOStream::Device * | m_ibuf |
OutputPin | m_tx |
uint8_t | m_stops |
uint8_t | m_bits |
uint16_t | m_count |
bool | m_blocking |
Mode | m_eol |
Friends | |
class | RXPinChangeInterrupt |
Soft UART using serial write and input sampling. The Output serial write method is used for transmission and a pin change interrupt for detecting start condition and receiving data.
|
inherited |
UART::UART | ( | Board::DigitalPin | tx, |
Board::InterruptPin | rx, | ||
IOStream::Device * | ibuf | ||
) |
Construct Soft UART with transmitter on given output pin and receiver on given pin change interrupt pin. Received data is captured by an interrupt service routine and put into given buffer (i.e. io-stream).
[in] | tx | transmitter pin. |
[in] | rx | receiver pin. |
[in] | ibuf | input buffer. |
Definition at line 25 of file SOFT_UART.cpp.
|
inlinevirtual |
|
virtual |
Start Soft UART device driver.
[in] | baudrate | serial bitrate (default 9600). |
[in] | format | serial frame format (default DATA8, NO PARITY, STOP2). |
Reimplemented from Soft::UAT.
Definition at line 33 of file SOFT_UART.cpp.
|
inlineinherited |
Set blocking mode.
Definition at line 85 of file IOStream.hh.
|
inlinevirtual |
Empty internal device buffers.
Reimplemented from IOStream::Device.
|
inlinevirtual |
|
inlineinherited |
Set end of line mode.
[in] | mode | for end of line. |
Definition at line 103 of file IOStream.hh.
|
inlineinherited |
|
virtualinherited |
Flush internal device buffers. Wait for device to become idle.
Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, UART, IOBuffer< SIZE >, CC3000::Driver, and WIO.
Definition at line 169 of file IOStream_Device.cpp.
|
inlinevirtual |
Read character from serial port input buffer. Returns character if successful otherwise on error or buffer empty returns EOF(-1),
Reimplemented from IOStream::Device.
|
virtualinherited |
Read string terminated by new-line or until size into given string buffer. Returns pointer to string or NULL if empty line.
[in] | s | string buffer to read into. |
[in] | count | max number of bytes to read. |
Definition at line 118 of file IOStream_Device.cpp.
|
inlineinherited |
|
inlineinherited |
Set non-blocking mode.
Definition at line 77 of file IOStream.hh.
|
inlinevirtual |
Peek next character from serial port input buffer. Returns character if successful otherwise on error or buffer empty returns EOF(-1),
Reimplemented from IOStream::Device.
|
inlinevirtual |
Peek for given character from serial port input buffer.
[in] | c | character to peek for. |
Reimplemented from IOStream::Device.
|
inlinevirtualinherited |
|
inlinevirtualinherited |
|
virtualinherited |
Write character to serial port output buffer. Returns character if successful otherwise on error or buffer full returns EOF(-1),
[in] | c | character to write. |
Reimplemented from IOStream::Device.
Definition at line 35 of file SOFT_UAT.cpp.
|
virtualinherited |
Write null terminated string to device. Terminating null is not written.
[in] | s | string to write. |
Definition at line 43 of file IOStream_Device.cpp.
|
virtualinherited |
Write null terminated string from program memory to device. Terminating null is not written.
[in] | s | string in program memory to write. |
Definition at line 54 of file IOStream_Device.cpp.
|
virtualinherited |
Read data to given buffer with given size from device.
[in] | buf | buffer to read into. |
[in] | size | number of bytes to read. |
Reimplemented in FAT16::File, W5200::Driver, W5500::Driver, W5100::Driver, CFFS::File, Socket, and CC3000::Driver.
Definition at line 144 of file IOStream_Device.cpp.
|
virtualinherited |
Read data to given buffers in null terminated io vector.
[in] | vec | io vector with buffers to read into. |
Definition at line 157 of file IOStream_Device.cpp.
|
virtualinherited |
Number of bytes room (write without blocking).
Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, UART, IOBuffer< SIZE >, CC3000::Driver, and WIO.
Definition at line 30 of file IOStream_Device.cpp.
|
virtualinherited |
Write data from buffer with given size to device.
[in] | buf | buffer to write. |
[in] | size | number of bytes to write. |
Reimplemented in FAT16::File, HD44780, CFFS::File, VLCD, Socket, and CC3000::Driver.
Definition at line 65 of file IOStream_Device.cpp.
|
virtualinherited |
Write data from buffers in null terminated io vector.
[in] | vec | io vector with buffers to write. |
Definition at line 87 of file IOStream_Device.cpp.
|
virtualinherited |
Write data from buffer in program memory with given size to device.
[in] | buf | buffer to write. |
[in] | size | number of bytes to write. |
Reimplemented in CFFS::File, Socket, and CC3000::Driver.
Definition at line 76 of file IOStream_Device.cpp.
|
friend |
|
staticinherited |
|
protectedinherited |
Blocking state
Definition at line 248 of file IOStream.hh.
|
protectedinherited |
End of line mode
Definition at line 251 of file IOStream.hh.
|
protected |
|
protected |
|
static |
|
static |