ClearCore Library
List of all members | Public Member Functions
ClearCore::SerialDriver Class Reference

Detailed Description

ClearCore Serial UART/SPI Connector class.

This class controls access to the COM-0 and COM-1 connectors.

For more detailed information on each configurable mode, see the SerialDriver COM Ports informational page.

For more detailed information on the ClearCore Connector interface in general, check out the ClearCore Connector System informational page.

ClearCore Serial UART/SPI Connector class. More...

#include <SerialDriver.h>

+ Inheritance diagram for ClearCore::SerialDriver:
+ Collaboration diagram for ClearCore::SerialDriver:

Public Member Functions

virtual ConnectorModes Mode () override
 Get the connector's operational mode. More...
 
bool Mode (ConnectorModes newMode) override
 Set the connector's operational mode. More...
 
Connector::ConnectorTypes Type () override
 Get connector type. More...
 
bool IsWritable () override
 Get R/W status of the connector. More...
 
bool Speed (uint32_t bitsPerSecond) override
 Change the baud rate for the port. More...
 
void PortOpen () override
 
void PortClose () override
 
- Public Member Functions inherited from ClearCore::SerialBase
bool PortMode (PortModes newMode)
 Setup the port mode. More...
 
void Flush () override
 
void FlushInput () override
 
virtual uint32_t Speed () override
 Gets the baud rate of the port. More...
 
int16_t CharGet () override
 Attempt to read the next character from serial channel. More...
 
int16_t CharPeek () override
 Attempt to get the next character from the serial channel without pulling the character out of the buffer. More...
 
bool SendChar (uint8_t charToSend) override
 Send an ascii character on the serial channel. More...
 
int32_t AvailableForRead () override
 
int32_t AvailableForWrite () override
 Determines the number of characters available in the transmit buffer. More...
 
void WaitForTransmitIdle () override
 
bool PortIsOpen () override
 Return whether or not the port is open. More...
 
void FlowControl (bool useFlowControl)
 Set UART CTS/RTS flow control. More...
 
bool FlowControl ()
 Return whether UART CTS/RTS flow control is enabled. More...
 
bool RtsMode (CtrlLineModes mode)
 Change the serial RTS mode. More...
 
bool CtsState ()
 Read the serial CTS state. More...
 
void SerialBreak (bool enable)
 Initiate a Serial Break. More...
 
bool Parity (Parities newParity) override
 Set UART transmission parity format. More...
 
Parities Parity () override
 Return current port UART transmission format. More...
 
bool StopBits (uint8_t bits) override
 
bool CharSize (uint8_t size) override
 Change the number of bits in a character. More...
 
void SpiClock (SpiClockPolarities polarity, SpiClockPhases phase)
 Change the polarity and phase for the SPI clock. More...
 
bool SpiSsMode (CtrlLineModes mode)
 Change the SPI Slave Select mode. More...
 
uint8_t SpiTransferData (uint8_t data)
 
int32_t SpiTransferData (uint8_t const *writeBuf, uint8_t *readBuf, int32_t len)
 SPI's multi-byte transmit and receive function. More...
 
bool SpiTransferDataAsync (uint8_t const *writeBuf, uint8_t *readBuf, int32_t len)
 SPI's asynchronous multi-byte transmit and receive function. More...
 
bool SpiAsyncWaitComplete ()
 Block until asynchronous transfers are completed. More...
 
void DataOrder (DataOrders newOrder)
 Change the data order for the port. More...
 
void HandleFrameError ()
 
void HandleParityError ()
 
void HandleOverflow ()
 
SerialErrorStatusRegister ErrorStatusAccum (SerialErrorStatusRegister mask=UINT32_MAX)
 Accumulating clear on read accessor for any error status bits that were asserted sometime since the previous invocation of this function. More...
 
- Public Member Functions inherited from ClearCore::ISerial
bool SendLine ()
 Send carriage return and newline characters. More...
 
bool Send (const char *buffer, size_t bufferSize)
 Send the array of characters out the port. More...
 
bool SendLine (const char *buffer, size_t bufferSize)
 Send the array of characters out the port. Terminate the line with carriage return and newline characters. More...
 
bool Send (const char *nullTermStr)
 Send a string of characters out the port. More...
 
bool SendLine (const char *nullTermStr)
 Send a string of characters out the port. Terminate the line with carriage return and newline characters. More...
 
bool Send (char theChar)
 Send a character to be printed to the serial port. More...
 
bool SendLine (char theChar)
 Send a character to be printed to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (double number, uint8_t precision=2)
 Send a floating point number to the serial port. More...
 
bool SendLine (double number, uint8_t precision=2)
 Send a floating point number to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (int8_t number, uint8_t radix=10)
 Send an 8-bit signed number to be printed to the serial port. More...
 
bool SendLine (int8_t number, uint8_t radix=10)
 Send an 8-bit signed number to be printed to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (uint8_t number, uint8_t radix=10)
 Send an 8-bit unsigned number to be printed to the serial port. More...
 
bool SendLine (uint8_t number, uint8_t radix=10)
 Send an 8-bit unsigned number to be printed to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (int16_t number, uint8_t radix=10)
 Send a 16-bit signed number to be printed to the serial port. More...
 
bool SendLine (int16_t number, uint8_t radix=10)
 Send a 16-bit signed number to be printed to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (uint16_t number, uint8_t radix=10)
 Send a 16-bit unsigned number to be printed to the serial port. More...
 
