You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.8 KiB

  1. // Copyright 2018-2022 Nick Brassel (@tzarc)
  2. // SPDX-License-Identifier: GPL-3.0-or-later
  3. #include QMK_KEYBOARD_H
  4. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  5. LAYOUT_ortho_1x1(QK_BOOT)
  6. };
  7. #ifdef DEBUG_EEPROM_OUTPUT
  8. # ifdef WEAR_LEVELING_ENABLE
  9. # include "wear_leveling.h"
  10. # endif // WEAR_LEVELING_ENABLE
  11. uint8_t prng(void) {
  12. static uint8_t s = 0xAA, a = 0;
  13. s ^= s << 3;
  14. s ^= s >> 5;
  15. s ^= a++ >> 2;
  16. return s;
  17. }
  18. void keyboard_post_init_user(void) {
  19. debug_enable = true;
  20. debug_matrix = true;
  21. debug_keyboard = true;
  22. }
  23. void matrix_scan_user(void) {
  24. static uint32_t last_eeprom_access = 0;
  25. uint32_t now = timer_read32();
  26. if (now - last_eeprom_access > 5000) {
  27. dprint("reading eeprom\n");
  28. last_eeprom_access = now;
  29. union {
  30. uint8_t bytes[4];
  31. uint32_t raw;
  32. } tmp;
  33. extern uint8_t prng(void);
  34. tmp.bytes[0] = prng();
  35. tmp.bytes[1] = prng();
  36. tmp.bytes[2] = prng();
  37. tmp.bytes[3] = prng();
  38. eeconfig_update_user(tmp.raw);
  39. uint32_t value = eeconfig_read_user();
  40. if (value != tmp.raw) {
  41. dprint("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
  42. dprint("!! EEPROM readback mismatch!\n");
  43. dprint("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
  44. }
  45. }
  46. # ifdef WEAR_LEVELING_ENABLE
  47. static uint32_t last_wear_leveling_init = 0;
  48. if (now - last_wear_leveling_init > 30000) {
  49. dprint("init'ing wear-leveling\n");
  50. last_wear_leveling_init = now;
  51. wear_leveling_init();
  52. }
  53. # endif // WEAR_LEVELING_ENABLE
  54. }
  55. #endif // DEBUG_EEPROM_OUTPUT