Add eeprom_tool project
This commit is contained in:
parent
21ff75715b
commit
c23225040f
10 changed files with 250 additions and 0 deletions
47
keyboard/eeprom_tool/Makefile
Normal file
47
keyboard/eeprom_tool/Makefile
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
TARGET ?= eeprom_tool
|
||||
TMK_DIR ?= ../../tmk_core
|
||||
TARGET_DIR ?= .
|
||||
|
||||
SRC ?= $(TARGET).c
|
||||
CONFIG_H ?= config.h
|
||||
|
||||
# MCU name
|
||||
MCU ?= atmega32u4
|
||||
#MCU ?= atmega32u2
|
||||
|
||||
# Processor frequency.
|
||||
F_CPU ?= 16000000
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
ARCH ?= AVR8
|
||||
F_USB ?= $(F_CPU)
|
||||
|
||||
# Interrupt driven control endpoint task
|
||||
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||
|
||||
#
|
||||
# Build Options
|
||||
#
|
||||
MOUSEKEY_ENABLE ?= no # Mouse keys
|
||||
EXTRAKEY_ENABLE ?= no # Media control and System control
|
||||
CONSOLE_ENABLE ?= yes # Console for debug
|
||||
COMMAND_ENABLE ?= no # Commands for debug and configuration
|
||||
NKRO_ENABLE ?= no # USB Nkey Rollover
|
||||
NO_KEYBOARD ?= yes # No keyboard interface
|
||||
NO_DEBUG ?= yes
|
||||
|
||||
# Boot Section Size in bytes
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
#OPT_DEFS += -DNO_DEBUG
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
||||
6
keyboard/eeprom_tool/Makefile.show_atmega32u2
Normal file
6
keyboard/eeprom_tool/Makefile.show_atmega32u2
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
NAME = eeprom_show
|
||||
MCU = atmega32u2
|
||||
TARGET = $(NAME)_$(MCU)
|
||||
SRC = $(NAME).c
|
||||
|
||||
include Makefile
|
||||
6
keyboard/eeprom_tool/Makefile.show_atmega32u4
Normal file
6
keyboard/eeprom_tool/Makefile.show_atmega32u4
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
NAME = eeprom_show
|
||||
MCU = atmega32u4
|
||||
TARGET = $(NAME)_$(MCU)
|
||||
SRC = $(NAME).c
|
||||
|
||||
include Makefile
|
||||
6
keyboard/eeprom_tool/Makefile.wipe_atmega32u2
Normal file
6
keyboard/eeprom_tool/Makefile.wipe_atmega32u2
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
NAME = eeprom_wipe
|
||||
MCU = atmega32u2
|
||||
TARGET = $(NAME)_$(MCU)
|
||||
SRC = $(NAME).c
|
||||
|
||||
include Makefile
|
||||
6
keyboard/eeprom_tool/Makefile.wipe_atmega32u4
Normal file
6
keyboard/eeprom_tool/Makefile.wipe_atmega32u4
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
NAME = eeprom_wipe
|
||||
MCU = atmega32u4
|
||||
TARGET = $(NAME)_$(MCU)
|
||||
SRC = $(NAME).c
|
||||
|
||||
include Makefile
|
||||
18
keyboard/eeprom_tool/README.md
Normal file
18
keyboard/eeprom_tool/README.md
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
EEPROM tool
|
||||
===========
|
||||
This can show and erase EEPROM content and would be useful when you have a trouble with EEPROM.
|
||||
|
||||
|
||||
Prebuilt firmware
|
||||
-----------------
|
||||
`eeprom_show` just shows content of EEPROM and `eeprom_wipe` overwrites all bytes of EEPROM with 0xFF.
|
||||
|
||||
You can see the contents using `hid_listen`.
|
||||
|
||||
#### For ATmega32u2:
|
||||
- eeprom_show_32u2.hex
|
||||
- eeprom_wipe_32u2.hex
|
||||
|
||||
#### For ATmega32u4:
|
||||
- eeprom_show_32u4.hex
|
||||
- eeprom_wipe_32u4.hex
|
||||
50
keyboard/eeprom_tool/config.h
Normal file
50
keyboard/eeprom_tool/config.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
Copyright 2012 Jun Wako <wakojun@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0xEEEE
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER TMK
|
||||
#define PRODUCT EEPROM Tool
|
||||
#define DESCRIPTION Product from TMK keyboard firmware project
|
||||
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 0
|
||||
#define MATRIX_COLS 0
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
|
||||
|
||||
|
||||
// Disable power saving in USB suspend loop but remote wakeup is still valid.
|
||||
// This allows keep USB::Task() going during suspend without power down time delay.
|
||||
//#define NO_SUSPEND_POWER_DOWN
|
||||
|
||||
|
||||
// Disable USB startup wait, which can delays starting UHS2 Task() for 350-600ms.
|
||||
//#define NO_USB_STARTUP_WAIT_LOOP
|
||||
|
||||
// Disable USB suspend loop, which blocks UHS2 Task() while power saving.
|
||||
// Note that this also disables power saving and remote wakeup from keyboard completely.
|
||||
//#define NO_USB_SUSPEND_LOOP
|
||||
|
||||
#endif
|
||||
28
keyboard/eeprom_tool/eeprom_show.c
Normal file
28
keyboard/eeprom_tool/eeprom_show.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include "hook.h"
|
||||
#include "print.h"
|
||||
#include "timer.h"
|
||||
#include <avr/eeprom.h>
|
||||
|
||||
static void eeprom_show(void)
|
||||
{
|
||||
xprintf("eeprom:");
|
||||
for (int i = 0; i < E2END + 1; i++) {
|
||||
if ((i % 16) == 0) { xprintf("\n%04X: ", i); }
|
||||
xprintf("%02X ", eeprom_read_byte((uint8_t *)i));
|
||||
}
|
||||
xprintf("\n");
|
||||
}
|
||||
|
||||
void hook_late_init(void)
|
||||
{
|
||||
eeprom_show();
|
||||
}
|
||||
|
||||
void hook_main_loop(void)
|
||||
{
|
||||
static uint16_t last_time = 0;
|
||||
uint16_t t = timer_read();
|
||||
if (t != last_time && (t % 1000) == 0) xprintf(".");
|
||||
last_time = t;
|
||||
}
|
||||
|
||||
42
keyboard/eeprom_tool/eeprom_tool.c
Normal file
42
keyboard/eeprom_tool/eeprom_tool.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#include "hook.h"
|
||||
#include "print.h"
|
||||
#include "timer.h"
|
||||
#include <avr/eeprom.h>
|
||||
|
||||
static void eeprom_show(void)
|
||||
{
|
||||
xprintf("eeprom:");
|
||||
for (int i = 0; i < E2END + 1; i++) {
|
||||
if ((i % 16) == 0) { xprintf("\n%04X: ", i); }
|
||||
xprintf("%02X ", eeprom_read_byte((uint8_t *)i));
|
||||
}
|
||||
xprintf("\n");
|
||||
}
|
||||
|
||||
static void eeprom_wipe(void)
|
||||
{
|
||||
xprintf("eeprom wipe: ");
|
||||
for (int i = 0; i < E2END + 1; i++) {
|
||||
if ((i % 16) == 0) { xprintf("%04X: ", i); }
|
||||
eeprom_write_byte((uint8_t *)i, 0xFF);
|
||||
}
|
||||
xprintf("\n");
|
||||
}
|
||||
|
||||
void hook_late_init(void)
|
||||
{
|
||||
//eeprom_show();
|
||||
//xprintf("\n");
|
||||
//eeprom_wipe();
|
||||
//xprintf("\n");
|
||||
eeprom_show();
|
||||
}
|
||||
|
||||
void hook_main_loop(void)
|
||||
{
|
||||
static uint16_t last_time = 0;
|
||||
uint16_t t = timer_read();
|
||||
if (t != last_time && (t % 1000) == 0) xprintf(".");
|
||||
last_time = t;
|
||||
}
|
||||
|
||||
41
keyboard/eeprom_tool/eeprom_wipe.c
Normal file
41
keyboard/eeprom_tool/eeprom_wipe.c
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#include "hook.h"
|
||||
#include "print.h"
|
||||
#include "timer.h"
|
||||
#include <avr/eeprom.h>
|
||||
|
||||
static void eeprom_show(void)
|
||||
{
|
||||
xprintf("eeprom:");
|
||||
for (int i = 0; i < E2END + 1; i++) {
|
||||
if ((i % 16) == 0) { xprintf("\n%04X: ", i); }
|
||||
xprintf("%02X ", eeprom_read_byte((uint8_t *)i));
|
||||
}
|
||||
xprintf("\n");
|
||||
}
|
||||
|
||||
static void eeprom_wipe(void)
|
||||
{
|
||||
xprintf("eeprom wipe: ");
|
||||
for (int i = 0; i < E2END + 1; i++) {
|
||||
if ((i % 16) == 0) { xprintf("%04X: ", i); }
|
||||
eeprom_write_byte((uint8_t *)i, 0xFF);
|
||||
}
|
||||
xprintf("\n");
|
||||
}
|
||||
|
||||
void hook_late_init(void)
|
||||
{
|
||||
eeprom_show();
|
||||
xprintf("\n");
|
||||
eeprom_wipe();
|
||||
xprintf("\n");
|
||||
eeprom_show();
|
||||
}
|
||||
|
||||
void hook_main_loop(void)
|
||||
{
|
||||
static uint16_t last_time = 0;
|
||||
uint16_t t = timer_read();
|
||||
if (t != last_time && (t % 1000) == 0) xprintf(".");
|
||||
last_time = t;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue