123
Fork of LG by
IAP.c@132:2c7bec5cf6fe, 2016-04-13 (annotated)
- Committer:
- Kovalev_D
- Date:
- Wed Apr 13 15:01:16 2016 +0000
- Revision:
- 132:2c7bec5cf6fe
- Parent:
- IAP.cpp@130:1421dda4d7e7
- Child:
- 183:c7a9c309086c
fhfh
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kovalev_D | 132:2c7bec5cf6fe | 1 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 2 | * $Id$ |
Kovalev_D | 132:2c7bec5cf6fe | 3 | * |
Kovalev_D | 132:2c7bec5cf6fe | 4 | * Project: NXP LPC1700 Secondary Bootloader Example |
Kovalev_D | 132:2c7bec5cf6fe | 5 | * |
Kovalev_D | 132:2c7bec5cf6fe | 6 | * Description: Provides access to In-Application Programming (IAP) routines |
Kovalev_D | 132:2c7bec5cf6fe | 7 | * contained within the bootROM sector of LPC1100 devices. |
Kovalev_D | 132:2c7bec5cf6fe | 8 | * |
Kovalev_D | 132:2c7bec5cf6fe | 9 | * Copyright(C) 2010, NXP Semiconductor |
Kovalev_D | 132:2c7bec5cf6fe | 10 | * All rights reserved. |
Kovalev_D | 132:2c7bec5cf6fe | 11 | * |
Kovalev_D | 132:2c7bec5cf6fe | 12 | ***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 13 | * Software that is described herein is for illustrative purposes only |
Kovalev_D | 132:2c7bec5cf6fe | 14 | * which provides customers with programming information regarding the |
Kovalev_D | 132:2c7bec5cf6fe | 15 | * products. This software is supplied "AS IS" without any warranties. |
Kovalev_D | 132:2c7bec5cf6fe | 16 | * NXP Semiconductors assumes no responsibility or liability for the |
Kovalev_D | 132:2c7bec5cf6fe | 17 | * use of the software, conveys no license or title under any patent, |
Kovalev_D | 132:2c7bec5cf6fe | 18 | * copyright, or mask work right to the product. NXP Semiconductors |
Kovalev_D | 132:2c7bec5cf6fe | 19 | * reserves the right to make changes in the software without |
Kovalev_D | 132:2c7bec5cf6fe | 20 | * notification. NXP Semiconductors also make no representation or |
Kovalev_D | 132:2c7bec5cf6fe | 21 | * warranty that such application will be suitable for the specified |
Kovalev_D | 132:2c7bec5cf6fe | 22 | * use without further testing or modification. |
Kovalev_D | 132:2c7bec5cf6fe | 23 | *****************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 24 | #include "IAP.h" |
Kovalev_D | 132:2c7bec5cf6fe | 25 | #include <LPC17xx.h> |
Kovalev_D | 130:1421dda4d7e7 | 26 | |
Kovalev_D | 132:2c7bec5cf6fe | 27 | /* IAP Command Definitions */ |
Kovalev_D | 132:2c7bec5cf6fe | 28 | #define IAP_CMD_PREPARE_SECTORS 50 |
Kovalev_D | 132:2c7bec5cf6fe | 29 | #define IAP_CMD_COPY_RAM_TO_FLASH 51 |
Kovalev_D | 132:2c7bec5cf6fe | 30 | #define IAP_CMD_ERASE_SECTORS 52 |
Kovalev_D | 132:2c7bec5cf6fe | 31 | #define IAP_CMD_BLANK_CHECK_SECTORS 53 |
Kovalev_D | 132:2c7bec5cf6fe | 32 | #define IAP_CMD_READ_PART_ID 54 |
Kovalev_D | 132:2c7bec5cf6fe | 33 | #define IAP_CMD_READ_BOOT_ROM_VERSION 55 |
Kovalev_D | 132:2c7bec5cf6fe | 34 | #define IAP_CMD_COMPARE 56 |
Kovalev_D | 132:2c7bec5cf6fe | 35 | #define IAP_CMD_REINVOKE_ISP 57 |
Kovalev_D | 132:2c7bec5cf6fe | 36 | #define IAP_CMD_READ_SERIAL_NUMBER 58 |
Kovalev_D | 130:1421dda4d7e7 | 37 | |
Kovalev_D | 132:2c7bec5cf6fe | 38 | /* IAP boot ROM location and access function */ |
Kovalev_D | 132:2c7bec5cf6fe | 39 | #define IAP_ROM_LOCATION 0x1FFF1FF1UL |
Kovalev_D | 132:2c7bec5cf6fe | 40 | #define IAP_EXECUTE_CMD(a, b) ((void (*)())(IAP_ROM_LOCATION))(a, b) |
Kovalev_D | 130:1421dda4d7e7 | 41 | |
Kovalev_D | 132:2c7bec5cf6fe | 42 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 43 | ** Function name: u32IAP_PrepareSectors |
Kovalev_D | 132:2c7bec5cf6fe | 44 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 45 | ** Description: Prepares sector(s) for erasing or write operations. This |
Kovalev_D | 132:2c7bec5cf6fe | 46 | ** command must be executed before executing the "Copy RAM to |
Kovalev_D | 132:2c7bec5cf6fe | 47 | ** Flash" or "Erase Sector(s)" commands. |
Kovalev_D | 132:2c7bec5cf6fe | 48 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 49 | ** Parameters: u32StartSector - Number of first sector to prepare. |
Kovalev_D | 132:2c7bec5cf6fe | 50 | ** u32EndSector - Number of last sector to prepare. |
Kovalev_D | 132:2c7bec5cf6fe | 51 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 52 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 53 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 54 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 55 | uint32_t u32IAP_PrepareSectors(uint32_t u32StartSector, uint32_t u32EndSector) |
Kovalev_D | 132:2c7bec5cf6fe | 56 | { |
Kovalev_D | 132:2c7bec5cf6fe | 57 | uint32_t u32Status; |
Kovalev_D | 132:2c7bec5cf6fe | 58 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 59 | uint32_t au32Command[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 60 | |
Kovalev_D | 132:2c7bec5cf6fe | 61 | if (u32EndSector < u32StartSector) |
Kovalev_D | 132:2c7bec5cf6fe | 62 | { |
Kovalev_D | 132:2c7bec5cf6fe | 63 | u32Status = IAP_STA_INVALD_PARAM; |
Kovalev_D | 132:2c7bec5cf6fe | 64 | } |
Kovalev_D | 132:2c7bec5cf6fe | 65 | else |
Kovalev_D | 132:2c7bec5cf6fe | 66 | { |
Kovalev_D | 132:2c7bec5cf6fe | 67 | au32Command[0] = IAP_CMD_PREPARE_SECTORS; |
Kovalev_D | 132:2c7bec5cf6fe | 68 | au32Command[1] = u32StartSector; |
Kovalev_D | 132:2c7bec5cf6fe | 69 | au32Command[2] = u32EndSector; |
Kovalev_D | 132:2c7bec5cf6fe | 70 | |
Kovalev_D | 132:2c7bec5cf6fe | 71 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 132:2c7bec5cf6fe | 72 | |
Kovalev_D | 132:2c7bec5cf6fe | 73 | u32Status = au32Result[0]; |
Kovalev_D | 132:2c7bec5cf6fe | 74 | } |
Kovalev_D | 132:2c7bec5cf6fe | 75 | return u32Status; |
Kovalev_D | 130:1421dda4d7e7 | 76 | } |
Kovalev_D | 130:1421dda4d7e7 | 77 | |
Kovalev_D | 132:2c7bec5cf6fe | 78 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 79 | ** Function name: u32IAP_CopyRAMToFlash |
Kovalev_D | 132:2c7bec5cf6fe | 80 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 81 | ** Description: Program the flash memory with data stored in RAM. |
Kovalev_D | 132:2c7bec5cf6fe | 82 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 83 | ** Parameters: u32DstAddr - Destination Flash address, should be a 256 |
Kovalev_D | 132:2c7bec5cf6fe | 84 | ** byte boundary. |
Kovalev_D | 132:2c7bec5cf6fe | 85 | ** u32SrcAddr - Source RAM address, should be a word boundary |
Kovalev_D | 132:2c7bec5cf6fe | 86 | ** u32Len - Number of 8-bit bytes to write, must be 256 |
Kovalev_D | 132:2c7bec5cf6fe | 87 | ** 512, 1024, or 4096. |
Kovalev_D | 132:2c7bec5cf6fe | 88 | * |
Kovalev_D | 132:2c7bec5cf6fe | 89 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 90 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 91 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 92 | uint32_t u32IAP_CopyRAMToFlash(uint32_t u32DstAddr, uint32_t u32SrcAddr, uint32_t u32Len) |
Kovalev_D | 130:1421dda4d7e7 | 93 | { |
Kovalev_D | 132:2c7bec5cf6fe | 94 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 95 | uint32_t au32Command[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 96 | au32Command[0] = IAP_CMD_COPY_RAM_TO_FLASH; |
Kovalev_D | 132:2c7bec5cf6fe | 97 | au32Command[1] = u32DstAddr; |
Kovalev_D | 132:2c7bec5cf6fe | 98 | au32Command[2] = u32SrcAddr; |
Kovalev_D | 132:2c7bec5cf6fe | 99 | au32Command[3] = u32Len; |
Kovalev_D | 132:2c7bec5cf6fe | 100 | // au32Command[4] = SystemFrequency / 1000UL; /* Core clock frequency in kHz */ |
Kovalev_D | 132:2c7bec5cf6fe | 101 | au32Command[4] = SystemCoreClock1 / 1000UL; /* Core clock frequency in kHz */ |
Kovalev_D | 130:1421dda4d7e7 | 102 | |
Kovalev_D | 132:2c7bec5cf6fe | 103 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 130:1421dda4d7e7 | 104 | |
Kovalev_D | 132:2c7bec5cf6fe | 105 | return au32Result[0]; |
Kovalev_D | 130:1421dda4d7e7 | 106 | } |
Kovalev_D | 130:1421dda4d7e7 | 107 | |
Kovalev_D | 132:2c7bec5cf6fe | 108 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 109 | ** Function name: u32IAP_EraseSectors |
Kovalev_D | 132:2c7bec5cf6fe | 110 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 111 | ** Description: Erase a sector or multiple sectors of on-chip Flash memory. |
Kovalev_D | 132:2c7bec5cf6fe | 112 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 113 | ** Parameters: u32StartSector - Number of first sector to erase. |
Kovalev_D | 132:2c7bec5cf6fe | 114 | ** u32EndSector - Number of last sector to erase. |
Kovalev_D | 132:2c7bec5cf6fe | 115 | * |
Kovalev_D | 132:2c7bec5cf6fe | 116 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 117 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 118 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 119 | uint32_t u32IAP_EraseSectors(uint32_t u32StartSector, uint32_t u32EndSector) |
Kovalev_D | 130:1421dda4d7e7 | 120 | { |
Kovalev_D | 132:2c7bec5cf6fe | 121 | uint32_t u32Status; |
Kovalev_D | 132:2c7bec5cf6fe | 122 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 123 | uint32_t au32Command[5]; |
Kovalev_D | 130:1421dda4d7e7 | 124 | |
Kovalev_D | 132:2c7bec5cf6fe | 125 | if (u32EndSector < u32StartSector) |
Kovalev_D | 132:2c7bec5cf6fe | 126 | { |
Kovalev_D | 132:2c7bec5cf6fe | 127 | u32Status = IAP_STA_INVALD_PARAM; |
Kovalev_D | 132:2c7bec5cf6fe | 128 | } |
Kovalev_D | 132:2c7bec5cf6fe | 129 | else |
Kovalev_D | 132:2c7bec5cf6fe | 130 | { |
Kovalev_D | 132:2c7bec5cf6fe | 131 | au32Command[0] = IAP_CMD_ERASE_SECTORS; |
Kovalev_D | 132:2c7bec5cf6fe | 132 | au32Command[1] = u32StartSector; |
Kovalev_D | 132:2c7bec5cf6fe | 133 | au32Command[2] = u32EndSector; |
Kovalev_D | 132:2c7bec5cf6fe | 134 | au32Command[3] = SystemCoreClock1 / 1000UL; /* Core clock frequency in kHz */ |
Kovalev_D | 132:2c7bec5cf6fe | 135 | // au32Command[3] = /*SystemFrequency / 1000UL; /* Core clock frequency in kHz */ |
Kovalev_D | 130:1421dda4d7e7 | 136 | |
Kovalev_D | 132:2c7bec5cf6fe | 137 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 130:1421dda4d7e7 | 138 | |
Kovalev_D | 132:2c7bec5cf6fe | 139 | u32Status = au32Result[0]; |
Kovalev_D | 132:2c7bec5cf6fe | 140 | } |
Kovalev_D | 132:2c7bec5cf6fe | 141 | return u32Status; |
Kovalev_D | 130:1421dda4d7e7 | 142 | } |
Kovalev_D | 130:1421dda4d7e7 | 143 | |
Kovalev_D | 132:2c7bec5cf6fe | 144 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 145 | ** Function name: u32IAP_BlankCheckSectors |
Kovalev_D | 132:2c7bec5cf6fe | 146 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 147 | ** Description: Blank check a sector or multiple sectors of on-chip flash |
Kovalev_D | 132:2c7bec5cf6fe | 148 | ** memory. |
Kovalev_D | 132:2c7bec5cf6fe | 149 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 150 | ** Parameters: u32StartSector - Number of first sector to check. |
Kovalev_D | 132:2c7bec5cf6fe | 151 | ** u32EndSector - Number of last sector to check. |
Kovalev_D | 132:2c7bec5cf6fe | 152 | ** pu32Result[0] - Offset of the first non blank word location |
Kovalev_D | 132:2c7bec5cf6fe | 153 | ** if the Status Code is IAP_STA_SECTOR_NOT_BLANK. |
Kovalev_D | 132:2c7bec5cf6fe | 154 | ** pu32Result[1] - Contents of non blank word location. |
Kovalev_D | 132:2c7bec5cf6fe | 155 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 156 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 157 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 158 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 159 | uint32_t u32IAP_BlankCheckSectors(uint32_t u32StartSector, uint32_t u32EndSector, uint32_t *pu32Result) |
Kovalev_D | 130:1421dda4d7e7 | 160 | { |
Kovalev_D | 132:2c7bec5cf6fe | 161 | uint32_t u32Status; |
Kovalev_D | 132:2c7bec5cf6fe | 162 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 163 | uint32_t au32Command[5]; |
Kovalev_D | 130:1421dda4d7e7 | 164 | |
Kovalev_D | 132:2c7bec5cf6fe | 165 | if (u32EndSector < u32StartSector) |
Kovalev_D | 132:2c7bec5cf6fe | 166 | { |
Kovalev_D | 132:2c7bec5cf6fe | 167 | u32Status = IAP_STA_INVALD_PARAM; |
Kovalev_D | 132:2c7bec5cf6fe | 168 | } |
Kovalev_D | 132:2c7bec5cf6fe | 169 | else |
Kovalev_D | 132:2c7bec5cf6fe | 170 | { |
Kovalev_D | 132:2c7bec5cf6fe | 171 | au32Command[0] = IAP_CMD_BLANK_CHECK_SECTORS; |
Kovalev_D | 132:2c7bec5cf6fe | 172 | au32Command[1] = u32StartSector; |
Kovalev_D | 132:2c7bec5cf6fe | 173 | au32Command[2] = u32EndSector; |
Kovalev_D | 130:1421dda4d7e7 | 174 | |
Kovalev_D | 132:2c7bec5cf6fe | 175 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 130:1421dda4d7e7 | 176 | |
Kovalev_D | 132:2c7bec5cf6fe | 177 | if (au32Result[0] == IAP_STA_SECTOR_NOT_BLANK) |
Kovalev_D | 132:2c7bec5cf6fe | 178 | { |
Kovalev_D | 132:2c7bec5cf6fe | 179 | *pu32Result = au32Result[0]; |
Kovalev_D | 132:2c7bec5cf6fe | 180 | *(pu32Result + 1) = au32Result[1]; |
Kovalev_D | 132:2c7bec5cf6fe | 181 | } |
Kovalev_D | 132:2c7bec5cf6fe | 182 | u32Status = au32Result[0]; |
Kovalev_D | 132:2c7bec5cf6fe | 183 | } |
Kovalev_D | 132:2c7bec5cf6fe | 184 | return u32Status; |
Kovalev_D | 130:1421dda4d7e7 | 185 | } |
Kovalev_D | 130:1421dda4d7e7 | 186 | |
Kovalev_D | 132:2c7bec5cf6fe | 187 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 188 | ** Function name: u32IAP_ReadPartID |
Kovalev_D | 132:2c7bec5cf6fe | 189 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 190 | ** Description: Read the part identification number. |
Kovalev_D | 132:2c7bec5cf6fe | 191 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 192 | ** Parameters: pu32PartID - Pointer to storage for part ID number. |
Kovalev_D | 132:2c7bec5cf6fe | 193 | * |
Kovalev_D | 132:2c7bec5cf6fe | 194 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 195 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 196 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 197 | uint32_t u32IAP_ReadPartID(uint32_t *pu32PartID) |
Kovalev_D | 130:1421dda4d7e7 | 198 | { |
Kovalev_D | 132:2c7bec5cf6fe | 199 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 200 | uint32_t au32Command[5]; |
Kovalev_D | 130:1421dda4d7e7 | 201 | |
Kovalev_D | 132:2c7bec5cf6fe | 202 | au32Command[0] = IAP_CMD_READ_PART_ID; |
Kovalev_D | 132:2c7bec5cf6fe | 203 | |
Kovalev_D | 132:2c7bec5cf6fe | 204 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 130:1421dda4d7e7 | 205 | |
Kovalev_D | 132:2c7bec5cf6fe | 206 | *pu32PartID = au32Result[1]; |
Kovalev_D | 132:2c7bec5cf6fe | 207 | |
Kovalev_D | 132:2c7bec5cf6fe | 208 | return au32Result[0]; |
Kovalev_D | 130:1421dda4d7e7 | 209 | } |
Kovalev_D | 130:1421dda4d7e7 | 210 | |
Kovalev_D | 132:2c7bec5cf6fe | 211 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 212 | ** Function name: u32IAP_ReadBootVersion |
Kovalev_D | 132:2c7bec5cf6fe | 213 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 214 | ** Description: Read the boot code version number. |
Kovalev_D | 132:2c7bec5cf6fe | 215 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 216 | ** Parameters: pu32Major - Major version number in ASCII format. |
Kovalev_D | 132:2c7bec5cf6fe | 217 | ** pu32Minor - Minor version number in ASCII format. |
Kovalev_D | 132:2c7bec5cf6fe | 218 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 219 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 220 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 221 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 222 | uint32_t u32IAP_ReadBootVersion(uint32_t *pu32Major, uint32_t *pu32Minor) |
Kovalev_D | 130:1421dda4d7e7 | 223 | { |
Kovalev_D | 132:2c7bec5cf6fe | 224 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 225 | uint32_t au32Command[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 226 | |
Kovalev_D | 132:2c7bec5cf6fe | 227 | au32Command[0] = IAP_CMD_READ_BOOT_ROM_VERSION; |
Kovalev_D | 132:2c7bec5cf6fe | 228 | |
Kovalev_D | 132:2c7bec5cf6fe | 229 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 132:2c7bec5cf6fe | 230 | |
Kovalev_D | 132:2c7bec5cf6fe | 231 | *pu32Major = (au32Result[1] & 0x0000FF00UL) >> 8; |
Kovalev_D | 132:2c7bec5cf6fe | 232 | *pu32Minor = au32Result[1] & 0x000000FFUL; |
Kovalev_D | 132:2c7bec5cf6fe | 233 | |
Kovalev_D | 132:2c7bec5cf6fe | 234 | return au32Result[0]; |
Kovalev_D | 130:1421dda4d7e7 | 235 | } |
Kovalev_D | 130:1421dda4d7e7 | 236 | |
Kovalev_D | 132:2c7bec5cf6fe | 237 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 238 | ** Function name: u32IAP_ReadBootVersion |
Kovalev_D | 132:2c7bec5cf6fe | 239 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 240 | ** Description: Read the boot code version number. |
Kovalev_D | 132:2c7bec5cf6fe | 241 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 242 | ** Parameters: pu32Major - Major version number in ASCII format. |
Kovalev_D | 132:2c7bec5cf6fe | 243 | ** pu32Minor - Minor version number in ASCII format. |
Kovalev_D | 132:2c7bec5cf6fe | 244 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 245 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 246 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 247 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 248 | void u32IAP_ReadSerialNumber(uint32_t *pu32byte0, uint32_t *pu32byte1, |
Kovalev_D | 132:2c7bec5cf6fe | 249 | uint32_t *pu32byte2, uint32_t *pu32byte3) |
Kovalev_D | 130:1421dda4d7e7 | 250 | { |
Kovalev_D | 132:2c7bec5cf6fe | 251 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 252 | uint32_t au32Command[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 253 | |
Kovalev_D | 132:2c7bec5cf6fe | 254 | au32Command[0] = IAP_CMD_READ_SERIAL_NUMBER; |
Kovalev_D | 132:2c7bec5cf6fe | 255 | |
Kovalev_D | 132:2c7bec5cf6fe | 256 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 130:1421dda4d7e7 | 257 | |
Kovalev_D | 132:2c7bec5cf6fe | 258 | *pu32byte0 = au32Result[0]; |
Kovalev_D | 132:2c7bec5cf6fe | 259 | *pu32byte1 = au32Result[1]; |
Kovalev_D | 132:2c7bec5cf6fe | 260 | *pu32byte2 = au32Result[2]; |
Kovalev_D | 132:2c7bec5cf6fe | 261 | *pu32byte3 = au32Result[3]; |
Kovalev_D | 130:1421dda4d7e7 | 262 | |
Kovalev_D | 132:2c7bec5cf6fe | 263 | return; |
Kovalev_D | 130:1421dda4d7e7 | 264 | } |
Kovalev_D | 130:1421dda4d7e7 | 265 | |
Kovalev_D | 132:2c7bec5cf6fe | 266 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 267 | ** Function name: u32IAP_Compare |
Kovalev_D | 132:2c7bec5cf6fe | 268 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 269 | ** Description: Compares the memory contents at two locations. |
Kovalev_D | 132:2c7bec5cf6fe | 270 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 271 | ** Parameters: u32Len - Number of bytes to compare, must be a multiple of 4. |
Kovalev_D | 132:2c7bec5cf6fe | 272 | ** pu32Offset - Offset of the first mismatch if the Status Code is COMPARE_ERROR |
Kovalev_D | 132:2c7bec5cf6fe | 273 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 274 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 275 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 276 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 277 | uint32_t u32IAP_Compare(uint32_t u32DstAddr, uint32_t u32SrcAddr, uint32_t u32Len, uint32_t *pu32Offset) |
Kovalev_D | 130:1421dda4d7e7 | 278 | { |
Kovalev_D | 132:2c7bec5cf6fe | 279 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 280 | uint32_t au32Command[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 281 | |
Kovalev_D | 132:2c7bec5cf6fe | 282 | au32Command[0] = IAP_CMD_COMPARE; |
Kovalev_D | 132:2c7bec5cf6fe | 283 | au32Command[1] = u32DstAddr; |
Kovalev_D | 132:2c7bec5cf6fe | 284 | au32Command[2] = u32SrcAddr; |
Kovalev_D | 132:2c7bec5cf6fe | 285 | au32Command[3] = u32Len; |
Kovalev_D | 130:1421dda4d7e7 | 286 | |
Kovalev_D | 132:2c7bec5cf6fe | 287 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 130:1421dda4d7e7 | 288 | |
Kovalev_D | 132:2c7bec5cf6fe | 289 | if (au32Result[0] == IAP_STA_COMPARE_ERROR) |
Kovalev_D | 132:2c7bec5cf6fe | 290 | { |
Kovalev_D | 132:2c7bec5cf6fe | 291 | if (pu32Offset != 0) |
Kovalev_D | 132:2c7bec5cf6fe | 292 | { |
Kovalev_D | 132:2c7bec5cf6fe | 293 | *pu32Offset = au32Result[1]; |
Kovalev_D | 132:2c7bec5cf6fe | 294 | } |
Kovalev_D | 132:2c7bec5cf6fe | 295 | } |
Kovalev_D | 132:2c7bec5cf6fe | 296 | return au32Result[0]; |
Kovalev_D | 130:1421dda4d7e7 | 297 | } |
Kovalev_D | 130:1421dda4d7e7 | 298 | |
Kovalev_D | 132:2c7bec5cf6fe | 299 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 300 | ** Function name: vIAP_ReinvokeISP |
Kovalev_D | 132:2c7bec5cf6fe | 301 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 302 | ** Description: Invoke the bootloader in ISP mode. |
Kovalev_D | 132:2c7bec5cf6fe | 303 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 304 | ** Parameters: None. |
Kovalev_D | 132:2c7bec5cf6fe | 305 | * |
Kovalev_D | 132:2c7bec5cf6fe | 306 | ** Returned value: None. |
Kovalev_D | 132:2c7bec5cf6fe | 307 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 308 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 309 | void vIAP_ReinvokeISP(void) |
Kovalev_D | 130:1421dda4d7e7 | 310 | { |
Kovalev_D | 132:2c7bec5cf6fe | 311 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 312 | uint32_t au32Command[5]; |
Kovalev_D | 130:1421dda4d7e7 | 313 | |
Kovalev_D | 132:2c7bec5cf6fe | 314 | au32Command[0] = IAP_CMD_REINVOKE_ISP; |
Kovalev_D | 130:1421dda4d7e7 | 315 | |
Kovalev_D | 132:2c7bec5cf6fe | 316 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 130:1421dda4d7e7 | 317 | } |
Kovalev_D | 130:1421dda4d7e7 | 318 | |
Kovalev_D | 132:2c7bec5cf6fe | 319 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 320 | ** End Of File |
Kovalev_D | 132:2c7bec5cf6fe | 321 | *****************************************************************************/ |