![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
IAP.c@186:c7a9c309086c, 2016-07-31 (annotated)
- Committer:
- Diletant
- Date:
- Sun Jul 31 06:19:02 2016 +0000
- Revision:
- 186:c7a9c309086c
- Parent:
- 132:2c7bec5cf6fe
Device&... update. More AskGld&Techno functionality.NotFinal!!!
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> |
Diletant | 186:c7a9c309086c | 26 | extern uint32_t SystemCoreClock1; |
Kovalev_D | 130:1421dda4d7e7 | 27 | |
Kovalev_D | 132:2c7bec5cf6fe | 28 | /* IAP Command Definitions */ |
Kovalev_D | 132:2c7bec5cf6fe | 29 | #define IAP_CMD_PREPARE_SECTORS 50 |
Kovalev_D | 132:2c7bec5cf6fe | 30 | #define IAP_CMD_COPY_RAM_TO_FLASH 51 |
Kovalev_D | 132:2c7bec5cf6fe | 31 | #define IAP_CMD_ERASE_SECTORS 52 |
Kovalev_D | 132:2c7bec5cf6fe | 32 | #define IAP_CMD_BLANK_CHECK_SECTORS 53 |
Kovalev_D | 132:2c7bec5cf6fe | 33 | #define IAP_CMD_READ_PART_ID 54 |
Kovalev_D | 132:2c7bec5cf6fe | 34 | #define IAP_CMD_READ_BOOT_ROM_VERSION 55 |
Kovalev_D | 132:2c7bec5cf6fe | 35 | #define IAP_CMD_COMPARE 56 |
Kovalev_D | 132:2c7bec5cf6fe | 36 | #define IAP_CMD_REINVOKE_ISP 57 |
Kovalev_D | 132:2c7bec5cf6fe | 37 | #define IAP_CMD_READ_SERIAL_NUMBER 58 |
Kovalev_D | 130:1421dda4d7e7 | 38 | |
Kovalev_D | 132:2c7bec5cf6fe | 39 | /* IAP boot ROM location and access function */ |
Kovalev_D | 132:2c7bec5cf6fe | 40 | #define IAP_ROM_LOCATION 0x1FFF1FF1UL |
Kovalev_D | 132:2c7bec5cf6fe | 41 | #define IAP_EXECUTE_CMD(a, b) ((void (*)())(IAP_ROM_LOCATION))(a, b) |
Kovalev_D | 130:1421dda4d7e7 | 42 | |
Kovalev_D | 132:2c7bec5cf6fe | 43 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 44 | ** Function name: u32IAP_PrepareSectors |
Kovalev_D | 132:2c7bec5cf6fe | 45 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 46 | ** Description: Prepares sector(s) for erasing or write operations. This |
Kovalev_D | 132:2c7bec5cf6fe | 47 | ** command must be executed before executing the "Copy RAM to |
Kovalev_D | 132:2c7bec5cf6fe | 48 | ** Flash" or "Erase Sector(s)" commands. |
Kovalev_D | 132:2c7bec5cf6fe | 49 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 50 | ** Parameters: u32StartSector - Number of first sector to prepare. |
Kovalev_D | 132:2c7bec5cf6fe | 51 | ** u32EndSector - Number of last sector to prepare. |
Kovalev_D | 132:2c7bec5cf6fe | 52 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 53 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 54 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 55 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 56 | uint32_t u32IAP_PrepareSectors(uint32_t u32StartSector, uint32_t u32EndSector) |
Kovalev_D | 132:2c7bec5cf6fe | 57 | { |
Kovalev_D | 132:2c7bec5cf6fe | 58 | uint32_t u32Status; |
Kovalev_D | 132:2c7bec5cf6fe | 59 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 60 | uint32_t au32Command[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 61 | |
Kovalev_D | 132:2c7bec5cf6fe | 62 | if (u32EndSector < u32StartSector) |
Kovalev_D | 132:2c7bec5cf6fe | 63 | { |
Kovalev_D | 132:2c7bec5cf6fe | 64 | u32Status = IAP_STA_INVALD_PARAM; |
Kovalev_D | 132:2c7bec5cf6fe | 65 | } |
Kovalev_D | 132:2c7bec5cf6fe | 66 | else |
Kovalev_D | 132:2c7bec5cf6fe | 67 | { |
Kovalev_D | 132:2c7bec5cf6fe | 68 | au32Command[0] = IAP_CMD_PREPARE_SECTORS; |
Kovalev_D | 132:2c7bec5cf6fe | 69 | au32Command[1] = u32StartSector; |
Kovalev_D | 132:2c7bec5cf6fe | 70 | au32Command[2] = u32EndSector; |
Kovalev_D | 132:2c7bec5cf6fe | 71 | |
Kovalev_D | 132:2c7bec5cf6fe | 72 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 132:2c7bec5cf6fe | 73 | |
Kovalev_D | 132:2c7bec5cf6fe | 74 | u32Status = au32Result[0]; |
Kovalev_D | 132:2c7bec5cf6fe | 75 | } |
Kovalev_D | 132:2c7bec5cf6fe | 76 | return u32Status; |
Kovalev_D | 130:1421dda4d7e7 | 77 | } |
Kovalev_D | 130:1421dda4d7e7 | 78 | |
Kovalev_D | 132:2c7bec5cf6fe | 79 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 80 | ** Function name: u32IAP_CopyRAMToFlash |
Kovalev_D | 132:2c7bec5cf6fe | 81 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 82 | ** Description: Program the flash memory with data stored in RAM. |
Kovalev_D | 132:2c7bec5cf6fe | 83 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 84 | ** Parameters: u32DstAddr - Destination Flash address, should be a 256 |
Kovalev_D | 132:2c7bec5cf6fe | 85 | ** byte boundary. |
Kovalev_D | 132:2c7bec5cf6fe | 86 | ** u32SrcAddr - Source RAM address, should be a word boundary |
Kovalev_D | 132:2c7bec5cf6fe | 87 | ** u32Len - Number of 8-bit bytes to write, must be 256 |
Kovalev_D | 132:2c7bec5cf6fe | 88 | ** 512, 1024, or 4096. |
Kovalev_D | 132:2c7bec5cf6fe | 89 | * |
Kovalev_D | 132:2c7bec5cf6fe | 90 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 91 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 92 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 93 | uint32_t u32IAP_CopyRAMToFlash(uint32_t u32DstAddr, uint32_t u32SrcAddr, uint32_t u32Len) |
Kovalev_D | 130:1421dda4d7e7 | 94 | { |
Kovalev_D | 132:2c7bec5cf6fe | 95 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 96 | uint32_t au32Command[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 97 | au32Command[0] = IAP_CMD_COPY_RAM_TO_FLASH; |
Kovalev_D | 132:2c7bec5cf6fe | 98 | au32Command[1] = u32DstAddr; |
Kovalev_D | 132:2c7bec5cf6fe | 99 | au32Command[2] = u32SrcAddr; |
Kovalev_D | 132:2c7bec5cf6fe | 100 | au32Command[3] = u32Len; |
Kovalev_D | 132:2c7bec5cf6fe | 101 | // au32Command[4] = SystemFrequency / 1000UL; /* Core clock frequency in kHz */ |
Kovalev_D | 132:2c7bec5cf6fe | 102 | au32Command[4] = SystemCoreClock1 / 1000UL; /* Core clock frequency in kHz */ |
Kovalev_D | 130:1421dda4d7e7 | 103 | |
Kovalev_D | 132:2c7bec5cf6fe | 104 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 130:1421dda4d7e7 | 105 | |
Kovalev_D | 132:2c7bec5cf6fe | 106 | return au32Result[0]; |
Kovalev_D | 130:1421dda4d7e7 | 107 | } |
Kovalev_D | 130:1421dda4d7e7 | 108 | |
Kovalev_D | 132:2c7bec5cf6fe | 109 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 110 | ** Function name: u32IAP_EraseSectors |
Kovalev_D | 132:2c7bec5cf6fe | 111 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 112 | ** Description: Erase a sector or multiple sectors of on-chip Flash memory. |
Kovalev_D | 132:2c7bec5cf6fe | 113 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 114 | ** Parameters: u32StartSector - Number of first sector to erase. |
Kovalev_D | 132:2c7bec5cf6fe | 115 | ** u32EndSector - Number of last sector to erase. |
Kovalev_D | 132:2c7bec5cf6fe | 116 | * |
Kovalev_D | 132:2c7bec5cf6fe | 117 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 118 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 119 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 120 | uint32_t u32IAP_EraseSectors(uint32_t u32StartSector, uint32_t u32EndSector) |
Kovalev_D | 130:1421dda4d7e7 | 121 | { |
Kovalev_D | 132:2c7bec5cf6fe | 122 | uint32_t u32Status; |
Kovalev_D | 132:2c7bec5cf6fe | 123 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 124 | uint32_t au32Command[5]; |
Kovalev_D | 130:1421dda4d7e7 | 125 | |
Kovalev_D | 132:2c7bec5cf6fe | 126 | if (u32EndSector < u32StartSector) |
Kovalev_D | 132:2c7bec5cf6fe | 127 | { |
Kovalev_D | 132:2c7bec5cf6fe | 128 | u32Status = IAP_STA_INVALD_PARAM; |
Kovalev_D | 132:2c7bec5cf6fe | 129 | } |
Kovalev_D | 132:2c7bec5cf6fe | 130 | else |
Kovalev_D | 132:2c7bec5cf6fe | 131 | { |
Kovalev_D | 132:2c7bec5cf6fe | 132 | au32Command[0] = IAP_CMD_ERASE_SECTORS; |
Kovalev_D | 132:2c7bec5cf6fe | 133 | au32Command[1] = u32StartSector; |
Kovalev_D | 132:2c7bec5cf6fe | 134 | au32Command[2] = u32EndSector; |
Kovalev_D | 132:2c7bec5cf6fe | 135 | au32Command[3] = SystemCoreClock1 / 1000UL; /* Core clock frequency in kHz */ |
Kovalev_D | 132:2c7bec5cf6fe | 136 | // au32Command[3] = /*SystemFrequency / 1000UL; /* Core clock frequency in kHz */ |
Kovalev_D | 130:1421dda4d7e7 | 137 | |
Kovalev_D | 132:2c7bec5cf6fe | 138 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 130:1421dda4d7e7 | 139 | |
Kovalev_D | 132:2c7bec5cf6fe | 140 | u32Status = au32Result[0]; |
Kovalev_D | 132:2c7bec5cf6fe | 141 | } |
Kovalev_D | 132:2c7bec5cf6fe | 142 | return u32Status; |
Kovalev_D | 130:1421dda4d7e7 | 143 | } |
Kovalev_D | 130:1421dda4d7e7 | 144 | |
Kovalev_D | 132:2c7bec5cf6fe | 145 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 146 | ** Function name: u32IAP_BlankCheckSectors |
Kovalev_D | 132:2c7bec5cf6fe | 147 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 148 | ** Description: Blank check a sector or multiple sectors of on-chip flash |
Kovalev_D | 132:2c7bec5cf6fe | 149 | ** memory. |
Kovalev_D | 132:2c7bec5cf6fe | 150 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 151 | ** Parameters: u32StartSector - Number of first sector to check. |
Kovalev_D | 132:2c7bec5cf6fe | 152 | ** u32EndSector - Number of last sector to check. |
Kovalev_D | 132:2c7bec5cf6fe | 153 | ** pu32Result[0] - Offset of the first non blank word location |
Kovalev_D | 132:2c7bec5cf6fe | 154 | ** if the Status Code is IAP_STA_SECTOR_NOT_BLANK. |
Kovalev_D | 132:2c7bec5cf6fe | 155 | ** pu32Result[1] - Contents of non blank word location. |
Kovalev_D | 132:2c7bec5cf6fe | 156 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 157 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 158 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 159 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 160 | uint32_t u32IAP_BlankCheckSectors(uint32_t u32StartSector, uint32_t u32EndSector, uint32_t *pu32Result) |
Kovalev_D | 130:1421dda4d7e7 | 161 | { |
Kovalev_D | 132:2c7bec5cf6fe | 162 | uint32_t u32Status; |
Kovalev_D | 132:2c7bec5cf6fe | 163 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 164 | uint32_t au32Command[5]; |
Kovalev_D | 130:1421dda4d7e7 | 165 | |
Kovalev_D | 132:2c7bec5cf6fe | 166 | if (u32EndSector < u32StartSector) |
Kovalev_D | 132:2c7bec5cf6fe | 167 | { |
Kovalev_D | 132:2c7bec5cf6fe | 168 | u32Status = IAP_STA_INVALD_PARAM; |
Kovalev_D | 132:2c7bec5cf6fe | 169 | } |
Kovalev_D | 132:2c7bec5cf6fe | 170 | else |
Kovalev_D | 132:2c7bec5cf6fe | 171 | { |
Kovalev_D | 132:2c7bec5cf6fe | 172 | au32Command[0] = IAP_CMD_BLANK_CHECK_SECTORS; |
Kovalev_D | 132:2c7bec5cf6fe | 173 | au32Command[1] = u32StartSector; |
Kovalev_D | 132:2c7bec5cf6fe | 174 | au32Command[2] = u32EndSector; |
Kovalev_D | 130:1421dda4d7e7 | 175 | |
Kovalev_D | 132:2c7bec5cf6fe | 176 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 130:1421dda4d7e7 | 177 | |
Kovalev_D | 132:2c7bec5cf6fe | 178 | if (au32Result[0] == IAP_STA_SECTOR_NOT_BLANK) |
Kovalev_D | 132:2c7bec5cf6fe | 179 | { |
Kovalev_D | 132:2c7bec5cf6fe | 180 | *pu32Result = au32Result[0]; |
Kovalev_D | 132:2c7bec5cf6fe | 181 | *(pu32Result + 1) = au32Result[1]; |
Kovalev_D | 132:2c7bec5cf6fe | 182 | } |
Kovalev_D | 132:2c7bec5cf6fe | 183 | u32Status = au32Result[0]; |
Kovalev_D | 132:2c7bec5cf6fe | 184 | } |
Kovalev_D | 132:2c7bec5cf6fe | 185 | return u32Status; |
Kovalev_D | 130:1421dda4d7e7 | 186 | } |
Kovalev_D | 130:1421dda4d7e7 | 187 | |
Kovalev_D | 132:2c7bec5cf6fe | 188 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 189 | ** Function name: u32IAP_ReadPartID |
Kovalev_D | 132:2c7bec5cf6fe | 190 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 191 | ** Description: Read the part identification number. |
Kovalev_D | 132:2c7bec5cf6fe | 192 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 193 | ** Parameters: pu32PartID - Pointer to storage for part ID number. |
Kovalev_D | 132:2c7bec5cf6fe | 194 | * |
Kovalev_D | 132:2c7bec5cf6fe | 195 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 196 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 197 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 198 | uint32_t u32IAP_ReadPartID(uint32_t *pu32PartID) |
Kovalev_D | 130:1421dda4d7e7 | 199 | { |
Kovalev_D | 132:2c7bec5cf6fe | 200 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 201 | uint32_t au32Command[5]; |
Kovalev_D | 130:1421dda4d7e7 | 202 | |
Kovalev_D | 132:2c7bec5cf6fe | 203 | au32Command[0] = IAP_CMD_READ_PART_ID; |
Kovalev_D | 132:2c7bec5cf6fe | 204 | |
Kovalev_D | 132:2c7bec5cf6fe | 205 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 130:1421dda4d7e7 | 206 | |
Kovalev_D | 132:2c7bec5cf6fe | 207 | *pu32PartID = au32Result[1]; |
Kovalev_D | 132:2c7bec5cf6fe | 208 | |
Kovalev_D | 132:2c7bec5cf6fe | 209 | return au32Result[0]; |
Kovalev_D | 130:1421dda4d7e7 | 210 | } |
Kovalev_D | 130:1421dda4d7e7 | 211 | |
Kovalev_D | 132:2c7bec5cf6fe | 212 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 213 | ** Function name: u32IAP_ReadBootVersion |
Kovalev_D | 132:2c7bec5cf6fe | 214 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 215 | ** Description: Read the boot code version number. |
Kovalev_D | 132:2c7bec5cf6fe | 216 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 217 | ** Parameters: pu32Major - Major version number in ASCII format. |
Kovalev_D | 132:2c7bec5cf6fe | 218 | ** pu32Minor - Minor version number in ASCII format. |
Kovalev_D | 132:2c7bec5cf6fe | 219 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 220 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 221 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 222 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 223 | uint32_t u32IAP_ReadBootVersion(uint32_t *pu32Major, uint32_t *pu32Minor) |
Kovalev_D | 130:1421dda4d7e7 | 224 | { |
Kovalev_D | 132:2c7bec5cf6fe | 225 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 226 | uint32_t au32Command[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 227 | |
Kovalev_D | 132:2c7bec5cf6fe | 228 | au32Command[0] = IAP_CMD_READ_BOOT_ROM_VERSION; |
Kovalev_D | 132:2c7bec5cf6fe | 229 | |
Kovalev_D | 132:2c7bec5cf6fe | 230 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 132:2c7bec5cf6fe | 231 | |
Kovalev_D | 132:2c7bec5cf6fe | 232 | *pu32Major = (au32Result[1] & 0x0000FF00UL) >> 8; |
Kovalev_D | 132:2c7bec5cf6fe | 233 | *pu32Minor = au32Result[1] & 0x000000FFUL; |
Kovalev_D | 132:2c7bec5cf6fe | 234 | |
Kovalev_D | 132:2c7bec5cf6fe | 235 | return au32Result[0]; |
Kovalev_D | 130:1421dda4d7e7 | 236 | } |
Kovalev_D | 130:1421dda4d7e7 | 237 | |
Kovalev_D | 132:2c7bec5cf6fe | 238 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 239 | ** Function name: u32IAP_ReadBootVersion |
Kovalev_D | 132:2c7bec5cf6fe | 240 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 241 | ** Description: Read the boot code version number. |
Kovalev_D | 132:2c7bec5cf6fe | 242 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 243 | ** Parameters: pu32Major - Major version number in ASCII format. |
Kovalev_D | 132:2c7bec5cf6fe | 244 | ** pu32Minor - Minor version number in ASCII format. |
Kovalev_D | 132:2c7bec5cf6fe | 245 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 246 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 247 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 248 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 249 | void u32IAP_ReadSerialNumber(uint32_t *pu32byte0, uint32_t *pu32byte1, |
Kovalev_D | 132:2c7bec5cf6fe | 250 | uint32_t *pu32byte2, uint32_t *pu32byte3) |
Kovalev_D | 130:1421dda4d7e7 | 251 | { |
Kovalev_D | 132:2c7bec5cf6fe | 252 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 253 | uint32_t au32Command[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 254 | |
Kovalev_D | 132:2c7bec5cf6fe | 255 | au32Command[0] = IAP_CMD_READ_SERIAL_NUMBER; |
Kovalev_D | 132:2c7bec5cf6fe | 256 | |
Kovalev_D | 132:2c7bec5cf6fe | 257 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 130:1421dda4d7e7 | 258 | |
Kovalev_D | 132:2c7bec5cf6fe | 259 | *pu32byte0 = au32Result[0]; |
Kovalev_D | 132:2c7bec5cf6fe | 260 | *pu32byte1 = au32Result[1]; |
Kovalev_D | 132:2c7bec5cf6fe | 261 | *pu32byte2 = au32Result[2]; |
Kovalev_D | 132:2c7bec5cf6fe | 262 | *pu32byte3 = au32Result[3]; |
Kovalev_D | 130:1421dda4d7e7 | 263 | |
Kovalev_D | 132:2c7bec5cf6fe | 264 | return; |
Kovalev_D | 130:1421dda4d7e7 | 265 | } |
Kovalev_D | 130:1421dda4d7e7 | 266 | |
Kovalev_D | 132:2c7bec5cf6fe | 267 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 268 | ** Function name: u32IAP_Compare |
Kovalev_D | 132:2c7bec5cf6fe | 269 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 270 | ** Description: Compares the memory contents at two locations. |
Kovalev_D | 132:2c7bec5cf6fe | 271 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 272 | ** Parameters: u32Len - Number of bytes to compare, must be a multiple of 4. |
Kovalev_D | 132:2c7bec5cf6fe | 273 | ** pu32Offset - Offset of the first mismatch if the Status Code is COMPARE_ERROR |
Kovalev_D | 132:2c7bec5cf6fe | 274 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 275 | ** Returned value: Status code returned by IAP ROM function. |
Kovalev_D | 132:2c7bec5cf6fe | 276 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 277 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 278 | uint32_t u32IAP_Compare(uint32_t u32DstAddr, uint32_t u32SrcAddr, uint32_t u32Len, uint32_t *pu32Offset) |
Kovalev_D | 130:1421dda4d7e7 | 279 | { |
Kovalev_D | 132:2c7bec5cf6fe | 280 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 281 | uint32_t au32Command[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 282 | |
Kovalev_D | 132:2c7bec5cf6fe | 283 | au32Command[0] = IAP_CMD_COMPARE; |
Kovalev_D | 132:2c7bec5cf6fe | 284 | au32Command[1] = u32DstAddr; |
Kovalev_D | 132:2c7bec5cf6fe | 285 | au32Command[2] = u32SrcAddr; |
Kovalev_D | 132:2c7bec5cf6fe | 286 | au32Command[3] = u32Len; |
Kovalev_D | 130:1421dda4d7e7 | 287 | |
Kovalev_D | 132:2c7bec5cf6fe | 288 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 130:1421dda4d7e7 | 289 | |
Kovalev_D | 132:2c7bec5cf6fe | 290 | if (au32Result[0] == IAP_STA_COMPARE_ERROR) |
Kovalev_D | 132:2c7bec5cf6fe | 291 | { |
Kovalev_D | 132:2c7bec5cf6fe | 292 | if (pu32Offset != 0) |
Kovalev_D | 132:2c7bec5cf6fe | 293 | { |
Kovalev_D | 132:2c7bec5cf6fe | 294 | *pu32Offset = au32Result[1]; |
Kovalev_D | 132:2c7bec5cf6fe | 295 | } |
Kovalev_D | 132:2c7bec5cf6fe | 296 | } |
Kovalev_D | 132:2c7bec5cf6fe | 297 | return au32Result[0]; |
Kovalev_D | 130:1421dda4d7e7 | 298 | } |
Kovalev_D | 130:1421dda4d7e7 | 299 | |
Kovalev_D | 132:2c7bec5cf6fe | 300 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 301 | ** Function name: vIAP_ReinvokeISP |
Kovalev_D | 132:2c7bec5cf6fe | 302 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 303 | ** Description: Invoke the bootloader in ISP mode. |
Kovalev_D | 132:2c7bec5cf6fe | 304 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 305 | ** Parameters: None. |
Kovalev_D | 132:2c7bec5cf6fe | 306 | * |
Kovalev_D | 132:2c7bec5cf6fe | 307 | ** Returned value: None. |
Kovalev_D | 132:2c7bec5cf6fe | 308 | ** |
Kovalev_D | 132:2c7bec5cf6fe | 309 | ******************************************************************************/ |
Kovalev_D | 132:2c7bec5cf6fe | 310 | void vIAP_ReinvokeISP(void) |
Kovalev_D | 130:1421dda4d7e7 | 311 | { |
Kovalev_D | 132:2c7bec5cf6fe | 312 | uint32_t au32Result[5]; |
Kovalev_D | 132:2c7bec5cf6fe | 313 | uint32_t au32Command[5]; |
Kovalev_D | 130:1421dda4d7e7 | 314 | |
Kovalev_D | 132:2c7bec5cf6fe | 315 | au32Command[0] = IAP_CMD_REINVOKE_ISP; |
Kovalev_D | 130:1421dda4d7e7 | 316 | |
Kovalev_D | 132:2c7bec5cf6fe | 317 | IAP_EXECUTE_CMD(au32Command, au32Result); |
Kovalev_D | 130:1421dda4d7e7 | 318 | } |
Kovalev_D | 130:1421dda4d7e7 | 319 | |
Kovalev_D | 132:2c7bec5cf6fe | 320 | /***************************************************************************** |
Kovalev_D | 132:2c7bec5cf6fe | 321 | ** End Of File |
Kovalev_D | 132:2c7bec5cf6fe | 322 | *****************************************************************************/ |