| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
flash_001.h
Go to the documentation of this file.
1 /*
2 * @brief Flash/EEPROM programming
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 __FLASH_EEPROM_001_H
33 #define __FLASH_EEPROM_001_H
34
35 #include "sys_config.h"
36 #include "cmsis.h"
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
47 #if defined(CHIP_LPC1347)
48 #define ERASE_PAGE_SUPPORT
49 #define EEPROM_RW_SUPPORT
50 #endif
51
53 #define FLASH_PARAMETER_NUM (5)
54
56 #define FLASH_RESULT_NUM (4)
57
59 typedef void (*FLASH_ENTRY_T)(unsigned int[], unsigned int[]);
60
64 typedef enum {
65 FLASH_PREPARE = 50,
66 FLASH_COPY_RAM_TO_FLASH = 51,
67 FLASH_ERASE = 52,
68 FLASH_BLANK_CHECK = 53,
69 FLASH_READ_PART_ID = 54,
70 FLASH_READ_BOOT_VER = 55,
71 FLASH_COMPARE = 56,
72 FLASH_REINVOKE_ISP = 57,
73 FLASH_READ_UID = 58,
74 #if defined(ERASE_PAGE_SUPPORT)
75 FLASH_ERASE_PAGE = 59,
76 #endif
77 #if defined(EEPROM_RW_SUPPORT)
78 FLASH_EEPROM_WRITE = 61,
79 FLASH_EEPROM_READ = 62,
80 #endif
81 } FLASH_CMD_CODE_T;
82
86 typedef enum {
87 CMD_SUCCESS,
88 INVALID_COMMAND,
89 SRC_ADDR_ERROR,
90 DST_ADDR_ERROR,
91 SRC_ADDR_NOT_MAPPED,
92 DST_ADDR_NOT_MAPPED,
93 COUNT_ERROR,
94 INVALID_SECTOR,
95 SECTOR_NOT_BLANK,
96 SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION,
97 COMPARE_ERROR,
98 BUSY,
99 } FLASH_STATUS_CODE_T;
100
104 typedef struct {
105 uint32_t cmd;
106 uint32_t pParams[FLASH_PARAMETER_NUM];
107 } FLASH_COMMAND_T;
108
112 typedef struct {
113 uint32_t status;
114 uint32_t pResult[FLASH_RESULT_NUM];
115 } FLASH_OUTPUT_T;
116
117 /* Flash Programming Command Description
118 Command Parameters Return Code Result
119 ----------------------------------------------------------------------------------------------------------
120 FLASH_PREPARE Start Sector Number CMD_SUCCESS None
121 End Sector Number BUSY
122 INVALID_SECTOR
123 FLASH_COPY_RAM2FLASH Destination Flash Addr CMD_SUCCESS None
124 Source RAM Addr SRC_ADDR_ERROR
125 Number of bytes written SRC_ADDR_NOT_MAPPED
126 CCLK in kHz DST_ADDR_NOT_MAPPED
127 COUNT_ERROR
128 SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION
129 BUSY
130 FLASH_ERASE Start Sector Number CMD_SUCCESS None
131 Emd Sector Number BUSY
132 CCLK in kHz SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION
133 INVALID_SECTOR
134 FLASH_BLANK_CHECK Start Sector Number CMD_SUCCESS Non Blank Sector Offset(if Status code is SECTOR_NOT_BLANK)
135 End Sector Number BUSY Content of non blank word location
136 SECTOR_NOT_BLANK
137 INVALID_SECTOR
138 FLASH_READ_PART_ID None CMD_SUCCESS Part ID
139 FLASH_READ_BOOT_VER None CMD_SUCCESS <byte1(Major)>.<byte0(Minor)>
140 FLASH_COMPARE Destination Addr CMD_SUCCESS Offset of the first mismatch
141 Source Address COMPARE_ERROR
142 Number of bytes compared COUNT_ERROR
143 ADDR_ERROR
144 ADDR_NOT_MAPPED
145 FLASH_REINVOKE_ISP None None None
146 FLASH_READ_UID None CMD_SUCCESS The first 32-bit word
147 The second 32-bit word.
148 The third 32-bit word.
149 The fourth 32-bit word
150 FLASH_ERASE_PAGE Start Page Number CMD_SUCCESS None
151 End Page Number BUSY
152 CCLK in kHz SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION
153 INVALID_SECTOR
154 FLASH_EEPROM_WRITE EEPROM Addr CMD_SUCCESS None
155 RAM Addr SRC_ADDR_NOT_MAPPED
156 Number of bytes written DST_ADDR_NOT_MAPPED
157 CCLK in kHz
158 FLASH_EEPROM_READ EEPROM Addr CMD_SUCCESS None
159 RAM Addr SRC_ADDR_NOT_MAPPED
160 Number of bytes read DST_ADDR_NOT_MAPPED
161 CCLK in kHz
162 */
163
171 STATIC INLINE void IP_FLASH_Execute(FLASH_ENTRY_T entry, FLASH_COMMAND_T *pCommand, FLASH_OUTPUT_T *pOutput)
172 {
173 (entry) ((unsigned int *) pCommand, (unsigned int *) pOutput);
174 }
175
179 typedef struct {
180 uint32_t cmd;
181 uint32_t start;
182 uint32_t end;
183 } FLASH_PREPARE_SECTORS_COMMAND_T;
184
188 typedef struct {
189 uint32_t status;
190 } FLASH_PREPARE_SECTORS_OUTPUT_T;
191
195 typedef struct {
196 uint32_t cmd;
197 uint32_t dst;
198 uint32_t src;
199 uint32_t byteNum;
200 uint32_t cclk;
201 } FLASH_COPY_RAM_TO_FLASH_COMMAND_T;
202
206 typedef struct {
207 uint32_t status;
208 } FLASH_COPY_RAM_TO_FLASH_OUTPUT_T;
209
213 typedef struct {
214 uint32_t cmd;
215 uint32_t start;
216 uint32_t end;
217 uint32_t cclk;
218 } FLASH_ERASE_SECTORS_COMMAND_T;
219
223 typedef struct {
224 uint32_t status;
225 } FLASH_ERASE_SECTORS_OUTPUT_T;
226
230 typedef struct {
231 uint32_t cmd;
232 uint32_t start;
233 uint32_t end;
234 } FLASH_BLANK_CHECK_SECTORS_COMMAND_T;
235
239 typedef struct {
240 uint32_t status;
241 uint32_t firstNonBlankLoc;
242 uint32_t firstNonBlankVal;
243 } FLASH_BLANK_CHECK_SECTORS_OUTPUT_T;
244
248 typedef struct {
249 uint32_t cmd;
250 } FLASH_READ_PART_ID_COMMAND_T;
251
255 typedef struct {
256 uint32_t status;
257 uint32_t partID;
258 } FLASH_READ_PART_ID_OUTPUT_T;
259
263 typedef struct {
264 uint32_t cmd;
265 } FLASH_READ_BOOTCODE_VER_COMMAND_T;
266
270 typedef struct {
271 uint32_t status;
272 uint8_t minor;
273 uint8_t major;
274 } FLASH_READ_BOOTCODE_VER_OUTPUT_T;
275
279 typedef struct {
280 uint32_t cmd;
281 uint32_t dst;
282 uint32_t src;
283 uint32_t byteNum;
284 } FLASH_COMPARE_MEM_COMMAND_T;
285
289 typedef struct {
290 uint32_t status;
291 uint32_t offset;
292 } FLASH_COMPARE_MEM_OUTPUT_T;
293
297 typedef struct {
298 uint32_t cmd;
299 } FLASH_REINVOKE_ISP_COMMAND_T;
300
304 typedef struct {
305 uint32_t status;
306 } FLASH_REINVOKE_ISP_OUTPUT_T;
307
311 typedef struct {
312 uint32_t cmd;
313 } FLASH_READ_UID_COMMAND_T;
314
318 typedef struct {
319 uint32_t status;
320 uint32_t id[4];
321 } FLASH_READ_UID_OUTPUT_T;
322
323 #if defined(ERASE_PAGE_SUPPORT)
324
327 typedef struct {
328 uint32_t cmd;
329 uint32_t start;
330 uint32_t end;
331 uint32_t cclk;
332 } FLASH_ERASE_PAGES_COMMAND_T;
333
337 typedef struct {
338 uint32_t status;
339 } FLASH_ERASE_PAGES_OUTPUT_T;
340
341 #endif /* defined(ERASE_PAGE_SUPPORT) */
342
343 #if defined(EEPROM_RW_SUPPORT)
344
347 typedef struct {
348 uint32_t cmd;
349 uint32_t eepromAddr;
350 uint32_t ramAddr;
351 uint32_t byteNum;
352 uint32_t cclk;
353 } EEPROM_WRITE_COMMAND_T;
354
358 typedef struct {
359 uint32_t status;
360 } EEPROM_WRITE_OUTPUT_T;
361
365 typedef struct {
366 uint32_t cmd;
367 uint32_t eepromAddr;
368 uint32_t ramAddr;
369 uint32_t byteNum;
370 uint32_t cclk;
371 } EEPROM_READ_COMMAND_T;
372
376 typedef struct {
377 uint32_t status;
378 } EEPROM_READ_OUTPUT_T;
379
380 #endif /* defined(EEPROM_RW_SUPPORT) */
381
386 #ifdef __cplusplus
387 }
388 #endif
389
390 #endif /* __FLASH_EEPROM_001_H */