LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dfuutil_programming_api.h
Go to the documentation of this file.
1 /*
2  * @brief Programming API used with DFU Utility programmer
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 __DFUSEC_PROGRAMMING_API_H_
33 #define __DFUSEC_PROGRAMMING_API_H_
34 
35 #include "board.h"
36 
37 #ifdef __cplusplus
38 extern "C"
39 {
40 #endif
41 
56 typedef struct {
57  uint32_t region_addr; /* Offset address */
58  uint32_t region_size; /* Size in bytes */
60 
65 
69 typedef int32_t (*progalgo_flash_erase_all)(void);
70 
77 typedef int32_t (*progalgo_flash_write)(void *, uint32_t, uint32_t);
78 
85 typedef int32_t (*progalgo_flash_read)(void *, uint32_t, uint32_t);
86 
90 typedef struct {
95 } PROGALGOS_T;
96 
100 typedef struct {
101  /* Number of program regions on the device, it is recommended to
102  keep the number of regions less than 10 */
103  int32_t num_regions;
104  /* This must be a minimum of 64 bytes and a max of 4096 bytes. This must
105  be a factor (1x, 2x, 3x, etc.) of MAXP size */
106  uint32_t buffer_size;
108  const DFUPROG_REGZONE_T *pregions; /* Address and region size array */
109  uint32_t ver; /* Versioning info */
110  const char *algoname; /* Unique name for the algorithm */
112 
117 
121 typedef enum {
122  DFU_HOSTCMD_SETDEBUG, /* Enables/disables debug output */
123  DFU_HOSTCMD_ERASE_ALL, /* Erase the entire device */
124  DFU_HOSTCMD_ERASE_REGION, /* Erase a region defined with addr/size */
125  DFU_HOSTCMD_PROGRAM, /* Program a region defined with addr/size */
126  DFU_HOSTCMD_READBACK, /* Read a region defined with addr/size */
127  DFU_HOSTCMD_RESET, /* Reset the device/board */
128  DFU_HOSTCMD_EXECUTE /* Execute code at address addr */
129 } DFU_HOSTCMD_T;
130 
135 typedef struct {
136  uint32_t hostCmd; /* Host command */
137  uint32_t addr; /* Start of program/erase/read region, or execute address */
138  uint32_t size; /* Size of program/erase/read region */
139  uint32_t magic; /* Should be DFUPROG_VALIDVAL */
141 
149 #define DFUPROG_VALIDVAL (0x18430000 | (0x010A))
150 
155 typedef enum {
156  DFU_OPSTS_IDLE, /* Idle, can accept new host command */
157  DFU_OPSTS_ERRER, /* Erase error */
158  DFU_OPSTS_PROGER, /* Program error */
159  DFU_OPSTS_READER, /* Readback error */
160  DFU_OPSTS_ERRUN, /* Unknown error */
161  DFU_OPSTS_READBUSY, /* Device is busy reading a block of data */
162  DFU_OPSTS_READTRIG, /* Device data is ready to read */
163  DFU_OPSTS_READREADY, /* Block of data is ready */
164  DFU_OPSTS_ERASE_ALL_ST, /* Device is about to start full erase */
165  DFU_OPSTS_ERASE_ST, /* Device is about to start region erase */
166  DFU_OPSTS_ERASE, /* Device is currently erasing */
167  DFU_OPSTS_PROG, /* Device is currently programming a range */
168  DFU_OPSTS_PROG_RSVD, /* Reserved state, not used */
169  DFU_OPSTS_PROG_STREAM, /* Device is in buffer streaming mode */
170  DFU_OPSTS_RESET, /* Will shutdown and reset */
171  DFU_OPSTS_EXEC, /* Will shutdown USB and start execution */
172  DFU_OPSTS_LOOP /* Loop on error after DFU status check */
173 } DFU_OPSTS_T;
174 
180 typedef struct {
181  uint32_t cmdResponse; /* Command responding from host */
182  uint32_t progStatus; /* Current status of system */
183  uint32_t strBytes; /* Number of bytes in string field */
184  uint32_t reserved;
186 
192 void usbDebug(char *str);
193 
198 #ifdef __cplusplus
199 }
200 #endif
201 
202 #endif /* __DFUSEC_PROGRAMMING_API_H_ */