diff options
author | Nick Brassel <nick@tzarc.org> | 2022-12-02 21:55:28 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-02 21:55:28 +1100 |
commit | cf3c26533cadf4e6739dbc9117caad01df2fa5e3 (patch) | |
tree | 8bd4f7151edcc67e0bba16f1fcdbf83cbaf172b6 /keyboards/handwired/onekey/keymaps | |
parent | f98a7e8ffecdf4904879d8d3c0cc3307aa6f9966 (diff) |
Fixup EFL and F4's sector selection. (#19221)
Diffstat (limited to 'keyboards/handwired/onekey/keymaps')
3 files changed, 72 insertions, 0 deletions
diff --git a/keyboards/handwired/onekey/keymaps/wear_leveling/config.h b/keyboards/handwired/onekey/keymaps/wear_leveling/config.h new file mode 100644 index 0000000000..642b442da3 --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/wear_leveling/config.h @@ -0,0 +1,6 @@ +// Copyright 2018-2022 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-3.0-or-later +#pragma once + +#define DEBUG_EEPROM_OUTPUT +#define WEAR_LEVELING_DEBUG_OUTPUT diff --git a/keyboards/handwired/onekey/keymaps/wear_leveling/keymap.c b/keyboards/handwired/onekey/keymaps/wear_leveling/keymap.c new file mode 100644 index 0000000000..dc40ca1580 --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/wear_leveling/keymap.c @@ -0,0 +1,65 @@ +// Copyright 2018-2022 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-3.0-or-later +#include QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + LAYOUT_ortho_1x1(QK_BOOT) +}; + +#ifdef DEBUG_EEPROM_OUTPUT + +# ifdef WEAR_LEVELING_ENABLE +# include "wear_leveling.h" +# endif // WEAR_LEVELING_ENABLE + +uint8_t prng(void) { + static uint8_t s = 0xAA, a = 0; + s ^= s << 3; + s ^= s >> 5; + s ^= a++ >> 2; + return s; +} + +void keyboard_post_init_user(void) { + debug_enable = true; + debug_matrix = true; + debug_keyboard = true; +} + +void matrix_scan_user(void) { + static uint32_t last_eeprom_access = 0; + uint32_t now = timer_read32(); + if (now - last_eeprom_access > 5000) { + dprint("reading eeprom\n"); + last_eeprom_access = now; + + union { + uint8_t bytes[4]; + uint32_t raw; + } tmp; + extern uint8_t prng(void); + tmp.bytes[0] = prng(); + tmp.bytes[1] = prng(); + tmp.bytes[2] = prng(); + tmp.bytes[3] = prng(); + + eeconfig_update_user(tmp.raw); + uint32_t value = eeconfig_read_user(); + if (value != tmp.raw) { + dprint("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + dprint("!! EEPROM readback mismatch!\n"); + dprint("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + } + } + +# ifdef WEAR_LEVELING_ENABLE + static uint32_t last_wear_leveling_init = 0; + if (now - last_wear_leveling_init > 30000) { + dprint("init'ing wear-leveling\n"); + last_wear_leveling_init = now; + wear_leveling_init(); + } +# endif // WEAR_LEVELING_ENABLE +} + +#endif // DEBUG_EEPROM_OUTPUT diff --git a/keyboards/handwired/onekey/keymaps/wear_leveling/rules.mk b/keyboards/handwired/onekey/keymaps/wear_leveling/rules.mk new file mode 100644 index 0000000000..15b7f725b2 --- /dev/null +++ b/keyboards/handwired/onekey/keymaps/wear_leveling/rules.mk @@ -0,0 +1 @@ +CONSOLE_ENABLE = yes |