PropWare
C++ objects and CMake build system for Parallax Propeller
|
An easy-to-use class for simplex (transmit only) UART communication. More...
#include <simplexuart.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 | |
SimplexUART () | |
No-arg constructors are helpful when avoiding dynamic allocation. | |
SimplexUART (const Port::Mask tx) | |
Construct a UART instance capable of simplex serial communications. 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... | |
virtual ErrorCode | set_data_width (const uint8_t dataWidth) |
Set the number of bits for each word of data. More... | |
uint8_t | get_data_width () const |
Retrieve the currently configured data width. More... | |
virtual void | set_parity (const UART::Parity parity) |
Set the parity configuration. 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 |
An easy-to-use class for simplex (transmit only) UART communication.
Definition at line 35 of file simplexuart.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::SimplexUART::SimplexUART | ( | const Port::Mask | tx | ) |
Construct a UART instance capable of simplex serial communications.
[in] | tx | Bit mask used for the TX (transmit) pin |
Definition at line 51 of file simplexuart.h.
|
virtualinherited |
Retrieve the current baud rate.
Implements PropWare::UART.
Definition at line 150 of file abstractsimplexuart.h.
|
virtualinherited |
Retrieve the currently configured data width.
Implements PropWare::UART.
Definition at line 113 of file abstractsimplexuart.h.
|
virtualinherited |
Retrieve the current parity configuration.
Implements PropWare::UART.
Definition at line 124 of file abstractsimplexuart.h.
|
virtualinherited |
Retrieve the current number of stop bits in use.
Implements PropWare::UART.
Definition at line 142 of file abstractsimplexuart.h.
|
virtualinherited |
Retrieve the currently configured transmit (TX) pin mask.
Implements PropWare::UART.
Definition at line 93 of file abstractsimplexuart.h.
|
virtualinherited |
Print a single character.
[in] | c | Individual char to be printed |
Implements PropWare::PrintCapable.
Definition at line 311 of file abstractsimplexuart.h.
|
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.
|
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.
|
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.
|
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.
|
virtualinherited |
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 |
Implements PropWare::UART.
Reimplemented in PropWare::AbstractDuplexUART.
Definition at line 97 of file abstractsimplexuart.h.
|
virtualinherited |
Set the parity configuration.
[in] | parity | No parity, even or odd parity can be selected |
Implements PropWare::UART.
Reimplemented in PropWare::AbstractDuplexUART.
Definition at line 117 of file abstractsimplexuart.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.
|
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.