SAMV71 Xplained Ultra Software Package 1.4

Usbd_cdc

Collaboration diagram for Usbd_cdc:

Data Structures

struct  CDCDParseData
struct  _CDCDEEMDriverConfigurationDescriptors
struct  _CDCDEEMDriverConfigurationDescriptorsOTG
struct  CDCDEEMPort
struct  _CDCDSerialDriverConfigurationDescriptors
struct  _CDCDSerialDriverConfigurationDescriptorsOTG
struct  CDCDSerialPort

Modules

 CDC Serial Device IDs
 USB Device CDC EEM Interface IDs
 USB Device EEM Port Descriptor Values
 USB Device Serial Port Descriptor Values
 USB Device Serial Port Events

Defines

#define MIN(a, b)   ((a < b) ? a : b)
#define DATAPACKETSIZE   (1536)
#define DATABUFFERSIZE   (DATAPACKETSIZE+2)
#define USB_TX_BUFFERS   64

Typedefs

typedef uint32_t(* CDCDSerialPortEventHandler )(uint32_t dwEvent, uint32_t dwParam, void *pArguments)

Functions

void CDCDEEM_Initialize (USBDDriver *pUsbd, uint8_t bInterfaceNb)
void CDCDEEM_ConfigureFunction (USBGenericDescriptor *pDescriptors, uint16_t wLength)
uint32_t CDCDEEM_RequestHandler (const USBGenericRequest *request)
uint32_t CDCDEEM_Read (void *data, uint32_t size, TransferCallback callback, void *argument)
uint32_t CDCDEEM_Write (void *data, uint32_t size, TransferCallback callback, void *argument)
void CDCDEEMDriver_Initialize (const USBDDriverDescriptors *pDescriptors)
void CDCDEEMDriver_ConfigurationChangedHandler (uint8_t cfgnum)
void CDCDEEMDriver_RequestHandler (const USBGenericRequest *request)
void CDCDEEMPort_Initialize (CDCDEEMPort *pCdcd, USBDDriver *pUsbd, uint8_t firstInterface, uint8_t numInterface)
USBGenericDescriptor * CDCDEEMPort_ParseInterfaces (CDCDEEMPort *pCdcd, USBGenericDescriptor *pDescriptors, uint32_t dwLength)
uint32_t CDCDEEMPort_RequestHandler (CDCDEEMPort *pCdcd, const USBGenericRequest *request)
uint32_t CDCDEEMPort_Read (const CDCDEEMPort *pCdcd, void *pData, uint32_t dwSize, TransferCallback fCallback, void *pArg)
uint32_t CDCDEEMPort_Write (const CDCDEEMPort *pCdcd, void *pData, uint32_t dwSize, TransferCallback fCallback, void *pArg)
void CDCDSerial_Initialize (USBDDriver *pUsbd, uint8_t bInterfaceNb)
void CDCDSerial_ConfigureFunction (USBGenericDescriptor *pDescriptors, uint16_t wLength)
uint32_t CDCDSerial_RequestHandler (const USBGenericRequest *request)
uint32_t CDCDSerial_Read (void *data, uint32_t size, TransferCallback callback, void *argument)
uint32_t CDCDSerial_Write (void *data, uint32_t size, TransferCallback callback, void *argument)
uint8_t CDCDSerial_GetControlLineState (void)
void CDCDSerial_GetLineCoding (CDCLineCoding *pLineCoding)
uint16_t CDCDSerial_GetSerialState (void)
void CDCDSerial_SetSerialState (uint16_t serialState)
void CDCDSerialDriver_Initialize (const USBDDriverDescriptors *pDescriptors)
void CDCDSerialDriver_ConfigurationChangedHandler (uint8_t cfgnum)
void CDCDSerialDriver_RequestHandler (const USBGenericRequest *request)
void CDCDSerialPort_Initialize (CDCDSerialPort *pCdcd, USBDDriver *pUsbd, CDCDSerialPortEventHandler fEventHandler, void *pArg, uint8_t firstInterface, uint8_t numInterface)
USBGenericDescriptor * CDCDSerialPort_ParseInterfaces (CDCDSerialPort *pCdcd, USBGenericDescriptor *pDescriptors, uint32_t dwLength)
uint32_t CDCDSerialPort_RequestHandler (CDCDSerialPort *pCdcd, const USBGenericRequest *request)
uint32_t CDCDSerialPort_Read (const CDCDSerialPort *pCdcd, void *pData, uint32_t dwSize, TransferCallback fCallback, void *pArg)
uint32_t CDCDSerialPort_Write (const CDCDSerialPort *pCdcd, void *pData, uint32_t dwSize, TransferCallback fCallback, void *pArg)
uint8_t CDCDSerialPort_GetControlLineState (const CDCDSerialPort *pCdcd)
void CDCDSerialPort_GetLineCoding (const CDCDSerialPort *pCdcd, CDCLineCoding *pLineCoding)
uint16_t CDCDSerialPort_GetSerialState (const CDCDSerialPort *pCdcd)
void CDCDSerialPort_SetSerialState (CDCDSerialPort *pCdcd, uint16_t wSerialState)
struct
_CDCDEEMDriverConfigurationDescriptors 
__attribute__ ((__packed__)) CDCDEEMDriverConfigurationDescriptors
uint8_t CDCDSerial_LineCodingIsToChange (CDCLineCoding *pLineCoding)
void CDCDSerial_ControlLineStateChanged (uint8_t DTR, uint8_t RTS)

