LPCOpen Platform
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 */
106  uint8_t (*DFU_Write)( uint32_t block_num, uint8_t** src, uint32_t length, uint8_t* bwPollTimeout);
107 
122  uint32_t (*DFU_Read)( uint32_t block_num, uint8_t** dst, uint32_t length);
123 
133  void (*DFU_Done)(void);
134 
151  void (*DFU_Detach)(USBD_HANDLE_T hUsb);
152 
172  ErrorCode_t (*DFU_Ep0_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
173 
175 
176 
183 typedef struct USBD_DFU_API
184 {
196  uint32_t (*GetMemSize)(USBD_DFU_INIT_PARAM_T* param);
197 
218  ErrorCode_t (*init)(USBD_HANDLE_T hUsb, USBD_DFU_INIT_PARAM_T* param, uint32_t init_state);
219 
221 
222 /*-----------------------------------------------------------------------------
223  * Private functions & structures prototypes
224  *-----------------------------------------------------------------------------*/
227 typedef struct _USBD_DFU_CTRL_T
228 {
229  /*ALIGNED(4)*/ DFU_STATUS_T dfu_req_get_status;
230  uint8_t dfu_state;
231  uint8_t dfu_status;
232  uint8_t download_done;
233  uint8_t if_num; /* interface number */
234 
235  uint8_t* xfr_buf;
236  USB_DFU_FUNC_DESCRIPTOR* dfu_desc;
237 
238  USB_CORE_CTRL_T* pUsbCtrl;
239  /* user defined functions */
240  /* return DFU_STATUS_ values defined in mw_usbd_dfu.h */
241  uint8_t (*DFU_Write)( uint32_t block_num, uint8_t** src, uint32_t length, uint8_t* bwPollTimeout);
242  /* return
243  * DFU_STATUS_ : values defined in mw_usbd_dfu.h in case of errors
244  * 0 : If end of memory reached
245  * length : Amount of data copied to destination buffer
246  */
247  uint32_t (*DFU_Read)( uint32_t block_num, uint8_t** dst, uint32_t length);
248  /* callback called after download is finished */
249  void (*DFU_Done)(void);
250  /* callback called after USB_REQ_DFU_DETACH is recived */
251  void (*DFU_Detach)(USBD_HANDLE_T hUsb);
252 
253 } USBD_DFU_CTRL_T;
254 
255 
258 #endif /* __DFUUSER_H__ */