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

Member Function Documentation

int32_t ClearCore::UsbManager::AvailableForRead ( )

Returns number of characters waiting in the receive buffer.

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
}
Returns
Returns number of free characters in transmit buffer
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.
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.
bool ClearCore::UsbManager::PortIsOpen ( )

Return whether or not the USB port is open.

Returns
True if the port is open, and false otherwise.
bool ClearCore::UsbManager::SendChar ( uint8_t  charToSend)

Send an ascii character on the serial channel.

Parameters
[in]charToSendThe character to be sent
Returns
success
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.
uint32_t ClearCore::UsbManager::Speed ( )

Get current port speed.

Returns
Returns port speed in bits per second.

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