[an error occurred while processing this directive]
|
#include //определения типов //МАКРОСЫ //ожидаем завершения операций с EEPROM и Flash void Wait_EESPM(void) @ NRWW_SEG BYTE FlashWrite(void) @ NRWW_SEG for (i=0; i<64; i+=2){ Wait_EESPM(); SETB(TIMSK, BIT(TOIE0)); //разрешаем Timer 0 for (i=0; i<64; i++){
E-mail:
info@telesys.ru
#include
typedef unsigned char BYTE;
typedef unsigned int WORD;
#define BIT(x) ((BYTE)0x01 << (x))
#define SETB(addr,bits) ((addr) |= (bits))
#define CLEARB(addr,bits) ((addr) &= ~(bits))
#define INVERTB(addr,bits) ((addr) ^= (bits))
#define CHECKB(addr,bits) (((addr) & (bits))!=(BYTE)0x00)
#define _REENABLE_RWW() __DataToR0ByteToSPMCR_SPM(0x00,0x11) /* re-enable the RWW section */
// пока ждем, периодически разрешаем прерывания
{
do{
__enable_interrupt();
__no_operation();
__no_operation();
__disable_interrupt();
}while(CHECKB(EECR, BIT(EEWE)) || CHECKB(SPMCR, BIT(SPMEN)));
}
{
BYTE i;
Wait_EESPM();
CLEARB(TIMSK, BIT(TOIE0)); //запрещаем Timer 0
_SPM_ERASE(MemoryAddr); //стираем страницу
Wait_EESPM();
_SPM_FILLTEMP(i, *(WORD*)(PageBuf+i)); //заполняем буфер
}
_SPM_PAGEWRITE(MemoryAddr); //записываем страницу
Wait_EESPM();
_REENABLE_RWW();
__enable_interrupt();
while(CHECKB(SPMCR, BIT(RWWSB))); //ожидаем разрешения RWW
if(*(__flash BYTE*)(MemoryAddr+i) != *(PageBuf+i))
return 0x01;
}
return 0x00;
}
Ответы