USBLibAPIGuide  1.00.00.01
Macros | Typedefs | Enumerations | Functions | Variables
Usblib_host_class_cdc

Macros

#define MAX_CDC_DEVICES   MAX_USB_DEVICES
 
#define CDC_EVENT_OPEN   1
 
#define CDC_EVENT_CLOSE   2
 
#define USBREQ_GET_LINE_CODING   0x21
 
#define USBREQ_SET_LINE_CODING   0x20
 
#define USBREQ_SET_CONTROL_LINE_STATE   0x22
 
#define USB_GET_LINE_CODING_SIZE   0x07
 
#define CDC_DEACTIVATE_CARRIER   0x00
 
#define CDC_ACTIVATE_CARRIER   0x03
 
#define USBH_EVENT_RX_CDC_DATA   USBH_CDC_EVENT_BASE + 16
 The CDC data detected. More...
 
#define USBH_EVENT_TX_CDC_DATA   USBH_CDC_EVENT_BASE + 17
 

Typedefs

typedef struct tCDCInstance tCDCInstance
 

Enumerations

enum  tCDCSubClassProtocol {
  eUSBHCDCClassNone = 0, eUSBHCDCClassDirectLineControl, eUSBHCDCClassAbstractContol, eUSBHCDCClassTelephoneControl,
  eUSBHCDCClassMultichannelControl, eUSBHCDCClassCapiControl, eUSBHCDCClassEthernetNetworkingControl, eUSBHCDCClassATMNetworkingControl,
  eUSBHCDCClassVendor
}
 

Functions

tCDCInstanceUSBHCDCOpen (tCDCSubClassProtocol iDeviceType, tUSBCallback pfnCallback, void *pvCBData)
 
void USBHCDCClose (tCDCInstance *psCDCInstance)
 
uint32_t USBHCDCGetLineCoding (tCDCInstance *psCDCInstance, uint8_t *pui8Buffer, uint32_t ui32Size)
 
uint32_t USBHCDCSetLineCoding (tCDCInstance *psCDCInstance, uint8_t *pui8Data)
 
uint32_t USBHCDCSetControlLineState (tCDCInstance *psCDCInstance, uint16_t carrierValue)
 
uint32_t USBHCDCReadData (tCDCInstance *psCDCInstance, uint32_t ui32Interface, uint8_t *pui8Data, uint32_t ui32Size)
 
uint32_t USBHCDCWriteData (tCDCInstance *psCDCInstance, uint32_t ui32Interface, uint8_t *pui8Data, uint32_t ui32Size)
 

Variables

const tUSBHostClassDriver g_sUSBCDCClassDriver
 
const tUSBHostClassDriver g_sUSBCDCClassDriver
 

Detailed Description

Macro Definition Documentation

§ MAX_CDC_DEVICES

#define MAX_CDC_DEVICES   MAX_USB_DEVICES

Referenced by USBHCDCOpen().

§ CDC_EVENT_OPEN

#define CDC_EVENT_OPEN   1

§ CDC_EVENT_CLOSE

#define CDC_EVENT_CLOSE   2

§ USBREQ_GET_LINE_CODING

#define USBREQ_GET_LINE_CODING   0x21

Referenced by USBHCDCGetLineCoding().

§ USBREQ_SET_LINE_CODING

#define USBREQ_SET_LINE_CODING   0x20

Referenced by USBHCDCSetLineCoding().

§ USBREQ_SET_CONTROL_LINE_STATE

#define USBREQ_SET_CONTROL_LINE_STATE   0x22

§ USB_GET_LINE_CODING_SIZE

#define USB_GET_LINE_CODING_SIZE   0x07

Referenced by USBHCDCSerialInit().

§ CDC_DEACTIVATE_CARRIER

#define CDC_DEACTIVATE_CARRIER   0x00

Referenced by USBHCDCSerialInit().

§ CDC_ACTIVATE_CARRIER

#define CDC_ACTIVATE_CARRIER   0x03

§ USBH_EVENT_RX_CDC_DATA

