LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 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 {
67  FLASH_ERASE = 52,
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
82 
86 typedef enum {
98  BUSY,
100 
104 typedef struct {
108 
112 typedef struct {
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 
172 {
173  (entry) ((unsigned int *) pCommand, (unsigned int *) pOutput);
174 }
175 
179 typedef struct {
184 
188 typedef struct {
191 
195 typedef struct {
202 
206 typedef struct {
209 
213 typedef struct {
219 
223 typedef struct {
226 
230 typedef struct {
235 
239 typedef struct {
244 
248 typedef struct {
251 
255 typedef struct {
259 
263 typedef struct {
266 
270 typedef struct {
272  uint8_t minor;
273  uint8_t major;
275 
279 typedef struct {
285 
289 typedef struct {
293 
297 typedef struct {
300 
304 typedef struct {
307 
311 typedef struct {
314 
318 typedef struct {
320  uint32_t id[4];
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 */