USB Device CDC API#
USBD_CDC_ConfigureMemSeg()#
Description#
Configures the memory segment to use when allocating control data.
Files#
usbd_cdc.h/usbd_cdc.c
Prototype#
void USBD_CDC_ConfigureMemSeg (MEM_SEG *p_mem_seg)Arguments#
p_mem_seg
Pointer to memory segment to use when allocating control data. DEF_NULL means general purpose heap segment.
Returned Value#
None.
Notes / Warnings#
This function is optional, if it is not called, the default value will be used.
This function MUST be called before the CDC class is initialized via the
USBD_CDC_Init()function.
USBD_CDC_Init()#
Description#
Initializes CDC class.
Files#
usbd_cdc.h/usbd_cdc.c
Prototype#
void USBD_CDC_Init (USBD_CDC_QTY_CFG *p_qty_cfg,
RTOS_ERR *p_err)Arguments#
p_qty_cfg
Pointer to CDC bas class configuration structure.
p_err
Pointer to the variable that will receive one of these returned error codes from this function :
RTOS_ERR_NONERTOS_ERR_SEG_OVF
Returned Value#
None.
Notes / Warnings#
None.
USBD_CDC_Add()#
Description#
Adds a new instance of the CDC class.
Files#
usbd_cdc.h/usbd_cdc.c
Prototype#
CPU_INT08U USBD_CDC_Add (CPU_INT08U subclass,
USBD_CDC_SUBCLASS_DRV *p_subclass_drv,
void *p_subclass_arg,
CPU_INT08U protocol,
CPU_BOOLEAN notify_en,
CPU_INT16U notify_interval,
RTOS_ERR *p_err)Arguments#
subclass
Communication class subclass subcode (see Note #1).
p_subclass_drv
Pointer to the CDC subclass driver.
p_subclass_arg
Pointer to the CDC subclass driver argument.
protocol
Communication class protocol code.
notify_en
Notification enabled :
DEF_ENABLED Enable CDC class notifications.
DEF_DISABLED Disable CDC class notifications.
notify_interval
Notification interval in milliseconds (must be a power of 2).
p_err
Pointer to the variable that will receive one of these returned error codes from this function :
RTOS_ERR_NONERTOS_ERR_CLASS_INSTANCE_ALLOC
Returned Value#
CDC class instance number, if no errors are returned.
USBD_CDC_NBR_NONE, if any errors returned.
Notes / Warnings#
Communication class subclass codes are defined in '
usbd_cdc.h' 'USBD_CDC_SUBCLASS_XXXX'.
USBD_CDC_ConfigAdd()#
Description#
Adds a CDC instance into the USB device configuration.
Files#
usbd_cdc.h/usbd_cdc.c
Prototype#
CPU_BOOLEAN USBD_CDC_ConfigAdd (CPU_INT08U class_nbr,
CPU_INT08U dev_nbr,
CPU_INT08U config_nbr,
RTOS_ERR *p_err)Arguments#
class_nbr
Class instance number.
dev_nbr
Device number.
config_nbr
Configuration index to which to add the new CDC class interface.
p_err
Pointer to the variable that will receive one of these returned error codes from this function :
RTOS_ERR_NONERTOS_ERR_INVALID_DEV_STATERTOS_ERR_IF_ALT_ALLOCRTOS_ERR_ALLOCRTOS_ERR_IF_GRP_ALLOCRTOS_ERR_CLASS_INSTANCE_ALLOCRTOS_ERR_ALREADY_EXISTSRTOS_ERR_IF_ALLOCRTOS_ERR_INVALID_ARGRTOS_ERR_EP_ALLOCRTOS_ERR_EP_NONE_AVAIL
Returned Value#
DEF_YES, if the CDC class instance was added to USB device configuration successfully.DEF_NO, if the instance was not added successfully.
Notes / Warnings#
None.
USBD_CDC_IsConn()#
Description#
Gets the CDC class connection state.
Files#
usbd_cdc.h/usbd_cdc.c
Prototype#
CPU_BOOLEAN USBD_CDC_IsConn (CPU_INT08U class_nbr)Arguments#
class_nbr
Class instance number.
Returned Value#
DEF_YES, if CDC class is connected.DEF_NO, if CDC class is not connected.
Notes / Warnings#
None.
USBD_CDC_DataIF_Add()#
Description#
Adds a data interface class to the CDC communication interface class.
Files#
usbd_cdc.h/usbd_cdc.c
Prototype#
CPU_INT08U USBD_CDC_DataIF_Add (CPU_INT08U class_nbr,
CPU_BOOLEAN isoc_en,
CPU_INT08U protocol,
RTOS_ERR *p_err)Arguments#
class_nbr
Class instance number.
isoc_en
Data interface isochronous enable (see Note #1) :
DEF_ENABLEDData interface uses isochronous EPs.DEF_DISABLEDData interface uses bulk EPs.
protocol
Data interface protocol code.
p_err
Pointer to the variable that will receive one of these returned error codes from this function :
RTOS_ERR_NONERTOS_ERR_ALLOC
Returned Value#
Data interface number.
Notes / Warnings#
The value of '
isoc_en' must beDEF_DISABLED. Isochronous EPs are not supported.
USBD_CDC_DataRx()#
Description#
Receives data on the CDC data interface.
Files#
usbd_cdc.h/usbd_cdc.c
Prototype#
CPU_INT32U USBD_CDC_DataRx (CPU_INT08U class_nbr,
CPU_INT08U data_if_nbr,
CPU_INT08U *p_buf,
CPU_INT32U buf_len,
CPU_INT16U timeout,
RTOS_ERR *p_err)Arguments#
class_nbr
Class instance number.
data_if_nbr
CDC data interface number.
p_buf
Pointer to the destination buffer to receive data.
buf_len
Number of octets to receive.
timeout
Timeout in milliseconds.
p_err
Pointer to the variable that will receive one of these returned error codes from this function :
RTOS_ERR_NONERTOS_ERR_INVALID_DEV_STATERTOS_ERR_NULL_PTRRTOS_ERR_EP_QUEUINGRTOS_ERR_RXRTOS_ERR_NOT_SUPPORTEDRTOS_ERR_NOT_READYRTOS_ERR_EP_INVALIDRTOS_ERR_OS_SCHED_LOCKEDRTOS_ERR_NOT_AVAILRTOS_ERR_WOULD_OVFRTOS_ERR_OS_OBJ_DELRTOS_ERR_INVALID_HANDLERTOS_ERR_WOULD_BLOCKRTOS_ERR_INVALID_ARGRTOS_ERR_IS_OWNERRTOS_ERR_INVALID_CLASS_STATERTOS_ERR_INVALID_EP_STATERTOS_ERR_ABORTRTOS_ERR_TIMEOUT
Returned Value#
Number of octets received, if no errors are returned.
0, if any errors returned.
Notes / Warnings#
None.
USBD_CDC_DataTx()#
Description#
Sends data on the CDC data interface.
Files#
usbd_cdc.h/usbd_cdc.c
Prototype#
CPU_INT32U USBD_CDC_DataTx (CPU_INT08U class_nbr,
CPU_INT08U data_if_nbr,
CPU_INT08U *p_buf,
CPU_INT32U buf_len,
CPU_INT16U timeout,
RTOS_ERR *p_err)Arguments#
class_nbr
Class instance number.
data_if_nbr
CDC data interface number.
p_buf
Pointer to the buffer of data that will be transmitted.
buf_len
Number of octets to transmit.
timeout
Timeout in milliseconds.
p_err
Pointer to the variable that will receive one of these returned error codes from this function :
RTOS_ERR_NONERTOS_ERR_INVALID_DEV_STATERTOS_ERR_NULL_PTRRTOS_ERR_EP_QUEUINGRTOS_ERR_TXRTOS_ERR_NOT_SUPPORTEDRTOS_ERR_NOT_READYRTOS_ERR_EP_INVALIDRTOS_ERR_OS_SCHED_LOCKEDRTOS_ERR_NOT_AVAILRTOS_ERR_WOULD_OVFRTOS_ERR_OS_OBJ_DELRTOS_ERR_INVALID_HANDLERTOS_ERR_WOULD_BLOCKRTOS_ERR_INVALID_ARGRTOS_ERR_IS_OWNERRTOS_ERR_INVALID_CLASS_STATERTOS_ERR_INVALID_EP_STATERTOS_ERR_ABORTRTOS_ERR_TIMEOUT
Returned Value#
Number of octets transmitted, if no errors are returned.
0, if any errors returned.
Notes / Warnings#
None.
USBD_CDC_Notify()#
Description#
Sends a communication interface class notification to the host.
Files#
usbd_cdc.h/usbd_cdc.c
Prototype#
CPU_BOOLEAN USBD_CDC_Notify (CPU_INT08U class_nbr,
CPU_INT08U notification,
CPU_INT16U value,
CPU_INT08U *p_buf,
CPU_INT16U data_len,
RTOS_ERR *p_err)Arguments#
class_nbr
Class instance number.
notification
Notification code.
value
Notification value.
p_buf
Pointer to the notification buffer (see Note #1).
data_len
Length of the data portion of the notification.
p_err
Pointer to the variable that will receive one of these returned error codes from this function :
RTOS_ERR_NONERTOS_ERR_INVALID_DEV_STATERTOS_ERR_NULL_PTRRTOS_ERR_EP_QUEUINGRTOS_ERR_TXRTOS_ERR_NOT_READYRTOS_ERR_EP_INVALIDRTOS_ERR_OS_SCHED_LOCKEDRTOS_ERR_NOT_AVAILRTOS_ERR_WOULD_OVFRTOS_ERR_OS_OBJ_DELRTOS_ERR_INVALID_HANDLERTOS_ERR_WOULD_BLOCKRTOS_ERR_IS_OWNERRTOS_ERR_INVALID_CLASS_STATERTOS_ERR_INVALID_EP_STATERTOS_ERR_ABORTRTOS_ERR_TIMEOUT
Returned Value#
None.
Notes / Warnings#
The notification buffer MUST contain space for the notification header '
USBD_CDC_NOTIFICATION_HEADER' plus the variable-length data portion.