bool SendLine (uint16_t number, uint8_t radix=10)
 Send a 16-bit unsigned number to be printed to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (int32_t number, uint8_t radix=10)
 Send a 32-bit signed number to be printed to the serial port. More...
 
bool SendLine (int32_t number, uint8_t radix=10)
 Send a 32-bit signed number to be printed to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (uint32_t number, uint8_t radix=10)
 Send a 32-bit unsigned number to be printed to the serial port. More...
 
bool SendLine (uint32_t number, uint8_t radix=10)
 Send a 32-bit unsigned number to be printed to the serial port. Terminate the line with carriage return and newline characters. More...
 
bool Send (int number, uint8_t radix=10)
 Send an integer to be printed to the serial port. More...
 
bool SendLine (int number, uint8_t radix=10)
 Send an integer to be printed to the serial port. More...
 
virtual operator bool ()=0
 
- Public Member Functions inherited from ClearCore::Connector
void Reinitialize ()
 Reinitialize this connector to the power-up state. More...
 
int32_t ConnectorIndex ()
 Accessor for the bit index of this connector in the input register. More...
 
virtual int16_t State ()=0
 Get the connector's last sampled value. More...
 
virtual bool State (int16_t newState)=0
 Set the state of a R/W connector. More...
 
virtual bool IsInHwFault ()=0
 Get whether the connector is in a hardware fault state. More...
 
uint32_t InputRegMask ()
 Get a bit mask representing this connector. More...
 

Additional Inherited Members

- Public Types inherited from ClearCore::SerialBase
enum  DataOrders { COM_MSB_FIRST = 0, COM_LSB_FIRST = 1 }
 
enum  PortModes { UART, SPI }
 
enum  SpiClockPolarities { SCK_LOW = 0, SCK_HIGH }
 
enum  SpiClockPhases { LEAD_SAMPLE = 0, LEAD_CHANGE }
 
enum  CtrlLineModes { LINE_OFF, LINE_ON, LINE_HW }
 
- Public Types inherited from ClearCore::ISerial
enum  _Parities { PARITY_E = 0, PARITY_O, PARITY_N }
 
typedef enum ClearCore::ISerial::_Parities Parities
 
- Public Types inherited from ClearCore::Connector
enum  ConnectorModes {
  INVALID_NONE, INPUT_ANALOG, INPUT_DIGITAL, OUTPUT_ANALOG,
  OUTPUT_DIGITAL, OUTPUT_H_BRIDGE, OUTPUT_PWM, OUTPUT_TONE,
  OUTPUT_WAVE, CPM_MODE_A_DIRECT_B_DIRECT, CPM_MODE_STEP_AND_DIR, CPM_MODE_A_DIRECT_B_PWM,
  CPM_MODE_A_PWM_B_PWM, TTL, RS232, SPI,
  CCIO, USB_CDC
}
 All possible operational modes for a connector. More...
 
enum  ConnectorTypes {
  DIGITAL_IN_TYPE, DIGITAL_IN_OUT_TYPE, SHIFT_REG_TYPE, ANALOG_IN_DIGITAL_IN_TYPE,
  ANALOG_OUT_DIGITAL_IN_OUT_TYPE, H_BRIDGE_TYPE, CPM_TYPE, SERIAL_TYPE,
  SERIAL_USB_TYPE, CCIO_DIGITAL_IN_OUT_TYPE
}
 The different types of ClearCore connectors. More...
 
- Static Public Attributes inherited from ClearCore::SerialBase
static const int16_t BREAK_DETECTED = int16_t(0xBDBD)
 
static const int16_t EOB = -1
 

Member Function Documentation

bool ClearCore::SerialDriver::IsWritable ( )
inlineoverridevirtual

Get R/W status of the connector.

Returns
True if the port is open.

Implements ClearCore::Connector.

virtual ConnectorModes ClearCore::SerialDriver::Mode ( )
inlineoverridevirtual

Get the connector's operational mode.

// COM-0 is currently in TTL mode.
}
Returns
The connector's current operational mode.

Reimplemented from ClearCore::Connector.

bool ClearCore::SerialDriver::Mode ( ConnectorModes  newMode)
overridevirtual

Set the connector's operational mode.

// Set COM-1's mode to be the port controlling a CCIO-8 link
Parameters
[in]newModeThe new mode to be set. The valid modes for this connector type are:
Returns
Returns false if the mode is invalid or setup fails.

Implements ClearCore::Connector.

void ClearCore::SerialDriver::PortClose ( )
overridevirtual

Shut down the port and discontinue operations/communications.

Reimplemented from ClearCore::SerialBase.

void ClearCore::SerialDriver::PortOpen ( )
overridevirtual

Set up the port to allow operations/communications.

Reimplemented from ClearCore::SerialBase.

bool ClearCore::SerialDriver::Speed ( uint32_t  bitsPerSecond)
inlineoverridevirtual

Change the baud rate for the port.

Parameters
[in]bitsPerSecondThe new speed to set.
Returns
Returns true if port accepted the speed request. Will return false if the baud rate gets clipped for SPI mode.

Reimplemented from ClearCore::SerialBase.

Connector::ConnectorTypes ClearCore::SerialDriver::Type ( )
inlineoverridevirtual

Get connector type.

Returns
The type of the current connector.

Implements ClearCore::Connector.


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