LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
usbd_cdcuser.h
Go to the documentation of this file.
1 /***********************************************************************
2 * $Id: mw_usbd_cdcuser.h.rca 1.3 Tue Nov 1 11:45:07 2011 nlv09221 Experimental $
3 *
4 * Project: USB device ROM Stack
5 *
6 * Description:
7 * USB Communication Device Class User module Definitions.
8 *
9 ***********************************************************************
10 * Copyright(C) 2011, NXP Semiconductor
11 * All rights reserved.
12 *
13 * Software that is described herein is for illustrative purposes only
14 * which provides customers with programming information regarding the
15 * products. This software is supplied "AS IS" without any warranties.
16 * NXP Semiconductors assumes no responsibility or liability for the
17 * use of the software, conveys no license or title under any patent,
18 * copyright, or mask work right to the product. NXP Semiconductors
19 * reserves the right to make changes in the software without
20 * notification. NXP Semiconductors also make no representation or
21 * warranty that such application will be suitable for the specified
22 * use without further testing or modification.
23 **********************************************************************/
24 #ifndef __CDCUSER_H__
25 #define __CDCUSER_H__
26 
27 #include "error.h"
28 #include "usbd.h"
29 #include "usbd_cdc.h"
30 
49 /*----------------------------------------------------------------------------
50  We need a buffer for incomming data on USB port because USB receives
51  much faster than UART transmits
52  *---------------------------------------------------------------------------*/
53 /* Buffer masks */
54 #define CDC_BUF_SIZE (128) /* Output buffer in bytes (power 2) */
55  /* large enough for file transfer */
56 #define CDC_BUF_MASK (CDC_BUF_SIZE-1ul)
57 
65 typedef struct USBD_CDC_INIT_PARAM
66 {
67  /* memory allocation params */
68  uint32_t mem_base;
73  uint32_t mem_size;
80  uint8_t* cif_intf_desc;
85  uint8_t* dif_intf_desc;
86 
87  /* user defined functions */
88 
89  /* required functions */
113  ErrorCode_t (*CIC_GetRequest)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* length);
114 
143  ErrorCode_t (*CIC_SetRequest)( USBD_HANDLE_T hCdc, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t length);
144 
162  ErrorCode_t (*CDC_BulkIN_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
163 
181  ErrorCode_t (*CDC_BulkOUT_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
182 
183  ErrorCode_t (*SendEncpsCmd) (USBD_HANDLE_T hCDC, uint8_t* buffer, uint16_t len);
184  ErrorCode_t (*GetEncpsResp) (USBD_HANDLE_T hCDC, uint8_t** buffer, uint16_t* len);
185  ErrorCode_t (*SetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t* buffer, uint16_t len);
186  ErrorCode_t (*GetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t** pBuffer, uint16_t* len);
187  ErrorCode_t (*ClrCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature);
188  ErrorCode_t (*SetCtrlLineState) (USBD_HANDLE_T hCDC, uint16_t state);
189  ErrorCode_t (*SendBreak) (USBD_HANDLE_T hCDC, uint16_t mstime);
190  ErrorCode_t (*SetLineCode) (USBD_HANDLE_T hCDC, CDC_LINE_CODING* line_coding);
191 
209  ErrorCode_t (*CDC_InterruptEP_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
210 
230  ErrorCode_t (*CDC_Ep0_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
231 
233 
240 typedef struct USBD_CDC_API
241 {
254 
272 
289  ErrorCode_t (*SendNotification)(USBD_HANDLE_T hCdc, uint8_t bNotification, uint16_t data);
290 
292 
293 /*-----------------------------------------------------------------------------
294  * Private functions & structures prototypes
295  *-----------------------------------------------------------------------------*/
298 typedef struct _CDC_CTRL_T
299 {
300  USB_CORE_CTRL_T* pUsbCtrl;
301  /* notification buffer */
302  uint8_t notice_buf[12];
303  CDC_LINE_CODING line_coding;
304  uint8_t pad0;
305 
306  uint8_t cif_num; /* control interface number */
307  uint8_t dif_num; /* data interface number */
308  uint8_t epin_num; /* BULK IN endpoint number */
309  uint8_t epout_num; /* BULK OUT endpoint number */
310  uint8_t epint_num; /* Interrupt IN endpoint number */
311  uint8_t pad[3];
312  /* user defined functions */
313  ErrorCode_t (*SendEncpsCmd) (USBD_HANDLE_T hCDC, uint8_t* buffer, uint16_t len);
314  ErrorCode_t (*GetEncpsResp) (USBD_HANDLE_T hCDC, uint8_t** buffer, uint16_t* len);
315  ErrorCode_t (*SetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t* buffer, uint16_t len);
316  ErrorCode_t (*GetCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature, uint8_t** pBuffer, uint16_t* len);
317  ErrorCode_t (*ClrCommFeature) (USBD_HANDLE_T hCDC, uint16_t feature);
318  ErrorCode_t (*SetCtrlLineState) (USBD_HANDLE_T hCDC, uint16_t state);
319  ErrorCode_t (*SendBreak) (USBD_HANDLE_T hCDC, uint16_t state);
320  ErrorCode_t (*SetLineCode) (USBD_HANDLE_T hCDC, CDC_LINE_CODING* line_coding);
321 
322  /* virtual functions */
323  ErrorCode_t (*CIC_GetRequest)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* length);
324  ErrorCode_t (*CIC_SetRequest)( USBD_HANDLE_T hCdc, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t length);
325 
326 }USB_CDC_CTRL_T;
327 
329 extern uint32_t mwCDC_GetMemSize(USBD_CDC_INIT_PARAM_T* param);
331 extern ErrorCode_t mwCDC_SendNotification (USBD_HANDLE_T hCdc, uint8_t bNotification, uint16_t data);
340 #endif /* __CDCUSER_H__ */