LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
usbd_api.h
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------
2  * U S B - K e r n e l
3  *----------------------------------------------------------------------------
4  * Name: mw_usbd_api.h
5  * Purpose: USB Custom Configuration
6  * Version: V1.20
7  *----------------------------------------------------------------------------
8  * This software is supplied "AS IS" without any warranties, express,
9  * implied or statutory, including but not limited to the implied
10  * warranties of fitness for purpose, satisfactory quality and
11  * noninfringement. Keil extends you a royalty-free right to reproduce
12  * and distribute executable files created using this software for use
13  * on NXP ARM microcontroller devices only. Nothing else gives
14  * you the right to use this software.
15  *
16  * Copyright (c) 2005-2009 Keil Software.
17  * Adaption to LPCxxxx, Copyright (c) 2009 NXP.
18  *----------------------------------------------------------------------------*/
19 
20 #include "error.h"
21 #include "mw_usbd.h"
22 
23 #ifndef __MW_USBD_API_H__
24 #define __MW_USBD_API_H__
25 
26 typedef void* USBD_HANDLE_T;
27 typedef void* USBD_HID_HANDLE_T;
28 
29 /* function pointer types */
32 /* USBD setup request and endpoint event handler type */
34 
35 /* USB descriptors data structure */
36 typedef struct _USB_CORE_DESCS_T
37 {
38  /* all pointers in this structure should be 4 byte aligned */
39  //ALIGNED(4)
40  uint8_t *device_desc;
41  uint8_t *string_desc;
42  uint8_t *full_speed_desc;
43  uint8_t *high_speed_desc;
44  uint8_t *device_qualifier;
46 
47 
48 /* Override functions */
49 typedef struct __USBD_OVERRIDES_T
50 {
62 
63 
64 typedef struct __USBD_API_INIT_PARAM_T
65 {
69  uint8_t max_num_ep; /* max number of endpoints supported by the HW */
70 
71  /* USB Device Events Callback Functions */
77  /*0 - Clear, 1 - Set*/
81 
82  /* USB Core Events Callback Functions */
86 
87  /* cache and mmu translation functions */
88  uint32_t (* virt_to_phys)(void* vaddr);
89  void (* cache_flush)(uint32_t* start_adr, uint32_t* end_adr);
90 
92 
93 //#include "mw_usbd/mw_usbd_hw.h" Batjo
94 #include "mw_usbd_hw.h"
95 
96 /* midleware API */
99 extern void mwUSB_SetupStage (USBD_HANDLE_T hUsb);
104 extern void mwUSB_StallEp0(USBD_HANDLE_T hUsb);
105 
106 
107 /************************************************************
108 * Mass Storage API structures and function prototypes
109 ************************************************************/
110 typedef struct __USBD_MSC_INIT_PARAM_T
111 {
112  /* memory allocation params */
115  /* mass storage paramas */
116  uint8_t* InquiryStr; /* Data pointed by the pointer should be of global scope. */
120  /* Pointer to the interface descriptor within the descriptor
121  * array passed to USBD_Init(). Assumes both HS and FS use same
122  * BULK endpoints. Also the mwMSC_init() assumes that both BULK_IN
123  * and BULK_OUT endpoints have same number. If different the EP_ISR
124  * handlers should be installed manual by user code.
125  */
126  uint8_t* intf_desc;
127  /* user defined functions */
128  void (*MSC_Write)( uint32_t offset, uint8_t** src, uint32_t length);
129  void (*MSC_Read)( uint32_t offset, uint8_t** dst, uint32_t length);
130  ErrorCode_t (*MSC_Verify)( uint32_t offset, uint8_t dst[], uint32_t length);
131  /* optional call back for MSC_Write optimization */
132  void (*MSC_GetWriteBuf)( uint32_t offset, uint8_t** buff_adr, uint32_t length);
133  /* user overridable function */
134  ErrorCode_t (*MSC_Ep0_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
135 
137 
140 
141 /************************************************************
142 * Device Firmware Upgrade (DFU) API structures and function prototypes
143 ************************************************************/
144 typedef struct __USBD_DFU_INIT_PARAM_T
145 {
146  /* memory allocation params */
149  /* DFU paramas */
150  uint16_t wTransferSize;
151 
152  /* Pointer to the interface descriptor within the descriptor
153  * array passed to USBD_Init().
154  */
155  uint8_t* intf_desc;
156  /* user defined functions */
157  /* return DFU_STATUS_ values defined in mw_usbd_dfu.h */
158  uint8_t (*DFU_Write)( uint32_t block_num, uint8_t** src, uint32_t length);
159  /* return
160  * DFU_STATUS_ : values defined in mw_usbd_dfu.h in case of errors
161  * 0 : If end of memory reached
162  * length : Amount of data copied to destination buffer
163  */
164  uint32_t (*DFU_Read)( uint32_t block_num, uint8_t** dst, uint32_t length);
165  /* callback called after download is finished */
166  void (*DFU_Done)(void);
167  /* callback called after USB_REQ_DFU_DETACH is recived */
168  void (*DFU_Detach)(USBD_HANDLE_T hUsb);
169 
170  /* user overridable function */
171  ErrorCode_t (*DFU_Ep0_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
172 
174 
177 
178 /************************************************************
179 * Human Interface Device (HID) API structures and function prototypes
180 ************************************************************/
181 typedef struct _HID_REPORT_T {
182  uint16_t len;
183  uint8_t idle_time;
184  uint8_t __pad;
185  uint8_t* desc;
187 
188 typedef struct __USBD_HID_INIT_PARAM_T
189 {
190  /* memory allocation params */
193  /* HID paramas */
194  uint8_t max_reports;
195 
196  /* Pointer to the interface descriptor within the descriptor
197  * array passed to USBD_Init().
198  */
199  uint8_t* intf_desc;
201 
202  /* user defined functions */
203  /* required functions */
204  ErrorCode_t (*HID_GetReport)( USBD_HID_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* length);
205  ErrorCode_t (*HID_SetReport)( USBD_HID_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t length);
206  /* optional functions */
207  ErrorCode_t (*HID_GetPhysDesc)( USBD_HID_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuf, uint16_t* length);
208  ErrorCode_t (*HID_SetIdle)( USBD_HID_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t idleTime);
209  ErrorCode_t (*HID_SetProtocol)( USBD_HID_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t protocol);
210  ErrorCode_t (*HID_EpIn_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
211  ErrorCode_t (*HID_EpOut_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
212 
213  /* user overridable function */
214  ErrorCode_t (*HID_GetReportDesc)(USBD_HID_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuf, uint16_t* length);
215  ErrorCode_t (*HID_Ep0_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
216 
218 
221 
222 #endif /* __MW_USBD_API_H__ */