Variables

const USBDeviceDescriptor deviceDescriptor
const
CDCDSerialDriverConfigurationDescriptors 
configurationDescriptorsFS
const
CDCDSerialDriverConfigurationDescriptors 
otherSpeedDescriptorsFS
const
CDCDSerialDriverConfigurationDescriptors 
configurationDescriptorsHS
const
CDCDSerialDriverConfigurationDescriptors 
otherSpeedDescriptorsHS
const unsigned char languageIdStringDescriptor []
const unsigned char productStringDescriptor []
const unsigned char * stringDescriptors []
WEAK const USBDDriverDescriptors cdcdSerialDriverDescriptors

Define Documentation

#define DATABUFFERSIZE   (DATAPACKETSIZE+2)

Size in bytes of the buffer used for reading data from USB

Definition at line 69 of file CDCDEEMPort.c.

#define DATAPACKETSIZE   (1536)

Maximum packet size in bytes

Definition at line 66 of file CDCDEEMPort.c.

#define MIN (   a,
  b 
)    ((a < b) ? a : b)

Returns the minimum between two values.

Definition at line 71 of file USBDDriverDescriptors.c.

#define USB_TX_BUFFERS   64

Number of transmit buffers

Definition at line 72 of file CDCDEEMPort.c.


Typedef Documentation

typedef uint32_t(* CDCDSerialPortEventHandler)(uint32_t dwEvent, uint32_t dwParam, void *pArguments)

Callback function for serial port events

Definition at line 88 of file CDCDSerialPort.h.


Function Documentation

void CDCDEEM_ConfigureFunction ( USBGenericDescriptor *  pDescriptors,
uint16_t  wLength 
)

Invoked whenever the device is changed by the host. Pointer to the descriptors for function configure. Length of descriptors in number of bytes.

void CDCDEEM_Initialize ( USBDDriver pUsbd,
uint8_t  bInterfaceNb 
)

Initializes the USB Device CDC serial driver & USBD Driver.

Parameters:
pUsbd Pointer to USBDDriver instance.
bInterfaceNb Interface number for the function.
uint32_t CDCDEEM_Read ( void *  data,
uint32_t  size,
TransferCallback  callback,
void *  argument 
)

