caterina.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Copyright 2021 QMK
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 3 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "bootloader.h"
  17. #include <avr/wdt.h>
  18. __attribute__((weak)) void bootloader_jump(void) {
  19. // this block may be optional
  20. // TODO: figure it out
  21. uint16_t *const bootKeyPtr = (uint16_t *)0x0800;
  22. // Value used by Caterina bootloader use to determine whether to run the
  23. // sketch or the bootloader programmer.
  24. uint16_t bootKey = 0x7777;
  25. *bootKeyPtr = bootKey;
  26. // setup watchdog timeout
  27. wdt_enable(WDTO_60MS);
  28. // wait for watchdog timer to trigger
  29. while (1) {
  30. }
  31. }
  32. __attribute__((weak)) void mcu_reset(void) {
  33. // setup watchdog timeout
  34. wdt_enable(WDTO_60MS);
  35. // wait for watchdog timer to trigger
  36. while (1) {
  37. }
  38. }