|
Вот ето в бут а остальное куды хочешь ! ;-)
#define WaitSPM() while(SPMCSR & (1 << SPMEN))
#define WaitEEPROM() while(EECR & (1 << EEWE))
#define WaitReady() while(SPMCSR & (1 << RWWSB))
#define _DoSpm(vol) while(SPMCSR & (1 << SPMEN));\SPMCSR = vol; asm("SPM");
bool iflPageWrite(unsigned long address,unsigned int *buffer,int sizeb) {
BYTE wsize,sreg,cntr;
if((sizeb % 2) != 0) return false;
wsize = sizeb / 2;
sreg = SREG;
__disable_interrupt();
WaitSPM();
WaitEEPROM();
RAMPZ = 0;
if(address >= (1024L * 64L)) RAMPZ = 1;
_SPM_24_ERASE(address);
for(cntr=0;cntr<128;cntr++) {
WaitSPM();
WaitEEPROM();
if(cntr < wsize) _SPM_24_FILLTEMP(cntr << 1,buffer[cntr]);
else _SPM_24_FILLTEMP(cntr << 1,0);
}
WaitSPM();
WaitEEPROM();
_SPM_24_PAGEWRITE(address);
WaitEEPROM();
_DoSpm((1 << RWWSRE) | (1 << SPMEN));
WaitReady();
SREG = sreg;
return true;
}
E-mail: info@telesys.ru