www.pudn.com > hx711_LCD5110.rar > HW_EEPROM.c, change:2015-07-04,size:1272b


#include "STC12C5A60S2.h" 
#include "intrins.h" 
//#include "HW_EEPROM.h" 
 
void HW_OpenIAP(void) 
{ 
    IAP_CONTR= 0x80;           //充许ISP/IAP 
}  
 
void HW_CloseIAP(void) 
{ 
    IAP_CONTR = 0x00;           //禁止ISP/IAP 
    IAP_ADDRH = 0xFF; 
    IAP_ADDRL = 0xFF; 
} 
 
unsigned char HW_ReadIAPByte(unsigned int addr) 
{   
	unsigned char _dat; 
	HW_OpenIAP(); 
    IAP_CMD = 0x01; 
    IAP_ADDRH = (addr & 0xFF00)>>8; 
    IAP_ADDRL = addr & 0x00FF; 
    IAP_TRIG = 0x5A; 
    IAP_TRIG = 0xA5;                     //对IAP_TRIG先写0x5A再写0xA5,ISP/IAP命令才会生效 
	_dat=IAP_DATA; 
	HW_CloseIAP();	 
    return _dat; 
} 
 
 
void HW_WriteIAPByte(unsigned int addr, unsigned int _bat) 
{ 
	HW_OpenIAP(); 
	IAP_CMD = 0x02; 
    IAP_ADDRH = addr >>8; 
    IAP_ADDRL = addr; 
    IAP_DATA = _bat; 
	IAP_TRIG = 0x5A; 
    IAP_TRIG = 0xA5;                     //对IAP_TRIG先写0x5A再写0xA5,ISP/IAP命令才会生效 
	HW_CloseIAP(); 
} 
 
void HW_EraseIAPSector(unsigned int addr) 
{  
       HW_OpenIAP(); 
	   IAP_CMD = 0x03; 
       IAP_ADDRH = addr>>8; 
       IAP_ADDRL = addr; 
       IAP_TRIG = 0x5A; 
       IAP_TRIG = 0xA5;                     //对IAP_TRIG先写0x5A再写0xA5,ISP/IAP命令才会生效 
	   HW_CloseIAP(); 
}