You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
217 lines
5.3 KiB
217 lines
5.3 KiB
/**
|
|
******************************************************************************
|
|
|
|
* @author
|
|
* @version V1.0.0
|
|
* @date 22-JAN-2021
|
|
* @brief This file provides all the IAP_TABLE firmware functions.
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
|
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
|
* TIME. AS A RESULT, ICHAIER SHALL NOT BE HELD LIABLE FOR ANY
|
|
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
|
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
|
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
|
*
|
|
* <h2><center>© COPYRIGHT 2014 ICHaier</center></h2>
|
|
******************************************************************************
|
|
*/
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "es8p5066_iap_table.h"
|
|
|
|
|
|
/** @defgroup IAP_TABLE
|
|
* @brief IAP_TABLE driver modules
|
|
* @{
|
|
*/
|
|
|
|
/** @defgroup IAP_TABLE_Private_TypesDefinitions
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
/** @defgroup IAP_TABLE_Private_Defines
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
/** @defgroup IAP_TABLE_Private_Macros
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
/** @defgroup IAP_TABLE_Private_Variables
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
/** @defgroup IAP_TABLE_Private_FunctionPrototypes
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
/** @defgroup IAP_TABLE_Private_Functions
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* @brief CODE区 IAP 页擦除编程.回调固化在ROM中的程序
|
|
* @param address: 页首地址
|
|
* @retval None
|
|
*/
|
|
ErrorStatus IAP_Code_PageErase(uint32_t address, uint32_t addressInv, uint32_t sector)
|
|
{
|
|
IAP_PE IAPPageErase = (IAP_PE)(*(uint32_t *)IAP_Code_PageErase_addr);
|
|
ErrorStatus result;
|
|
__ASM("CPSID i");
|
|
result = (*IAPPageErase)(address, addressInv, sector);
|
|
__ASM("CPSIE i");
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* @brief DATA区 IAP 页擦除编程.回调固化在ROM中的程序
|
|
* @param address: 页首地址
|
|
* @retval None
|
|
*/
|
|
ErrorStatus IAP_Data_PageErase(uint32_t address, uint32_t addressInv, uint32_t sector)
|
|
{
|
|
IAP_PE IAPPageErase = (IAP_PE)(*(uint32_t *)IAP_Data_PageErase_addr);
|
|
ErrorStatus result;
|
|
__ASM("CPSID i");
|
|
result = (*IAPPageErase)(address, addressInv, sector);
|
|
__ASM("CPSIE i");
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* @brief CODE区 IAP 单字自编程.回调固化在ROM中的程序
|
|
* @param address:
|
|
* @retval None
|
|
*/
|
|
ErrorStatus IAP_Code_WordProgram(uint32_t address, uint32_t addressInv, uint32_t data)
|
|
{
|
|
IAP_WP IAPWordProgram = (IAP_WP)(*(uint32_t *)IAP_Code_WordProgram_addr);
|
|
ErrorStatus result;
|
|
__ASM("CPSID i");
|
|
result = (*IAPWordProgram)(address, addressInv, data);
|
|
__ASM("CPSIE i");
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* @brief DATA区 IAP 单字自编程.回调固化在ROM中的程序
|
|
* @param address: 页首地址
|
|
* @retval None
|
|
*/
|
|
ErrorStatus IAP_Data_WordProgram(uint32_t address, uint32_t addressInv, uint32_t data)
|
|
{
|
|
IAP_WP IAPWordProgram = (IAP_WP)(*(uint32_t *)IAP_Data_WordProgram_addr);
|
|
ErrorStatus result;
|
|
__ASM("CPSID i");
|
|
result = (*IAPWordProgram)(address, addressInv, data);
|
|
__ASM("CPSIE i");
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* @brief CODE区 IAP 多字自编程.回调固化在ROM中的程序
|
|
* @param address:
|
|
* @retval None
|
|
*/
|
|
ErrorStatus IAP_Code_PageProgram(uint32_t address, uint32_t addressInv, uint8_t data[], uint32_t length, uint32_t erase)
|
|
{
|
|
IAP_PP IAPPageProgram = (IAP_PP)(*(uint32_t *)IAP_Code_PageProgram_addr);
|
|
ErrorStatus result;
|
|
__ASM("CPSID i");
|
|
result = (*IAPPageProgram)(address, addressInv, data, length, erase);
|
|
__ASM("CPSIE i");
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* @brief DATA区 IAP 多字自编程.回调固化在ROM中的程序
|
|
* @param address: 页首地址
|
|
* @retval None
|
|
*/
|
|
ErrorStatus IAP_Data_PageProgram(uint32_t address, uint32_t addressInv, uint8_t data[], uint32_t length, uint32_t erase)
|
|
{
|
|
IAP_PP IAPPageProgram = (IAP_PP)(*(uint32_t *)IAP_Data_PageProgram_addr);
|
|
ErrorStatus result;
|
|
__ASM("CPSID i");
|
|
result = (*IAPPageProgram)(address, addressInv, data, length, erase);
|
|
__ASM("CPSIE i");
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* @brief 读取特定地址上的数据
|
|
* @param Ram_Addr: 保存读取数据的地址
|
|
* Flash_Addr: FLASH上的地址(字对齐)
|
|
* Len: 读取的长度(以字(4字节)为单位)
|
|
* @retval None
|
|
*/
|
|
ErrorStatus IAPRead(uint32_t *Ram_Addr, uint32_t Flash_Addr, uint8_t Len)
|
|
{
|
|
uint8_t i;
|
|
uint32_t *ram_addr;
|
|
const uint32_t *flash_addr;
|
|
|
|
if (Flash_Addr % 4 != 0)
|
|
return ERROR;
|
|
|
|
ram_addr = Ram_Addr;
|
|
flash_addr = (const uint32_t *)Flash_Addr;
|
|
|
|
for (i = 0; i < Len; ++i)
|
|
{
|
|
*ram_addr = *flash_addr;
|
|
++ram_addr;
|
|
++flash_addr;
|
|
}
|
|
|
|
return SUCCESS;
|
|
}
|
|
|
|
/**
|
|
* @brief 解锁FLASH
|
|
* @param None
|
|
* @retval None
|
|
*/
|
|
void IAP_FLASH_Unlock(void)
|
|
{
|
|
IAP->FLASHKEY.Word = 0x8ACE0246;
|
|
IAP->FLASHKEY.Word = 0x9BDF1357;
|
|
}
|
|
|
|
/**
|
|
* @brief 锁定FLASH
|
|
* @param None
|
|
* @retval None
|
|
*/
|
|
void IAP_FLASH_Lock(void)
|
|
{
|
|
IAP->FLASHKEY.Word = 0x0;
|
|
}
|
|
|
|
|
|
/******************* (C) COPYRIGHT 2014 ICHaier *****END OF FILE****/
|
|
|