avr-fw-modules/core/src/bootloader.c

52 lines
632 B
C
Executable File

#include <stdint.h>
#include <stdio.h>
#include <avr/io.h>
#include <sys/bootloader.h>
struct bl_cmd bl_cmd;
uint32_t flash_pointer;
char flash_buffer[ SPM_PAGESIZE ];
uint8_t bootloader(FILE *stream)
{
uint8_t n;
int ch;
for (n=0;n<10;n++)
{
fputc( '*', stream );
wait_ms(100);
ch = fgetc( stream );
if (ch == '$')
break;
};
if (n == 10)
bl_boot_application();
while (1)
{
ch = bl_recv( stream, &bl_cmd );
if (ch > 0)
{
switch (bl_cmd.cmd)
{
case BL_CMD_ERASE_FLASH:
break;
case BL_CMD_WRITE_FLASH:
break;
case BL_CMD_FLUSH:
break;
};
};
};
};