Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup EFL and F4's sector selection. #19221

Merged
merged 4 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add WL onekey test.
  • Loading branch information
tzarc committed Dec 2, 2022
commit b01af674d91356b181ae58097461775502e8f1ff
6 changes: 6 additions & 0 deletions keyboards/handwired/onekey/keymaps/wear_leveling/config.h
Original file line number Diff line number Diff line change
@@ -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
65 changes: 65 additions & 0 deletions keyboards/handwired/onekey/keymaps/wear_leveling/keymap.c
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions keyboards/handwired/onekey/keymaps/wear_leveling/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONSOLE_ENABLE = yes