--- /dev/null
+/***********************************************************************\r
+* $Id:: mw_usbd_cdcuser.h 331 2012-08-09 18:54:34Z usb10131 $\r
+*\r
+* Project: USB device ROM Stack\r
+*\r
+* Description:\r
+* USB Communication Device Class User module Definitions.\r
+*\r
+***********************************************************************\r
+* Copyright(C) 2011, NXP Semiconductor\r
+* All rights reserved.\r
+*\r
+* Software that is described herein is for illustrative purposes only\r
+* which provides customers with programming information regarding the\r
+* products. This software is supplied "AS IS" without any warranties.\r
+* NXP Semiconductors assumes no responsibility or liability for the\r
+* use of the software, conveys no license or title under any patent,\r
+* copyright, or mask work right to the product. NXP Semiconductors\r
+* reserves the right to make changes in the software without\r
+* notification. NXP Semiconductors also make no representation or\r
+* warranty that such application will be suitable for the specified\r
+* use without further testing or modification.\r
+**********************************************************************/\r
+#ifndef __CDCUSER_H__\r
+#define __CDCUSER_H__\r
+\r
+#include "error.h"\r
+#include "usbd.h"\r
+#include "usbd_cdc.h"\r
+\r
+/** \file\r
+ * \brief Communication Device Class (CDC) API structures and function prototypes.\r
+ *\r
+ * Definition of functions exported by ROM based CDC function driver.\r
+ *\r
+ */\r
+\r
+/** \ingroup Group_USBD\r
+ * @defgroup USBD_CDC Communication Device Class (CDC) Function Driver\r
+ * \section Sec_CDCModDescription Module Description\r
+ * CDC Class Function Driver module. This module contains an internal implementation of the USB CDC Class.\r
+ *\r
+ * User applications can use this class driver instead of implementing the CDC-ACM class manually\r
+ * via the low-level USBD_HW and USBD_Core APIs.\r
+ *\r
+ * This module is designed to simplify the user code by exposing only the required interface needed to interface with\r
+ * Devices using the USB CDC-ACM Class.\r
+ */\r
+\r
+/*----------------------------------------------------------------------------\r
+ We need a buffer for incoming data on USB port because USB receives\r
+ much faster than UART transmits\r
+ *---------------------------------------------------------------------------*/\r
+/* Buffer masks */\r
+#define CDC_BUF_SIZE (128) /* Output buffer in bytes (power 2) */\r
+ /* large enough for file transfer */\r
+#define CDC_BUF_MASK (CDC_BUF_SIZE-1ul)\r
+\r
+/** \brief Communication Device Class function driver initialization parameter data structure.\r
+ * \ingroup USBD_CDC\r
+ *\r
+ * \details This data structure is used to pass initialization parameters to the \r
+ * Communication Device Class function driver's init function.\r
+ *\r
+ */\r
+typedef struct USBD_CDC_INIT_PARAM\r
+{\r
+ /* memory allocation params */\r
+ uint32_t mem_base; /**< Base memory location from where the stack can allocate\r
+ data and buffers. \note The memory address set in this field\r
+ should be accessible by USB DMA controller. Also this value\r
+ should be aligned on 4 byte boundary.\r
+ */\r
+ uint32_t mem_size; /**< The size of memory buffer which stack can use. \r
+ \note The \em mem_size should be greater than the size \r
+ returned by USBD_CDC_API::GetMemSize() routine.*/\r
+ /** Pointer to the control interface descriptor within the descriptor\r
+ * array (\em high_speed_desc) passed to Init() through \ref USB_CORE_DESCS_T \r
+ * structure. The stack assumes both HS and FS use same BULK endpoints. \r
+ */\r
+ uint8_t* cif_intf_desc;\r
+ /** Pointer to the data interface descriptor within the descriptor\r
+ * array (\em high_speed_desc) passed to Init() through \ref USB_CORE_DESCS_T \r
+ * structure. The stack assumes both HS and FS use same BULK endpoints. \r
+ */\r
+ uint8_t* dif_intf_desc;\r
+\r
+ /* user defined functions */\r
+\r
+ /* required functions */\r
+ /** \r
+ * Communication Interface Class specific get request call-back function.\r
+ *\r
+ * This function is provided by the application software. This function gets called \r
+ * when host sends CIC management element get requests.\r
+ * \note Applications implementing Abstract Control Model subclass can set this\r
+ * param to NULL. As the default driver parses ACM requests and calls the\r
+ * individual ACM call-back routines defined in this structure. For all other subclasses\r
+ * this routine should be provided by the application.\r
+ * \n\r
+ * The setup packet data (\em pSetup) is passed to the call-back so that application\r
+ * can extract the CIC request type and other associated data. By default the stack\r
+ * will assign \em pBuffer pointer to \em EP0Buff allocated at init. The application\r
+ * code can directly write data into this buffer as long as data is less than 64 byte.\r
+ * If more data has to be sent then application code should update \em pBuffer pointer\r
+ * and length accordingly.\r
+ * \r
+ * \r
+ * \param[in] hCdc Handle to CDC function driver. \r
+ * \param[in] pSetup Pointer to setup packet received from host.\r
+ * \param[in, out] pBuffer Pointer to a pointer of data buffer containing request data. \r
+ * Pointer-to-pointer is used to implement zero-copy buffers. \r
+ * See \ref USBD_ZeroCopy for more details on zero-copy concept.\r
+ * \param[in, out] length Amount of data to be sent back to host.\r
+ * \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success.\r
+ * \retval ERR_USBD_UNHANDLED Event is not handled hence pass the event to next in line. \r
+ * \retval ERR_USBD_xxx For other error conditions. \r
+ * \r
+ */\r
+ ErrorCode_t (*CIC_GetRequest)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* length); \r
+ \r
+ /** \r
+ * Communication Interface Class specific set request call-back function.\r
+ *\r
+ * This function is provided by the application software. This function gets called \r
+ * when host sends a CIC management element requests.\r
+ * \note Applications implementing Abstract Control Model subclass can set this\r
+ * param to NULL. As the default driver parses ACM requests and calls the\r
+ * individual ACM call-back routines defined in this structure. For all other subclasses\r
+ * this routine should be provided by the application.\r
+ * \n\r
+ * The setup packet data (\em pSetup) is passed to the call-back so that application can\r
+ * extract the CIC request type and other associated data. If a set request has data associated,\r
+ * then this call-back is called twice.\r
+ * -# First when setup request is received, at this time application code could update\r
+ * \em pBuffer pointer to point to the intended destination. The length param is set to 0\r
+ * so that application code knows this is first time. By default the stack will\r
+ * assign \em pBuffer pointer to \em EP0Buff allocated at init. Note, if data length is \r
+ * greater than 64 bytes and application code doesn't update \em pBuffer pointer the \r
+ * stack will send STALL condition to host.\r
+ * -# Second when the data is received from the host. This time the length param is set\r
+ * with number of data bytes received.\r
+ * \r
+ * \param[in] hCdc Handle to CDC function driver. \r
+ * \param[in] pSetup Pointer to setup packet received from host.\r
+ * \param[in, out] pBuffer Pointer to a pointer of data buffer containing request data. \r
+ * Pointer-to-pointer is used to implement zero-copy buffers. \r
+ * See \ref USBD_ZeroCopy for more details on zero-copy concept.\r
+ * \param[in] length Amount of data copied to destination buffer.\r
+ * \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success.\r
+ * \retval ERR_USBD_UNHANDLED Event is not handled hence pass the event to next in line. \r
+ * \retval ERR_USBD_xxx For other error conditions. \r
+ * \r
+ */\r
+ ErrorCode_t (*CIC_SetRequest)( USBD_HANDLE_T hCdc, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t length);\r
+\r
+ /** \r
+ * Communication Device Class specific BULK IN endpoint handler.\r
+ *\r
+ * The application software should provide the BULK IN endpoint handler.\r
+ * Applications should transfer data depending on the communication protocol type set in descriptors. \r
+ * \n\r
+ * \note \r
+ * \r
+ * \param[in] hUsb Handle to the USB device stack. \r
+ * \param[in] data Pointer to the data which will be passed when callback function is called by the stack. \r
+ * \param[in] event Type of endpoint event. See \ref USBD_EVENT_T for more details.\r
+ * \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success.\r
+ * \retval ERR_USBD_UNHANDLED Event is not handled hence pass the event to next in line. \r
+ * \retval ERR_USBD_xxx For other error conditions. \r
+ * \r
+ */\r
+ ErrorCode_t (*CDC_BulkIN_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);\r
+\r
+ /** \r
+ * Communication Device Class specific BULK OUT endpoint handler.\r
+ *\r
+ * The application software should provide the BULK OUT endpoint handler.\r
+ * Applications should transfer data depending on the communication protocol type set in descriptors. \r
+ * \n\r
+ * \note \r
+ * \r
+ * \param[in] hUsb Handle to the USB device stack. \r
+ * \param[in] data Pointer to the data which will be passed when callback function is called by the stack. \r
+ * \param[in] event Type of endpoint event. See \ref USBD_EVENT_T for more details.\r
+ * \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success.\r
+ * \retval ERR_USBD_UNHANDLED Event is not handled hence pass the event to next in line. \r
+ * \retval ERR_USBD_xxx For other error conditions. \r
+ * \r
+ */\r
+ ErrorCode_t (*CDC_BulkOUT_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);\r
+\r
+ /**\r
+ * Abstract control model(ACM) subclass specific SEND_ENCAPSULATED_COMMAND request call-back function.\r
+ *\r
+ * This function is provided by the application software. This function gets called\r
+ * when host sends a SEND_ENCAPSULATED_COMMAND set request.\r
+ *\r
+ * \param[in] hCdc Handle to CDC function driver.\r
+ * \param[in] buffer Pointer to the command buffer.\r
+ * \param[in] len Length of the command buffer.\r
+ * \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success.\r
+ * \retval ERR_USBD_UNHANDLED Event is not handled hence pass the event to next in line.\r
+ * \retval ERR_USBD_xxx For other error conditions.\r
+ *\r
+ */\r
+ ErrorCode_t (*SendEncpsCmd) (USBD_HANDLE_T hCDC, uint8_t* buffer, uint16_t len);\r
+\r
+ /**\r
+ * Abstract control model(ACM) subclass specific GET_ENCAPSULATED_RESPONSE request call-back function.\r
+ *\r
+ * This function is provided by the application software. This function gets called\r
+ * when host sends a GET_ENCAPSULATED_RESPONSE request.\r
+ *\r
+ * \param[in] hCdc Handle to CDC function driver.\r
+ * \param[in, out] buffer Pointer to a pointer of data buffer containing response data.\r
+ * Pointer-to-pointer is used to implement zero-copy buffers.\r
+ * See \ref USBD_ZeroCopy for more details on zero-copy concept.\r
+ * \param[in, out] len Amount of data to be sent back to host.\r
+ * \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success.\r
+ * \retval ERR_USBD_UNHANDLED Event is not handled hence pass the event to next in line.\r
+ * \retval ERR_USBD_xxx For other error conditions.\r
+ *\r
+ */\r
+ ErrorCode_t (*GetEncpsResp) (USBD_HANDLE_T hCDC, uint8_t** buffer, uint16_t* len);\r
+\r
+ /**\r
+ * Abstract control model(ACM) subclass specific SET_COMM_FEATURE request call-back function.\r
+ *\r
+ * This function is provided by the application software. This function gets called\r
+ * when host sends a SET_COMM_FEATURE set request.\r
+ *\r
+ * \param[in] hCdc Handle to CDC function driver.\r
+ * \param[in] feature Communication feature type. See usbcdc11.pdf, section 6.2.4, Table 47.\r
+ * \param[in] buffer Pointer to the settings buffer for the specified communication feature.\r
+ * \param[in] len Length of the request buffer.\r
+ * \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success.\r
+ * \retval ERR_USBD_UNHANDLED Event is not handled hence pass the event to next in line.\r
+ * \retval ERR_USBD_xxx For other error conditions.\r
+ *\r
+ */\r
+ ErrorCode_t (*SetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t* buffer, uint16_t len);\r
+\r
+ /**\r
+ * Abstract control model(ACM) subclass specific GET_COMM_FEATURE request call-back function.\r
+ *\r
+ * This function is provided by the application software. This function gets called\r
+ * when host sends a GET_ENCAPSULATED_RESPONSE request.\r
+ *\r
+ * \param[in] hCdc Handle to CDC function driver.\r
+ * \param[in] feature Communication feature type. See usbcdc11.pdf, section 6.2.4, Table 47.\r
+ * \param[in, out] buffer Pointer to a pointer of data buffer containing current settings\r
+ * for the communication feature.\r
+ * Pointer-to-pointer is used to implement zero-copy buffers.\r
+ * \param[in, out] len Amount of data to be sent back to host.\r
+ * \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success.\r
+ * \retval ERR_USBD_UNHANDLED Event is not handled hence pass the event to next in line.\r
+ * \retval ERR_USBD_xxx For other error conditions.\r
+ *\r
+ */\r
+ ErrorCode_t (*GetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t** pBuffer, uint16_t* len);\r
+\r
+ /**\r
+ * Abstract control model(ACM) subclass specific CLEAR_COMM_FEATURE request call-back function.\r
+ *\r
+ * This function is provided by the application software. This function gets called\r
+ * when host sends a CLEAR_COMM_FEATURE request. In the call-back the application\r
+ * should Clears the settings for a particular communication feature.\r
+ *\r
+ * \param[in] hCdc Handle to CDC function driver.\r
+ * \param[in] feature Communication feature type. See usbcdc11.pdf, section 6.2.4, Table 47.\r
+ * \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success.\r
+ * \retval ERR_USBD_UNHANDLED Event is not handled hence pass the event to next in line.\r
+ * \retval ERR_USBD_xxx For other error conditions.\r
+ *\r
+ */\r
+ ErrorCode_t (*ClrCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature);\r
+\r
+ /**\r
+ * Abstract control model(ACM) subclass specific SET_CONTROL_LINE_STATE request call-back function.\r
+ *\r
+ * This function is provided by the application software. This function gets called\r
+ * when host sends a SET_CONTROL_LINE_STATE request. RS-232 signal used to tell the DCE\r
+ * device the DTE device is now present\r
+ *\r
+ * \param[in] hCdc Handle to CDC function driver.\r
+ * \param[in] state The state value uses bitmap values defined in usbcdc11.pdf,\r
+ * section 6.2.14, Table 51.\r
+ * \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success.\r
+ * \retval ERR_USBD_UNHANDLED Event is not handled hence pass the event to next in line.\r
+ * \retval ERR_USBD_xxx For other error conditions.\r
+ *\r
+ */\r
+ ErrorCode_t (*SetCtrlLineState) (USBD_HANDLE_T hCDC, uint16_t state);\r
+\r
+ /**\r
+ * Abstract control model(ACM) subclass specific SEND_BREAK request call-back function.\r
+ *\r
+ * This function is provided by the application software. This function gets called\r
+ * when host sends a SEND_BREAK request.\r
+ *\r
+ * \param[in] hCdc Handle to CDC function driver.\r
+ * \param[in] mstime Duration of Break signal in milliseconds. If mstime is FFFFh, then\r
+ * the application should send break until another SendBreak request is received\r
+ * with the wValue of 0000h.\r
+ * \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success.\r
+ * \retval ERR_USBD_UNHANDLED Event is not handled hence pass the event to next in line.\r
+ * \retval ERR_USBD_xxx For other error conditions.\r
+ *\r
+ */\r
+ ErrorCode_t (*SendBreak) (USBD_HANDLE_T hCDC, uint16_t mstime);\r
+\r
+ /**\r
+ * Abstract control model(ACM) subclass specific SET_LINE_CODING request call-back function.\r
+ *\r
+ * This function is provided by the application software. This function gets called\r
+ * when host sends a SET_LINE_CODING request. The application should configure the device\r
+ * per DTE rate, stop-bits, parity, and number-of-character bits settings provided in\r
+ * command buffer. See usbcdc11.pdf, section 6.2.13, table 50 for detail of the command buffer.\r
+ *\r
+ * \param[in] hCdc Handle to CDC function driver.\r
+ * \param[in] line_coding Pointer to the CDC_LINE_CODING command buffer.\r
+ * \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success.\r
+ * \retval ERR_USBD_UNHANDLED Event is not handled hence pass the event to next in line.\r
+ * \retval ERR_USBD_xxx For other error conditions.\r
+ *\r
+ */\r
+ ErrorCode_t (*SetLineCode) (USBD_HANDLE_T hCDC, CDC_LINE_CODING* line_coding);\r
+\r
+ /** \r
+ * Optional Communication Device Class specific INTERRUPT IN endpoint handler.\r
+ *\r
+ * The application software should provide the INT IN endpoint handler.\r
+ * Applications should transfer data depending on the communication protocol type set in descriptors. \r
+ * \n\r
+ * \note \r
+ * \r
+ * \param[in] hUsb Handle to the USB device stack. \r
+ * \param[in] data Pointer to the data which will be passed when callback function is called by the stack. \r
+ * \param[in] event Type of endpoint event. See \ref USBD_EVENT_T for more details.\r
+ * \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success.\r
+ * \retval ERR_USBD_UNHANDLED Event is not handled hence pass the event to next in line. \r
+ * \retval ERR_USBD_xxx For other error conditions. \r
+ * \r
+ */\r
+ ErrorCode_t (*CDC_InterruptEP_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);\r
+\r
+ /** \r
+ * Optional user override-able function to replace the default CDC class handler.\r
+ *\r
+ * The application software could override the default EP0 class handler with their\r
+ * own by providing the handler function address as this data member of the parameter\r
+ * structure. Application which like the default handler should set this data member\r
+ * to zero before calling the USBD_CDC_API::Init().\r
+ * \n\r
+ * \note \r
+ * \r
+ * \param[in] hUsb Handle to the USB device stack. \r
+ * \param[in] data Pointer to the data which will be passed when callback function is called by the stack. \r
+ * \param[in] event Type of endpoint event. See \ref USBD_EVENT_T for more details.\r
+ * \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success.\r
+ * \retval ERR_USBD_UNHANDLED Event is not handled hence pass the event to next in line. \r
+ * \retval ERR_USBD_xxx For other error conditions. \r
+ * \r
+ */\r
+ ErrorCode_t (*CDC_Ep0_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);\r
+\r
+} USBD_CDC_INIT_PARAM_T;\r
+\r
+/** \brief CDC class API functions structure.\r
+ * \ingroup USBD_CDC\r
+ *\r
+ * This module exposes functions which interact directly with USB device controller hardware.\r
+ *\r
+ */\r
+typedef struct USBD_CDC_API\r
+{\r
+ /** \fn uint32_t GetMemSize(USBD_CDC_INIT_PARAM_T* param)\r
+ * Function to determine the memory required by the CDC function driver module.\r
+ * \r
+ * This function is called by application layer before calling pUsbApi->CDC->Init(), to allocate memory used \r
+ * by CDC function driver module. The application should allocate the memory which is accessible by USB\r
+ * controller/DMA controller. \r
+ * \note Some memory areas are not accessible by all bus masters.\r
+ *\r
+ * \param[in] param Structure containing CDC function driver module initialization parameters.\r
+ * \return Returns the required memory size in bytes.\r
+ */\r
+ uint32_t (*GetMemSize)(USBD_CDC_INIT_PARAM_T* param);\r
+ \r
+ /** \fn ErrorCode_t init(USBD_HANDLE_T hUsb, USBD_CDC_INIT_PARAM_T* param)\r
+ * Function to initialize CDC function driver module.\r
+ * \r
+ * This function is called by application layer to initialize CDC function driver module.\r
+ *\r
+ * \param[in] hUsb Handle to the USB device stack. \r
+ * \param[in, out] param Structure containing CDC function driver module initialization parameters.\r
+ * \return Returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success\r
+ * \retval ERR_USBD_BAD_MEM_BUF Memory buffer passed is not 4-byte \r
+ * aligned or smaller than required. \r
+ * \retval ERR_API_INVALID_PARAM2 Either CDC_Write() or CDC_Read() or\r
+ * CDC_Verify() callbacks are not defined. \r
+ * \retval ERR_USBD_BAD_INTF_DESC Wrong interface descriptor is passed. \r
+ * \retval ERR_USBD_BAD_EP_DESC Wrong endpoint descriptor is passed. \r
+ */\r
+ ErrorCode_t (*init)(USBD_HANDLE_T hUsb, USBD_CDC_INIT_PARAM_T* param, USBD_HANDLE_T* phCDC);\r
+\r
+ /** \fn ErrorCode_t SendNotification(USBD_HANDLE_T hCdc, uint8_t bNotification, uint16_t data)\r
+ * Function to send CDC class notifications to host. \r
+ * \r
+ * This function is called by application layer to send CDC class notifications to host. \r
+ * See usbcdc11.pdf, section 6.3, Table 67 for various notification types the CDC device can send.\r
+ * \note The current version of the driver only supports following notifications allowed by ACM subclass:\r
+ * CDC_NOTIFICATION_NETWORK_CONNECTION, CDC_RESPONSE_AVAILABLE, CDC_NOTIFICATION_SERIAL_STATE.\r
+ * \n \r
+ * For all other notifications application should construct the notification buffer appropriately\r
+ * and call hw->USB_WriteEP() for interrupt endpoint associated with the interface.\r
+ *\r
+ * \param[in] hCdc Handle to CDC function driver. \r
+ * \param[in] bNotification Notification type allowed by ACM subclass. Should be CDC_NOTIFICATION_NETWORK_CONNECTION,\r
+ * CDC_RESPONSE_AVAILABLE or CDC_NOTIFICATION_SERIAL_STATE. For all other types ERR_API_INVALID_PARAM2\r
+ * is returned. See usbcdc11.pdf, section 3.6.2.1, table 5.\r
+ * \param[in] data Data associated with notification. \r
+ * \n For CDC_NOTIFICATION_NETWORK_CONNECTION a non-zero data value is interpreted as connected state.\r
+ * \n For CDC_RESPONSE_AVAILABLE this parameter is ignored.\r
+ * \n For CDC_NOTIFICATION_SERIAL_STATE the data should use bitmap values defined in usbcdc11.pdf, \r
+ * section 6.3.5, Table 69.\r
+ * \return Returns \ref ErrorCode_t type to indicate success or error condition.\r
+ * \retval LPC_OK On success\r
+ * \retval ERR_API_INVALID_PARAM2 If unsupported notification type is passed. \r
+ * \r
+ */\r
+ ErrorCode_t (*SendNotification)(USBD_HANDLE_T hCdc, uint8_t bNotification, uint16_t data);\r
+\r
+} USBD_CDC_API_T;\r
+\r
+/*-----------------------------------------------------------------------------\r
+ * Private functions & structures prototypes\r
+ *-----------------------------------------------------------------------------*/\r
+/** @cond ADVANCED_API */\r
+\r
+typedef struct _CDC_CTRL_T\r
+{\r
+ USB_CORE_CTRL_T* pUsbCtrl;\r
+ /* notification buffer */\r
+ uint8_t notice_buf[12];\r
+ CDC_LINE_CODING line_coding;\r
+ uint8_t pad0;\r
+\r
+ uint8_t cif_num; /* control interface number */\r
+ uint8_t dif_num; /* data interface number */\r
+ uint8_t epin_num; /* BULK IN endpoint number */\r
+ uint8_t epout_num; /* BULK OUT endpoint number */\r
+ uint8_t epint_num; /* Interrupt IN endpoint number */\r
+ uint8_t pad[3];\r
+ /* user defined functions */\r
+ ErrorCode_t (*SendEncpsCmd) (USBD_HANDLE_T hCDC, uint8_t* buffer, uint16_t len);\r
+ ErrorCode_t (*GetEncpsResp) (USBD_HANDLE_T hCDC, uint8_t** buffer, uint16_t* len);\r
+ ErrorCode_t (*SetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t* buffer, uint16_t len);\r
+ ErrorCode_t (*GetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t** pBuffer, uint16_t* len);\r
+ ErrorCode_t (*ClrCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature);\r
+ ErrorCode_t (*SetCtrlLineState) (USBD_HANDLE_T hCDC, uint16_t state);\r
+ ErrorCode_t (*SendBreak) (USBD_HANDLE_T hCDC, uint16_t state);\r
+ ErrorCode_t (*SetLineCode) (USBD_HANDLE_T hCDC, CDC_LINE_CODING* line_coding);\r
+\r
+ /* virtual functions */\r
+ ErrorCode_t (*CIC_GetRequest)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* length); \r
+ ErrorCode_t (*CIC_SetRequest)( USBD_HANDLE_T hCdc, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t length);\r
+\r
+}USB_CDC_CTRL_T;\r
+\r
+/** @cond DIRECT_API */\r
+extern uint32_t mwCDC_GetMemSize(USBD_CDC_INIT_PARAM_T* param);\r
+extern ErrorCode_t mwCDC_init(USBD_HANDLE_T hUsb, USBD_CDC_INIT_PARAM_T* param, USBD_HANDLE_T* phCDC);\r
+extern ErrorCode_t mwCDC_SendNotification (USBD_HANDLE_T hCdc, uint8_t bNotification, uint16_t data); \r
+/** @endcond */\r
+\r
+/** @endcond */\r
+\r
+\r
+\r
+\r
+\r
+#endif /* __CDCUSER_H__ */ \r