Receives data from the host through the virtual COM port created by the CDC device serial driver. This function behaves like USBD_Read.

Parameters:
data Pointer to the data buffer to put received data.
size Size of the data buffer in bytes.
callback Optional callback function to invoke when the transfer finishes.
argument Optional argument to the callback function.
Returns:
USBD_STATUS_SUCCESS if the read operation has been started normally; otherwise, the corresponding error code.
uint32_t CDCDEEM_RequestHandler ( const USBGenericRequest request  ) 

Handles CDC-specific SETUP requests. Should be called from a re-implementation of USBDCallbacks_RequestReceived() method.

Parameters:
request Pointer to a USBGenericRequest instance.
uint32_t CDCDEEM_Write ( void *  data,
uint32_t  size,
TransferCallback  callback,
void *  argument 
)

Sends a data buffer through the virtual COM port created by the CDC device serial driver. This function behaves exactly like USBD_Write.

Parameters:
data Pointer to the data buffer to send.
size Size of the data buffer in bytes.
callback Optional callback function to invoke when the transfer finishes.
argument Optional argument to the callback function.
Returns:
USBD_STATUS_SUCCESS if the read operation has been started normally; otherwise, the corresponding error code.
void CDCDEEMDriver_ConfigurationChangedHandler ( uint8_t  cfgnum  ) 

Invoked whenever the active configuration of device is changed by the host.

Parameters:
cfgnum Configuration number.
void CDCDEEMDriver_Initialize ( const USBDDriverDescriptors pDescriptors  ) 

Initializes the USB Device CDC serial driver & USBD Driver.

Parameters:
pDescriptors Pointer to Descriptors list for CDC EEM Device.
void CDCDEEMDriver_RequestHandler ( const USBGenericRequest request  ) 

Handles CDC-specific SETUP requests. Should be called from a re-implementation of USBDCallbacks_RequestReceived() method.

Parameters:
request Pointer to a USBGenericRequest instance.
void CDCDEEMPort_Initialize ( CDCDEEMPort pCdcd,
USBDDriver pUsbd,
uint8_t  firstInterface,
uint8_t  numInterface 
)

Initializes the USB Device CDC serial port function.

Parameters:
pCdcd Pointer to CDCDEEMPort instance.
pUsbd Pointer to USBDDriver instance.
fEventHandler Pointer to event handler function.
firstInterface First interface index for the function (0xFF to parse from descriptors).
numInterface Number of interfaces for the function.
USBGenericDescriptor * CDCDEEMPort_ParseInterfaces ( CDCDEEMPort pCdcd,
USBGenericDescriptor *  pDescriptors,
uint32_t  dwLength 
)

Parse CDC EEM Port information for CDCDEEMPort instance. Accepted interfaces:

  • Communication Interface + Data Interface
  • Data Interface ONLY
    Parameters:
    pCdcd Pointer to CDCDEEMPort instance.
    pDescriptors Pointer to descriptor list.
    dwLength Descriptor list size in bytes.
uint32_t CDCDEEMPort_Read ( const CDCDEEMPort pCdcd,
void *  pData,
uint32_t  dwSize,
TransferCallback  fCallback,
void *  pArg 
)

Receives data from the host through the virtual COM port created by the CDC device serial driver. This function behaves like USBD_Read.

Parameters:
pCdcd Pointer to CDCDEEMPort instance.
pData Pointer to the data buffer to put received data.
dwSize Size of the data buffer in bytes.
fCallback Optional callback function to invoke when the transfer finishes.
pArg Optional argument to the callback function.
Returns:
USBD_STATUS_SUCCESS if the read operation has been started normally; otherwise, the corresponding error code.
uint32_t CDCDEEMPort_RequestHandler ( CDCDEEMPort pCdcd,
const USBGenericRequest request 
)

Handles CDC-specific SETUP requests. Should be called from a re-implementation of USBDCallbacks_RequestReceived() method.

