LPCOpen Platform for LPC112X microcontrollers  112X
LPCOpen Platform for the NXP LPC112X family of Microcontrollers
iap.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_EEPROM_WRITE 61
56 #define IAP_EEPROM_READ 62
58 /* IAP response definitions */
59 #define IAP_CMD_SUCCESS 0
60 #define IAP_INVALID_COMMAND 1
61 #define IAP_SRC_ADDR_ERROR 2
62 #define IAP_DST_ADDR_ERROR 3
63 #define IAP_SRC_ADDR_NOT_MAPPED 4
64 #define IAP_DST_ADDR_NOT_MAPPED 5
65 #define IAP_COUNT_ERROR 6
66 #define IAP_INVALID_SECTOR 7
67 #define IAP_SECTOR_NOT_BLANK 8
68 #define IAP_SECTOR_NOT_PREPARED 9
69 #define IAP_COMPARE_ERROR 10
70 #define IAP_BUSY 11
71 #define IAP_PARAM_ERROR 12
72 #define IAP_ADDR_ERROR 13
73 #define IAP_ADDR_NOT_MAPPED 14
74 #define IAP_CMD_LOCKED 15
75 #define IAP_INVALID_CODE 16
76 #define IAP_INVALID_BAUD_RATE 17
77 #define IAP_INVALID_STOP_BIT 18
78 #define IAP_CRP_ENABLED 19
80 /* IAP_ENTRY API function type */
81 typedef void (*IAP_ENTRY_T)(unsigned int[], unsigned int[]);
82 
92 uint8_t Chip_IAP_PreSectorForReadWrite(uint32_t strSector, uint32_t endSector);
93 
103 uint8_t Chip_IAP_CopyRamToFlash(uint32_t dstAdd, uint32_t *srcAdd, uint32_t byteswrt);
104 
112 uint8_t Chip_IAP_EraseSector(uint32_t strSector, uint32_t endSector);
113 
121 // FIXME - There are two return value (result[0] & result[1]
122 // Result0:Offset of the first non blank word location if the Status Code is
123 // SECTOR_NOT_BLANK.
124 // Result1:Contents of non blank word location.
125 uint8_t Chip_IAP_BlankCheckSector(uint32_t strSector, uint32_t endSector);
126 
131 uint32_t Chip_IAP_ReadPID(void);
132 
137 uint32_t Chip_IAP_ReadBootCode(void);
138 
148 uint8_t Chip_IAP_Compare(uint32_t dstAdd, uint32_t srcAdd, uint32_t bytescmp);
149 
154 uint8_t Chip_IAP_ReinvokeISP(void);
155 
160 uint32_t Chip_IAP_ReadUID(uint32_t* uid);
161 
169 // FIXME - There are four return value
170 // Result0:The first 32-bit word (at the lowest address)
171 // Result1:The second 32-bit word.
172 // Result2:The third 32-bit word.
173 // Result3:The fourth 32-bit word.
174 uint8_t Chip_IAP_ErasePage(uint32_t strPage, uint32_t endPage);
175 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif /* __IAP_H_ */