bootmagic_lite.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "quantum.h"
  2. /** \brief Reset eeprom
  3. *
  4. * ...just incase someone wants to only change the eeprom behaviour
  5. */
  6. __attribute__((weak)) void bootmagic_lite_reset_eeprom(void) {
  7. #if defined(VIA_ENABLE)
  8. via_eeprom_reset();
  9. #else
  10. eeconfig_disable();
  11. #endif
  12. }
  13. /** \brief The lite version of TMK's bootmagic based on Wilba.
  14. *
  15. * 100% less potential for accidentally making the keyboard do stupid things.
  16. */
  17. __attribute__((weak)) void bootmagic_lite(void) {
  18. // We need multiple scans because debouncing can't be turned off.
  19. matrix_scan();
  20. #if defined(DEBOUNCE) && DEBOUNCE > 0
  21. wait_ms(DEBOUNCE * 2);
  22. #else
  23. wait_ms(30);
  24. #endif
  25. matrix_scan();
  26. // If the configured key (commonly Esc) is held down on power up,
  27. // reset the EEPROM valid state and jump to bootloader.
  28. // This isn't very generalized, but we need something that doesn't
  29. // rely on user's keymaps in firmware or EEPROM.
  30. uint8_t row = BOOTMAGIC_LITE_ROW;
  31. uint8_t col = BOOTMAGIC_LITE_COLUMN;
  32. #if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_LITE_ROW_RIGHT) && defined(BOOTMAGIC_LITE_COLUMN_RIGHT)
  33. if (!is_keyboard_left()) {
  34. row = BOOTMAGIC_LITE_ROW_RIGHT;
  35. col = BOOTMAGIC_LITE_COLUMN_RIGHT;
  36. }
  37. #endif
  38. if (matrix_get_row(row) & (1 << col)) {
  39. bootmagic_lite_reset_eeprom();
  40. // Jump to bootloader.
  41. bootloader_jump();
  42. }
  43. }