LPCOpen Platform for LPC18XX/43XX microcontrollers  18XX43XX
LPCOpen Platform for the NXP LPC18XX/43XX family of Microcontrollers
iap_18xx_43xx.h
Go to the documentation of this file.
1 /*
2  * @brief Common IAP support functions
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2013
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 licenser 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 __IAP_H_
33 #define __IAP_H_
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
44 /* IAP command definitions */
45 #define IAP_PREWRRITE_CMD 50
46 #define IAP_WRISECTOR_CMD 51
47 #define IAP_ERSSECTOR_CMD 52
48 #define IAP_BLANK_CHECK_SECTOR_CMD 53
49 #define IAP_REPID_CMD 54
50 #define IAP_READ_BOOT_CODE_CMD 55
51 #define IAP_COMPARE_CMD 56
52 #define IAP_REINVOKE_ISP_CMD 57
53 #define IAP_READ_UID_CMD 58
54 #define IAP_ERASE_PAGE_CMD 59
55 #define IAP_SET_BOOT_FLASH 60
56 #define IAP_EEPROM_WRITE 61
57 #define IAP_EEPROM_READ 62
59 /* IAP response definitions */
60 #define IAP_CMD_SUCCESS 0
61 #define IAP_INVALID_COMMAND 1
62 #define IAP_SRC_ADDR_ERROR 2
63 #define IAP_DST_ADDR_ERROR 3
64 #define IAP_SRC_ADDR_NOT_MAPPED 4
65 #define IAP_DST_ADDR_NOT_MAPPED 5
66 #define IAP_COUNT_ERROR 6
67 #define IAP_INVALID_SECTOR 7
68 #define IAP_SECTOR_NOT_BLANK 8
69 #define IAP_SECTOR_NOT_PREPARED 9
70 #define IAP_COMPARE_ERROR 10
71 #define IAP_BUSY 11
72 #define IAP_PARAM_ERROR 12
73 #define IAP_ADDR_ERROR 13
74 #define IAP_ADDR_NOT_MAPPED 14
75 #define IAP_CMD_LOCKED 15
76 #define IAP_INVALID_CODE 16
77 #define IAP_INVALID_BAUD_RATE 17
78 #define IAP_INVALID_STOP_BIT 18
79 #define IAP_CRP_ENABLED 19
81 /* IAP_ENTRY API function type */
82 typedef void (*IAP_ENTRY_T)(unsigned int[5], unsigned int[4]);
83 
94 uint8_t Chip_IAP_PreSectorForReadWrite(uint32_t strSector, uint32_t endSector, uint8_t bankNum);
95 
105 uint8_t Chip_IAP_CopyRamToFlash(uint32_t dstAdd, uint32_t *srcAdd, uint32_t byteswrt);
106 
115 uint8_t Chip_IAP_EraseSector(uint32_t strSector, uint32_t endSector, uint8_t bankNum);
116 
125 // FIXME - There are two return value (result[0] & result[1]
126 // Result0:Offset of the first non blank word location if the Status Code is
127 // SECTOR_NOT_BLANK.
128 // Result1:Contents of non blank word location.
129 uint8_t Chip_IAP_BlankCheckSector(uint32_t strSector, uint32_t endSector, uint8_t bankNum);
130 
135 uint32_t Chip_IAP_ReadPID(void);
136 
141 uint8_t Chip_IAP_ReadBootCode(void);
142 
152 uint8_t Chip_IAP_Compare(uint32_t dstAdd, uint32_t srcAdd, uint32_t bytescmp);
153 
158 uint8_t Chip_IAP_ReinvokeISP(void);
159 
164 uint32_t Chip_IAP_ReadUID(void);
165 
173 // FIXME - There are four return value
174 // Result0:The first 32-bit word (at the lowest address)
175 // Result1:The second 32-bit word.
176 // Result2:The third 32-bit word.
177 // Result3:The fourth 32-bit word.
178 uint8_t Chip_IAP_ErasePage(uint32_t strPage, uint32_t endPage);
179 
187 uint8_t Chip_IAP_SetBootFlashBank(uint8_t bankNum);
188 
193 #ifdef __cplusplus
194 }
195 #endif
196 
197 #endif /* __IAP_H_ */