]> git.sur5r.net Git - armstart-ibdap/blob - inc/usbd/usbd_cdcuser.h
initial commit
[armstart-ibdap] / inc / usbd / usbd_cdcuser.h
1 /***********************************************************************\r
2 * $Id:: mw_usbd_cdcuser.h 331 2012-08-09 18:54:34Z usb10131                   $\r
3 *\r
4 * Project: USB device ROM Stack\r
5 *\r
6 * Description:\r
7 *     USB Communication Device Class User module Definitions.\r
8 *\r
9 ***********************************************************************\r
10 *   Copyright(C) 2011, NXP Semiconductor\r
11 *   All rights reserved.\r
12 *\r
13 * Software that is described herein is for illustrative purposes only\r
14 * which provides customers with programming information regarding the\r
15 * products. This software is supplied "AS IS" without any warranties.\r
16 * NXP Semiconductors assumes no responsibility or liability for the\r
17 * use of the software, conveys no license or title under any patent,\r
18 * copyright, or mask work right to the product. NXP Semiconductors\r
19 * reserves the right to make changes in the software without\r
20 * notification. NXP Semiconductors also make no representation or\r
21 * warranty that such application will be suitable for the specified\r
22 * use without further testing or modification.\r
23 **********************************************************************/\r
24 #ifndef __CDCUSER_H__\r
25 #define __CDCUSER_H__\r
26 \r
27 #include "error.h"\r
28 #include "usbd.h"\r
29 #include "usbd_cdc.h"\r
30 \r
31 /** \file\r
32  *  \brief Communication Device Class (CDC) API structures and function prototypes.\r
33  *\r
34  *  Definition of functions exported by ROM based CDC function driver.\r
35  *\r
36  */\r
37 \r
38 /** \ingroup Group_USBD\r
39  *  @defgroup USBD_CDC Communication Device Class (CDC) Function Driver\r
40  *  \section Sec_CDCModDescription Module Description\r
41  *  CDC Class Function Driver module. This module contains an internal implementation of the USB CDC Class.\r
42  *\r
43  *  User applications can use this class driver instead of implementing the CDC-ACM class manually\r
44  *  via the low-level USBD_HW and USBD_Core APIs.\r
45  *\r
46  *  This module is designed to simplify the user code by exposing only the required interface needed to interface with\r
47  *  Devices using the USB CDC-ACM Class.\r
48  */\r
49 \r
50 /*----------------------------------------------------------------------------\r
51   We need a buffer for incoming data on USB port because USB receives\r
52   much faster than  UART transmits\r
53  *---------------------------------------------------------------------------*/\r
54 /* Buffer masks */\r
55 #define CDC_BUF_SIZE               (128)               /* Output buffer in bytes (power 2) */\r
56                                                        /* large enough for file transfer */\r
57 #define CDC_BUF_MASK               (CDC_BUF_SIZE-1ul)\r
58 \r
59 /** \brief Communication Device Class function driver initialization parameter data structure.\r
60  *  \ingroup USBD_CDC\r
61  *\r
62  *  \details  This data structure is used to pass initialization parameters to the \r
63  *  Communication Device Class function driver's init function.\r
64  *\r
65  */\r
66 typedef struct USBD_CDC_INIT_PARAM\r
67 {\r
68   /* memory allocation params */\r
69   uint32_t mem_base;  /**< Base memory location from where the stack can allocate\r
70                       data and buffers. \note The memory address set in this field\r
71                       should be accessible by USB DMA controller. Also this value\r
72                       should be aligned on 4 byte boundary.\r
73                       */\r
74   uint32_t mem_size;  /**< The size of memory buffer which stack can use. \r
75                       \note The \em mem_size should be greater than the size \r
76                       returned by USBD_CDC_API::GetMemSize() routine.*/\r
77   /** Pointer to the control interface descriptor within the descriptor\r
78   * array (\em high_speed_desc) passed to Init() through \ref USB_CORE_DESCS_T \r
79   * structure. The stack assumes both HS and FS use same BULK endpoints. \r
80   */\r
81   uint8_t* cif_intf_desc;\r
82   /** Pointer to the data interface descriptor within the descriptor\r
83   * array (\em high_speed_desc) passed to Init() through \ref USB_CORE_DESCS_T \r
84   * structure. The stack assumes both HS and FS use same BULK endpoints. \r
85   */\r
86   uint8_t* dif_intf_desc;\r
87 \r
88   /* user defined functions */\r
89 \r
90   /* required functions */\r
91   /** \r
92   *  Communication Interface Class specific get request call-back function.\r
93   *\r
94   *  This function is provided by the application software. This function gets called \r
95   *  when host sends CIC management element get requests.\r
96   *  \note Applications implementing Abstract Control Model subclass can set this\r
97   *  param to NULL. As the default driver parses ACM requests and calls the\r
98   *  individual ACM call-back routines defined in this structure. For all other subclasses\r
99   *  this routine should be provided by the application.\r
100   *  \n\r
101   *  The setup packet data (\em pSetup) is passed to the call-back so that application\r
102   *  can extract the CIC request type and other associated data. By default the stack\r
103   *  will assign \em pBuffer pointer to \em EP0Buff allocated at init. The application\r
104   *  code can directly write data into this buffer as long as data is less than 64 byte.\r
105   *  If more data has to be sent then application code should update \em pBuffer pointer\r
106   *  and length accordingly.\r
107   *   \r
108   *  \r
109   *  \param[in] hCdc Handle to CDC function driver. \r
110   *  \param[in] pSetup Pointer to setup packet received from host.\r
111   *  \param[in, out] pBuffer  Pointer to a pointer of data buffer containing request data. \r
112   *                       Pointer-to-pointer is used to implement zero-copy buffers. \r
113   *                       See \ref USBD_ZeroCopy for more details on zero-copy concept.\r
114   *  \param[in, out] length  Amount of data to be sent back to host.\r
115   *  \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
116   *          \retval LPC_OK On success.\r
117   *          \retval ERR_USBD_UNHANDLED  Event is not handled hence pass the event to next in line. \r
118   *          \retval ERR_USBD_xxx  For other error conditions. \r
119   *                                             \r
120   */\r
121   ErrorCode_t (*CIC_GetRequest)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* length); \r
122   \r
123   /** \r
124   *  Communication Interface Class specific set request call-back function.\r
125   *\r
126   *  This function is provided by the application software. This function gets called \r
127   *  when host sends a CIC management element requests.\r
128   *  \note Applications implementing Abstract Control Model subclass can set this\r
129   *  param to NULL. As the default driver parses ACM requests and calls the\r
130   *  individual ACM call-back routines defined in this structure. For all other subclasses\r
131   *  this routine should be provided by the application.\r
132   *  \n\r
133   *  The setup packet data (\em pSetup) is passed to the call-back so that application can\r
134   *  extract the CIC request type and other associated data. If a set request has data associated,\r
135   *  then this call-back is called twice.\r
136   *  -# First when setup request is received, at this time application code could update\r
137   *  \em pBuffer pointer to point to the intended destination. The length param is set to 0\r
138   *  so that application code knows this is first time. By default the stack will\r
139   *  assign \em pBuffer pointer to \em EP0Buff allocated at init. Note, if data length is \r
140   *  greater than 64 bytes and application code doesn't update \em pBuffer pointer the \r
141   *  stack will send STALL condition to host.\r
142   *  -# Second when the data is received from the host. This time the length param is set\r
143   *  with number of data bytes received.\r
144   *  \r
145   *  \param[in] hCdc Handle to CDC function driver. \r
146   *  \param[in] pSetup Pointer to setup packet received from host.\r
147   *  \param[in, out] pBuffer  Pointer to a pointer of data buffer containing request data. \r
148   *                       Pointer-to-pointer is used to implement zero-copy buffers. \r
149   *                       See \ref USBD_ZeroCopy for more details on zero-copy concept.\r
150   *  \param[in] length  Amount of data copied to destination buffer.\r
151   *  \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
152   *          \retval LPC_OK On success.\r
153   *          \retval ERR_USBD_UNHANDLED  Event is not handled hence pass the event to next in line. \r
154   *          \retval ERR_USBD_xxx  For other error conditions. \r
155   *                                             \r
156   */\r
157   ErrorCode_t (*CIC_SetRequest)( USBD_HANDLE_T hCdc, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t length);\r
158 \r
159   /** \r
160   *  Communication Device Class specific BULK IN endpoint handler.\r
161   *\r
162   *  The application software should provide the BULK IN endpoint handler.\r
163   *  Applications should transfer data depending on the communication protocol type set in descriptors. \r
164   *  \n\r
165   *  \note \r
166   *  \r
167   *  \param[in] hUsb Handle to the USB device stack. \r
168   *  \param[in] data Pointer to the data which will be passed when callback function is called by the stack. \r
169   *  \param[in] event  Type of endpoint event. See \ref USBD_EVENT_T for more details.\r
170   *  \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
171   *          \retval LPC_OK On success.\r
172   *          \retval ERR_USBD_UNHANDLED  Event is not handled hence pass the event to next in line. \r
173   *          \retval ERR_USBD_xxx  For other error conditions. \r
174   *                                             \r
175   */\r
176   ErrorCode_t (*CDC_BulkIN_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);\r
177 \r
178   /** \r
179   *  Communication Device Class specific BULK OUT endpoint handler.\r
180   *\r
181   *  The application software should provide the BULK OUT endpoint handler.\r
182   *  Applications should transfer data depending on the communication protocol type set in descriptors. \r
183   *  \n\r
184   *  \note \r
185   *  \r
186   *  \param[in] hUsb Handle to the USB device stack. \r
187   *  \param[in] data Pointer to the data which will be passed when callback function is called by the stack. \r
188   *  \param[in] event  Type of endpoint event. See \ref USBD_EVENT_T for more details.\r
189   *  \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
190   *          \retval LPC_OK On success.\r
191   *          \retval ERR_USBD_UNHANDLED  Event is not handled hence pass the event to next in line. \r
192   *          \retval ERR_USBD_xxx  For other error conditions. \r
193   *                                             \r
194   */\r
195   ErrorCode_t (*CDC_BulkOUT_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);\r
196 \r
197   /**\r
198   *  Abstract control model(ACM) subclass specific SEND_ENCAPSULATED_COMMAND request call-back function.\r
199   *\r
200   *  This function is provided by the application software. This function gets called\r
201   *  when host sends a SEND_ENCAPSULATED_COMMAND set request.\r
202   *\r
203   *  \param[in] hCdc Handle to CDC function driver.\r
204   *  \param[in] buffer Pointer to the command buffer.\r
205   *  \param[in] len  Length of the command buffer.\r
206   *  \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
207   *          \retval LPC_OK On success.\r
208   *          \retval ERR_USBD_UNHANDLED  Event is not handled hence pass the event to next in line.\r
209   *          \retval ERR_USBD_xxx  For other error conditions.\r
210   *\r
211   */\r
212   ErrorCode_t (*SendEncpsCmd) (USBD_HANDLE_T hCDC, uint8_t* buffer, uint16_t len);\r
213 \r
214   /**\r
215   *  Abstract control model(ACM) subclass specific GET_ENCAPSULATED_RESPONSE request call-back function.\r
216   *\r
217   *  This function is provided by the application software. This function gets called\r
218   *  when host sends a GET_ENCAPSULATED_RESPONSE request.\r
219   *\r
220   *  \param[in] hCdc Handle to CDC function driver.\r
221   *  \param[in, out] buffer Pointer to a pointer of data buffer containing response data.\r
222   *                       Pointer-to-pointer is used to implement zero-copy buffers.\r
223   *                       See \ref USBD_ZeroCopy for more details on zero-copy concept.\r
224   *  \param[in, out] len  Amount of data to be sent back to host.\r
225   *  \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
226   *          \retval LPC_OK On success.\r
227   *          \retval ERR_USBD_UNHANDLED  Event is not handled hence pass the event to next in line.\r
228   *          \retval ERR_USBD_xxx  For other error conditions.\r
229   *\r
230   */\r
231   ErrorCode_t (*GetEncpsResp) (USBD_HANDLE_T hCDC, uint8_t** buffer, uint16_t* len);\r
232 \r
233   /**\r
234   *  Abstract control model(ACM) subclass specific SET_COMM_FEATURE request call-back function.\r
235   *\r
236   *  This function is provided by the application software. This function gets called\r
237   *  when host sends a SET_COMM_FEATURE set request.\r
238   *\r
239   *  \param[in] hCdc Handle to CDC function driver.\r
240   *  \param[in] feature Communication feature type. See usbcdc11.pdf, section 6.2.4, Table 47.\r
241   *  \param[in] buffer Pointer to the settings buffer for the specified communication feature.\r
242   *  \param[in] len  Length of the request buffer.\r
243   *  \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
244   *          \retval LPC_OK On success.\r
245   *          \retval ERR_USBD_UNHANDLED  Event is not handled hence pass the event to next in line.\r
246   *          \retval ERR_USBD_xxx  For other error conditions.\r
247   *\r
248   */\r
249   ErrorCode_t (*SetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t* buffer, uint16_t len);\r
250 \r
251   /**\r
252   *  Abstract control model(ACM) subclass specific GET_COMM_FEATURE request call-back function.\r
253   *\r
254   *  This function is provided by the application software. This function gets called\r
255   *  when host sends a GET_ENCAPSULATED_RESPONSE request.\r
256   *\r
257   *  \param[in] hCdc Handle to CDC function driver.\r
258   *  \param[in] feature Communication feature type. See usbcdc11.pdf, section 6.2.4, Table 47.\r
259   *  \param[in, out] buffer Pointer to a pointer of data buffer containing current settings\r
260   *                         for the communication feature.\r
261   *                       Pointer-to-pointer is used to implement zero-copy buffers.\r
262   *  \param[in, out] len  Amount of data to be sent back to host.\r
263   *  \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
264   *          \retval LPC_OK On success.\r
265   *          \retval ERR_USBD_UNHANDLED  Event is not handled hence pass the event to next in line.\r
266   *          \retval ERR_USBD_xxx  For other error conditions.\r
267   *\r
268   */\r
269   ErrorCode_t (*GetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t** pBuffer, uint16_t* len);\r
270 \r
271   /**\r
272   *  Abstract control model(ACM) subclass specific CLEAR_COMM_FEATURE request call-back function.\r
273   *\r
274   *  This function is provided by the application software. This function gets called\r
275   *  when host sends a CLEAR_COMM_FEATURE request. In the call-back the application\r
276   *  should Clears the settings for a particular communication feature.\r
277   *\r
278   *  \param[in] hCdc Handle to CDC function driver.\r
279   *  \param[in] feature Communication feature type. See usbcdc11.pdf, section 6.2.4, Table 47.\r
280   *  \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
281   *          \retval LPC_OK On success.\r
282   *          \retval ERR_USBD_UNHANDLED  Event is not handled hence pass the event to next in line.\r
283   *          \retval ERR_USBD_xxx  For other error conditions.\r
284   *\r
285   */\r
286   ErrorCode_t (*ClrCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature);\r
287 \r
288   /**\r
289   *  Abstract control model(ACM) subclass specific SET_CONTROL_LINE_STATE request call-back function.\r
290   *\r
291   *  This function is provided by the application software. This function gets called\r
292   *  when host sends a SET_CONTROL_LINE_STATE request. RS-232 signal used to tell the DCE\r
293   *  device the DTE device is now present\r
294   *\r
295   *  \param[in] hCdc Handle to CDC function driver.\r
296   *  \param[in] state The state value uses bitmap values defined in usbcdc11.pdf,\r
297   *        section 6.2.14, Table 51.\r
298   *  \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
299   *          \retval LPC_OK On success.\r
300   *          \retval ERR_USBD_UNHANDLED  Event is not handled hence pass the event to next in line.\r
301   *          \retval ERR_USBD_xxx  For other error conditions.\r
302   *\r
303   */\r
304   ErrorCode_t (*SetCtrlLineState) (USBD_HANDLE_T hCDC, uint16_t state);\r
305 \r
306   /**\r
307   *  Abstract control model(ACM) subclass specific SEND_BREAK request call-back function.\r
308   *\r
309   *  This function is provided by the application software. This function gets called\r
310   *  when host sends a SEND_BREAK request.\r
311   *\r
312   *  \param[in] hCdc Handle to CDC function driver.\r
313   *  \param[in] mstime Duration of Break signal in milliseconds. If mstime is FFFFh, then\r
314   *        the application should send break until another SendBreak request is received\r
315   *        with the wValue of 0000h.\r
316   *  \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
317   *          \retval LPC_OK On success.\r
318   *          \retval ERR_USBD_UNHANDLED  Event is not handled hence pass the event to next in line.\r
319   *          \retval ERR_USBD_xxx  For other error conditions.\r
320   *\r
321   */\r
322   ErrorCode_t (*SendBreak) (USBD_HANDLE_T hCDC, uint16_t mstime);\r
323 \r
324   /**\r
325   *  Abstract control model(ACM) subclass specific SET_LINE_CODING request call-back function.\r
326   *\r
327   *  This function is provided by the application software. This function gets called\r
328   *  when host sends a SET_LINE_CODING request. The application should configure the device\r
329   *  per DTE rate, stop-bits, parity, and number-of-character bits settings provided in\r
330   *  command buffer. See usbcdc11.pdf, section 6.2.13, table 50 for detail of the command buffer.\r
331   *\r
332   *  \param[in] hCdc Handle to CDC function driver.\r
333   *  \param[in] line_coding Pointer to the CDC_LINE_CODING command buffer.\r
334   *  \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
335   *          \retval LPC_OK On success.\r
336   *          \retval ERR_USBD_UNHANDLED  Event is not handled hence pass the event to next in line.\r
337   *          \retval ERR_USBD_xxx  For other error conditions.\r
338   *\r
339   */\r
340   ErrorCode_t (*SetLineCode) (USBD_HANDLE_T hCDC, CDC_LINE_CODING* line_coding);\r
341 \r
342   /** \r
343   *  Optional Communication Device Class specific INTERRUPT IN endpoint handler.\r
344   *\r
345   *  The application software should provide the INT IN endpoint handler.\r
346   *  Applications should transfer data depending on the communication protocol type set in descriptors. \r
347   *  \n\r
348   *  \note \r
349   *  \r
350   *  \param[in] hUsb Handle to the USB device stack. \r
351   *  \param[in] data Pointer to the data which will be passed when callback function is called by the stack. \r
352   *  \param[in] event  Type of endpoint event. See \ref USBD_EVENT_T for more details.\r
353   *  \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
354   *          \retval LPC_OK On success.\r
355   *          \retval ERR_USBD_UNHANDLED  Event is not handled hence pass the event to next in line. \r
356   *          \retval ERR_USBD_xxx  For other error conditions. \r
357   *                                             \r
358   */\r
359   ErrorCode_t (*CDC_InterruptEP_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);\r
360 \r
361   /** \r
362   *  Optional user override-able function to replace the default CDC class handler.\r
363   *\r
364   *  The application software could override the default EP0 class handler with their\r
365   *  own by providing the handler function address as this data member of the parameter\r
366   *  structure. Application which like the default handler should set this data member\r
367   *  to zero before calling the USBD_CDC_API::Init().\r
368   *  \n\r
369   *  \note \r
370   *  \r
371   *  \param[in] hUsb Handle to the USB device stack. \r
372   *  \param[in] data Pointer to the data which will be passed when callback function is called by the stack. \r
373   *  \param[in] event  Type of endpoint event. See \ref USBD_EVENT_T for more details.\r
374   *  \return The call back should returns \ref ErrorCode_t type to indicate success or error condition.\r
375   *          \retval LPC_OK On success.\r
376   *          \retval ERR_USBD_UNHANDLED  Event is not handled hence pass the event to next in line. \r
377   *          \retval ERR_USBD_xxx  For other error conditions. \r
378   *                                             \r
379   */\r
380   ErrorCode_t (*CDC_Ep0_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);\r
381 \r
382 } USBD_CDC_INIT_PARAM_T;\r
383 \r
384 /** \brief CDC class API functions structure.\r
385  *  \ingroup USBD_CDC\r
386  *\r
387  *  This module exposes functions which interact directly with USB device controller hardware.\r
388  *\r
389  */\r
390 typedef struct USBD_CDC_API\r
391 {\r
392   /** \fn uint32_t GetMemSize(USBD_CDC_INIT_PARAM_T* param)\r
393    *  Function to determine the memory required by the CDC function driver module.\r
394    * \r
395    *  This function is called by application layer before calling pUsbApi->CDC->Init(), to allocate memory used \r
396    *  by CDC function driver module. The application should allocate the memory which is accessible by USB\r
397    *  controller/DMA controller. \r
398    *  \note Some memory areas are not accessible by all bus masters.\r
399    *\r
400    *  \param[in] param Structure containing CDC function driver module initialization parameters.\r
401    *  \return Returns the required memory size in bytes.\r
402    */\r
403   uint32_t (*GetMemSize)(USBD_CDC_INIT_PARAM_T* param);\r
404   \r
405   /** \fn ErrorCode_t init(USBD_HANDLE_T hUsb, USBD_CDC_INIT_PARAM_T* param)\r
406    *  Function to initialize CDC function driver module.\r
407    * \r
408    *  This function is called by application layer to initialize CDC function driver module.\r
409    *\r
410    *  \param[in] hUsb Handle to the USB device stack. \r
411    *  \param[in, out] param Structure containing CDC function driver module initialization parameters.\r
412    *  \return Returns \ref ErrorCode_t type to indicate success or error condition.\r
413    *          \retval LPC_OK On success\r
414    *          \retval ERR_USBD_BAD_MEM_BUF  Memory buffer passed is not 4-byte \r
415    *              aligned or smaller than required. \r
416    *          \retval ERR_API_INVALID_PARAM2 Either CDC_Write() or CDC_Read() or\r
417    *              CDC_Verify() callbacks are not defined. \r
418    *          \retval ERR_USBD_BAD_INTF_DESC  Wrong interface descriptor is passed. \r
419    *          \retval ERR_USBD_BAD_EP_DESC  Wrong endpoint descriptor is passed. \r
420    */\r
421   ErrorCode_t (*init)(USBD_HANDLE_T hUsb, USBD_CDC_INIT_PARAM_T* param, USBD_HANDLE_T* phCDC);\r
422 \r
423   /** \fn ErrorCode_t SendNotification(USBD_HANDLE_T hCdc, uint8_t bNotification, uint16_t data)\r
424    *  Function to send CDC class notifications to host. \r
425    * \r
426    *  This function is called by application layer to send CDC class notifications to host. \r
427    *  See usbcdc11.pdf, section 6.3, Table 67 for various notification types the CDC device can send.\r
428    *  \note The current version of the driver only supports following notifications allowed by ACM subclass:\r
429    *  CDC_NOTIFICATION_NETWORK_CONNECTION, CDC_RESPONSE_AVAILABLE, CDC_NOTIFICATION_SERIAL_STATE.\r
430    *  \n \r
431    *  For all other notifications application should construct the notification buffer appropriately\r
432    *  and call hw->USB_WriteEP() for interrupt endpoint associated with the interface.\r
433    *\r
434    *  \param[in] hCdc Handle to CDC function driver.  \r
435    *  \param[in] bNotification Notification type allowed by ACM subclass. Should be CDC_NOTIFICATION_NETWORK_CONNECTION,\r
436    *        CDC_RESPONSE_AVAILABLE or CDC_NOTIFICATION_SERIAL_STATE. For all other types ERR_API_INVALID_PARAM2\r
437    *        is returned. See usbcdc11.pdf, section 3.6.2.1, table 5.\r
438    *  \param[in] data Data associated with notification.  \r
439    *        \n For CDC_NOTIFICATION_NETWORK_CONNECTION a non-zero data value is interpreted as connected state.\r
440    *        \n For CDC_RESPONSE_AVAILABLE this parameter is ignored.\r
441    *        \n For CDC_NOTIFICATION_SERIAL_STATE the data should use bitmap values defined in usbcdc11.pdf, \r
442    *        section 6.3.5, Table 69.\r
443    *  \return Returns \ref ErrorCode_t type to indicate success or error condition.\r
444    *          \retval LPC_OK On success\r
445    *          \retval ERR_API_INVALID_PARAM2  If unsupported notification type is passed. \r
446    *              \r
447    */\r
448   ErrorCode_t (*SendNotification)(USBD_HANDLE_T hCdc, uint8_t bNotification, uint16_t data);\r
449 \r
450 } USBD_CDC_API_T;\r
451 \r
452 /*-----------------------------------------------------------------------------\r
453  *  Private functions & structures prototypes\r
454  *-----------------------------------------------------------------------------*/\r
455 /** @cond  ADVANCED_API */\r
456 \r
457 typedef struct _CDC_CTRL_T\r
458 {\r
459   USB_CORE_CTRL_T*  pUsbCtrl;\r
460   /* notification buffer */\r
461   uint8_t notice_buf[12];\r
462   CDC_LINE_CODING line_coding;\r
463   uint8_t pad0;\r
464 \r
465   uint8_t cif_num;                 /* control interface number */\r
466   uint8_t dif_num;                 /* data interface number */\r
467   uint8_t epin_num;                /* BULK IN endpoint number */\r
468   uint8_t epout_num;               /* BULK OUT endpoint number */\r
469   uint8_t epint_num;               /* Interrupt IN endpoint number */\r
470   uint8_t pad[3];\r
471   /* user defined functions */\r
472   ErrorCode_t (*SendEncpsCmd) (USBD_HANDLE_T hCDC, uint8_t* buffer, uint16_t len);\r
473   ErrorCode_t (*GetEncpsResp) (USBD_HANDLE_T hCDC, uint8_t** buffer, uint16_t* len);\r
474   ErrorCode_t (*SetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t* buffer, uint16_t len);\r
475   ErrorCode_t (*GetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t** pBuffer, uint16_t* len);\r
476   ErrorCode_t (*ClrCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature);\r
477   ErrorCode_t (*SetCtrlLineState) (USBD_HANDLE_T hCDC, uint16_t state);\r
478   ErrorCode_t (*SendBreak) (USBD_HANDLE_T hCDC, uint16_t state);\r
479   ErrorCode_t (*SetLineCode) (USBD_HANDLE_T hCDC, CDC_LINE_CODING* line_coding);\r
480 \r
481   /* virtual functions */\r
482   ErrorCode_t (*CIC_GetRequest)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* length); \r
483   ErrorCode_t (*CIC_SetRequest)( USBD_HANDLE_T hCdc, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t length);\r
484 \r
485 }USB_CDC_CTRL_T;\r
486 \r
487 /** @cond  DIRECT_API */\r
488 extern uint32_t mwCDC_GetMemSize(USBD_CDC_INIT_PARAM_T* param);\r
489 extern ErrorCode_t mwCDC_init(USBD_HANDLE_T hUsb, USBD_CDC_INIT_PARAM_T* param, USBD_HANDLE_T* phCDC);\r
490 extern ErrorCode_t mwCDC_SendNotification (USBD_HANDLE_T hCdc, uint8_t bNotification, uint16_t data); \r
491 /** @endcond */\r
492 \r
493 /** @endcond */\r
494 \r
495 \r
496 \r
497 \r
498 \r
499 #endif  /* __CDCUSER_H__ */ \r