📄 iap.h
字号:
/****************************************Copyright (c)****************************************************
** Guangzhou ZHIYUAN electronics Co.,LTD.
**
** http://www.embedtools.com
**
**--------------File Info---------------------------------------------------------------------------------
** File name: IAP.c
** Last modified Date: 2011-05-05
** Last Version: V1.00
** Descriptions: IAP编程接口函数
**
**--------------------------------------------------------------------------------------------------------
** Created by: Lanwuqiang
** Created date: 2011-05-05
** Version: V1.00
** Descriptions: IAP接口函数
**
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
** Rechecked by:
*********************************************************************************************************/
#ifndef __IAP_H
#define __IAP_H
#include <stdint.h>
#define SystemCoreClock SystemFrequency
/* IAP Command Status Codes */
#define IAP_STA_CMD_SUCCESS 0
#define IAP_STA_INVALID_COMMAND 1
#define IAP_STA_SRC_ADDR_ERROR 2
#define IAP_STA_DST_ADDR_ERROR 3
#define IAP_STA_SRC_ADDR_NOT_MAPPED 4
#define IAP_STA_DST_ADDR_NOT_MAPPED 5
#define IAP_STA_COUNT_ERROR 6
#define IAP_STA_INVALID_SECTOR 7
#define IAP_STA_SECTOR_NOT_BLANK 8
#define IAP_STA_SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION 9
#define IAP_STA_COMPARE_ERROR 10
#define IAP_STA_BUSY 11
#define IAP_STA_INVALD_PARAM 12
/* Define the flash page size, this is the minimum amount of data can be written in one operation */
#define IAP_FLASH_PAGE_SIZE_BYTES 256
#define IAP_FLASH_PAGE_SIZE_WORDS (IAP_FLASH_PAGE_SIZE_BYTES >> 2)
/*******************************************************************************************************
** Function name: u32IAP_PrepareSectors
**
** Description: Prepares sector(s) for erasing or write operations. This
** command must be executed before executing the "Copy RAM to
** Flash" or "Erase Sector(s)" commands.
**
** Parameters: u32StartSector - Number of first sector to prepare.
** u32EndSector - Number of last sector to prepare.
**
** Returned value: Status code returned by IAP ROM function.
**
********************************************************************************************************/
extern uint32_t u32IAP_PrepareSectors(uint32_t u32StartSector, uint32_t u32EndSector);
/*******************************************************************************************************
** Function name: u32IAP_CopyRAMToFlash
**
** Description: Program the flash memory with data stored in RAM.
**
** Parameters: u32DstAddr - Destination Flash address, should be a 256
** byte boundary.
** u32SrcAddr - Source RAM address, should be a word boundary
** u32Len - Number of 8-bit bytes to write, must be a
** multiple of 256.
*
** Returned value: Status code returned by IAP ROM function.
**
********************************************************************************************************/
extern uint32_t u32IAP_CopyRAMToFlash(uint32_t u32DstAddr, uint32_t u32SrcAddr, uint32_t u32Len);
/*******************************************************************************************************
** Function name: u32IAP_EraseSectors
**
** Description: Erase a sector or multiple sectors of on-chip Flash memory.
**
** Parameters: u32StartSector - Number of first sector to erase.
** u32EndSector - Number of last sector to erase.
*
** Returned value: Status code returned by IAP ROM function.
**
*******************************************************************************************************/
extern uint32_t u32IAP_EraseSectors(uint32_t u32StartSector, uint32_t u32EndSector);
/*******************************************************************************************************
** Function name: u32IAP_BlankCheckSectors
**
** Description: Blank check a sector or multiple sectors of on-chip flash
** memory.
**
** Parameters: u32StartSector - Number of first sector to check.
** u32EndSector - Number of last sector to check.
** pu32Result[0] - Offset of the first non blank word location
** if the Status Code is IAP_STA_SECTOR_NOT_BLANK.
** pu32Result[1] - Contents of non blank word location.
**
** Returned value: Status code returned by IAP ROM function.
**
*******************************************************************************************************/
extern uint32_t u32IAP_BlankCheckSectors(uint32_t u32StartSector, uint32_t u32EndSector, uint32_t *pu32Result);
/*******************************************************************************************************
** Function name: u32IAP_ReadPartID
**
** Description: Read the part identification number.
**
** Parameters: pu32PartID - Pointer to storage for part ID number.
*
** Returned value: Status code returned by IAP ROM function.
**
*******************************************************************************************************/
extern uint32_t u32IAP_ReadPartID(uint32_t *pu32PartID);
/*******************************************************************************************************
** Function name: u32IAP_ReadBootVersion
**
** Description: Read the boot code version number.
**
** Parameters: pu32Major - Major version number in ASCII format.
** pu32Minor - Minor version number in ASCII format.
**
** Returned value: Status code returned by IAP ROM function.
**
*******************************************************************************************************/
extern uint32_t u32IAP_ReadBootVersion(uint32_t *pu32Major, uint32_t *pu32Minor);
/*******************************************************************************************************
** Function name: u32IAP_Compare
**
** Description: Compares the memory contents at two locations.
**
** Parameters: u32Len - Number of bytes to compare, must be a multiple of 4.
** pu32Offset - Offset of the first mismatch if the Status Code is COMPARE_ERROR
**
** Returned value: Status code returned by IAP ROM function.
**
*******************************************************************************************************/
extern uint32_t u32IAP_Compare(uint32_t u32DstAddr, uint32_t u32SrcAddr, uint32_t u32Len, uint32_t *pu32Offset);
/*******************************************************************************************************
** Function name: vIAP_ReinvokeISP
**
** Description: Invoke the bootloader in ISP mode.
**
** Parameters: None.
*
** Returned value: None.
**
*******************************************************************************************************/
extern void vIAP_ReinvokeISP(void);
#endif /* end __IAP_H */
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -