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::FullDuplexSerial Class Reference

Converted to C++ using spin2cpp and then modified to become a PrintCapable object in PropWare's arsenal. More...

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

+ Inheritance diagram for PropWare::FullDuplexSerial:
+ Collaboration diagram for PropWare::FullDuplexSerial:

Public Types

enum  Mode {
  INVERT_RX = BIT_0,
  INVERT_TX = BIT_1,
  OPEN_DRAIN_SOURCE_TX = BIT_2,
  IGNORE_TX_ECHO_ON_RX = BIT_3
}
 

Public Member Functions

 FullDuplexSerial (const int rxPinNumber=_cfg_rxpin, const int txPinNumber=_cfg_txpin, const uint32_t mode=0, const int baudrate=_cfg_baudrate)
 
 ~FullDuplexSerial ()
 Stop the driver cog and return the locks.
 
int start ()
 Start the driver cog. More...
 
void truncate ()
 Empty the receive buffer.
 
bool receive_ready () const
 Find out if a byte is waiting in the receive buffer. More...
 
bool get_char_non_blocking (char &c)
 Check if byte received (never waits) More...
 
bool get_char (char &c, const unsigned int timeout)
 Wait for a byte to be received and return after a timeout. More...
 
char get_char ()
 Read and return a single character. Whether the method is blocking or not depends entirely on the implementation.
 
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 size_t BUFFER_SIZE = 16
 

Detailed Description

Converted to C++ using spin2cpp and then modified to become a PrintCapable object in PropWare's arsenal.

Examples
FullDuplexSerial_Demo.cpp, and Hello_Demo.cpp.

Definition at line 42 of file fullduplexserial.h.

Constructor & Destructor Documentation

◆ FullDuplexSerial()

PropWare::FullDuplexSerial::FullDuplexSerial ( const int  rxPinNumber = _cfg_rxpin,
const int  txPinNumber = _cfg_txpin,
const uint32_t  mode = 0,
const int  baudrate = _cfg_baudrate 
)

Construct a full-duplex, buffered UART instance

This object requires a dedicated cog to run the driver code. The driver must be started by invoking PropWare::FullDuplexSerial::start() on this object.

Parameters
rxPinNumberPin number to receive data
txPinNumberPin number to transmit data
modeCombination of some, none, or all of the Mode values which can change the behavior of the device
baudrateBaudrate to run the transmit and recieve routines

Definition at line 67 of file fullduplexserial.h.

Member Function Documentation

◆ get_char()

bool PropWare::FullDuplexSerial::get_char ( char c,
const unsigned int  timeout 
)

Wait for a byte to be received and return after a timeout.

Parameters
[out]cByte received from the buffer
[in]timeoutTimeout (in clock ticks) before exiting the function
Returns
True if c is valid, false if no character was available before the timeout

Definition at line 139 of file fullduplexserial.h.

+ Here is the call graph for this function:

◆ get_char_non_blocking()

bool PropWare::FullDuplexSerial::get_char_non_blocking ( char c)

Check if byte received (never waits)

Parameters
[out]cByte received from the buffer
Returns
True if c is valid, false otherwise

Definition at line 122 of file fullduplexserial.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ put_char()

void PropWare::FullDuplexSerial::put_char ( const char  c)
virtual

Print a single character.

Parameters
[in]cIndividual char to be printed

Implements PropWare::PrintCapable.

Definition at line 153 of file fullduplexserial.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ puts()

void PropWare::FullDuplexSerial::puts ( const char  string[])
virtual

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.

Precondition
string[] must be terminated with a null terminator
Parameters
[in]string[]Array of data words with the final word being 0 - the null terminator

Implements PropWare::PrintCapable.

Definition at line 164 of file fullduplexserial.h.

+ Here is the call graph for this function:

◆ receive_ready()

bool PropWare::FullDuplexSerial::receive_ready ( ) const

Find out if a byte is waiting in the receive buffer.

Returns
True if a byte is waiting, false otherwise

Definition at line 111 of file fullduplexserial.h.

+ Here is the caller graph for this function:

◆ start()

int PropWare::FullDuplexSerial::start ( )

Start the driver cog.

Returns
Cog ID of the driver cog. -1 for failure

Definition at line 94 of file fullduplexserial.h.


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