Parameters:
pCdcd Pointer to CDCDEEMPort instance.
request Pointer to a USBGenericRequest instance.
Returns:
USBRC_SUCCESS if request handled, otherwise error.
uint32_t CDCDEEMPort_Write ( const CDCDEEMPort pCdcd,
void *  pData,
uint32_t  dwSize,
TransferCallback  fCallback,
void *  pArg 
)

Sends a data buffer through the virtual COM port created by the CDC device serial driver. This function behaves exactly like USBD_Write.

TODO batch packets ?

Parameters:
pCdcd Pointer to CDCDEEMPort instance.
pData Pointer to the data buffer to send.
dwSize Size of the data buffer in bytes.
fCallback Optional callback function to invoke when the transfer finishes.
pArg Optional argument to the callback function.
Returns:
USBD_STATUS_SUCCESS if the read operation has been started normally; otherwise, the corresponding error code.
void CDCDSerial_ConfigureFunction ( USBGenericDescriptor *  pDescriptors,
uint16_t  wLength 
)

Invoked whenever the device is changed by the host. Pointer to the descriptors for function configure. Length of descriptors in number of bytes.

void CDCDSerial_ControlLineStateChanged ( uint8_t  DTR,
uint8_t  RTS 
)

Invoked when the CDC ControlLineState is changed

Parameters:
DTR New DTR value.
RTS New RTS value.

Invoked when the CDC ControlLineState is changed

Parameters:
port Port number.
DTR New DTR value.
RTS New RTS value.

Definition at line 521 of file main.c.

uint8_t CDCDSerial_GetControlLineState ( void   ) 

Returns the current control line state of the RS-232 line.

void CDCDSerial_GetLineCoding ( CDCLineCoding *  pLineCoding  ) 

Copy current line coding settings to pointered space.

Parameters:
pLineCoding Pointer to CDCLineCoding instance.
uint16_t CDCDSerial_GetSerialState ( void   ) 

Returns the current status of the RS-232 line.

void CDCDSerial_Initialize ( USBDDriver pUsbd,
uint8_t  bInterfaceNb 
)

Initializes the USB Device CDC serial driver & USBD Driver.

Parameters:
pUsbd Pointer to USBDDriver instance.
bInterfaceNb Interface number for the function.
uint8_t CDCDSerial_LineCodingIsToChange ( CDCLineCoding *  pLineCoding  ) 

Invoked when the CDC LineCoding is requested to changed

Parameters:
pLineCoding Pointer to new LineCoding settings.
Returns:
USBRC_SUCCESS if ready to receive the line coding.

Invoked when the CDC LineCoding is requested to changed

Parameters:
port Port number.
pLineCoding Pointer to new LineCoding settings.
Returns:
USBRC_SUCCESS if ready to receive the line coding.

Definition at line 265 of file main.c.

uint32_t CDCDSerial_Read ( void *  data,
uint32_t  size,
TransferCallback  callback,
void *  argument 
)

Receives data from the host through the virtual COM port created by the CDC device serial driver. This function behaves like USBD_Read.

Parameters:
data Pointer to the data buffer to put received data.
size Size of the data buffer in bytes.
callback Optional callback function to invoke when the transfer finishes.
argument Optional argument to the callback function.
Returns:
USBD_STATUS_SUCCESS if the read operation has been started normally; otherwise, the corresponding error code.
uint32_t CDCDSerial_RequestHandler ( const USBGenericRequest request  ) 

Handles CDC-specific SETUP requests. Should be called from a re-implementation of USBDCallbacks_RequestReceived() method.

Parameters:
request Pointer to a USBGenericRequest instance.
void CDCDSerial_SetSerialState ( uint16_t  serialState  ) 

Sets the current serial state of the device to the given value.

Parameters:
serialState New device state.
uint32_t CDCDSerial_Write ( void *  data,
uint32_t  size,
TransferCallback  callback,
void *  argument 
)

