| USBD ROM Stack 2.0 ROM based USB device stack

mw_usbd_cdcuser.h
Go to the documentation of this file.
1 /***********************************************************************
2 * $Id:: mw_usbd_cdcuser.h 331 2012-08-09 18:54:34Z usb10131 $
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 "mw_usbd.h"
29 #include "mw_usbd_cdc.h"
30
50 /*----------------------------------------------------------------------------
51 We need a buffer for incoming data on USB port because USB receives
52 much faster than UART transmits
53 *---------------------------------------------------------------------------*/
54 /* Buffer masks */
55 #define CDC_BUF_SIZE (128) /* Output buffer in bytes (power 2) */
56 /* large enough for file transfer */
57 #define CDC_BUF_MASK (CDC_BUF_SIZE - 1ul)
58
66 typedef struct USBD_CDC_INIT_PARAM {
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 */
120 ErrorCode_t (*CIC_GetRequest)(USBD_HANDLE_T hHid, USB_SETUP_PACKET *pSetup, uint8_t * *pBuffer, uint16_t *length);
121
156 ErrorCode_t (*CIC_SetRequest)(USBD_HANDLE_T hCdc, USB_SETUP_PACKET *pSetup, uint8_t * *pBuffer, uint16_t length);
157
175 ErrorCode_t (*CDC_BulkIN_Hdlr)(USBD_HANDLE_T hUsb, void *data, uint32_t event);
176
194 ErrorCode_t (*CDC_BulkOUT_Hdlr)(USBD_HANDLE_T hUsb, void *data, uint32_t event);
195
211 ErrorCode_t (*SendEncpsCmd)(USBD_HANDLE_T hCDC, uint8_t *buffer, uint16_t len);
212
230 ErrorCode_t (*GetEncpsResp)(USBD_HANDLE_T hCDC, uint8_t * *buffer, uint16_t *len);
231
248 ErrorCode_t (*SetCommFeature)(USBD_HANDLE_T hCDC, uint16_t feature, uint8_t *buffer, uint16_t len);
249
268 ErrorCode_t (*GetCommFeature)(USBD_HANDLE_T hCDC, uint16_t feature, uint8_t * *pBuffer, uint16_t *len);
269
285 ErrorCode_t (*ClrCommFeature)(USBD_HANDLE_T hCDC, uint16_t feature);
286
303 ErrorCode_t (*SetCtrlLineState)(USBD_HANDLE_T hCDC, uint16_t state);
304
321 ErrorCode_t (*SendBreak)(USBD_HANDLE_T hCDC, uint16_t mstime);
322
339 ErrorCode_t (*SetLineCode)(USBD_HANDLE_T hCDC, CDC_LINE_CODING *line_coding);
340
358 ErrorCode_t (*CDC_InterruptEP_Hdlr)(USBD_HANDLE_T hUsb, void *data, uint32_t event);
359
379 ErrorCode_t (*CDC_Ep0_Hdlr)(USBD_HANDLE_T hUsb, void *data, uint32_t event);
380
381 } USBD_CDC_INIT_PARAM_T;
382
389 typedef struct USBD_CDC_API {
401 uint32_t (*GetMemSize)(USBD_CDC_INIT_PARAM_T *param);
402
419 ErrorCode_t (*init)(USBD_HANDLE_T hUsb, USBD_CDC_INIT_PARAM_T *param, USBD_HANDLE_T *phCDC);
420
446 ErrorCode_t (*SendNotification)(USBD_HANDLE_T hCdc, uint8_t bNotification, uint16_t data);
447
448 } USBD_CDC_API_T;
449
450 /*-----------------------------------------------------------------------------
451 * Private functions & structures prototypes
452 *-----------------------------------------------------------------------------*/
455 typedef struct _CDC_CTRL_T {
456 USB_CORE_CTRL_T *pUsbCtrl;
457 /* notification buffer */
458 uint8_t notice_buf[12];
459 CDC_LINE_CODING line_coding;
460 uint8_t pad0;
461
462 uint8_t cif_num; /* control interface number */
463 uint8_t dif_num; /* data interface number */
464 uint8_t epin_num; /* BULK IN endpoint number */
465 uint8_t epout_num; /* BULK OUT endpoint number */
466 uint8_t epint_num; /* Interrupt IN endpoint number */
467 uint8_t pad[3];
468 /* user defined functions */
469 ErrorCode_t (*SendEncpsCmd)(USBD_HANDLE_T hCDC, uint8_t *buffer, uint16_t len);
470 ErrorCode_t (*GetEncpsResp)(USBD_HANDLE_T hCDC, uint8_t * *buffer, uint16_t *len);
471 ErrorCode_t (*SetCommFeature)(USBD_HANDLE_T hCDC, uint16_t feature, uint8_t *buffer, uint16_t len);
472 ErrorCode_t (*GetCommFeature)(USBD_HANDLE_T hCDC, uint16_t feature, uint8_t * *pBuffer, uint16_t *len);
473 ErrorCode_t (*ClrCommFeature)(USBD_HANDLE_T hCDC, uint16_t feature);
474 ErrorCode_t (*SetCtrlLineState)(USBD_HANDLE_T hCDC, uint16_t state);
475 ErrorCode_t (*SendBreak)(USBD_HANDLE_T hCDC, uint16_t state);
476 ErrorCode_t (*SetLineCode)(USBD_HANDLE_T hCDC, CDC_LINE_CODING *line_coding);
477
478 /* virtual functions */
479 ErrorCode_t (*CIC_GetRequest)(USBD_HANDLE_T hHid, USB_SETUP_PACKET *pSetup, uint8_t * *pBuffer, uint16_t *length);
480 ErrorCode_t (*CIC_SetRequest)(USBD_HANDLE_T hCdc, USB_SETUP_PACKET *pSetup, uint8_t * *pBuffer, uint16_t length);
481
482 } USB_CDC_CTRL_T;
483
485 extern uint32_t mwCDC_GetMemSize(USBD_CDC_INIT_PARAM_T *param);
486
487 extern ErrorCode_t mwCDC_init(USBD_HANDLE_T hUsb, USBD_CDC_INIT_PARAM_T *param, USBD_HANDLE_T *phCDC);
488
489 extern ErrorCode_t mwCDC_SendNotification (USBD_HANDLE_T hCdc, uint8_t bNotification, uint16_t data);
490
495 #endif /* __CDCUSER_H__ */
ErrorCode_t
ErrorCode_t
Definition: error.h:38
USBD_CDC_INIT_PARAM_T::mem_size
uint32_t mem_size
Definition: mw_usbd_cdcuser.h:73
error.h
Error code returned by Boot ROM drivers/library functions.This file contains unified error codes to b...
USBD_CDC_API_T
CDC class API functions structure.This module exposes functions which interact directly with USB devi...
Definition: mw_usbd_cdcuser.h:389
USBD_CDC_INIT_PARAM_T::cif_intf_desc
uint8_t * cif_intf_desc
Definition: mw_usbd_cdcuser.h:80
mw_usbd.h
Common definitions and declarations for the USB stack.
USBD_CDC_INIT_PARAM_T
Communication Device Class function driver initialization parameter data structure.
Definition: mw_usbd_cdcuser.h:66
USBD_HANDLE_T
void * USBD_HANDLE_T
Definition: mw_usbd.h:704
USBD_CDC_INIT_PARAM_T::mem_base
uint32_t mem_base
Definition: mw_usbd_cdcuser.h:68
USBD_CDC_INIT_PARAM_T::dif_intf_desc
uint8_t * dif_intf_desc
Definition: mw_usbd_cdcuser.h:85