bootloadhid.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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/eeprom.h>
  18. #include <avr/wdt.h>
  19. __attribute__((weak)) void bootloader_jump(void) {
  20. // force bootloadHID to stay in bootloader mode, so that it waits
  21. // for a new firmware to be flashed
  22. // NOTE: this byte is part of QMK's "magic number" - changing it causes the EEPROM to be re-initialized
  23. // thus every time the device is flashed the EEPROM will be wiped
  24. eeprom_write_byte((uint8_t *)1, 0x00);
  25. // watchdog reset
  26. wdt_enable(WDTO_250MS);
  27. for (;;)
  28. ;
  29. }
  30. __attribute__((weak)) void mcu_reset(void) {
  31. // watchdog reset
  32. wdt_enable(WDTO_250MS);
  33. for (;;)
  34. ;
  35. }