Sends a data buffer through the virtual COM port created by the CDC device serial driver. This function behaves exactly like USBD_Write.

Parameters:
data Pointer to the data buffer to send.
size Size of the data buffer in bytes.
callback Optional callback function to invoke when the transfer finishes.
argument Optional argument to the callback function.
Returns:
USBD_STATUS_SUCCESS if the read operation has been started normally; otherwise, the corresponding error code.
void CDCDSerialDriver_ConfigurationChangedHandler ( uint8_t  cfgnum  ) 

Invoked whenever the active configuration of device is changed by the host.

Parameters:
cfgnum Configuration number.
void CDCDSerialDriver_Initialize ( const USBDDriverDescriptors pDescriptors  ) 

Initializes the USB Device CDC serial driver & USBD Driver.

Parameters:
pDescriptors Pointer to Descriptors list for CDC Serial Device.
void CDCDSerialDriver_RequestHandler ( const USBGenericRequest request  ) 

Handles CDC-specific SETUP requests. Should be called from a re-implementation of USBDCallbacks_RequestReceived() method.

Parameters:
request Pointer to a USBGenericRequest instance.
uint8_t CDCDSerialPort_GetControlLineState ( const CDCDSerialPort pCdcd  ) 

Returns the current control line state of the RS-232 line.

Parameters:
pCdcd Pointer to CDCDSerialPort instance.
void CDCDSerialPort_GetLineCoding ( const CDCDSerialPort pCdcd,
CDCLineCoding *  pLineCoding 
)

Copy current line coding settings to pointered space.

Parameters:
pCdcd Pointer to CDCDSerialPort instance.
pLineCoding Pointer to CDCLineCoding instance.
uint16_t CDCDSerialPort_GetSerialState ( const CDCDSerialPort pCdcd  ) 

Returns the current status of the RS-232 line.

Parameters:
pCdcd Pointer to CDCDSerialPort instance.
void CDCDSerialPort_Initialize ( CDCDSerialPort pCdcd,
USBDDriver pUsbd,
CDCDSerialPortEventHandler  fEventHandler,
void *  pArg,
uint8_t  firstInterface,
uint8_t  numInterface 
)

Initializes the USB Device CDC serial port function.

Parameters:
pCdcd Pointer to CDCDSerialPort instance.
pUsbd Pointer to USBDDriver instance.
fEventHandler Pointer to event handler function.
firstInterface First interface index for the function (0xFF to parse from descriptors).
numInterface Number of interfaces for the function.
USBGenericDescriptor * CDCDSerialPort_ParseInterfaces ( CDCDSerialPort pCdcd,
USBGenericDescriptor *  pDescriptors,
uint32_t  dwLength 
)

Parse CDC Serial Port information for CDCDSerialPort instance. Accepted interfaces:

  • Communication Interface + Data Interface
  • Data Interface ONLY
    Parameters:
    pCdcd Pointer to CDCDSerialPort instance.
    pDescriptors Pointer to descriptor list.
    dwLength Descriptor list size in bytes.
uint32_t CDCDSerialPort_Read ( const CDCDSerialPort pCdcd,
void *  pData,
uint32_t  dwSize,
TransferCallback  fCallback,
void *  pArg 
)

Receives data from the host through the virtual COM port created by the CDC device serial driver. This function behaves like USBD_Read.

Parameters:
pCdcd Pointer to CDCDSerialPort instance.
pData Pointer to the data buffer to put received data.
dwSize Size of the data buffer in bytes.
fCallback Optional callback function to invoke when the transfer finishes.
pArg Optional argument to the callback function.
Returns:
USBD_STATUS_SUCCESS if the read operation has been started normally; otherwise, the corresponding error code.
uint32_t CDCDSerialPort_RequestHandler ( CDCDSerialPort pCdcd,
const USBGenericRequest request 
)

