PropWare
C++ objects and CMake build system for Parallax Propeller
|
A base class for any non-buffered UART that is capable of both transmitting and receiving. More...
#include <abstractduplexuart.h>
Public Types | |
enum | Parity { NO_PARITY, EVEN_PARITY, ODD_PARITY } |
enum | ErrorCode { NO_ERROR = 0, BEG_ERROR = UART_ERRORS_BASE, BAUD_TOO_HIGH = BEG_ERROR, PARITY_ERROR, INVALID_DATA_WIDTH, INVALID_STOP_BIT_WIDTH, NULL_POINTER, END_ERROR = UART::NULL_POINTER } |
Public Member Functions | |
void | set_rx_mask (const Port::Mask rx) |
Set the pin mask for RX pin. More... | |
Port::Mask | get_rx_mask () const |
Retrieve the currently configured receive (RX) pin mask. More... | |
virtual ErrorCode | set_data_width (const uint8_t dataWidth) |
Set the number of bits for each word of data. More... | |
virtual void | set_parity (const UART::Parity parity) |
Set the parity configuration. More... | |
uint32_t | receive () const |
Receive one word of data; Will block until word is received. More... | |
ErrorCode | get_line (char *buffer, int32_t *length, const uint32_t delimiter= '\n') const |
Receive an array of data words. More... | |
ErrorCode | receive_array (uint8_t *buffer, uint32_t length) const |
Receive an array of data words. More... | |
PropWare::ErrorCode | fgets (char string[], int32_t *bufferSize) const |
Read words from the bus until a newline character (\\n ) is received or the buffer is filled. More... | |
char | get_char () |
Read and return a single character. Whether the method is blocking or not depends entirely on the implementation. | |
virtual void | set_tx_mask (const Port::Mask tx)=0 |
Set the pin mask for TX pin. More... | |
virtual Port::Mask | get_tx_mask () const =0 |
Retrieve the currently configured transmit (TX) pin mask. More... | |
virtual uint8_t | get_data_width () const =0 |
Retrieve the currently configured data width. More... | |
virtual UART::Parity | get_parity () const =0 |
Retrieve the current parity configuration. More... | |
virtual ErrorCode | set_stop_bit_width (const uint8_t stopBitWidth)=0 |
Set the number of stop bits used. More... | |
virtual uint8_t | get_stop_bit_width () const =0 |
Retrieve the current number of stop bits in use. More... | |
virtual void | set_baud_rate (const int32_t baudRate)=0 |
Set the baud rate. More... | |
virtual int32_t | get_baud_rate () const =0 |
Retrieve the current baud rate. More... | |
virtual void | send (uint16_t originalData) const =0 |
Send a word of data out the serial port. More... | |
virtual HUBTEXT void | send_array (const char array[], uint32_t words) const =0 |
Send an array of 8-bit (or smaller) words. More... | |
virtual void | put_char (const char c)=0 |
Print a single character. More... | |
virtual void | puts (const char string[])=0 |
Send a null-terminated character array. Though this method could be created using put_char, some objects (such as PropWare::UART), have optimized methods for sending a string and PrintCapable::puts can utilize them. More... | |
void | set_tx_mask (const Port::Mask tx) |
Set the pin mask for TX pin. More... | |
Port::Mask | get_tx_mask () const |
Retrieve the currently configured transmit (TX) pin mask. More... | |
uint8_t | get_data_width () const |
Retrieve the currently configured data width. More... | |
UART::Parity | get_parity () const |
Retrieve the current parity configuration. More... | |
ErrorCode | set_stop_bit_width (const uint8_t stopBitWidth) |
Set the number of stop bits used. More... | |
uint8_t | get_stop_bit_width () const |
Retrieve the current number of stop bits in use. More... | |
void | set_baud_rate (const int32_t baudRate) |
Set the baud rate. More... | |
int32_t | get_baud_rate () const |
Retrieve the current baud rate. More... | |
virtual void | send (uint16_t originalData) const |
Send a word of data out the serial port. More... | |
virtual void | send_array (const char array[], uint32_t words) const |
Send an array of 8-bit (or smaller) words. More... | |
void | put_char (const char c) |
Print a single character. More... | |
void | puts (const char string[]) |
Send a null-terminated character array. Though this method could be created using put_char, some objects (such as PropWare::UART), have optimized methods for sending a string and PrintCapable::puts can utilize them. More... | |
Static Public Attributes | |
static const uint8_t | DEFAULT_DATA_WIDTH = 8 |
static const UART::Parity | DEFAULT_PARITY = NO_PARITY |
static const uint8_t | DEFAULT_STOP_BIT_WIDTH = 1 |
static const int | MAX_BAUD = 4413793 |
static const int * | DEFAULT_BAUD = &_cfg_baudrate |
static const int * | PARALLAX_STANDARD_TX = &_cfg_txpin |
static const int * | PARALLAX_STANDARD_RX = &_cfg_rxpin |
A base class for any non-buffered UART that is capable of both transmitting and receiving.
PropWare::FullDuplexUART
and PropWare::HalfDuplexUART
for concrete classes, and consider using them with the PropWare::Printer
class Definition at line 40 of file abstractduplexuart.h.
|
inherited |
Error codes - Proceeded by SD, SPI, and HD44780
Enumerator | |
---|---|
NO_ERROR |
No errors; Successful completion of the function |
BEG_ERROR |
First error code for PropWare::UART |
BAUD_TOO_HIGH |
The requested baud rate is too high |
PARITY_ERROR |
A parity error has occurred during read |
INVALID_DATA_WIDTH |
The requested data width is not between 1 and 16 (inclusive) |
INVALID_STOP_BIT_WIDTH |
The requested stop bit width is not between 1 and 14 (inclusive) |
NULL_POINTER |
Null pointer was passed as an argument |
END_ERROR |
Last error code used by PropWare::UART |
|
inherited |
PropWare::ErrorCode PropWare::AbstractDuplexUART::fgets | ( | char | string[], |
int32_t * | bufferSize | ||
) | const |
Read words from the bus until a newline character (\\n
) is received or the buffer is filled.
If found, the newline character will be replaced with a null-terminator. If the buffer is filled before a newline is found, no null-terminator will be inserted
[in] | string[] | Output buffer which should store the data |
[out] | *bufferSize | Address where the new length of the buffer will be written |
Definition at line 160 of file abstractduplexuart.h.
|
virtualinherited |
Retrieve the current baud rate.
Implements PropWare::UART.
Definition at line 150 of file abstractsimplexuart.h.
|
pure virtualinherited |
Retrieve the current baud rate.
Implemented in PropWare::AbstractSimplexUART.
|
pure virtualinherited |
Retrieve the currently configured data width.
Implemented in PropWare::AbstractSimplexUART.
|
virtualinherited |
Retrieve the currently configured data width.
Implements PropWare::UART.
Definition at line 113 of file abstractsimplexuart.h.
|
virtual |
Receive an array of data words.
Cog execution will be blocked by this call and there is no timeout; Execution will not resume until all data words have been received
Current configuration must be data width + parity width <= 8 bits. If receivable bits is greater than 8, an error will be thrown without any regard for the data being sent to the Propeller
[out] | *buffer | Address to begin storing data words |
[in] | *length | Pointer to max number of words to receive; If value is 0, INT32_MAX will be used. Null-pointer will result in PropWare::UART::NULL_POINTER error code |
[in] | delimiter | Delimiting character used to determine when reading should stop |
Implements PropWare::DuplexUART.
Definition at line 83 of file abstractduplexuart.h.
|
pure virtualinherited |
Retrieve the current parity configuration.
Implemented in PropWare::AbstractSimplexUART.
|
virtualinherited |
Retrieve the current parity configuration.
Implements PropWare::UART.
Definition at line 124 of file abstractsimplexuart.h.
|
virtual |
Retrieve the currently configured receive (RX) pin mask.
Implements PropWare::DuplexUART.
Definition at line 48 of file abstractduplexuart.h.
|
virtualinherited |
Retrieve the current number of stop bits in use.
Implements PropWare::UART.
Definition at line 142 of file abstractsimplexuart.h.
|
pure virtualinherited |
Retrieve the current number of stop bits in use.
Implemented in PropWare::AbstractSimplexUART.
|
pure virtualinherited |
Retrieve the currently configured transmit (TX) pin mask.
Implemented in PropWare::AbstractSimplexUART.
|
virtualinherited |
Retrieve the currently configured transmit (TX) pin mask.
Implements PropWare::UART.
Definition at line 93 of file abstractsimplexuart.h.
|
pure virtualinherited |
Print a single character.
[in] | c | Individual char to be printed |
Implemented in PropWare::SPI, PropWare::HD44780, PropWare::AbstractSimplexUART, PropWare::StringBuilder, PropWare::FileWriter, PropWare::StaticStringBuilder, and SimplePrinter.
|
virtualinherited |
Print a single character.
[in] | c | Individual char to be printed |
Implements PropWare::PrintCapable.
Definition at line 311 of file abstractsimplexuart.h.
|
pure virtualinherited |
Send a null-terminated character array. Though this method could be created using put_char, some objects (such as PropWare::UART), have optimized methods for sending a string and PrintCapable::puts can utilize them.
string[]
must be terminated with a null terminator[in] | string[] | Array of data words with the final word being 0 - the null terminator |
Implemented in PropWare::SPI, PropWare::AbstractSimplexUART, PropWare::HD44780, PropWare::FileWriter, PropWare::StringBuilder, PropWare::StaticStringBuilder, and SimplePrinter.
|
virtualinherited |
Send a null-terminated character array. Though this method could be created using put_char, some objects (such as PropWare::UART), have optimized methods for sending a string and PrintCapable::puts can utilize them.
string[]
must be terminated with a null terminator[in] | string[] | Array of data words with the final word being 0 - the null terminator |
Implements PropWare::PrintCapable.
Definition at line 315 of file abstractsimplexuart.h.
|
virtual |
Receive one word of data; Will block until word is received.
Cog execution will be blocked by this call and there is no timeout; Execution will not resume until the RX pin is driven low
Implements PropWare::DuplexUART.
Definition at line 68 of file abstractduplexuart.h.
|
virtual |
Receive an array of data words.
Cog execution will be blocked by this call and there is no timeout; Execution will not resume until all data words have been received
Current configuration must be data width + parity width <= 8 bits. If receivable bits is greater than 8, an error will be thrown without any regard for the data being sent to the Propeller
[out] | *buffer | Address to begin storing data words |
[in] | length | Number of words to receive |
Implements PropWare::DuplexUART.
Definition at line 122 of file abstractduplexuart.h.
|
virtualinherited |
Send a word of data out the serial port.
[in] | originalData | Data word to send out the serial port |
Implements PropWare::UART.
Reimplemented in PropWare::SharedSimplexUART, and PropWare::HalfDuplexUART.
Definition at line 154 of file abstractsimplexuart.h.
|
pure virtualinherited |
Send a word of data out the serial port.
[in] | originalData | Data word to send out the serial port |
Implemented in PropWare::AbstractSimplexUART, PropWare::SharedSimplexUART, and PropWare::HalfDuplexUART.
|
virtualinherited |
Send an array of 8-bit (or smaller) words.
words
must be greater than 0[in] | array[] | Array of data words |
[in] | words | Number of words to be sent |
Implements PropWare::UART.
Reimplemented in PropWare::SharedSimplexUART, and PropWare::HalfDuplexUART.
Definition at line 185 of file abstractsimplexuart.h.
|
pure virtualinherited |
Send an array of 8-bit (or smaller) words.
words
must be greater than 0[in] | array[] | Array of data words |
[in] | words | Number of words to be sent |
Implemented in PropWare::AbstractSimplexUART, PropWare::SharedSimplexUART, and PropWare::HalfDuplexUART.
|
virtualinherited |
Set the baud rate.
[in] | baudRate | A value between 1 and PropWare::UART::MAX_BAUD representing the desired baud rate |
Implements PropWare::UART.
Definition at line 146 of file abstractsimplexuart.h.
|
pure virtualinherited |
Set the baud rate.
[in] | baudRate | A value between 1 and PropWare::UART::MAX_BAUD representing the desired baud rate |
Implemented in PropWare::AbstractSimplexUART.
|
virtual |
Set the number of bits for each word of data.
[in] | dataWidth | Typical values are between 5 and 9, but any value between 1 and 16 is valid |
Reimplemented from PropWare::AbstractSimplexUART.
Definition at line 52 of file abstractduplexuart.h.
|
virtual |
Set the parity configuration.
[in] | parity | No parity, even or odd parity can be selected |
Reimplemented from PropWare::AbstractSimplexUART.
Definition at line 62 of file abstractduplexuart.h.
|
virtual |
Set the pin mask for RX pin.
[in] | rx | Pin mask for the receive (RX) pin |
Implements PropWare::DuplexUART.
Definition at line 43 of file abstractduplexuart.h.
|
virtualinherited |
Set the number of stop bits used.
[in] | stopBitWidth | Typically either 1 or 2, but can be any number between 1 and 14 |
Implements PropWare::UART.
Definition at line 128 of file abstractsimplexuart.h.
|
pure virtualinherited |
Set the number of stop bits used.
[in] | stopBitWidth | Typically either 1 or 2, but can be any number between 1 and 14 |
Implemented in PropWare::AbstractSimplexUART.
|
virtualinherited |
Set the pin mask for TX pin.
[in] | tx | Pin mask for the transmit (TX) pin |
Implements PropWare::UART.
Definition at line 83 of file abstractsimplexuart.h.
|
pure virtualinherited |
Set the pin mask for TX pin.
[in] | tx | Pin mask for the transmit (TX) pin |
Implemented in PropWare::AbstractSimplexUART.