use pointer access
This commit is contained in:
parent
f302c14c93
commit
d1f7b638d1
20
main.c
20
main.c
@ -141,12 +141,10 @@ static inline void eraseFlash(void)
|
||||
static inline void recvBuffer(pagebuf_t size)
|
||||
{
|
||||
pagebuf_t cnt;
|
||||
for (cnt = 0; cnt < sizeof(gBuffer); cnt++) {
|
||||
if (cnt < size)
|
||||
gBuffer[cnt] = recvchar();
|
||||
else
|
||||
gBuffer[cnt] = 0xFF;
|
||||
}
|
||||
uint8_t *tmp = gBuffer;
|
||||
|
||||
for (cnt = 0; cnt < sizeof(gBuffer); cnt++)
|
||||
*tmp++ = (cnt < size) ? recvchar() : 0xFF;
|
||||
}
|
||||
|
||||
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 baddr = pagestart;
|
||||
uint16_t data;
|
||||
pagebuf_t cnt = 0;
|
||||
uint8_t *tmp = gBuffer;
|
||||
|
||||
do {
|
||||
data = gBuffer[cnt++];
|
||||
data |= gBuffer[cnt++] << 8;
|
||||
data = *tmp++;
|
||||
data |= *tmp++ << 8;
|
||||
boot_page_fill(baddr, data); // call asm routine.
|
||||
|
||||
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)
|
||||
{
|
||||
pagebuf_t cnt = 0;
|
||||
uint8_t *tmp = gBuffer;
|
||||
|
||||
do {
|
||||
EEARL = address; // Setup EEPROM address
|
||||
EEARH = (address >> 8);
|
||||
EEDR = gBuffer[cnt++];
|
||||
EEDR = *tmp++;
|
||||
address++; // Select next byte
|
||||
|
||||
EECR |= (1<<EEMWE); // Write data into EEPROM
|
||||
|
Loading…
Reference in New Issue
Block a user