#define USBH_EVENT_RX_CDC_DATA   USBH_CDC_EVENT_BASE + 16

The CDC data detected.

Referenced by USBHCDCGetDataFromDevice().

§ USBH_EVENT_TX_CDC_DATA

#define USBH_EVENT_TX_CDC_DATA   USBH_CDC_EVENT_BASE + 17

Referenced by USBHCDCSendDataToDevice().

Typedef Documentation

§ tCDCInstance

typedef struct tCDCInstance tCDCInstance

Enumeration Type Documentation

§ tCDCSubClassProtocol

The following values are used to register callbacks to the USB HOST CDC device class layer.

Enumerator
eUSBHCDCClassNone 

No device should be used. This value should not be used by applications.

eUSBHCDCClassDirectLineControl 

This is a direct line control device.

eUSBHCDCClassAbstractContol 

This is a abstract control device.

eUSBHCDCClassTelephoneControl 

This is telephone control device.

eUSBHCDCClassMultichannelControl 

This is multi-channel control device.

eUSBHCDCClassCapiControl 

This is CAPI control device.

eUSBHCDCClassEthernetNetworkingControl 

This is Ethernet Networking Control device.

eUSBHCDCClassATMNetworkingControl 

This is ATM Networking control device.

eUSBHCDCClassVendor 

This is a vendor specific device.

Function Documentation

§ USBHCDCOpen()

tCDCInstance * USBHCDCOpen ( tCDCSubClassProtocol  iDeviceType,
tUSBCallback  pfnCallback,
void *  pvCBData 
)

This function is used to open an instance of a CDC device.

Parameters
iDeviceTypeis the type of device that should be loaded for this instance of the CDC device.
pfnCallbackis the function that will be called whenever changes are detected for this device.
pvCBDatais the data that will be returned in when the pfnCallback function is called.

This function creates an instance of an specific type of CDC device. The iDeviceType parameter is one subclass/protocol values of the types specified in enumerated types tCDCSubClassProtocol. Only devices that enumerate with this type will be called back via the pfnCallback function. The pfnCallback parameter is the callback function for any events that occur for this device type. The pfnCallback function must point to a valid function of type tUSBCallback for this call to complete successfully. To release this device instance the caller of USBHCDCOpen() should call USBHCDCClose() and pass in the value returned from the USBHCDCOpen() call.

Returns
tCDCInstance is the instance value. If a value of 0 is returned then the device instance could not be created.

References eUSBHCDCClassNone, and MAX_CDC_DEVICES.

Referenced by USBHCDCSerialOpen().

§ USBHCDCClose()

void USBHCDCClose ( tCDCInstance psCDCInstance)

This function is used to release an instance of a CDC device.

Parameters
psCDCInstanceis the instance value for a CDC device to release.

This function releases an instance of a CDC device that was created by a call to USBHCDCOpen(). This call is required to allow other CDC devices to be enumerated after another CDC device has been disconnected. The psCDCInstance parameter should hold the value that was returned from the previous call to USBHCDCOpen().

Returns
None.

References eUSBHCDCClassNone.

Referenced by USBHCDCSerialClose().

§ USBHCDCGetLineCoding()

uint32_t USBHCDCGetLineCoding ( tCDCInstance psCDCInstance,
uint8_t *  pui8Buffer,
uint32_t  ui32Size 
)

This function is used to get line coding information for a CDC device.

Parameters
psCDCInstanceis the instance value of a CDC device USBHCDCOpen().
pui8Bufferis buffer that holds the CDC line coding parameter data
ui32Sizeis the line coding size

This function is used to retrieve line parameter information from a device. The parameters retrieved are DTR rate, stop bit, partity and data bits This request is sent when a CDC device is connected to the host.

Returns
ui32Bytes is the number of bytes read into the pui8Buffer.

References USB_RTYPE_CLASS, USB_RTYPE_DIR_IN, USB_RTYPE_INTERFACE, USBHCDControlTransfer(), and USBREQ_GET_LINE_CODING.

