ClearCore Library
Loading...
Searching...
No Matches
List of all members | Public Member Functions
ClearCore::UsbManager Class Reference

Detailed Description

USB manager Class.

Generates a mask for all of the items in the USB_STATUS_REG_LIST. Appends the text "Mask" to the item in the list.

e.g. The mask for TimeoutRead is TimeoutReadMask

Implements a CDC (Communications Device Class) USB device. The CDC uses an abstract control model (ACM) to emulate a serial port.

Reading: Upon receiving data (interrupt based), the data is copied into a circular buffer. When the buffer is full, the receipt of data is acknowledged, but not copied into the buffer. Data is drained from the buffer via the Read function. To Query the number of available bytes call Available().

Writing: Small transfers (less than a packet size) are copied into a buffer and sent in the background. Larger transfers are still sent in the background, but are not buffered. This means that the pointer to the data must remain valid during the sending procedure.

USB manager Class. More...

#include <UsbManager.h>

Public Member Functions

bool Speed (uint32_t bitsPerSecond)
 Change the baud rate for the port.
 
uint32_t Speed ()
 Get current port speed.
 
bool PortIsOpen ()
 Return whether or not the USB port is open.
 
void PortOpen ()
 
void PortClose ()
 
void FlushInput ()
 
void WaitForWriteFinish ()
 
int32_t AvailableForRead ()
 
int32_t AvailableForWrite ()
 Determines the number of characters available in the transmit buffer.
 
int16_t CharGet ()
 Attempt to read the next character from serial channel.
 
int16_t CharPeek ()
 Attempt to get the next character from the serial channel without pulling the character out of the buffer.
 
bool SendChar (uint8_t charToSend)
 Send an ascii character on the serial channel.
 
 operator bool ()
 Returns whether USB is connected and operational.
 
const volatile usb_cdc_control_signal_t & LineState ()
 

Member Function Documentation

◆ AvailableForRead()

int32_t ClearCore::UsbManager::AvailableForRead ( )

Returns number of characters waiting in the receive buffer.

◆ AvailableForWrite()

int32_t ClearCore::UsbManager::AvailableForWrite ( )

Determines the number of characters available in the transmit buffer.

// There are less than 10 free characters in COM-0's transmit buffer
}
int32_t AvailableForWrite() override
Determines the number of characters available in the transmit buffer.
SerialDriver ConnectorCOM0
COM-0 connector instance.
Returns
Returns number of free characters in transmit buffer

◆ CharGet()

int16_t ClearCore::UsbManager::CharGet ( )

Attempt to read the next character from serial channel.

Returns
Returns the first character in the serial buffer, or SerialBase::EOB if no data are available. If a character is found, it will be consumed and removed from the serial buffer.

◆ CharPeek()

int16_t ClearCore::UsbManager::CharPeek ( )

Attempt to get the next character from the serial channel without pulling the character out of the buffer.

Returns
Returns the first character in the serial buffer, or SerialBase::EOB if no data are available. If a character is found, it will not be consumed, and will remain in the serial buffer for reading.

◆ PortIsOpen()

bool ClearCore::UsbManager::PortIsOpen ( )

Return whether or not the USB port is open.

Returns
True if the port is open, and false otherwise.

◆ SendChar()

bool ClearCore::UsbManager::SendChar ( uint8_t  charToSend)

Send an ascii character on the serial channel.

Parameters
[in]charToSendThe character to be sent
Returns
success

◆ Speed() [1/2]

uint32_t ClearCore::UsbManager::Speed ( )

Get current port speed.

Returns
Returns port speed in bits per second.

◆ Speed() [2/2]

bool ClearCore::UsbManager::Speed ( uint32_t  bitsPerSecond)

Change the baud rate for the port.

Parameters
[in]bitsPerSecondThe new speed setting
Returns
Returns true if port accepted the speed request.

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