use pointer access

This commit is contained in:
Olaf Rempel 2006-05-26 19:33:50 +02:00
parent f302c14c93
commit d1f7b638d1

20
main.c
View File

@ -141,12 +141,10 @@ static inline void eraseFlash(void)
static inline void recvBuffer(pagebuf_t size) static inline void recvBuffer(pagebuf_t size)
{ {
pagebuf_t cnt; pagebuf_t cnt;
for (cnt = 0; cnt < sizeof(gBuffer); cnt++) { uint8_t *tmp = gBuffer;
if (cnt < size)
gBuffer[cnt] = recvchar(); for (cnt = 0; cnt < sizeof(gBuffer); cnt++)
else *tmp++ = (cnt < size) ? recvchar() : 0xFF;
gBuffer[cnt] = 0xFF;
}
} }
static inline uint16_t writeFlashPage(uint16_t waddr, pagebuf_t size) static inline uint16_t writeFlashPage(uint16_t waddr, pagebuf_t size)
@ -154,11 +152,11 @@ static inline uint16_t writeFlashPage(uint16_t waddr, pagebuf_t size)
uint32_t pagestart = (uint32_t)waddr<<1; uint32_t pagestart = (uint32_t)waddr<<1;
uint32_t baddr = pagestart; uint32_t baddr = pagestart;
uint16_t data; uint16_t data;
pagebuf_t cnt = 0; uint8_t *tmp = gBuffer;
do { do {
data = gBuffer[cnt++]; data = *tmp++;
data |= gBuffer[cnt++] << 8; data |= *tmp++ << 8;
boot_page_fill(baddr, data); // call asm routine. boot_page_fill(baddr, data); // call asm routine.
baddr += 2; // Select next word in memory baddr += 2; // Select next word in memory
@ -174,12 +172,12 @@ static inline uint16_t writeFlashPage(uint16_t waddr, pagebuf_t size)
static inline uint16_t writeEEpromPage(uint16_t address, pagebuf_t size) static inline uint16_t writeEEpromPage(uint16_t address, pagebuf_t size)
{ {
pagebuf_t cnt = 0; uint8_t *tmp = gBuffer;
do { do {
EEARL = address; // Setup EEPROM address EEARL = address; // Setup EEPROM address
EEARH = (address >> 8); EEARH = (address >> 8);
EEDR = gBuffer[cnt++]; EEDR = *tmp++;
address++; // Select next byte address++; // Select next byte
EECR |= (1<<EEMWE); // Write data into EEPROM EECR |= (1<<EEMWE); // Write data into EEPROM