PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Public Types | Public Member Functions | Static Public Attributes | List of all members
PropWare::UART Class Reference

Abstract base class for all unbuffered UART devices. More...

#include <PropWare/serial/uart/uart.h>

+ Inheritance diagram for PropWare::UART:
+ Collaboration diagram for PropWare::UART:

Public Types

enum  Parity {
  Parity::NO_PARITY,
  Parity::EVEN_PARITY,
  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,
  TIMEOUT_ERROR,
  END_ERROR = UART::TIMEOUT_ERROR
}
 

Public Member Functions

virtual ErrorCode set_data_width (const uint8_t dataWidth)
 
uint8_t get_data_width () const
 
virtual void set_parity (const UART::Parity parity)
 
UART::Parity get_parity () const
 
ErrorCode set_stop_bit_width (const uint8_t stopBitWidth)
 
uint8_t get_stop_bit_width () const
 
void set_baud_rate (const int32_t baudRate)
 
int32_t get_baud_rate () const
 

Static Public Attributes

static const uint8_t DEFAULT_DATA_WIDTH = 8
 
static const Parity DEFAULT_PARITY = Parity::NO_PARITY
 
static const uint8_t DEFAULT_STOP_BIT_WIDTH = 1
 
static const int MAX_BAUD = 4413793
 

Detailed Description

Abstract base class for all unbuffered UART devices.

Configurable with the following options:

Note
Total number of bits within start, data, parity, and stop cannot exceed 32. For instance, a configuration of 16 data bits, even or odd parity, and 2 stop bits would be 1 + 16 + 1 + 2 = 20 (this is allowed). A configuration of 16 data bits, no parity, and 16 stop bits would be 1 + 16 + 0 + 16 = 33 (not allowed).
No independent cog is needed for execution and therefore all communication methods are blocking (cog execution will not return from the method until the relevant data has been received/sent)

Speed tests:

Examples
UARTRX_Demo.cpp, and UARTTX_Demo.cpp.

Definition at line 86 of file uart.h.

Member Enumeration Documentation

◆ ErrorCode

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

TIMEOUT_ERROR 

Reading from the serial connection timed out

END_ERROR 

Last error code used by PropWare::UART

Definition at line 102 of file uart.h.

◆ Parity

Enumerator
NO_PARITY 

No parity

EVEN_PARITY 

Even parity

ODD_PARITY 

Odd parity

Definition at line 88 of file uart.h.


The documentation for this class was generated from the following file: