bootapp.c 880 B

1234567891011121314151617181920212223242526272829303132
  1. //bootapp.c
  2. #include "bootapp.h"
  3. #include <avr/pgmspace.h>
  4. #include <avr/wdt.h>
  5. #include <avr/interrupt.h>
  6. /*
  7. void bootapp_print_vars()
  8. {
  9. printf_P(_n("boot_src_addr =0x%08lx\n"), boot_src_addr);
  10. printf_P(_n("boot_dst_addr =0x%08lx\n"), boot_dst_addr);
  11. printf_P(_n("boot_copy_size =0x%04x\n"), boot_copy_size);
  12. printf_P(_n("boot_reserved =0x%02x\n"), boot_reserved);
  13. printf_P(_n("boot_app_flags =0x%02x\n"), boot_app_flags);
  14. printf_P(_n("boot_app_magic =0x%08lx\n"), boot_app_magic);
  15. }
  16. */
  17. void bootapp_ram2flash(uint16_t rptr, uint16_t fptr, uint16_t size)
  18. {
  19. cli();
  20. // uint16_t ui; for (ui = 0; ui < size; ui++)
  21. // ram_array[ui+rptr] = 0xff;
  22. boot_app_magic = 0x55aa55aa;
  23. boot_app_flags = BOOT_APP_FLG_ERASE | BOOT_APP_FLG_COPY;
  24. boot_copy_size = (uint16_t)size;
  25. boot_src_addr = (uint32_t)rptr;
  26. boot_dst_addr = (uint32_t)fptr;
  27. wdt_enable(WDTO_15MS);
  28. while(1);
  29. }