LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
usbd_dfuuser.h
Go to the documentation of this file.
1 /*
2  * @brief Definition of functions exported by ROM based DFU 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 #ifndef __DFUUSER_H__
33 #define __DFUUSER_H__
34 
35 #include "usbd.h"
36 #include "usbd_dfu.h"
37 #include "usbd_core.h"
38 
39 
62 typedef struct USBD_DFU_INIT_PARAM
63 {
64  /* memory allocation params */
65  uint32_t mem_base;
70  uint32_t mem_size;
73  /* DFU paramas */
74  uint16_t wTransferSize;
84  uint8_t* intf_desc;
85  /* user defined functions */
105  uint8_t (*DFU_Write)( uint32_t block_num, uint8_t** src, uint32_t length, uint8_t* bwPollTimeout);
106 
120  uint32_t (*DFU_Read)( uint32_t block_num, uint8_t** dst, uint32_t length);
121 
131  void (*DFU_Done)(void);
132 
149  void (*DFU_Detach)(USBD_HANDLE_T hUsb);
150 
170  ErrorCode_t (*DFU_Ep0_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
171 
173 
174 
181 typedef struct USBD_DFU_API
182 {
194  uint32_t (*GetMemSize)(USBD_DFU_INIT_PARAM_T* param);
195 
217 
219 
220 /*-----------------------------------------------------------------------------
221  * Private functions & structures prototypes
222  *-----------------------------------------------------------------------------*/
225 typedef struct _USBD_DFU_CTRL_T
226 {
227  /*ALIGNED(4)*/ DFU_STATUS_T dfu_req_get_status;
228  uint8_t dfu_state;
229  uint8_t dfu_status;
230  uint8_t download_done;
231  uint8_t if_num; /* interface number */
232 
233  uint8_t* xfr_buf;
234  USB_DFU_FUNC_DESCRIPTOR* dfu_desc;
235 
236  USB_CORE_CTRL_T* pUsbCtrl;
237  /* user defined functions */
238  /* return DFU_STATUS_ values defined in mw_usbd_dfu.h */
239  uint8_t (*DFU_Write)( uint32_t block_num, uint8_t** src, uint32_t length, uint8_t* bwPollTimeout);
240  /* return
241  * DFU_STATUS_ : values defined in mw_usbd_dfu.h in case of errors
242  * 0 : If end of memory reached
243  * length : Amount of data copied to destination buffer
244  */
245  uint32_t (*DFU_Read)( uint32_t block_num, uint8_t** dst, uint32_t length);
246  /* callback called after download is finished */
247  void (*DFU_Done)(void);
248  /* callback called after USB_REQ_DFU_DETACH is recived */
249  void (*DFU_Detach)(USBD_HANDLE_T hUsb);
250 
251 } USBD_DFU_CTRL_T;
252 
253 
256 #endif /* __DFUUSER_H__ */