| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
usbd_cdcuser.h
Go to the documentation of this file.
1 /*
2 * @brief Definition of functions exported by ROM based CDC function driver
3 *
4 * @note
5 * Copyright(C) NXP Semiconductors, 2012
6 * All rights reserved.
7 *
8 * @par
9 * Software that is described herein is for illustrative purposes only
10 * which provides customers with programming information regarding the
11 * LPC products. This software is supplied "AS IS" without any warranties of
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
13 * all warranties, express or implied, including all implied warranties of
14 * merchantability, fitness for a particular purpose and non-infringement of
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
16 * or liability for the use of the software, conveys no license or rights under any
17 * patent, copyright, mask work right, or any other intellectual property rights in
18 * or to any products. NXP Semiconductors reserves the right to make changes
19 * in the software without notification. NXP Semiconductors also makes no
20 * representation or warranty that such application will be suitable for the
21 * specified use without further testing or modification.
22 *
23 * @par
24 * Permission to use, copy, modify, and distribute this software and its
25 * documentation is hereby granted, under NXP Semiconductors' and its
26 * licensor's relevant copyrights in the software, without fee, provided that it
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
28 * copyright, permission, and disclaimer notice must appear in all copies of
29 * this code.
30 */
31
32 #include "error.h"
33 #include "usbd.h"
34 #include "usbd_cdc.h"
35
36 #ifndef __CDCUSER_H__
37 #define __CDCUSER_H__
38
39
51 /*----------------------------------------------------------------------------
52 We need a buffer for incomming data on USB port because USB receives
53 much faster than UART transmits
54 *---------------------------------------------------------------------------*/
55 /* Buffer masks */
56 #define CDC_BUF_SIZE (128) /* Output buffer in bytes (power 2) */
57 /* large enough for file transfer */
58 #define CDC_BUF_MASK (CDC_BUF_SIZE-1ul)
59
67 typedef struct USBD_CDC_INIT_PARAM
68 {
69 /* memory allocation params */
70 uint32_t mem_base;
75 uint32_t mem_size;
82 uint8_t* cif_intf_desc;
87 uint8_t* dif_intf_desc;
88
89 /* user defined functions */
90
91 /* required functions */
115 ErrorCode_t (*CIC_GetRequest)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* length);
116
145 ErrorCode_t (*CIC_SetRequest)( USBD_HANDLE_T hCdc, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t length);
146
164 ErrorCode_t (*CDC_BulkIN_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
165
183 ErrorCode_t (*CDC_BulkOUT_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
184
185 ErrorCode_t (*SendEncpsCmd) (USBD_HANDLE_T hCDC, uint8_t* buffer, uint16_t len);
186 ErrorCode_t (*GetEncpsResp) (USBD_HANDLE_T hCDC, uint8_t** buffer, uint16_t* len);
187 ErrorCode_t (*SetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t* buffer, uint16_t len);
188 ErrorCode_t (*GetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t** pBuffer, uint16_t* len);
189 ErrorCode_t (*ClrCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature);
190 ErrorCode_t (*SetCtrlLineState) (USBD_HANDLE_T hCDC, uint16_t state);
191 ErrorCode_t (*SendBreak) (USBD_HANDLE_T hCDC, uint16_t mstime);
192 ErrorCode_t (*SetLineCode) (USBD_HANDLE_T hCDC, CDC_LINE_CODING* line_coding);
193
211 ErrorCode_t (*CDC_InterruptEP_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
212
232 ErrorCode_t (*CDC_Ep0_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
233
234 } USBD_CDC_INIT_PARAM_T;
235
242 typedef struct USBD_CDC_API
243 {
255 uint32_t (*GetMemSize)(USBD_CDC_INIT_PARAM_T* param);
256
273 ErrorCode_t (*init)(USBD_HANDLE_T hUsb, USBD_CDC_INIT_PARAM_T* param, USBD_HANDLE_T* phCDC);
274
291 ErrorCode_t (*SendNotification)(USBD_HANDLE_T hCdc, uint8_t bNotification, uint16_t data);
292
293 } USBD_CDC_API_T;
294
295 /*-----------------------------------------------------------------------------
296 * Private functions & structures prototypes
297 *-----------------------------------------------------------------------------*/
300 typedef struct _CDC_CTRL_T
301 {
302 USB_CORE_CTRL_T* pUsbCtrl;
303 /* notification buffer */
304 uint8_t notice_buf[12];
305 CDC_LINE_CODING line_coding;
306
307 uint8_t cif_num; /* control interface number */
308 uint8_t dif_num; /* data interface number */
309 uint8_t epin_num; /* BULK IN endpoint number */
310 uint8_t epout_num; /* BULK OUT endpoint number */
311 uint8_t epint_num; /* Interrupt IN endpoint number */
312
313 /* user defined functions */
314 ErrorCode_t (*SendEncpsCmd) (USBD_HANDLE_T hCDC, uint8_t* buffer, uint16_t len);
315 ErrorCode_t (*GetEncpsResp) (USBD_HANDLE_T hCDC, uint8_t** buffer, uint16_t* len);
316 ErrorCode_t (*SetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t* buffer, uint16_t len);
317 ErrorCode_t (*GetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t** pBuffer, uint16_t* len);
318 ErrorCode_t (*ClrCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature);
319 ErrorCode_t (*SetCtrlLineState) (USBD_HANDLE_T hCDC, uint16_t state);
320 ErrorCode_t (*SendBreak) (USBD_HANDLE_T hCDC, uint16_t state);
321 ErrorCode_t (*SetLineCode) (USBD_HANDLE_T hCDC, CDC_LINE_CODING* line_coding);
322
323 /* virtual functions */
324 ErrorCode_t (*CIC_GetRequest)( USBD_HANDLE_T hCdc, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* length);
325 ErrorCode_t (*CIC_SetRequest)( USBD_HANDLE_T hCdc, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t length);
326
327 }USB_CDC_CTRL_T;
328
329
332 void UsbdCdc_IO_Buffer_Sync_Task(void);
333 void UsbdCdc_SendData(uint8_t* buffer, uint32_t cnt);
334 uint32_t UsbdCdc_RecvData(uint8_t* buffer, uint32_t len);
335
336
337 #endif /* __CDCUSER_H__ */
338