Referenced by USBHCDCSerialInit().

§ USBHCDCSetLineCoding()

uint32_t USBHCDCSetLineCoding ( tCDCInstance psCDCInstance,
uint8_t *  pui8Data 
)

This function is used to set the line coding information for a CDC device.

Parameters
psCDCInstanceis the value that was returned from the call to USBHCDCOpen().
pui8Datais the line parameter values

This function is used to set the line parameter information from a device. The parameters are baud rate, stop bit, partiy and data bits This request is sent when a CDC device is connected to the host.

Returns
0 since this is a status message

References USB_RTYPE_CLASS, USB_RTYPE_DIR_OUT, USB_RTYPE_INTERFACE, USBHCDControlTransfer(), and USBREQ_SET_LINE_CODING.

Referenced by USBHCDCSerialInit().

§ USBHCDCSetControlLineState()

uint32_t USBHCDCSetControlLineState ( tCDCInstance psCDCInstance,
uint16_t  carrierValue 
)

This function is used to set the line state of a CDC device.

Parameters
psCDCInstanceis the value that was returned from the call to USBHCDCOpen().
carrierValueis the indicator that deactivates or activates the Control Line

This function is used to set the line parameter information from a device. The parameters are baud rate, stop bit, partiy and data bits This request is sent when a CDC device is connected to the host.

Returns
Returns 0 since this is a status message.

References USB_RTYPE_CLASS, USB_RTYPE_DIR_OUT, USB_RTYPE_INTERFACE, USBHCDControlTransfer(), and USBREQ_SET_CONTROL_LINE_STATE.

Referenced by USBHCDCSerialInit().

§ USBHCDCReadData()

uint32_t USBHCDCReadData ( tCDCInstance psCDCInstance,
uint32_t  ui32Interface,
uint8_t *  pui8Data,
uint32_t  ui32Size 
)

This function is used to read data from bulk IN endpoint.

Parameters
psCDCInstanceis the value that was returned from the call to USBHCDCOpen().
ui32Interfaceis the interface to retrieve the data from.
pui8Datais the memory buffer to use to store the data.
ui32Sizeis the size in bytes of the buffer pointed to by pui8Buffer.

This function is used to read data sent from a connected device. The function specifically reads data from a USB Bulk IN pipe. The data is sent every time the main loop enters STATE_CDC_DEVICE_CONNECTED state.

Returns
ui32Size is the number of bytes read from buffer.

References USBHCDPipeRead().

Referenced by USBHCDCGetDataFromDevice().

§ USBHCDCWriteData()

uint32_t USBHCDCWriteData ( tCDCInstance psCDCInstance,
uint32_t  ui32Interface,
uint8_t *  pui8Data,
uint32_t  ui32Size 
)

This function writes data to bulk OUT endpoint.

Parameters
psCDCInstanceis the value that was returned from the call to USBHCDCOpen().
ui32Interfaceis the interface to write the data to.
pui8Datais the memory buffer storing the data.
ui32Sizeis the size in bytes of the buffer pointed to by pui8Buffer.

This function is used to send data to a connected device by writing the data stored in a memory buffer to a USB Bulk OUT pipe. The data is polled every time the main loop enters STATE_CDC_DEVICE_CONNECTED state.

Returns
ui32Size is the number of bytes read from buffer.

References USBHCDPipeWrite().

Referenced by USBHCDCSendDataToDevice().

Variable Documentation

§ g_sUSBCDCClassDriver [1/2]

const tUSBHostClassDriver g_sUSBCDCClassDriver
Initial value:
=
{
CDCDriverOpen,
CDCDriverClose,
0
}
#define USB_CLASS_CDC
Definition: usblib.h:421

This constant global structure defines the CDC Class Driver that is provided with the USB library.

§ g_sUSBCDCClassDriver [2/2]

const tUSBHostClassDriver g_sUSBCDCClassDriver

This constant global structure defines the CDC Class Driver that is provided with the USB library.

© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale