98 lines
2.7 KiB
C
98 lines
2.7 KiB
C
|
/***************************************************************
|
|||
|
*Copyright (C), 2017, Shanghai Eastsoft Microelectronics Co., Ltd.
|
|||
|
*<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: Liut
|
|||
|
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: V1.00
|
|||
|
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: 2017/07/14
|
|||
|
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*<EFBFBD><EFBFBD> ע<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ES8P508оƬ
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧϰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>κη<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ρ<EFBFBD>
|
|||
|
***************************************************************/
|
|||
|
#include "lib_iap.h"
|
|||
|
|
|||
|
/*************************************************
|
|||
|
* @brief IAP ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.<EFBFBD>ص<EFBFBD><EFBFBD>̻<EFBFBD><EFBFBD><EFBFBD>ROM<EFBFBD>еij<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param address: ҳ<EFBFBD><EFBFBD>ַ
|
|||
|
* @retval None
|
|||
|
***********************************************/
|
|||
|
ErrorStatus IAP_PageErase(uint32_t address)
|
|||
|
{
|
|||
|
IAP_PE IAPPageErase = (IAP_PE)(*(uint32_t *)IAP_PageErase_addr);
|
|||
|
|
|||
|
ErrorStatus result;
|
|||
|
__ASM("CPSID i");
|
|||
|
result = (*IAPPageErase)(address);
|
|||
|
__ASM("CPSIE i");
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
/*************************************************
|
|||
|
* @brief IAP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD>.<EFBFBD>ص<EFBFBD><EFBFBD>̻<EFBFBD><EFBFBD><EFBFBD>ROM<EFBFBD>еij<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param address: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
* @param data: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @retval None
|
|||
|
************************************************/
|
|||
|
ErrorStatus IAP_WordProgram(uint32_t address, uint32_t data)
|
|||
|
{
|
|||
|
IAP_WP IAPWordProgram = (IAP_WP)(*(uint32_t *)IAP_WordProgram_addr);
|
|||
|
|
|||
|
ErrorStatus result;
|
|||
|
__ASM("CPSID i");
|
|||
|
result = (*IAPWordProgram)( address, data);
|
|||
|
__ASM("CPSIE i");
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
/************************************************
|
|||
|
* @brief IAP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD>.<EFBFBD>ص<EFBFBD><EFBFBD>̻<EFBFBD><EFBFBD><EFBFBD>ROM<EFBFBD>еij<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param address: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
* @param data[]: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param length: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD>ȣ<EFBFBD><EFBFBD>ֽڣ<EFBFBD>
|
|||
|
* @param address: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD>Ƿ<EFBFBD><EFBFBD>Ȳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @arg 0: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @arg 1: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @retval None
|
|||
|
**********************************************/
|
|||
|
ErrorStatus IAP_PageProgram(uint32_t address, uint32_t data[], uint32_t length, uint32_t erase) //@0x100001c5
|
|||
|
{
|
|||
|
IAP_PP IAPPageProgram = (IAP_PP)(*(uint32_t *)IAP_PageProgram_addr);
|
|||
|
|
|||
|
ErrorStatus result;
|
|||
|
__ASM("CPSID i");
|
|||
|
result = (*IAPPageProgram)(address,data,length,erase);
|
|||
|
__ASM("CPSIE i");
|
|||
|
return result;
|
|||
|
}
|
|||
|
/*************************************
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IARead
|
|||
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Flash<EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ--<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݵĴ<EFBFBD><EFBFBD>ŵ<EFBFBD>ַ
|
|||
|
Flash<EFBFBD><EFBFBD>ַ
|
|||
|
<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݵij<EFBFBD><EFBFBD>ȣ<EFBFBD><EFBFBD><EFBFBD>λΪ<EFBFBD>֣<EFBFBD>4<EFBFBD>ֽڣ<EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD><EFBFBD>
|
|||
|
**************************************/
|
|||
|
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;
|
|||
|
|
|||
|
ram_addr = Ram_Addr;
|
|||
|
flash_addr = (const uint32_t *)Flash_Addr;
|
|||
|
|
|||
|
if (Len == 0)
|
|||
|
return ERROR;
|
|||
|
|
|||
|
for (i = 0; i < Len; ++i)
|
|||
|
{
|
|||
|
*ram_addr = *flash_addr;
|
|||
|
++ram_addr;
|
|||
|
++flash_addr;
|
|||
|
}
|
|||
|
|
|||
|
return SUCCESS;
|
|||
|
}
|
|||
|
|
|||
|
/************************END OF FILE**************************/
|
|||
|
|