bootmagic_lite.c 1.4 KB

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