1 Star 0 Fork 1

蒹葭平台/smartWinery51

forked from Lisq/smartWinery51 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
iapEEPROM.c 2.30 KB
一键复制 编辑 原始数据 按行查看 历史
Lisq 提交于 2020-05-23 09:38 . 增加OLED显示部分
#include "iapEEPROM.h"
#include "reg51.h"
#include "intrins.h"
/*----------------------------
�ر�IAP
----------------------------*/
void IapIdle()
{
IAP_CONTR = 0; //�ر�IAP����
IAP_CMD = 0; //�������Ĵ���
IAP_TRIG = 0; //��������Ĵ���
IAP_ADDRH = 0x80; //����ַ���õ���IAP����
IAP_ADDRL = 0;
}
/*----------------------------
��ISP/IAP/EEPROM�����ȡһ�ֽ�
----------------------------*/
BYTE IapReadByte(WORD addr)
{
BYTE dat; //���ݻ�����
IAP_CONTR = ENABLE_IAP; //ʹ��IAP
IAP_CMD = CMD_READ; //����IAP����
IAP_ADDRL = addr; //����IAP�͵�ַ
IAP_ADDRH = addr >> 8; //����IAP�ߵ�ַ
IAP_TRIG = 0x5a; //�������(0x5a)
IAP_TRIG = 0xa5; //�������(0xa5)
_nop_(); //�ȴ�ISP/IAP/EEPROM�������
dat = IAP_DATA; //��ISP/IAP/EEPROM����
IapIdle(); //�ر�IAP����
return dat; //����
}
/*----------------------------
дһ�ֽ����ݵ�ISP/IAP/EEPROM����
----------------------------*/
void IapProgramByte(WORD addr, BYTE dat)
{
IAP_CONTR = ENABLE_IAP; //ʹ��IAP
IAP_CMD = CMD_PROGRAM; //����IAP����
IAP_ADDRL = addr; //����IAP�͵�ַ
IAP_ADDRH = addr >> 8; //����IAP�ߵ�ַ
IAP_DATA = dat; //дISP/IAP/EEPROM����
IAP_TRIG = 0x5a; //�������(0x5a)
IAP_TRIG = 0xa5; //�������(0xa5)
_nop_(); //�ȴ�ISP/IAP/EEPROM�������
IapIdle();
}
/*----------------------------
��������
----------------------------*/
void IapEraseSector(WORD addr)
{
IAP_CONTR = ENABLE_IAP; //ʹ��IAP
IAP_CMD = CMD_ERASE; //����IAP����
IAP_ADDRL = addr; //����IAP�͵�ַ
IAP_ADDRH = addr >> 8; //����IAP�ߵ�ַ
IAP_TRIG = 0x5a; //�������(0x5a)
IAP_TRIG = 0xa5; //�������(0xa5)
_nop_(); //�ȴ�ISP/IAP/EEPROM�������
IapIdle();
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/jianjia_paltform/smartWinery51.git
git@gitee.com:jianjia_paltform/smartWinery51.git
jianjia_paltform
smartWinery51
smartWinery51
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385