iap.c

来自「NXP(原飞利浦)的LPC214X系列ARM上的USB在系统升级的源代码,极力推」· C语言 代码 · 共 69 行

C
69
字号
#include "iap.h"

U32 IAP_FCCLK;

U32 command[5];			// IAP入口参数缓冲区
U32 result[2];		// IAP出口参数缓冲区

U32 IAP_SelectSector(U8 sectorStart, U8 sectorEnd) {
	command[0] = IAP_CMD_SELECTSECTOR;
	command[1] = sectorStart;
	command[2] = sectorEnd;
	IAP_Entry(command, result);

	return result[0];
}
U32 IAP_RamToFlash(U32 dst, U32 src, U32 num) {
	command[0] = IAP_CMD_RAMTOFLASH;
	command[1] = dst;
	command[2] = src;
	command[3] = num;
	command[4] = (IAP_FCCLK ? IAP_FCCLK : IAP_FCCLK_Default);
	IAP_Entry(command, result);

	return result[0];
}

U32 IAP_EraseSector(U8 sectorStart, U8 sectorEnd) {
	command[0] = IAP_CMD_ERASESECTOR;
	command[1] = sectorStart;
	command[2] = sectorEnd;
	command[3] = (IAP_FCCLK ? IAP_FCCLK : IAP_FCCLK_Default);
	IAP_Entry(command, result);

	return result[0];
}

U32 IAP_BlankCheck(U8 sectorStart, U8 sectorEnd) {
	command[0] = IAP_CMD_BLANKCHECK;
	command[1] = sectorStart;
	command[2] = sectorEnd;
	IAP_Entry(command, result);

	return result[0];
}

U32 IAP_ReadBootID(void) {
	command[0] = IAP_CMD_READBOOTID;
	IAP_Entry(command, result);

	return result[1];
}

U32 IAP_ReadPartID(void) {
	command[0] = IAP_CMD_READPARTID;
	IAP_Entry(command, result);

	return result[1];
}

U32 IAP_Compare(U32 dst, U32 src, U32 num) {
	command[0] = IAP_CMD_COMPARE;
	command[1] = dst;
	command[2] = src;
	command[3] = num;
	IAP_Entry(command, result);

	return result[0];
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?