Handles CDC-specific SETUP requests. Should be called from a re-implementation of USBDCallbacks_RequestReceived() method.

Parameters:
pCdcd Pointer to CDCDSerialPort instance.
request Pointer to a USBGenericRequest instance.
Returns:
USBRC_SUCCESS if request handled, otherwise error.
void CDCDSerialPort_SetSerialState ( CDCDSerialPort pCdcd,
uint16_t  wSerialState 
)

Sets the current serial state of the device to the given value.

Parameters:
pCdcd Pointer to CDCDSerialPort instance.
wSerialState New device state.
uint32_t CDCDSerialPort_Write ( const CDCDSerialPort pCdcd,
void *  pData,
uint32_t  dwSize,
TransferCallback  fCallback,
void *  pArg 
)

Sends a data buffer through the virtual COM port created by the CDC device serial driver. This function behaves exactly like USBD_Write.

Parameters:
pCdcd Pointer to CDCDSerialPort instance.
pData Pointer to the data buffer to send.
dwSize Size of the data buffer in bytes.
fCallback Optional callback function to invoke when the transfer finishes.
pArg Optional argument to the callback function.
Returns:
USBD_STATUS_SUCCESS if the read operation has been started normally; otherwise, the corresponding error code.

Variable Documentation

Initial value:
 {

    &deviceDescriptor,
    (USBConfigurationDescriptor *) &(configurationDescriptorsFS),
    &qualifierDescriptor,
    (USBConfigurationDescriptor *) &(otherSpeedDescriptorsFS),
    0, 
    (USBConfigurationDescriptor *) &(configurationDescriptorsHS),
    &qualifierDescriptor,
    (USBConfigurationDescriptor *) &(otherSpeedDescriptorsHS),
    stringDescriptors,
    2 
}

List of standard descriptors for the serial driver.

Definition at line 561 of file USBDDriverDescriptors.c.

const CDCDSerialDriverConfigurationDescriptors configurationDescriptorsFS

Standard USB configuration descriptor for the CDC serial driver

Definition at line 111 of file USBDDriverDescriptors.c.

const CDCDSerialDriverConfigurationDescriptors configurationDescriptorsHS

Configuration descriptor (when in high-speed).

Definition at line 317 of file USBDDriverDescriptors.c.

const USBDeviceDescriptor deviceDescriptor
Initial value:
 {

    sizeof(USBDeviceDescriptor),
    USBGenericDescriptor_DEVICE,
    USBDeviceDescriptor_USB2_00,
    CDCDeviceDescriptor_CLASS,
    CDCDeviceDescriptor_SUBCLASS,
    CDCDeviceDescriptor_PROTOCOL,
    CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
    CDCDSerialDriverDescriptors_VENDORID,
    CDCDSerialDriverDescriptors_PRODUCTID,
    CDCDSerialDriverDescriptors_RELEASE,
    0, 
    1, 
    0, 
    1 
}

Standard USB device descriptor for the CDC serial driver

Definition at line 78 of file USBDDriverDescriptors.c.

const unsigned char languageIdStringDescriptor[]
Initial value:
 {

    USBStringDescriptor_LENGTH(1),
    USBGenericDescriptor_STRING,
    USBStringDescriptor_ENGLISH_US
}

Language ID string descriptor

Definition at line 526 of file USBDDriverDescriptors.c.

const CDCDSerialDriverConfigurationDescriptors otherSpeedDescriptorsFS

Other-speed configuration descriptor (when in full-speed).

Definition at line 214 of file USBDDriverDescriptors.c.

const CDCDSerialDriverConfigurationDescriptors otherSpeedDescriptorsHS

Other-speed configuration descriptor (when in high-speed).

Definition at line 420 of file USBDDriverDescriptors.c.

const unsigned char* stringDescriptors[]
Initial value:

List of string descriptors used by the device

Definition at line 554 of file USBDDriverDescriptors.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines