PropWare
C++ objects and CMake build system for Parallax Propeller
|
Interface for all UART devices. More...
#include <uart.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 | |
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 ErrorCode | set_data_width (const uint8_t dataWidth)=0 |
Set the number of bits for each word of data. More... | |
virtual uint8_t | get_data_width () const =0 |
Retrieve the currently configured data width. More... | |
virtual void | set_parity (const UART::Parity parity)=0 |
Set the parity configuration. 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... | |
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 |
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 |
|
pure virtual |
Retrieve the current baud rate.
Implemented in PropWare::AbstractSimplexUART.
|
pure virtual |
Retrieve the currently configured data width.
Implemented in PropWare::AbstractSimplexUART.
|
pure virtual |
Retrieve the current parity configuration.
Implemented in PropWare::AbstractSimplexUART.
|
pure virtual |
Retrieve the current number of stop bits in use.
Implemented in PropWare::AbstractSimplexUART.
|
pure virtual |
Retrieve the currently configured transmit (TX) pin mask.
Implemented in PropWare::AbstractSimplexUART.
|
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.
|
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.
|
pure virtual |
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.
|
pure virtual |
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.
|
pure virtual |
Set the baud rate.
[in] | baudRate | A value between 1 and PropWare::UART::MAX_BAUD representing the desired baud rate |
Implemented in PropWare::AbstractSimplexUART.
|
pure 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 |
Implemented in PropWare::AbstractSimplexUART, and PropWare::AbstractDuplexUART.
|
pure virtual |
Set the parity configuration.
[in] | parity | No parity, even or odd parity can be selected |
Implemented in PropWare::AbstractSimplexUART, and PropWare::AbstractDuplexUART.
|
pure virtual |
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.
|
pure virtual |
Set the pin mask for TX pin.
[in] | tx | Pin mask for the transmit (TX) pin |
Implemented in PropWare::AbstractSimplexUART.