Merge branch 'master' of https://github.com/jackhumbert/qmk_firmware
@ -1,95 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = IIgs_Standard
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# keyboard dependent files
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name, you MUST set this to match the board you are using
|
||||
# type "make clean" after changing this, so all files will be rebuilt
|
||||
#MCU = at90usb162 # Teensy 1.0
|
||||
#MCU = atmega32u4 # Teensy 2.0
|
||||
#MCU = at90usb646 # Teensy++ 1.0
|
||||
MCU = at90usb1286 # Teensy++ 2.0
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# Normally the first thing your program should do is set the clock prescaler,
|
||||
# so your program will run at the correct speed. You should also set this
|
||||
# variable to same clock speed. The _delay_ms() macro uses this, and many
|
||||
# examples use this variable to calculate timings. Do not add a "UL" here.
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
MOUSEKEY_ENABLE = no # Mouse keys
|
||||
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover
|
||||
|
||||
|
||||
|
||||
#---------------- Programming Options --------------------------
|
||||
PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
|
||||
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/pjrc.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
@ -1,45 +0,0 @@
|
||||
Replaceable USB Controller for Apple IIgs/Standard(M0116)
|
||||
JeffreySung(nattyman@gmail.com)
|
||||
|
||||
===============================
|
||||
|
||||
Feature
|
||||
-------
|
||||
- Replaceable keyboard controller for Apple IIgs(A9M0330)/Standard(M0116)
|
||||
- Teensy++ 2.0 required
|
||||
- Some signal bypass required
|
||||
- ADB keyboard doesn't use matrix for modifier keys. With virtual row for modifier keys,
|
||||
these keys are merged into key matrix using virtual row.
|
||||
|
||||
History
|
||||
=======
|
||||
- 2012.09.17 First Release
|
||||
- 2012.09.17 CapsLock support
|
||||
- 2012.09.19 Power button added
|
||||
Build
|
||||
=====
|
||||
0. Just Type "Make" and return.
|
||||
|
||||
Hardware
|
||||
========
|
||||
PJRC Teensy
|
||||
-----------
|
||||
0. The following ports should not be connected to board.
|
||||
From top view of Teensy++, from GND and counter clock wise.
|
||||
-7,26(in keyboard PCB, these pins are VDD,GND)
|
||||
-30,31(in Teensy++, these pins are Ref,GND respectively)
|
||||
-5,6(D2,D3 for bluetooth in future)
|
||||
1. Bypass #31 pin(from board) to E4(Teensy)
|
||||
2. Bypass #30 pin(from board) to F2(Teensy)
|
||||
3. Bypass #6 pin(from board) to A0(Teensy)
|
||||
4. Refer to documentation directory
|
||||
|
||||
To Do
|
||||
=====
|
||||
0. When DEBOUNCE defined, there is a errors.
|
||||
1. Layer Change by toggling Clear Key
|
||||
2. Eject Key add. (following files should be modified.)
|
||||
common/keycode.h
|
||||
common/keyboard.c
|
||||
3. Use bluetooth
|
||||
EOF
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
Copyright 2011 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
|
||||
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
/* for Apple
|
||||
#define VENDOR_ID 0x05AC
|
||||
#define PRODUCT_ID 0xBEE0
|
||||
*/
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0xBEE0
|
||||
#define DEVICE_VER 0x0202
|
||||
#define MANUFACTURER t.m.k.
|
||||
#define PRODUCT Apple Desktop Bus Keyboard
|
||||
|
||||
|
||||
/* message strings */
|
||||
#define DESCRIPTION Apple M0116/A9M0660 keyboard firmware
|
||||
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 11 // last row is virtual for modifier
|
||||
#define MATRIX_COLS 8
|
||||
/* define if matrix has ghost */
|
||||
#define MATRIX_HAS_GHOST
|
||||
/* Set 0 if need no debouncing */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_LCTRL) | MOD_BIT(KC_LALT) | MOD_BIT(KC_LGUI)) || \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
|
||||
/* layer switching */
|
||||
#define LAYER_SWITCH_DELAY 100
|
||||
#define LAYER_SEND_FN_TERM 300
|
||||
|
||||
|
||||
/* legacy keymap support */
|
||||
#define USE_LEGACY_KEYMAP
|
||||
|
||||
|
||||
#endif
|
Before Width: | Height: | Size: 322 KiB |
Before Width: | Height: | Size: 72 KiB |
@ -1,142 +0,0 @@
|
||||
/*
|
||||
Copyright 2012 Jeffrey Sung <nattyman@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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Keymap for Apple IIgs/Standard Keyboard
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "keycode.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "keymap.h"
|
||||
|
||||
|
||||
// Convert physical keyboard layout to matrix array.
|
||||
// This is a macro to define keymap easily in keyboard layout form.
|
||||
#define KEYMAP( R10C5, \
|
||||
R3C7, R3C6, R3C5, R3C4, R3C3, R3C2, R3C1, R8C1, R8C0, R3C0, R0C0, R0C1, R0C2, R0C3, R4C4, R4C5, R4C6, R4C7, \
|
||||
R9C7, R9C6, R9C5, R9C4, R9C3, R9C2, R9C1, R9C0, R1C0, R1C1, R1C2, R1C3, R1C4, R2C4, R2C5, R2C6, R2C3, \
|
||||
R10C0,R7C7, R7C6, R7C5, R7C4, R7C3, R7C2, R7C1, R7C0, R0C4, R1C6, R1C7, R1C5, R2C0, R2C1, R2C2, R2C7, \
|
||||
R10C1,R6C7, R6C6, R6C5, R6C4, R6C3, R6C2, R6C1, R6C0, R0C5, R0C6, R4C0, R4C1, R4C2, \
|
||||
R10C4,R10C2,R10C3,R5C4, R5C7, R5C5, R5C6, R5C0, R5C2, R0C7, R5C1, R5C3, R4C3 \
|
||||
) { \
|
||||
{ R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7 }, \
|
||||
{ R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7 }, \
|
||||
{ R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7 }, \
|
||||
{ R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7 }, \
|
||||
{ R4C0, R4C1, R4C2, R4C3, R4C4, R4C5, R4C6, R4C7 }, \
|
||||
{ R5C0, R5C1, R5C2, R5C3, R5C4, R5C5, R5C6, R5C7 }, \
|
||||
{ R6C0, R6C1, R6C2, R6C3, R6C4, R6C5, R6C6, R6C7 }, \
|
||||
{ R7C0, R7C1, R7C2, R7C3, R7C4, R7C5, R7C6, R7C7 }, \
|
||||
{ R8C0, R8C1, KC_NO, KC_NO, KC_NO,KC_NO, KC_NO, KC_NO }, \
|
||||
{ R9C0, R9C1, R9C2, R9C3, R9C4, R9C5, R9C6, R9C7 }, \
|
||||
{ R10C0,R10C1, R10C2, R10C3, R10C4,R10C5, KC_NO, KC_NO} \
|
||||
}
|
||||
|
||||
#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
|
||||
|
||||
|
||||
// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
|
||||
static const uint8_t PROGMEM fn_layer[] = {
|
||||
0, // Fn0
|
||||
1, // Fn1
|
||||
2, // Fn2
|
||||
3, // Fn3
|
||||
4, // Fn4
|
||||
0, // Fn5
|
||||
3, // Fn6
|
||||
3 // Fn7
|
||||
};
|
||||
|
||||
// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
|
||||
// See layer.c for details.
|
||||
static const uint8_t PROGMEM fn_keycode[] = {
|
||||
KC_NO, // Fn0
|
||||
KC_NO, // Fn1
|
||||
KC_SLSH, // Fn2
|
||||
KC_SCLN, // Fn3
|
||||
KC_SPC, // Fn4
|
||||
KC_NO, // Fn5
|
||||
KC_NO, // Fn6
|
||||
KC_NO // Fn7
|
||||
};
|
||||
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Layer 0: Default Layer
|
||||
* ,-----------------------------------------------------------. ,---------------,
|
||||
* | POWER | | |
|
||||
* |-----------------------------------------------------------| |---------------|
|
||||
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |FN0| = | / | * |
|
||||
* |-----------------------------------------------------------| |---------------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7 | 8 | 9 | + |
|
||||
* |-----------------------------------------------------' | |---------------|
|
||||
* |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return | | 4 | 5 | 6 | - |
|
||||
* |-----------------------------------------------------------| |---------------|
|
||||
* |Shift | Z| X| C| V| B| N| M| ,| .| / |Shift | | 1 | 2 | 3 | E |
|
||||
* |-----------------------------------------------------------| |-----------| N |
|
||||
* |CAPS|Alt |Gui |` |SPC |BSLS |LFT|RGT|DN|UP| | 0 | . | T |
|
||||
* `-----------------------------------------------------------' |---------------'
|
||||
*/
|
||||
KEYMAP( KC_PWR,
|
||||
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,KC_EQL, KC_BSPC, KC_FN1, KC_PEQL, KC_PSLS, KC_PAST, \
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC, KC_P7, KC_P8, KC_P9, KC_PPLS, \
|
||||
KC_LCTL,KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,KC_ENT, KC_P4, KC_P5, KC_P6, KC_PMNS, \
|
||||
KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_P1, KC_P2, KC_P3, \
|
||||
KC_CAPS,KC_LALT,KC_LGUI,KC_GRV, KC_SPC, KC_BSLS,KC_LEFT,KC_RGHT,KC_DOWN,KC_UP, KC_P0, KC_PDOT, KC_PENT),
|
||||
|
||||
|
||||
/* Layer 1: Tenkey use Layer
|
||||
* ,-----------------------------------------------------------. ,---------------,
|
||||
* | POWER | | |
|
||||
* |-----------------------------------------------------------| |---------------|
|
||||
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |NLK| = | / | * |
|
||||
* |-----------------------------------------------------------| |---------------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | |INS| 8 |PGU|V+ |
|
||||
* |-----------------------------------------------------' | |---------------|
|
||||
* |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return | |DEL|UP |PGD|V- |
|
||||
* |-----------------------------------------------------------| |---------------|
|
||||
* |Shift | Z| X| C| V| B| N| M| ,| .| / |Shift | |LFT|DN |RGT| E |
|
||||
* |-----------------------------------------------------------| |-----------| N |
|
||||
* |CAPS|Alt |Gui |` |SPC |BSLS |LFT|RGT|DN|UP| | 0 | . | T |
|
||||
* `-----------------------------------------------------------' `---------------'
|
||||
*/
|
||||
KEYMAP( KC_PWR, \
|
||||
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,KC_EQL, KC_BSPC, KC_FN1, KC_PEQL, KC_PSLS, KC_MUTE, \
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC, KC_INS, KC_P8, KC_PGUP, KC_VOLU, \
|
||||
KC_LCTL,KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,KC_ENT, KC_DEL, KC_UP, KC_PGDN, KC_VOLD, \
|
||||
KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_LEFT, KC_DOWN, KC_RIGHT, \
|
||||
KC_CAPS,KC_LALT,KC_LGUI,KC_GRV, KC_SPC, KC_BSLS,KC_LEFT,KC_RGHT,KC_DOWN,KC_UP, KC_P0, KC_PDOT, KC_PENT),
|
||||
};
|
||||
|
||||
|
||||
uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
|
||||
{
|
||||
return KEYCODE(layer, row, col);
|
||||
}
|
||||
|
||||
uint8_t keymap_fn_layer(uint8_t index)
|
||||
{
|
||||
return pgm_read_byte(&fn_layer[index]);
|
||||
}
|
||||
|
||||
uint8_t keymap_fn_keycode(uint8_t index)
|
||||
{
|
||||
return pgm_read_byte(&fn_keycode[index]);
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
/*
|
||||
Copyright 2011 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/>.
|
||||
*/
|
||||
|
||||
#include "stdint.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
}
|
@ -1,363 +0,0 @@
|
||||
/*
|
||||
Copyright 2011 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* scan matrix
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
#if (MATRIX_COLS > 16)
|
||||
# error "MATRIX_COLS must not exceed 16"
|
||||
#endif
|
||||
#if (MATRIX_ROWS > 255)
|
||||
# error "MATRIX_ROWS must not exceed 255"
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 0
|
||||
#endif
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
// matrix state buffer(1:on, 0:off)
|
||||
#if (MATRIX_COLS <= 8)
|
||||
static uint8_t *matrix;
|
||||
static uint8_t *matrix_prev;
|
||||
static uint8_t _matrix0[MATRIX_ROWS];
|
||||
static uint8_t _matrix1[MATRIX_ROWS];
|
||||
#else
|
||||
static uint16_t *matrix;
|
||||
static uint16_t *matrix_prev;
|
||||
static uint16_t _matrix0[MATRIX_ROWS];
|
||||
static uint16_t _matrix1[MATRIX_ROWS];
|
||||
#endif
|
||||
|
||||
#ifdef MATRIX_HAS_GHOST
|
||||
static bool matrix_has_ghost_in_row(uint8_t row);
|
||||
#endif
|
||||
static uint8_t read_col(uint8_t row);
|
||||
static void unselect_rows(void);
|
||||
static void select_row(uint8_t row);
|
||||
|
||||
|
||||
inline
|
||||
uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
// initialize row and col
|
||||
unselect_rows();
|
||||
// Input with pull-up(DDR:0, PORT:1)
|
||||
// Column C1 ~ C7 (PortC0-6)
|
||||
// Column C0(Port E1)
|
||||
DDRC &= ~0b01111111;
|
||||
PORTC |= 0b01111111;
|
||||
DDRE &= ~0b00000010;
|
||||
PORTE |= 0b00000010;
|
||||
//DDRB &= ~0b00000100;
|
||||
//PORTB |= 0b00000100;
|
||||
// modifier B3/4,F4/5,E4 always input
|
||||
// A0
|
||||
//DDRA |= 0b00000001;
|
||||
//PORTA &= 0b00000001;
|
||||
//DDRB |= 0b00011000;
|
||||
//PORTB &= 0b00011000;
|
||||
//DDRF |= ~0b00110000;
|
||||
//PORTF &= 0b00110000;
|
||||
//DDRB &= ~0b00011000;
|
||||
//PORTB |= 0b00011000;
|
||||
//DDRF &= ~0b00110000;
|
||||
//PORTF |= 0b00110000;
|
||||
//DDRE &= ~0b00010000;
|
||||
//PORTE |= 0b00010000;
|
||||
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00;
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix1[i] = 0x00;
|
||||
matrix = _matrix0;
|
||||
matrix_prev = _matrix1;
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
if (!debouncing) {
|
||||
uint8_t *tmp = matrix_prev;
|
||||
matrix_prev = matrix;
|
||||
matrix = tmp;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
unselect_rows();
|
||||
select_row(i);
|
||||
_delay_us(30); // without this wait read unstable value.
|
||||
if ( i == ( MATRIX_ROWS - 1 ) ) { // CHECK CAPS LOCK
|
||||
if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { // CAPS LOCK is ON on HOST
|
||||
if ( ~read_col(i) & (1<< 4) ) { // CAPS LOCK is still DOWN ( 0bXXX1_XXXX)
|
||||
matrix[i] = ~read_col(i) & 0b11101111; // change CAPS LOCK as released
|
||||
} else { // CAPS LOCK in UP
|
||||
matrix[i] = ~read_col(i) | 0b00010000; // send fake caps lock down
|
||||
}
|
||||
} else { // CAPS LOCK is OFF on HOST
|
||||
if (matrix[i] != (uint8_t)~read_col(i)) {
|
||||
matrix[i] = (uint8_t)~read_col(i);
|
||||
if (debouncing) {
|
||||
debug("bounce!: "); debug_hex(debouncing); print("\n");
|
||||
}
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (matrix[i] != (uint8_t)~read_col(i)) {
|
||||
matrix[i] = (uint8_t)~read_col(i);
|
||||
if (debouncing) {
|
||||
debug("bounce!: "); debug_hex(debouncing); print("\n");
|
||||
}
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
unselect_rows();
|
||||
|
||||
if (debouncing) {
|
||||
debouncing--;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
if (debouncing) return false;
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
if (matrix[i] != matrix_prev[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_has_ghost(void)
|
||||
{
|
||||
#ifdef MATRIX_HAS_GHOST
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
if (matrix_has_ghost_in_row(i))
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
// if ( row == ( MATRIX_ROWS - 1 ) && col == 4) { // CHECK CAPS LOCK
|
||||
// if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { // CAPS LOCK is ON on HOST
|
||||
// if ((matrix_prev[row] & 0b00010000) && (~matrix[row] & 0b00010000)) {
|
||||
// debug("CapsLock Reverse:");debug_hex(matrix[row]);
|
||||
// matrix[row] |= 0b00010000;
|
||||
// matrix_prev[row] &= ~0b00010000;
|
||||
// debug("->");debug_hex(matrix[row]);debug("\n");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return (matrix[row] & (1<<col));
|
||||
}
|
||||
|
||||
inline
|
||||
#if (MATRIX_COLS <= 8)
|
||||
uint8_t matrix_get_row(uint8_t row)
|
||||
#else
|
||||
uint16_t matrix_get_row(uint8_t row)
|
||||
#endif
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
print("\nr/c 01234567\n");
|
||||
for (uint8_t row = 0; row < matrix_rows(); row++) {
|
||||
phex(row); print(": ");
|
||||
#if (MATRIX_COLS <= 8)
|
||||
pbin_reverse(matrix_get_row(row));
|
||||
#else
|
||||
pbin_reverse16(matrix_get_row(row));
|
||||
#endif
|
||||
#ifdef MATRIX_HAS_GHOST
|
||||
if (matrix_has_ghost_in_row(row)) {
|
||||
print(" <ghost");
|
||||
}
|
||||
#endif
|
||||
print("\n");
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_key_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
#if (MATRIX_COLS <= 8)
|
||||
count += bitpop(matrix[i]);
|
||||
#else
|
||||
count += bitpop16(matrix[i]);
|
||||
#endif
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
#ifdef MATRIX_HAS_GHOST
|
||||
inline
|
||||
static bool matrix_has_ghost_in_row(uint8_t row)
|
||||
{
|
||||
// no ghost exists in case less than 2 keys on
|
||||
if (((matrix[row] - 1) & matrix[row]) == 0)
|
||||
return false;
|
||||
|
||||
// ghost exists in case same state as other row
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
if (i != row && (matrix[i] & matrix[row]) == matrix[row])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline
|
||||
static uint8_t read_col(uint8_t row)
|
||||
{
|
||||
// For normal : Column C1 ~ C7 (PortC0-6), C0(Port E1)
|
||||
// For modifier : B3(CNTRL)/4(SHIFT),F4(CMD/GUI)/5(OPTION,ALT)
|
||||
// Modifier would be copied to report->mods except E4(CAPSLOCK)
|
||||
uint8_t tmp;
|
||||
if ( row == 10 ) {
|
||||
tmp = 0xC0;
|
||||
tmp |= (PINB >> 3 ) & 0b00000011; // LEFT CTRL is 0bit in modifier (HID Spec)
|
||||
// LEFT SHIFT is 1bit in modifier (HID Spec)
|
||||
tmp |= (PINF >> 3 ) & 0b00000100; // LEFT ALT is 2bit in modifier (HID Spec)
|
||||
tmp |= (PINF >> 1 ) & 0b00001000; // LEFT GUI is 3bit in modifier (HID Spec)
|
||||
tmp |= (PINA << 4 ) & 0b00010000; // CAPSLOCK
|
||||
tmp |= (PINB << 3 ) & 0b00100000; // POWER
|
||||
} else {
|
||||
tmp = 0x00;
|
||||
tmp = (PINE >> 1)&0b00000001;
|
||||
tmp |= PINC << 1 ;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
inline
|
||||
static void unselect_rows(void)
|
||||
{
|
||||
// Hi-Z(DDR:0, PORT:0) to unselect
|
||||
// DDR : 1, output 0, input
|
||||
DDRB &= ~0b00000011; // PB: 1,0
|
||||
PORTB &= ~0b00000011;
|
||||
DDRD &= ~0b00010000; // PD: 4
|
||||
PORTD &= ~0b00010000;
|
||||
DDRE &= ~0b11000000; // PE: 7,6
|
||||
PORTE &= ~0b11000000;
|
||||
DDRF &= ~0b11000111; // PF: 7,6,2,1,0
|
||||
PORTF &= ~0b11000111;
|
||||
// to unselect virtual row(modifier), set port to output with low
|
||||
DDRA |= 0b00000001; // PA: 0 for CAPSLOCK
|
||||
PORTA &= ~0b00000001;
|
||||
DDRB |= 0b00011100; // PB: 3,4 for modifier(row10)
|
||||
PORTB &= ~0b00011100; // PB: 2 for power
|
||||
DDRF |= 0b00110000; // PF: 4,5 for modifier
|
||||
PORTF &= ~0b00110000;
|
||||
}
|
||||
|
||||
inline
|
||||
static void select_row(uint8_t row)
|
||||
{
|
||||
// Output low(DDR:1, PORT:0) to select
|
||||
// with row enable, column could send low to AVR when pressed
|
||||
// row: 0 1 2 3 4 5 6 7 8 9
|
||||
// pin: PB1, PB0, PE7, PE6, PD4, PF2, PF0, PF1, PF6 PF7
|
||||
switch (row) {
|
||||
case 0:
|
||||
DDRB |= (1<<1);
|
||||
PORTB &= ~(1<<1);
|
||||
break;
|
||||
case 1:
|
||||
DDRB |= (1<<0);
|
||||
PORTB &= ~(1<<0);
|
||||
break;
|
||||
case 2:
|
||||
DDRE |= (1<<7);
|
||||
PORTE &= ~(1<<7);
|
||||
break;
|
||||
case 3:
|
||||
DDRE |= (1<<6);
|
||||
PORTE &= ~(1<<6);
|
||||
break;
|
||||
case 4:
|
||||
DDRD |= (1<<4);
|
||||
PORTD &= ~(1<<4);
|
||||
break;
|
||||
case 5:
|
||||
DDRF |= (1<<2);
|
||||
PORTF &= ~(1<<2);
|
||||
break;
|
||||
case 6:
|
||||
DDRF |= (1<<0);
|
||||
PORTF &= ~(1<<0);
|
||||
break;
|
||||
case 7:
|
||||
DDRF |= (1<<1);
|
||||
PORTF &= ~(1<<1);
|
||||
break;
|
||||
case 8:
|
||||
DDRF |= (1<<6);
|
||||
PORTF &= ~(1<<6);
|
||||
break;
|
||||
case 9:
|
||||
DDRF |= (1<<7);
|
||||
PORTF &= ~(1<<7);
|
||||
break;
|
||||
case 10:
|
||||
// modifier has no row enable
|
||||
// to select virtual row, set port as input
|
||||
DDRA &= ~0b00000001;
|
||||
PORTA |= 0b00000001;
|
||||
DDRB &= ~0b00011100;
|
||||
PORTB |= 0b00011100;
|
||||
DDRF &= ~0b00110000;
|
||||
PORTF |= 0b00110000;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
SuperCoder 2000 layout for the ErgoDox
|
||||
==================================================
|
||||
|
||||
![SuperCoder 2000](images/supercoder_2000.jpg)
|
||||
|
||||
Ever found yourself in need of entering binary codes rapidly? Ever wanted to use
|
||||
all ten fingers to do so? Ever felt your SuperCoder 2000 too limiting, by only
|
||||
having three buttons? We heard you! With this layout for the ErgoDox EZ, you
|
||||
will be able to tap in binary at an unparalleled speed and accuracy! Efficiency
|
||||
never seen before!
|
||||
|
||||
Behold the Ultimate SuperCoder 2000 layout!
|
||||
|
||||
![SuperCoder layout](images/layout.png)
|
||||
|
||||
### To use it...
|
||||
|
||||
To use this piece of top quality engineering, you can either
|
||||
[download the hex file][hex] we have prepared for you, or you can compile it on
|
||||
your own:
|
||||
|
||||
[hex]: https://raw.githubusercontent.com/algernon/ergodox-supercoder/master/supercoder.hex
|
||||
|
||||
```
|
||||
$ git clone https://github.com/jackhumbert/qmk_firmware.git
|
||||
$ cd qmk_firmware/keyboard/ergodox_ez
|
||||
$ git clone https://github.com/algernon/ergodox-supercoder.git keymaps/supercoder
|
||||
$ make KEYMAP=supercoder
|
||||
```
|
@ -0,0 +1,9 @@
|
||||
#ifndef CONFIG_USER_H
|
||||
#define CONFIG_USER_H 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#undef LOCKING_SUPPORT_ENABLE
|
||||
#undef LOCKING_RESYNC_ENABLE
|
||||
|
||||
#endif
|
After Width: | Height: | Size: 64 KiB |
After Width: | Height: | Size: 74 KiB |
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* SuperCoder 2000 layout
|
||||
*/
|
||||
|
||||
#include "ergodox_ez.h"
|
||||
|
||||
/* Layers */
|
||||
|
||||
#define SC2K 0 // default layer
|
||||
|
||||
/* The Keymap */
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
/* Keymap 0: Base Layer
|
||||
*
|
||||
* ,-----------------------------------------------------. ,-----------------------------------------------------.
|
||||
* | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
|
||||
* |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------|
|
||||
* | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
|
||||
* |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------|
|
||||
* | 0 | 0 | 0 | 0 | 0 | 0 |------| |------| 1 | 1 | 1 | 1 | 1 | 1 |
|
||||
* |-----------+------+------+------+------+------| 0 | | 1 |------+------+------+------+------+-----------|
|
||||
* | 0 | 0 | 0 | 0 | 0 | 0 | | | | 1 | 1 | 1 | 1 | 1 | 1 |
|
||||
* `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------'
|
||||
* | 0 | 0 | 0 | 0 | 0 | | 1 | 1 | 1 | 1 | 1 |
|
||||
* `-----------------------------------' `-----------------------------------'
|
||||
* ,-------------. ,-------------.
|
||||
* | DONE | DONE | | DONE | DONE |
|
||||
* ,------|------|------| |------+------+------.
|
||||
* | | | DONE | | DONE | | |
|
||||
* | DONE | DONE |------| |------| DONE | DONE |
|
||||
* | | | DONE | | DONE | | |
|
||||
* `--------------------' `--------------------'
|
||||
*/
|
||||
[SC2K] = KEYMAP(
|
||||
// left hand
|
||||
KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0
|
||||
,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0
|
||||
,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0
|
||||
,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0
|
||||
,KC_0 ,KC_0 ,KC_0 ,KC_0 ,KC_0
|
||||
|
||||
,KC_ENT ,KC_ENT
|
||||
,KC_ENT
|
||||
,KC_ENT ,KC_ENT ,KC_ENT
|
||||
|
||||
// right hand
|
||||
,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1
|
||||
,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1
|
||||
,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1
|
||||
,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1
|
||||
,KC_1 ,KC_1 ,KC_1 ,KC_1 ,KC_1
|
||||
|
||||
,KC_ENT ,KC_ENT
|
||||
,KC_ENT
|
||||
,KC_ENT ,KC_ENT ,KC_ENT
|
||||
),
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
};
|
||||
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
return MACRO_NONE;
|
||||
};
|
||||
|
||||
// Runs just one time when the keyboard initializes.
|
||||
void matrix_init_user(void) {
|
||||
};
|
||||
|
||||
// Runs constantly in the background, in a loop.
|
||||
void matrix_scan_user(void) {
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
BOOTMAGIC_ENABLE=no
|
||||
COMMAND_ENABLE=no
|
||||
SLEEP_LED_ENABLE=no
|
||||
UNICODE_ENABLE=no
|
||||
MOUSEKEY_ENABLE=no
|
||||
EXTRAKEY_ENABLE=no
|
@ -0,0 +1,846 @@
|
||||
:100000000C9456010C949D010C949D010C949D013F
|
||||
:100010000C949D010C949D010C949D010C949D01E8
|
||||
:100020000C949D010C949D010C94D90B0C94AB0C79
|
||||
:100030000C941D190C949D010C949D010C949D0130
|
||||
:100040000C949D010C949D010C949D010C949D01B8
|
||||
:100050000C949D010C9485190C949D010C949D01A8
|
||||
:100060000C949D010C949D010C949D010C949D0198
|
||||
:100070000C949D010C949D010C949D010C949D0188
|
||||
:100080000C949D010C949D010C949D010C949D0178
|
||||
:100090000C949D010C949D010C949D010C949D0168
|
||||
:1000A0000C949D010C949D010C949D01180D3A0D2A
|
||||
:1000B000280E3A0D280E7F0DA20D280EF70D0A0E00
|
||||
:1000C00071107110A010A010FC11FC11FC11FC119A
|
||||
:1000D000D610FC1186118611ED11FC11FC11F611E0
|
||||
:1000E00093119311931193119311931193119311F0
|
||||
:1000F00093119311931193119311931193119311E0
|
||||
:10010000A511B211B911C011CA112700270027008B
|
||||
:1001100027002700000027002700270027002700CE
|
||||
:100120002800270027002700270027002800270095
|
||||
:100130002700270027002700280027002700270086
|
||||
:10014000270027002800270027002700270000009D
|
||||
:1001500028002700270000002700000028001E00BC
|
||||
:100160001E0000001E00000028001E001E001E00D1
|
||||
:100170001E00000028001E001E001E001E001E00A3
|
||||
:1001800028001E001E001E001E001E0028001E006B
|
||||
:100190001E001E001E001E0028001E001E001E0065
|
||||
:1001A0001E001E0028001E001E001E001E001E0055
|
||||
:1001B000000016034500720067006F0044006F00E6
|
||||
:1001C0007800200045005A00000016034500720028
|
||||
:1001D00067006F0044006F007800200045005A005F
|
||||
:1001E00000000403090409023B00020100A0FA090F
|
||||
:1001F0000400000103010100092111010001223F57
|
||||
:10020000000705810308000A09040100010300003A
|
||||
:1002100000092111010001223900070582031000A5
|
||||
:10022000011201100100000008EDFE07130100019A
|
||||
:1002300002000105010906A101050719E029E715DA
|
||||
:100240000025019508750181020508190129059508
|
||||
:1002500005750191029501750391010507190029A2
|
||||
:100260007715002501957875018102C00501090601
|
||||
:10027000A101050719E029E7150025019508750179
|
||||
:100280008102950175088101050819012905950567
|
||||
:10029000750191029501750391010507190029FF68
|
||||
:1002A000150025FF950675088100C00011241FBEAA
|
||||
:1002B000CFEFDAE0DEBFCDBF04B603FE27C08091EA
|
||||
:1002C000CA019091CB01A091CC01B091CD018730B2
|
||||
:1002D000904BA740B04BD1F41092CA011092CB01C1
|
||||
:1002E0001092CC011092CD0114BE84B7877F84BFD9
|
||||
:1002F0000FB6F894A89580916000886180936000A3
|
||||
:10030000109260000FBEE0E0FFE3099511E0A0E06D
|
||||
:10031000B1E0E6EBF4E302C005900D92A031B10725
|
||||
:10032000D9F721E0A0E1B1E001C01D92AA3CB207DB
|
||||
:10033000E1F70E941D090C94591A0C94000080E00A
|
||||
:1003400090E00895089508950C94A30156985E983E
|
||||
:1003500025982D9826982E9827982F988FEF90E023
|
||||
:10036000909389008093880090938B0080938A00FB
|
||||
:1003700090938D0080938C00259A2D9A2FEF80E723
|
||||
:1003800092E0215080409040E1F700C00000269AA2
|
||||
:100390002E9A2FEF80E792E0215080409040E1F7C5
|
||||
:1003A00000C00000279A2F9A2FEF80E792E021509B
|
||||
:1003B00080409040E1F700C0000025982D982FEF75
|
||||
:1003C00080E792E0215080409040E1F700C00000BB
|
||||
:1003D00026982E982FEF80E792E0215080409040A1
|
||||
:1003E000E1F700C0000027982F9856985E9825984E
|
||||
:1003F0002D9826982E9827982F98089589EA80930B
|
||||
:10040000800089E08093810024982C983F988AB1DD
|
||||
:100410008F748AB96E98479A8BB1806B8BB9769A34
|
||||
:100420000E94A6010C94A20180E2809300018091B9
|
||||
:10043000100181110EC00E94630281E080931001BF
|
||||
:100440002FEF83ED90E3215080409040E1F700C012
|
||||
:10045000000080E40E9469028093000181112EC097
|
||||
:100460000E94930280930001811128C00E94930290
|
||||
:1004700080930001811122C08FE30E949302809338
|
||||
:10048000000181111BC00E948B0280E40E9469025E
|
||||
:1004900080930001811112C08CE00E94930280932E
|
||||
:1004A000000181110BC00E94930280930001811111
|
||||
:1004B00005C08FE30E949302809300010E948B028B
|
||||
:1004C0008091000108951092B9008AE08093B800ED
|
||||
:1004D000089594EA9093BC009091BC0097FFFCCFE4
|
||||
:1004E0009091B900987F983021F0903111F081E01F
|
||||
:1004F00008958093BB0084E88093BC008091BC0089
|
||||
:1005000087FFFCCF8091B900887F883111F080345B
|
||||
:1005100071F780E0089584E98093BC008091BC006D
|
||||
:1005200084FDFCCF08958093BB0084E88093BC00D9
|
||||
:100530008091BC0087FFFCCF9091B900987F81E04B
|
||||
:10054000983209F480E0089584E88093BC0080919B
|
||||
:10055000BC0087FFFCCF8091BB0008958091000113
|
||||
:10056000811115C080E40E9469028093000181110D
|
||||
:100570000CC082E10E94930280930001811105C0AA
|
||||
:100580008FEF0E949302809300010E948B0284B13E
|
||||
:10059000807F84B985B1807F85B98AB1837F8AB92C
|
||||
:1005A0008BB1837F8BB93E98469808950E941402C0
|
||||
:1005B000809300010E94AE0280B38C7080BB81B337
|
||||
:1005C000836F81BBA2E1B1E0E0E2F1E08EE08E0F4B
|
||||
:1005D00011921D928E13FCCF0C94FE01BF92CF920C
|
||||
:1005E000DF92EF92FF920F931F93CF93DF9380914F
|
||||
:1005F0000001882379F0809111018F5F80931101B0
|
||||
:10060000811108C00E94140280930001811102C070
|
||||
:100610000E94A60102E111E0C0E0D0E0DD24D39405
|
||||
:1006200082E0C82EEE24E394F12CC730D10500F50A
|
||||
:1006300080910001811164C080E40E94690280936E
|
||||
:100640000001811112C082E10E9493028093000197
|
||||
:1006500081110BC0C7010C2E01C0880F0A94EAF764
|
||||
:1006600080950E949302809300010E948B0248C0F3
|
||||
:10067000CA30A1F028F4C83059F0C93061F005C083
|
||||
:10068000CC3089F070F0CD3089F0209A289810C0D5
|
||||
:10069000219A29980DC0229A2A980AC0239A2B9849
|
||||
:1006A00007C0529A01C0539A5B9802C03E9A46987E
|
||||
:1006B00090EA9A95F1F79FB1799902C082E001C062
|
||||
:1006C00080E091709D25982B7C9902C084E001C048
|
||||
:1006D00080E0892B7D9902C038E001C030E0832B97
|
||||
:1006E0007E9902C020E101C020E0822B9FB190954D
|
||||
:1006F000991F9927991F9295990F907E892B0FC06A
|
||||
:1007000080910001811149C080E40E9469028093B8
|
||||
:100710000001882379F1B12C0E948B028B2DF80106
|
||||
:100720009081981719F08083C09201010E94AE0257
|
||||
:1007300021960F5F1F4FCE30D10509F076CF809103
|
||||
:100740000101882361F1815080930101882339F0F0
|
||||
:100750008FE99FE00197F1F700C0000020C0A0E200
|
||||
:10076000B1E0E2E1F1E0CF01825F91919D938E13C0
|
||||
:10077000FCCF15C083E10E94930280930001811198
|
||||
:10078000CACF81E40E946902809300018111C3CF26
|
||||
:100790000E94A402B82EB094BFCF80E0C0CF0E94C8
|
||||
:1007A000A40181E0DF91CF911F910F91FF90EF9015
|
||||
:1007B000DF90CF90BF900895E82FF0E0E05EFE4F0D
|
||||
:1007C0008081089508950F931F93CF93DF93C0E224
|
||||
:1007D000D1E010E00C2F025F899190E00E94CF18C9
|
||||
:1007E000180F0C13F9CF812FDF91CF911F910F912B
|
||||
:1007F000089581E0089508950F931F93CF93DF9399
|
||||
:100800008C01FC01C081D181CE010E945417BE0130
|
||||
:100810000E949F04EC01F8018281882309F44AC0F8
|
||||
:100820008091390181111FC0C431F0E5DF0709F063
|
||||
:1008300051C00E94FB0381E0809339010E944F194F
|
||||
:100840009093380180933701109230011092320159
|
||||
:10085000109231011092340110923301109236013E
|
||||
:100860001092350165C080913701909138010E9446
|
||||
:100870005B19883C910570F480913001E82FF0E01D
|
||||
:10088000EE0FFF1FEF5CFE4FD183C0838F5F80931D
|
||||
:1008900030014EC0C43880E5D80721F0C538D045B6
|
||||
:1008A00001F13AC0F8018281882341F010922E01B3
|
||||
:1008B00082E01EC0C438E0E5DE0759F580912E01C4
|
||||
:1008C000811106C086E20E94700F86E20E94041029
|
||||
:1008D00082E01CC0C438F0E5DF0741F3C538D045DD
|
||||
:1008E000D9F4F8018281882331F010922F0180E23F
|
||||
:1008F0000E942C101DC080912F01811106C087E23B
|
||||
:100900000E94700F87E20E94041080E20E94331060
|
||||
:100910000FC0C538D04529F381E080932E01809324
|
||||
:100920002F01C801DF91CF911F910F910C94F90312
|
||||
:1009300080E0DF91CF911F910F910895089596E087
|
||||
:10094000799FF001112494E5899FE00DF11D112498
|
||||
:10095000E60FF11DEE0FFF1FE65FFE4F85919491AC
|
||||
:100960000895880F991FFC01E657F04085919491F6
|
||||
:100970000895880F991FFC01E65FFE4F85919491C1
|
||||
:1009800008950F931F93CF93DF93EC01811590434C
|
||||
:1009900050F5C11580E2D80708F0C3C0CB3BD105A4
|
||||
:1009A00090F4C83AD10508F06AC0C53AD10508F0FC
|
||||
:1009B0005BC0C430D10508F0D0C1219709F0CAC18D
|
||||
:1009C00001E010E00AC2CF3FD10511F008F0C5C127
|
||||
:1009D000C03FD10508F0A2C0CE01805E9109089702
|
||||
:1009E00008F4BBC1B7C1C13090E5D90709F4A2C072
|
||||
:1009F00020F5C0318FE4D80770F4C11590E4D90711
|
||||
:100A000008F094C0C11521E3D20708F0A3C1DD2787
|
||||
:100A10008E01106CE2C1C115D04509F09BC10E9446
|
||||
:100A20005B128FEF94E32CE0815090402040E1F77F
|
||||
:100A300000C000000E94AA19D0C1C11597E5D907CE
|
||||
:100A400058F4C03121E5D20708F01CC1C43180E55B
|
||||
:100A5000D80708F475C07EC1CE019057811590412A
|
||||
:100A600008F078C1DF7073C1C53AD10509F477C1C8
|
||||
:100A7000C63AD10509F076C102E810E4AEC1C83A21
|
||||
:100A8000D10509F472C1C93AD10509F471C1CA3A54
|
||||
:100A9000D10509F470C1CB3AD10509F46FC1CC3A44
|
||||
:100AA000D10509F46EC1CD3AD10509F46DC1C03B41
|
||||
:100AB000D10509F46CC1CE3AD10509F46BC1CF3A26
|
||||
:100AC000D10509F46AC1C13BD10509F469C1C23B32
|
||||
:100AD000D10509F468C1C33BD10509F467C1C43B22
|
||||
:100AE000D10509F466C1C53BD10509F465C1C63B12
|
||||
:100AF000D10509F464C1C73BD10509F463C1C83B02
|
||||
:100B0000D10509F462C1C93BD10509F461C1CA3BF1
|
||||
:100B1000D10509F460C100E014E45FC18E011065E5
|
||||
:100B20005CC1CE019F700E94B90458C1DF708E0174
|
||||
:100B3000106A53C18091B60181608093B6014DC1A6
|
||||
:100B40000E94011A811102C00E94E7190E94141A22
|
||||
:100B500090E09093CA018093C901C23080E5D80724
|
||||
:100B600021F48091C901816086C0C43090E5D90725
|
||||
:100B700021F48091C90182607EC0C63020E5D20791
|
||||
:100B800021F48091C901846076C0C83080E5D8071F
|
||||
:100B900019F48091C90127C0CA3090E5D90721F422
|
||||
:100BA0008091C901806167C0CC3020E5D20721F473
|
||||
:100BB0008091C90180625FC0CE3080E5D80721F402
|
||||
:100BC0008091C901806457C0C03190E5D90721F4F4
|
||||
:100BD0008091C90180684FC0C23120E5D20729F455
|
||||
:100BE0008091C9018460886046C0C33080E5D80721
|
||||
:100BF00021F48091C9018E7F3EC0C53090E5D907B0
|
||||
:100C000021F48091C9018D7F36C0C73020E5D2071D
|
||||
:100C100021F48091C9018B7F2EC0C93080E5D807AF
|
||||
:100C200019F48091C90126C0CB3090E5D90721F491
|
||||
:100C30008091C9018F7E1FC0CD3020E5D20721F4FD
|
||||
:100C40008091C9018F7D17C0CF3080E5D80721F48E
|
||||
:100C50008091C9018F7B0FC0C13190E5D90721F484
|
||||
:100C60008091C9018F7707C0C331D04531F480919D
|
||||
:100C7000C9018B7F877F8093C9018091C9010E9440
|
||||
:100C8000181AABC08D2F99278F7099278130910545
|
||||
:100C9000D9F49E012370332702C0880F991F2A952B
|
||||
:100CA000E2F79C688E0144E0000F111F4A95E1F7BE
|
||||
:100CB00000271370802B912B53E0CC0FDD1F5A952A
|
||||
:100CC000E1F7C076DD272FC08230910531F4DC2FAB
|
||||
:100CD000CC278E01016F106A80C08330910569F4C2
|
||||
:100CE000CE018370992701E010E002C0000F111FB0
|
||||
:100CF0008A95E2F7C8019C680FC084309105B9F469
|
||||
:100D0000CE018370992701E010E002C0000F111F8F
|
||||
:100D10008A95E2F7C8019A6823E0CC0FDD1F2A9577
|
||||
:100D2000E1F7C07ED7708C010C2B1D2B56C085308F
|
||||
:100D3000910531F4DC2FCC278E01046F106A4DC071
|
||||
:100D4000069709F04AC0CF71DD27DC2FCC278E0132
|
||||
:100D5000106243C000E010E040C08E013EC001E8D8
|
||||
:100D600010E43BC003E810E438C002EE14E435C0E0
|
||||
:100D700009EE14E432C00AEE14E42FC005EB14E4CB
|
||||
:100D80002CC006EB14E429C007EB14E426C00CECDD
|
||||
:100D900014E423C00DEC14E420C003E815E41DC0E6
|
||||
:100DA0000AE815E41AC002E915E417C004E915E4DD
|
||||
:100DB00014C001E216E411C003E216E40EC004E21E
|
||||
:100DC00016E40BC005E216E408C006E216E405C00E
|
||||
:100DD00007E216E402C00AE216E4C801DF91CF91EF
|
||||
:100DE0001F910F91089596E0799FF001112494E5E9
|
||||
:100DF000899FE00DF11D1124E60FF11DEE0FFF1F7D
|
||||
:100E0000E65FFE4F85919491803E9105E0F4803C31
|
||||
:100E1000910558F58133910509F46FC048F4893282
|
||||
:100E2000910509F463C08A32910509F46DC072C05E
|
||||
:100E300089339105E9F082389105D1F08533910528
|
||||
:100E400009F44DC067C0833E910581F138F4803EBE
|
||||
:100E50009105B9F0823E9105D9F05CC0863E9105BE
|
||||
:100E600061F1873E9105A1F155C00E94B10408953A
|
||||
:100E70002091C90120FD02C021FF4CC080EE90E00E
|
||||
:100E800049C08091C90180FFF9CF89E390E042C059
|
||||
:100E90008091C90182FF0EC08091C90184FF03C007
|
||||
:100EA00080E090E037C083EE90E034C08091C901CB
|
||||
:100EB00082FFF2CF82EE90E02DC08091C90183FFC6
|
||||
:100EC0000BC08091C90184FDEBCF87EE90E022C07A
|
||||
:100ED0008091C90183FFF5CF86EE90E01BC0809121
|
||||
:100EE000C90185FF07C089E290E014C08091C90163
|
||||
:100EF00085FFF9CF85E390E00DC08091C90186FFA1
|
||||
:100F000007C08AE290E006C08091C90186FFF9CF50
|
||||
:100F100081E390E00E94C104089508950C948D0728
|
||||
:100F200080914A0108950895CF93DF9300D01F92D6
|
||||
:100F3000CDB7DEB72091C001243021F523E029830D
|
||||
:100F40009B838A8381E08093E9008FEF9091E80092
|
||||
:100F5000815095FD06C095ED9A95F1F7000081113D
|
||||
:100F6000F5CF8091E80085FF0DC040E050E063E0E0
|
||||
:100F700070E0CE0101960E94C9098091E8008E7749
|
||||
:100F80008093E8000F900F900F90DF91CF9108951C
|
||||
:100F9000CF93DF9300D01F92CDB7DEB72091C00171
|
||||
:100FA000243021F522E029839B838A8381E080938A
|
||||
:100FB000E9008FEF9091E800815095FD06C095ED16
|
||||
:100FC0009A95F1F700008111F5CF8091E80085FF37
|
||||
:100FD0000DC040E050E063E070E0CE0101960E9459
|
||||
:100FE000C9098091E8008E778093E8000F900F90F8
|
||||
:100FF0000F90DF91CF910895CF93DF932091C0019F
|
||||
:10100000243009F048C0EC0180910C018823E1F004
|
||||
:1010100080910D018823C1F082E08093E9008FEF79
|
||||
:101020009091E800815095FD06C095E19A95F1F701
|
||||
:1010300000008111F5CF8091E80085FF2CC040E0D1
|
||||
:1010400050E060E170E017C081E08093E9008FEF2D
|
||||
:101050009091E800815095FD06C095ED9A95F1F7C5
|
||||
:1010600000008111F5CF8091E80085FF14C040E0B9
|
||||
:1010700050E068E070E0CE010E94C9098091E8006C
|
||||
:101080008E778093E80080E1FE01AAE3B1E0019051
|
||||
:101090000D928A95E1F7DF91CF9108958091BF017C
|
||||
:1010A000811109C00E945E0B0E94BB0B8091E2007F
|
||||
:1010B00084608093E20008951092BF01089508951E
|
||||
:1010C00008950C94171942E061EC81E00E94D80A5F
|
||||
:1010D00042E161EC82E00C94D80A8091C201833035
|
||||
:1010E00009F453C030F4813071F0823009F48CC0BF
|
||||
:1010F00008958A3009F478C08B3009F45EC08930D5
|
||||
:1011000009F09AC020C08091C101813A09F094C0D1
|
||||
:101110008091E800877F8093E8008091C5019091DD
|
||||
:10112000C601892B21F460E18AE391E003C060E00D
|
||||
:1011300080E090E070E00E94140A8091E8008B77D4
|
||||
:101140008093E80008958091C101813209F074C054
|
||||
:101150008091C5019091C601029708F06DC0809101
|
||||
:10116000E800877F8093E8008091E80082FD05C059
|
||||
:101170008091C0018111F8CF5FC08091F100809310
|
||||
:101180004A018091E8008B7753C08091C101813A78
|
||||
:1011900009F052C08091C5019091C601892B09F0D8
|
||||
:1011A0004BC08091E800877F8093E8008091E80041
|
||||
:1011B00080FFFCCF80910C0136C08091C10181324B
|
||||
:1011C000D9F58091C5019091C601892BA9F580912F
|
||||
:1011D000E800877F8093E8000E940D0B8091C30197
|
||||
:1011E00080930C010C945B128091C101813221F536
|
||||
:1011F0008091E800877F8093E8000E940D0B80912A
|
||||
:10120000C40180934B0108958091C101813AA1F4FA
|
||||
:101210008091E800877F8093E8008091E80080FF5C
|
||||
:10122000FCCF80914B018093F1008091E8008E7794
|
||||
:101230008093E8000C940D0B089584B7877F84BFDA
|
||||
:101240000FB6F894A8958091600088618093600043
|
||||
:10125000109260000FBE90E080E80FB6F894809383
|
||||
:101260006100909361000FBE0E94A50E0E945E0B6C
|
||||
:101270000E94BB0B8091E20084608093E20078942E
|
||||
:101280000E94410E0E94A70E82E091E00E945C0E37
|
||||
:101290008091C001853069F40E94DB188091BE0105
|
||||
:1012A0008823B1F30E940919882391F30E94B3099E
|
||||
:1012B000EFCF0E94AD0EECCF292F3327233031051D
|
||||
:1012C000C9F064F42130310581F02230310509F094
|
||||
:1012D00042C08BE390E026EE31E041C0213231057F
|
||||
:1012E000F1F02232310549F136C082E190E021E28D
|
||||
:1012F00032E035C099278130910541F08230910567
|
||||
:1013000041F0892B41F5E2EEF1E005C0EAECF1E0B5
|
||||
:1013100002C0E2EBF1E0849190E09F0120C06623DF
|
||||
:1013200039F06130C1F489E090E021E132E017C08A
|
||||
:1013300089E090E028EF31E012C0662339F0613097
|
||||
:1013400051F489E390E023E332E009C08FE390E0B9
|
||||
:101350002CE632E004C080E090E020E030E0FA01CA
|
||||
:1013600031832083089580E189BD82E189BD09B47C
|
||||
:1013700000FEFDCF8091D8008F7D8093D8008091B2
|
||||
:10138000E00082608093E0008091E00081FDFCCF6E
|
||||
:101390000895CF92DF92EF92FF920F931F93CF9316
|
||||
:1013A000DF93EC018B016A010E942C0B811133C089
|
||||
:1013B000C114D10439F0F60180819181081B190B09
|
||||
:1013C000C80FD91FE12CF12C0115110519F18091DD
|
||||
:1013D000E80085FD16C08091E8008E778093E800D4
|
||||
:1013E000C114D10449F0F60180819181E80EF91E03
|
||||
:1013F000F182E08285E00FC00E942C0B882321F34C
|
||||
:101400000AC089918093F10001501109FFEFEF1A92
|
||||
:10141000FF0ADACF80E0DF91CF911F910F91FF900B
|
||||
:10142000EF90DF90CF9008952091C7013091C801CF
|
||||
:101430002617370748F06115710539F42091E80047
|
||||
:101440002E772093E80001C0B90140E061157105D5
|
||||
:10145000A9F12091C001222309F443C0253009F4E9
|
||||
:1014600042C02091E80023FD40C02091E80022FD09
|
||||
:1014700032C02091E80020FFE9CF4091F300209195
|
||||
:10148000F20030E0342BFC01CF016115710559F0F9
|
||||
:101490002830310540F481918093F1006150710949
|
||||
:1014A0002F5F3F4FF1CF41E02830310509F040E098
|
||||
:1014B0002091E8002E772093E800C8CF4111C9CFD2
|
||||
:1014C0000AC08091C001882361F0853061F080916D
|
||||
:1014D000E80083FD0AC08091E80082FFF2CF80E03F
|
||||
:1014E000089582E0089583E0089581E008952091B1
|
||||
:1014F000C7013091C8012617370748F061157105FB
|
||||
:1015000039F42091E8002E772093E80001C0B9015A
|
||||
:10151000FC0120E06115710591F18091C0018823E3
|
||||
:1015200009F440C0853009F43FC08091E80083FD94
|
||||
:101530003DC08091E80082FD2FC08091E80080FFCF
|
||||
:10154000E9CF2091F3008091F20090E0922B611599
|
||||
:10155000710559F08830910540F424912093F100F1
|
||||
:101560003196615071090196F2CF21E0089709F098
|
||||
:1015700020E08091E8008E778093E800CBCF2111A6
|
||||
:10158000CCCF0AC08091C001882361F0853061F022
|
||||
:101590008091E80083FD0AC08091E80082FFF2CFCD
|
||||
:1015A00080E0089582E0089583E0089581E0089541
|
||||
:1015B000982F973058F59093E900981739F070916B
|
||||
:1015C000EC002091ED005091F00003C0242F762F05
|
||||
:1015D00050E021FF19C03091EB003E7F3093EB00CB
|
||||
:1015E0003091ED003D7F3093ED003091EB003160A4
|
||||
:1015F0003093EB007093EC002093ED005093F000DB
|
||||
:101600002091EE0027FF07C09F5FD3CF8F7080939C
|
||||
:10161000E90081E0089580E008958091C10187FF8D
|
||||
:1016200011C08091E80082FD05C08091C001811148
|
||||
:10163000F8CF11C08091E8008B770BC08091C0017A
|
||||
:10164000882349F08091E80080FFF8CF8091E8007E
|
||||
:101650008E778093E80008952091E4003091E500B2
|
||||
:1016600095E64091EC00842F817040FF22C080916C
|
||||
:10167000E80080FD1CC08091C001882391F0853076
|
||||
:1016800091F08091EB0085FD10C04091E4005091F5
|
||||
:10169000E5004217530729F39A01915011F784E0AE
|
||||
:1016A000089582E0089583E0089581E0089580E040
|
||||
:1016B00008954091E80042FFDECF08950E94CC0BD0
|
||||
:1016C0000E94D40BE0EEF0E0808181608083E8ED41
|
||||
:1016D000F0E080818F77808319BCA7EDB0E08C911A
|
||||
:1016E0008E7F8C9380818F7E80831092BF010895BE
|
||||
:1016F0000F931F93CF93DF930E94CC0B0E94D40BC8
|
||||
:10170000C8EDD0E088818F7788838881806888835E
|
||||
:1017100088818F7D888319BC1092C0011092BC0112
|
||||
:101720001092BE011092BD0100EE10E0F801808120
|
||||
:101730008B7F808388818160888342E060E080E0E5
|
||||
:101740000E94D80AE1EEF0E080818E7F8083E2EE95
|
||||
:10175000F0E0808181608083808188608083F801EF
|
||||
:1017600080818E7F8083888180618883DF91CF91A3
|
||||
:101770001F910F910895E8EDF0E080818F7E8083C6
|
||||
:10178000E7EDF0E080818160808384E082BF81E0CA
|
||||
:101790008093BF010C94780BE8EDF0E080818E7FA0
|
||||
:1017A00080831092E20008951092DA001092E10016
|
||||
:1017B00008951F920F920FB60F9211242F933F930B
|
||||
:1017C0004F935F936F937F938F939F93AF93BF9349
|
||||
:1017D000EF93FF938091E10082FF0BC08091E200C4
|
||||
:1017E00082FF07C08091E1008B7F8093E1000E941F
|
||||
:1017F000400E8091DA0080FF1FC08091D80080FFEA
|
||||
:101800001BC08091DA008E7F8093DA008091D9002E
|
||||
:1018100080FF0DC080E189BD82E189BD09B400FE71
|
||||
:10182000FDCF81E08093C0010E944E0805C019BC25
|
||||
:101830001092C0010E945C088091E10080FF19C0F5
|
||||
:101840008091E20080FF15C08091E2008E7F80933E
|
||||
:10185000E2008091E20080618093E2008091D800F4
|
||||
:1018600080628093D80019BC85E08093C0010E94FB
|
||||
:1018700060088091E10084FF30C08091E20084FF25
|
||||
:101880002CC080E189BD82E189BD09B400FEFDCF95
|
||||
:101890008091D8008F7D8093D8008091E1008F7E69
|
||||
:1018A0008093E1008091E2008F7E8093E20080913E
|
||||
:1018B000E20081608093E2008091BC01882311F0F6
|
||||
:1018C00084E007C08091E30087FD02C081E001C091
|
||||
:1018D00083E08093C0010E9461088091E10083FF52
|
||||
:1018E00029C08091E20083FF25C08091E100877FBD
|
||||
:1018F0008093E10082E08093C0011092BC0180914E
|
||||
:10190000E1008E7F8093E1008091E2008E7F8093E2
|
||||
:10191000E2008091E20080618093E20042E060E0BA
|
||||
:1019200080E00E94D80A8091F00088608093F000E7
|
||||
:101930000E945F08FF91EF91BF91AF919F918F91AE
|
||||
:101940007F916F915F914F913F912F910F900FBEBB
|
||||
:101950000F901F9018951F920F920FB60F9211249F
|
||||
:101960002F933F934F935F936F937F938F939F93A7
|
||||
:10197000AF93BF93CF93DF93EF93FF93C091E900B1
|
||||
:10198000CF708091EC00D82FD17080FDD0E81092FC
|
||||
:10199000E9008091F000877F8093F00078940E94A6
|
||||
:1019A000EF0C1092E9008091F00088608093F000C5
|
||||
:1019B000CD2BCF70C093E900FF91EF91DF91CF91D4
|
||||
:1019C000BF91AF919F918F917F916F915F914F9157
|
||||
:1019D0003F912F910F900FBE0F901F9018951F935E
|
||||
:1019E000CF93DF93CDB7DEB7AA970FB6F894DEBFDB
|
||||
:1019F0000FBECDBFE1ECF1E088E08E0F9091F100D9
|
||||
:101A000091938E13FBCF0E946D088091E80083FFB5
|
||||
:101A10001FC18091C1019091C201492F50E04A300D
|
||||
:101A2000510508F015C1FA01EA5AFF4F0C941D1A2E
|
||||
:101A3000803881F0823809F00BC18091C5018F7028
|
||||
:101A40008093E9008091EB0085FB882780F9109254
|
||||
:101A5000E90006C08091BD019091BE0191118260A4
|
||||
:101A60009091E800977F9093E8008093F1001092A6
|
||||
:101A7000F100C8C0282F2D7F09F0EAC0882319F093
|
||||
:101A8000823061F0E5C08091C301813009F0E0C08F
|
||||
:101A9000933009F080E08093BE012BC08091C30198
|
||||
:101AA000811127C08091C5018F7009F4D1C0809346
|
||||
:101AB000E9002091EB0020FF1CC0933021F48091BD
|
||||
:101AC000EB00806214C09091EB0090619093EB006A
|
||||
:101AD00021E030E0A90102C0440F551F8A95E2F7CA
|
||||
:101AE0004093EA001092EA008091EB0088608093B6
|
||||
:101AF000EB001092E9008091E800877F86C0811199
|
||||
:101B0000A7C01091C3011F778091E3008078812BDB
|
||||
:101B10008093E3008091E800877F8093E8000E9433
|
||||
:101B20000D0B8091E80080FFFCCF8091E30080687E
|
||||
:101B30008093E300111102C082E001C083E0809332
|
||||
:101B4000C00186C08058823008F082C08091C301F5
|
||||
:101B50009091C4018C3D53E0950779F583E08A8329
|
||||
:101B60008AE289834FB7F894DE01139620E03EE0C5
|
||||
:101B700051E2E32FF0E050935700E49120FF03C0BF
|
||||
:101B8000E295EF703F5FEF708E2F90E0EA3010F03B
|
||||
:101B9000C79601C0C0968D939D932F5F243149F75E
|
||||
:101BA0004FBF8091E800877F8093E8006AE270E091
|
||||
:101BB000CE0101960E94140A14C0AE014F5F5F4F20
|
||||
:101BC0006091C5010E945C09BC01892B09F440C0E9
|
||||
:101BD0009091E800977F9093E80089819A810E9414
|
||||
:101BE000770A8091E8008B778093E80031C08038D5
|
||||
:101BF00079F58091E800877F8093E8008091BC01AF
|
||||
:101C00008093F1008091E8008E778093E8000E9435
|
||||
:101C10000D0B1EC081111CC09091C3019230C0F405
|
||||
:101C20008091E800877F8093E8009093BC010E9438
|
||||
:101C30000D0B8091BC01811106C08091E30087FDEE
|
||||
:101C400002C081E001C084E08093C0010E9463086B
|
||||
:101C50008091E80083FF0AC08091E800877F80932D
|
||||
:101C6000E8008091EB0080628093EB00AA960FB6AB
|
||||
:101C7000F894DEBF0FBECDBFDF91CF911F910895C5
|
||||
:101C80000895CF938091C0018823A1F0C091E9000D
|
||||
:101C9000CF709091EC00892F817090FD80E8C82B67
|
||||
:101CA0001092E9008091E80083FD0E94EF0CCF7054
|
||||
:101CB000C093E900CF910895909351018093500112
|
||||
:101CC0000895E0915001F0915101309721F0019079
|
||||
:101CD000F081E02D099480E00895E0915001F091A9
|
||||
:101CE0005101309721F00280F381E02D099408958D
|
||||
:101CF00020914E0130914F018217930771F090931C
|
||||
:101D00004F0180934E01E0915001F09151013097C5
|
||||
:101D100021F00680F781E02D0994089520914C016F
|
||||
:101D200030914D018217930771F090934D0180938C
|
||||
:101D30004C01E0915001F0915101309721F0008465
|
||||
:101D4000F185E02D0994089508950C94A40E0E9445
|
||||
:101D500046190E94D6020C94CC199F92AF92BF9262
|
||||
:101D6000CF92DF92EF92FF920F931F93CF93DF9367
|
||||
:101D700000D000D000D0CDB7DEB70E94EE020DE05B
|
||||
:101D800010E0AA24A394B12C902E802F0E94DC0393
|
||||
:101D900098012D5A3E4F6901F901F080F826A1F40F
|
||||
:101DA0000150110988F78FEF89838A831B820E9473
|
||||
:101DB0004F198160782F9D838C8349815A816B8173
|
||||
:101DC0008D810E94420F2FC09091B60191FF04C0F7
|
||||
:101DD0008E830E94E2038E8125E030E0A501022E71
|
||||
:101DE00001C0440F0A94EAF7E42E4F21C1F0298381
|
||||
:101DF0009A828E2191E009F490E09B830E944F1912
|
||||
:101E00008160782F9D838C8349815A816B818D817C
|
||||
:101E10000E94420FF6018081E826E08204C0215032
|
||||
:101E20003109E0F6BDCF109152010E94610E1817E2
|
||||
:101E3000B9F00E94610E8093520126960FB6F89475
|
||||
:101E4000DEBF0FBECDBFDF91CF911F910F91FF90ED
|
||||
:101E5000EF90DF90CF90BF90AF909F900C948E0743
|
||||
:101E600026960FB6F894DEBF0FBECDBFDF91CF919F
|
||||
:101E70001F910F91FF90EF90DF90CF90BF90AF90A8
|
||||
:101E80009F900895CF93DF93CDB7DEB72B970FB612
|
||||
:101E9000F894DEBF0FBECDBF4F83588769877A871E
|
||||
:101EA0008B87DE01119686E0FD0111928A95E9F794
|
||||
:101EB00085E0FE01379601900D928A95E1F7498100
|
||||
:101EC0005A816B817C818D819E810E94F9142B96B1
|
||||
:101ED0000FB6F894DEBF0FBECDBFDF91CF9108954E
|
||||
:101EE000882309F490C09CEF980F913A18F40E944F
|
||||
:101EF000D3170DC090E2980F983058F4877091E096
|
||||
:101F000001C0990F8A95EAF7892F0E9459180C94FD
|
||||
:101F1000A0189BE5980F933070F4853A29F0863A23
|
||||
:101F200031F083E890E005C081E890E002C082E8EB
|
||||
:101F300090E00C94780E98E5980F933108F063C008
|
||||
:101F4000883A39F1893A41F18A3A49F18B3A51F1AB
|
||||
:101F50008C3A59F18D3A61F1803B69F18E3A71F119
|
||||
:101F60008F3A79F1813B81F1823B89F1833B91F199
|
||||
:101F7000843B99F1853BA1F1863BA9F1873BB1F107
|
||||
:101F8000883BB9F1893BC1F18A3BC9F180E090E01F
|
||||
:101F900038C082EE90E035C089EE90E032C08AEE23
|
||||
:101FA00090E02FC085EB90E02CC086EB90E029C03C
|
||||
:101FB00087EB90E026C08CEC90E023C08DEC90E0A5
|
||||
:101FC00020C083E891E01DC08AE891E01AC082E950
|
||||
:101FD00091E017C084E991E014C081E292E011C061
|
||||
:101FE00083E292E00EC084E292E00BC085E292E0D0
|
||||
:101FF00008C086E292E005C087E292E002C08AE271
|
||||
:1020000092E00C948E0E0895882329F19CEF980F8E
|
||||
:10201000913A18F40E9415180DC090E2980F98306C
|
||||
:1020200058F4877091E001C0990F8A95EAF7892FDB
|
||||
:102030000E945F180C94A0189BE5980F933020F431
|
||||
:1020400080E090E00C94780E885A833120F480E090
|
||||
:1020500090E00C948E0E0895882321F00E94591868
|
||||
:102060000C94A0180895882321F00E945F180C9406
|
||||
:10207000A01808957F928F929F92AF92BF92CF92B5
|
||||
:10208000DF92EF92FF920F931F93CF93DF931F92F4
|
||||
:10209000CDB7DEB77C01C62E772EFC0115811295D7
|
||||
:1020A0001F70028101110E9476180E94CC178823AC
|
||||
:1020B00079F0002369F080E28C0D883048F082E0EE
|
||||
:1020C0000E94B5170E94CC1791E0D82ED92601C0E6
|
||||
:1020D000D12CE72DE295EF70F0E0E05AFF4F0C9421
|
||||
:1020E0001D1A872D807F172D1F70882311F01295E0
|
||||
:1020F000107F002389F0112309F465C180E28C0D63
|
||||
:10210000883020F4812F0E94591803C0812F0E942B
|
||||
:1021100069180E94A01857C18C2D0E940410112329
|
||||
:1021200009F46AC180E28C0D883020F4812F0E946E
|
||||
:102130005F1803C0812F0E946F180E94A0185CC115
|
||||
:10214000972D907F872D8F70903211F08295807F30
|
||||
:10215000CC2021F0F1E0CF16B1F01EC0002349F0F1
|
||||
:10216000112309F4E9C0113009F0E6C00E94891872
|
||||
:1021700043C1112319F0113009F43EC189830E9433
|
||||
:102180008C188981DFC0002321F0123008F034C19F
|
||||
:10219000D3C0111131C1D6C0002321F0112309F49D
|
||||
:1021A000CBC011C1112309F4CDC013C1872D837099
|
||||
:1021B00009F052C0011120C18C2D8295869587703F
|
||||
:1021C000880F880F9C2D9F70892E912CA12CB12CEB
|
||||
:1021D000082E04C0880C991CAA1CBB1C0A94D2F7B8
|
||||
:1021E000C4FE14C00FE010E020E030E0B901A80107
|
||||
:1021F00004C0440F551F661F771F8A95D2F7CB0185
|
||||
:10220000BA01609570958095909503C060E070E08C
|
||||
:10221000CB01272D26952695237030E022303105FD
|
||||
:1022200069F02330310589F0682979298A299B29A9
|
||||
:102230002130310571F00E944116DEC068297929EC
|
||||
:102240008A299B290E945D16D7C00E944116C501AC
|
||||
:10225000B4010E942516D0C0002319F0872D81708B
|
||||
:1022600001C08695882309F4C7C08C2D8295869578
|
||||
:102270008770880F880F9C2D9F70892E912CA12C20
|
||||
:10228000B12C082E04C0880C991CAA1CBB1C0A94F3
|
||||
:10229000D2F7C4FE14C00FE010E020E030E0B90136
|
||||
:1022A000A80104C0440F551F661F771F8A95D2F7F7
|
||||
:1022B000CB01BA01609570958095909503C060E060
|
||||
:1022C00070E0CB01272D269526952370422F50E0F4
|
||||
:1022D0004230510569F04330510589F06829792968
|
||||
:1022E0008A299B294130510571F00E941B1784C037
|
||||
:1022F000682979298A299B290E9437177DC00E9465
|
||||
:102300001B17C501B4010E94FF1676C08C2D90E00A
|
||||
:10231000FC01E05EF109E531F10508F050C0E0593B
|
||||
:10232000FF4F0C941D1A1C2D1F70872D8F710023D9
|
||||
:1023300031F00E949816812F0E942C105DC00E94DF
|
||||
:10234000B916812F0E94331057C0002339F01111A4
|
||||
:1023500053C0872D8F710E94DE164EC0123008F0D8
|
||||
:102360004BC0F7CF002339F0872D8F710E9498164C
|
||||
:1023700043C00023C9F3872D8F710E94B9163CC05A
|
||||
:10238000002329F0872D8F710E94831635C00E948B
|
||||
:10239000791632C0002351F0172D1F71812F0E9432
|
||||
:1023A000981663E0812F0E94AC1726C081E00E943E
|
||||
:1023B000B517123008F182E00E94B5171DC0002346
|
||||
:1023C00031F0112389F28C2D0E94700F15C011235A
|
||||
:1023D00091F28C2D0E9404100FC0472D4F706C2D70
|
||||
:1023E000C7010E949F010E949D1506C0472D4F7096
|
||||
:1023F0006C2DC7010E949E04DD20F9F00E94A817F1
|
||||
:1024000080FD1BC0F70112820E94A2170E9498163D
|
||||
:10241000C7010E942C120E94A2170F90DF91CF914A
|
||||
:102420001F910F91FF90EF90DF90CF90BF90AF90F2
|
||||
:102430009F908F907F900C94B9160F90DF91CF9161
|
||||
:102440001F910F91FF90EF90DF90CF90BF90AF90D2
|
||||
:102450009F908F907F9008950F931F93CF93DF935A
|
||||
:10246000EC01888199812B813C81232BB9F09F3F1E
|
||||
:1024700011F48F3F99F0CE010E94FC03882371F084
|
||||
:10248000688179818A810E949E178C010E9453176E
|
||||
:102490000E941A16B801CE010E943A10DF91CF9126
|
||||
:1024A0001F910F9108950E9476180E9486180E942D
|
||||
:1024B0004B180C94A0180E9466180C9453120E949A
|
||||
:1024C0009317292F22952F7030E02C3031054CF4D2
|
||||
:1024D0002A3031056CF42250310922303105A8F43C
|
||||
:1024E00007C02C30310569F02F30310551F00DC097
|
||||
:1024F000803F69F018F4803E40F409C0843F29F41D
|
||||
:1025000006C093FB882780F9089580E0089581E054
|
||||
:102510000895CF93DF9300D000D01F92CDB7DEB7E0
|
||||
:102520000F900F900F900F900F90DF91CF91089523
|
||||
:10253000CF93DF9300D000D000D0CDB7DEB7269682
|
||||
:102540000FB6F894DEBF0FBECDBFDF91CF910895D7
|
||||
:102550001F93CF93DF93C091610116E080916201D8
|
||||
:10256000C81799F0D0E01C9FF0011D9FF00D1124B9
|
||||
:10257000ED59FE4F40815181628173818481958143
|
||||
:102580000E9498122196C770E9CFDF91CF911F91D9
|
||||
:10259000089540919301509194016091950170913B
|
||||
:1025A000960180919701909198010C9498128091D6
|
||||
:1025B000980182958F7009F054C08091950188230D
|
||||
:1025C00009F44FC080916101A09162016091930173
|
||||
:1025D000709194014091960150919701B6E08A174D
|
||||
:1025E00009F43FC090E041155105C1F17F3F11F45E
|
||||
:1025F0006F3FA1F1B89FF001B99FF00D1124ED5983
|
||||
:10260000FE4F218172132AC02081621327C02281CC
|
||||
:10261000211124C0238134812417350710F421505F
|
||||
:102620003109241B350B283C3105C0F42091980159
|
||||
:102630002F7020612093980126E0289FF001299FA8
|
||||
:10264000F00D1124E859FE4F80818F7080618083E6
|
||||
:1026500083E991E00E942C120C94A81201968770D5
|
||||
:10266000BECF0895CF92DF92EF92FF920F931F9308
|
||||
:10267000CF93DF93CDB7DEB762970FB6F894DEBF86
|
||||
:102680000FBECDBF8C0185E0F801DE011D960190E3
|
||||
:102690000D928A95E1F7D8014C9111965C911197B2
|
||||
:1026A00012966C9112971396CD90DC9014973091FE
|
||||
:1026B00093017091940180919601909197010097F8
|
||||
:1026C00009F46BC17F3F19F43F3F09F466C1E09004
|
||||
:1026D0009501EE2009F4C0C020919801C816D906D2
|
||||
:1026E00028F0F601E81BF90BCF0104C08095909506
|
||||
:1026F0008C0D9D1DFF24F394883C910578F0F12CFE
|
||||
:10270000207F09F0C6C07C2DD98AC88A89890E9499
|
||||
:10271000891283E991E00E942C12B1C0822F807F40
|
||||
:1027200009F046C0751314C0341312C0611110C0F3
|
||||
:102730002F702061209398010E94C91283E991E0D3
|
||||
:102740000E942C1280919801D80115968C932EC06E
|
||||
:10275000CD2819F15F3F11F44F3FF9F0F62E6111CA
|
||||
:102760001CC0809161012091620136E0821709F45A
|
||||
:102770005AC090E0389FF001399FF00D1124ED59B7
|
||||
:10278000FE4F7181571306C07081471303C07281D9
|
||||
:10279000711103C001968770E9CFF62E662309F404
|
||||
:1027A00018C180919801816080939801F12C11C12A
|
||||
:1027B000751308C0341306C0611104C080919801DC
|
||||
:1027C000D801C3C04D875E878D859E856A8B0E9428
|
||||
:1027D0005F126A898823E1F16623D1F12091980183
|
||||
:1027E000822F82958F7090E0029774F08091930110
|
||||
:1027F0009091940198878F831986DB86CA862C87EF
|
||||
:10280000CE0107960E942C1286E0F801A3E9B1E000
|
||||
:1028100001900D928A95E1F70E94D7120E94C91289
|
||||
:10282000FF24F394D6C04D875E878D859E850E94D8
|
||||
:102830009317292F22952F7030E0223031050CF0AC
|
||||
:10284000BCC09F7009F0B6C0805E883008F4C1C07B
|
||||
:10285000C8010E942C12E4CFC816D90608F453C050
|
||||
:10286000F601E81BF90BCF01883C910508F450C034
|
||||
:10287000F12C7C2DD98AC88A89890E948912E3E9C2
|
||||
:10288000F1E086E0DF011D928A95E9F70E94C91206
|
||||
:10289000A0C0751314C0341312C0611110C0809110
|
||||
:1028A0009801F8018583C8010E942C1286E0E3E9B3
|
||||
:1028B000F1E0DF011D928A95E9F7FE2C8AC04D8771
|
||||
:1028C0005E878D859E856A8B0E945F126A89882348
|
||||
:1028D00009F4BECF662309F4BBCF20919801822F63
|
||||
:1028E00082958F7090E002970CF48ECF80919301C7
|
||||
:1028F000909194019A8389831B82DD82CC822E83FE
|
||||
:10290000CE0101967FCF809590958C0D9D1DACCF0B
|
||||
:10291000F62E662309F49CCF75132EC034132CC0F9
|
||||
:102920002091980120FD1FC0822F82958F70D9F0D1
|
||||
:10293000D80115962C9315978F3049F08F5F982FFB
|
||||
:102940009295907F822F8F70892B15968C93C8015A
|
||||
:102950000E942C1286E0F801A3E9B1E001900D92EB
|
||||
:102960008A95E1F793CF86E0F801A3E9B1E0019001
|
||||
:102970000D928A95E1F72DC04D875E878D859E85E6
|
||||
:102980000E945F12811140CF8091980181608093F5
|
||||
:102990009801C8010E942C121CC0662309F458CF6C
|
||||
:1029A0004D875E878D859E850E945F12882309F47E
|
||||
:1029B0004FCF2ACF811148CF0CC0243031050CF005
|
||||
:1029C00047CF9F7009F440CFF8019581907F09F0BF
|
||||
:1029D0003BCF8F2D62960FB6F894DEBF0FBECDBFF2
|
||||
:1029E000DF91CF911F910F91FF90EF90DF90CF90EB
|
||||
:1029F00008951F93CF93DF93CDB7DEB72C970FB613
|
||||
:102A0000F894DEBF0FBECDBF4F83588769877A87A2
|
||||
:102A10008B879C87CE0107960E943213882369F02A
|
||||
:102A20008F8198852A853B85232BF1F19F3F09F003
|
||||
:102A300063C08F3F09F060C037C086E0FE01379663
|
||||
:102A4000DE01119601900D928A95E1F76F817885EC
|
||||
:102A5000EA85FB85309741F17F3F11F46F3F21F10B
|
||||
:102A60002091620130E0C901019687709927409159
|
||||
:102A7000610150E08417950709F447C069837A83A0
|
||||
:102A8000FD83EC8396E0929FD001939FB00D1124BB
|
||||
:102A9000AD59BE4FFE01319601900D929A95E1F726
|
||||
:102AA000809362010E94A81216E0809161019091CA
|
||||
:102AB00062018917C1F1189FC00111248D599E4FE1
|
||||
:102AC0000E943213882379F1E09161011E9FF00189
|
||||
:102AD0001124ED59FE4F40815181628173818481BF
|
||||
:102AE00095810E9498128091610190E00196877013
|
||||
:102AF000992780936101D9CF4F81588569857A855F
|
||||
:102B00008B859C850E949812CFCF0E945B121092F9
|
||||
:102B1000620110926101E3E9F1E086E0DF011D92BC
|
||||
:102B20008A95E9F7C1CF2C960FB6F894DEBF0FBE99
|
||||
:102B3000CDBFDF91CF911F910895EF92FF920F9338
|
||||
:102B40001F93CF93DF938C01892B09F46CC0F12C78
|
||||
:102B5000EE24E394E8012196F8018491843740F44F
|
||||
:102B6000843008F051C0813081F0823019F15BC0AF
|
||||
:102B7000853709F444C0A8F19CE7980F903708F016
|
||||
:102B800052C08F770E94041041C00E5F1F4FFE019C
|
||||
:102B9000C49180E28C0F883048F4C7708E2D01C03C
|
||||
:102BA000880FCA95EAF70E94791814C08C2F0E94EA
|
||||
:102BB000700F2DC00E5F1F4FFE01C49180E28C0F7D
|
||||
:102BC000883058F4C7708E2D01C0880FCA95EAF777
|
||||
:102BD0000E947F180E94A0181AC08C2F0E94041017
|
||||
:102BE00016C00E5F1F4FFE01C491CC2381F08FE908
|
||||
:102BF0009FE00197F1F700C00000C150F6CF0E5FD3
|
||||
:102C00001F4FFE01F49003C00E94700F8E018F2DA4
|
||||
:102C1000882309F49FCFEFE9FFE03197F1F700C077
|
||||
:102C200000008150F5CFDF91CF911F910F91FF9060
|
||||
:102C3000EF900895089560939D0170939E01809395
|
||||
:102C40009F019093A0010C9453120F931F93009136
|
||||
:102C50009D0110919E0120919F013091A001DC0106
|
||||
:102C6000CB01802B912BA22BB32B80939D019093B2
|
||||
:102C70009E01A0939F01B093A0011F910F910C940E
|
||||
:102C800053120F931F9300919D0110919E0120916B
|
||||
:102C90009F013091A001DC01CB0180239123A2236D
|
||||
:102CA000B32380939D0190939E01A0939F01B093C5
|
||||
:102CB000A0011F910F910C9453120F931F93009139
|
||||
:102CC0009D0110919E0120919F013091A001DC0196
|
||||
:102CD000CB0180279127A227B32780939D01909352
|
||||
:102CE0009E01A0939F01B093A0011F910F910C949E
|
||||
:102CF00053121092990110929A0110929B01109216
|
||||
:102D00009C010C94531241E050E060E070E004C07C
|
||||
:102D1000440F551F661F771F8A95D2F7409399017C
|
||||
:102D200050939A0160939B0170939C010C945312F1
|
||||
:102D300041E050E060E070E004C0440F551F661FA2
|
||||
:102D4000771F8A95D2F78091990190919A01A0916D
|
||||
:102D50009B01B0919C01482B592B6A2B7B2B4093F4
|
||||
:102D6000990150939A0160939B0170939C010C947C
|
||||
:102D7000531241E050E060E070E004C0440F551F82
|
||||
:102D8000661F771F8A95D2F740955095609570958C
|
||||
:102D90008091990190919A01A0919B01B0919C0121
|
||||
:102DA000482359236A237B234093990150939A0126
|
||||
:102DB00060939B0170939C010C94531241E050E08E
|
||||
:102DC00060E070E004C0440F551F661F771F8A95AE
|
||||
:102DD000D2F78091990190919A01A0919B01B091B5
|
||||
:102DE0009C01482759276A277B27409399015093D4
|
||||
:102DF0009A0160939B0170939C010C9453120F9362
|
||||
:102E00001F930091990110919A0120919B0130919B
|
||||
:102E10009C01DC01CB01802B912BA22BB32B809347
|
||||
:102E2000990190939A01A0939B01B0939C011F91EB
|
||||
:102E30000F910C9453120F931F93009199011091CD
|
||||
:102E40009A0120919B0130919C01DC01CB018023F0
|
||||
:102E50009123A223B3238093990190939A01A09385
|
||||
:102E60009B01B0939C011F910F910C9453120F93EF
|
||||
:102E70001F930091990110919A0120919B0130912B
|
||||
:102E80009C01DC01CB0180279127A227B3278093E7
|
||||
:102E9000990190939A01A0939B01B0939C011F917B
|
||||
:102EA0000F910C9453120895CF92DF92EF92FF92FC
|
||||
:102EB0000F931F93CF93DF938C01C0909D01D0900F
|
||||
:102EC0009E01E0909F01F090A00180919901909166
|
||||
:102ED0009A01A0919B01B0919C01C82AD92AEA2AA3
|
||||
:102EE000FB2ACFE1D0E0D701C6010C2E04C0B69575
|
||||
:102EF000A795979587950A94D2F780FF06C0B801E9
|
||||
:102F00008C2F0E94F306019721F4219760F780E04F
|
||||
:102F100001C08C2FDF91CF911F910F91FF90EF9007
|
||||
:102F2000DF90CF900895CF93DF93EC010E94541768
|
||||
:102F3000BE010E94F306DF91CF910895CB010E945C
|
||||
:102F4000931708958091A10185958595859508959C
|
||||
:102F50008091A1018770089598E0899F90011124C4
|
||||
:102F6000262B2093A1010C9498162091A101809505
|
||||
:102F700082238093A101982F977069F430E0482F45
|
||||
:102F8000082E000C550B2417350729F085958595DB
|
||||
:102F900085950C94B91608959091A101977081E0E0
|
||||
:102FA00009F480E0089590910C01992321F090910B
|
||||
:102FB0000D01911109C020910E0130910F01F9010D
|
||||
:102FC00032969FEF40E01FC0982F96959695969564
|
||||
:102FD0009F3050F5E0910E01F0910F01E90FF11DC6
|
||||
:102FE000877021E030E0A90102C0440F551F8A9587
|
||||
:102FF000E2F7CA019181892B818308959F3F39F0BF
|
||||
:103000004F5F4E3041F051915813F8CF0DC0511120
|
||||
:10301000F7CF942FF5CF9F3F39F0F901E90FF11D5C
|
||||
:1030200097FDFA9582830895089590910C01992354
|
||||
:1030300021F090910D01911109C020910E01309164
|
||||
:103040000F01F9013296205F3F4F1FC0982F9695D0
|
||||
:10305000969596959F30F0F4E0910E01F0910F0156
|
||||
:10306000E90FF11D877021E030E0A90102C0440F93
|
||||
:10307000551F8A95E2F7CA01809591818923818342
|
||||
:1030800008953196E217F30729F090819813F9CF4C
|
||||
:103090001082F7CF089581E090E0E0910E01F09169
|
||||
:1030A0000F01E80FF91F1082019680319105A9F7F1
|
||||
:1030B00008959091B501892B8093B501089580956D
|
||||
:1030C0009091B50189238093B50108951092B501BF
|
||||
:1030D00008959091B401892B8093B401089580954F
|
||||
:1030E0009091B40189238093B40108951092B401A2
|
||||
:1030F00008959091B301892B8093B3010895809531
|
||||
:103100009091B30189238093B30108951092B30184
|
||||
:1031100008958093A20108951092A20108958091CC
|
||||
:103120000E0190910F01FC0131969C01205F3F4FF1
|
||||
:1031300080E0919191118F5FE217F307D1F7089525
|
||||
:10314000E0910E01F0910F018091B5018083E09133
|
||||
:103150000E01F0910F0190818091B401892B808341
|
||||
:10316000E0910E01F0910F0190818091B301892BC4
|
||||
:1031700080838091A201882361F0E0910E01F0919B
|
||||
:103180000F019081892B80830E948F1881111092EA
|
||||
:10319000A20180910E0190910F010C946D0E20E020
|
||||
:1031A000009739F0AC0141505109842395232F5FDA
|
||||
:1031B000F7CF822F08958091C001843039F11092A9
|
||||
:1031C000B70120E488E190E00FB6F894A8958093C9
|
||||
:1031D00060000FBE2093600080E00E948E0783B7DE
|
||||
:1031E000817F846083BF83B7816083BF7894889533
|
||||
:1031F00083B78E7F83BF0FB6F894A8958091600047
|
||||
:10320000886180936000109260000FBE0895089559
|
||||
:1032100008950E9407190E94EE020E9408190E9458
|
||||
:10322000E30391E0811101C090E0892F08950E948D
|
||||
:103230005B120E94610E0C948E071F920F920FB6C4
|
||||
:103240000F9211248F939F93AF93BF938091B701F7
|
||||
:10325000811113C08091B8019091B901A091BA0178
|
||||
:10326000B091BB014196A11DB11D8093B80190930F
|
||||
:10327000B901A093BA01B093BB01BF91AF919F91E7
|
||||
:103280008F910F900FBE0F901F90189582E084BD14
|
||||
:1032900093E095BD9AEF97BD80936E0008952FB788
|
||||
:1032A000F8948091B8019091B901A091BA01B091C0
|
||||
:1032B000BB012FBF0895CF92DF92EF92FF920F9341
|
||||
:1032C0001F932FB7F8944091B8015091B9016091C4
|
||||
:1032D000BA017091BB012FBF6A017B01EE24FF246C
|
||||
:1032E0008C0120E030E0C016D106E206F30610F4AF
|
||||
:1032F000415051099A01281B390BC9011F910F91A7
|
||||
:10330000FF90EF90DF90CF9008951F920F920FB62D
|
||||
:103310000F9211248F939F93AF93BF938091B80125
|
||||
:103320009091B901A091BA01B091BB010196A11D84
|
||||
:10333000B11D8093B8019093B901A093BA01B093E5
|
||||
:10334000BB01BF91AF919F918F910F900FBE0F90D6
|
||||
:103350001F9018950E945E0BF8942FEF87EA91E674
|
||||
:10336000215080409040E1F700C0000087E090EBE2
|
||||
:10337000DC018093CA019093CB01A093CC01B09360
|
||||
:10338000CD019CE088E10FB6F894A8958093600089
|
||||
:103390000FBE90936000FFCF0E94011A811102C0FE
|
||||
:1033A0000E94E7190E940C1A8093B6010E94141A19
|
||||
:1033B0008093C90187FB882780F980930D010E94C3
|
||||
:1033C000101A682F70E080E090E00C941B166DEEF0
|
||||
:1033D0007EEF80E090E00E94431A60E082E090E09F
|
||||
:1033E0000E94311A60E083E090E00E94311A60E0B0
|
||||
:1033F00084E090E00E94311A60E085E090E00C9457
|
||||
:10340000311A80E090E00E942B1A21E08D3E9E4F01
|
||||
:1034100009F020E0822F089582E090E00C94231AB6
|
||||
:1034200083E090E00C94231A84E090E00C94231A3B
|
||||
:10343000682F84E090E00C94311AEE0FFF1F059086
|
||||
:10344000F491E02D0994F999FECF92BD81BDF89ACF
|
||||
:10345000992780B50895A8E1B0E042E050E00C94CF
|
||||
:103460004B1A262FF999FECF92BD81BDF89A01978C
|
||||
:1034700000B4021639F01FBA20BD0FB6F894FA9ABC
|
||||
:10348000F99A0FBE08950196272F0E94321A0C94C4
|
||||
:10349000311ADC01CB01FC01F999FECF06C0F2BD67
|
||||
:1034A000E1BDF89A319600B40D9241505040B8F702
|
||||
:0634B0000895F894FFCF1F
|
||||
:1034B60020029007FC079307C80794070101A301A0
|
||||
:00000001FF
|
@ -1,117 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = ghostsquid_lufa
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# List C source files here. (C dependencies are automatically generated.)
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
# MCU name
|
||||
MCU = atmega32u2
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 16000000
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
#CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||
|
||||
|
||||
# Boot Section Size in bytes
|
||||
# Teensy halfKay 512
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
@ -1,20 +0,0 @@
|
||||
The Ghost Squid controller
|
||||
==========================
|
||||
Custom controller for the Cooler Master QuickFire XT keyboard designed by bpiphany.
|
||||
|
||||
*Note that this is not the official firmware*
|
||||
|
||||
Build
|
||||
-----
|
||||
Move to this directory then just run `make` like:
|
||||
|
||||
$ make -f Makefile.lufa
|
||||
|
||||
At the moment only the LUFA stack is supported.
|
||||
|
||||
|
||||
Bootloader
|
||||
---------
|
||||
To enter bootloader by hardware use a magnet above the controller before connecting the usb cable.
|
||||
|
||||
It is still possible to use Boot Magic and Command (LSFT+RSFT+PAUS) to access the bootloader though.
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED // 0x2516 (original CM XT value)
|
||||
#define PRODUCT_ID 0x001A
|
||||
#define DEVICE_VER 0x0000
|
||||
#define MANUFACTURER Cooler Master
|
||||
#define PRODUCT Cooler Master QuickFire XT
|
||||
|
||||
/* message strings */
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for Cooler Master QuickFire XT
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 8
|
||||
#define MATRIX_COLS 18
|
||||
|
||||
/* Set 0 if need no debouncing */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
#endif
|
@ -1,102 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
#include "action_macro.h"
|
||||
#include "report.h"
|
||||
#include "host.h"
|
||||
#include "debug.h"
|
||||
#include "keymap.h"
|
||||
|
||||
/*
|
||||
Matrix col/row mapping
|
||||
|
||||
,----. ,-------------------. ,-------------------. ,-------------------. ,--------------.
|
||||
|06/6| |07/4|08/4|08/2|08/6| |15/5|11/6|12/2|12/4| |14/4|14/5|14/6|14/0| |13/5|13/7|15/7|
|
||||
`----' `-------------------' `-------------------' `-------------------' `--------------'
|
||||
,-------------------------------------------------------------------------. ,--------------. ,-------------------.
|
||||
|06/4|06/5|07/5|08/5|09/5|09/4|10/4|10/5|11/5|12/5|05/5|05/4|11/4| 14/2| |17/4|02/4|04/4| |16/1|17/1|04/1|04/0|
|
||||
|-------------------------------------------------------------------------| |--------------| |-------------------|
|
||||
|06/2 |06/7|07/7|08/7|09/7|09/2|10/2|10/7|11/7|12/7|05/7|05/2|11/2| 14/3| |16/4|02/5|04/5| |16/7|17/7|04/7| |
|
||||
|-------------------------------------------------------------------------| '--------------' |-------------- 02/7|
|
||||
|02/7 |06/3|07/3|08/3|09/3|09/6|10/6|10/3|11/3|12/3|05/3|05/6| 14/1| |16/2|17/2|04/2| |
|
||||
|-------------------------------------------------------------------------| ,----. |-------------------|
|
||||
|01/2 |06/1|07/1|08/1|09/1|09/0|10/0|10/1|11/1|12/1|05/0| 01/3| |02/6| |16/3|17/3|04/3| |
|
||||
|-------------------------------------------------------------------------| ,--------------. |-------------- 02/3|
|
||||
|15/4|03/2|13/6| 16/6 |13/0|0/3|12/0|15/1| |02/0|16/0|17/0| | 17/6 |04/6| |
|
||||
`-------------------------------------------------------------------------' `--------------' `-------------------'
|
||||
*/
|
||||
|
||||
#define KEYMAP( \
|
||||
KG6, KH4, KI4, KI2, KI6, KP5, KL6, KM2, KM4, KO4, KO5, KO6, KO0, KN5, KN7, KP7, \
|
||||
KG4, KG5, KH5, KI5, KJ5, KJ4, KK4, KK5, KL5, KM5, KF5, KF4, KL4, KO2, KR4, KC4, KE4, KQ1, KR1, KE1, KE0, \
|
||||
KG2, KG7, KH7, KI7, KJ7, KJ2, KK2, KK7, KL7, KM7, KF7, KF2, KL2, KO3, KQ4, KC5, KE5, KQ7, KR7, KE7, KC7, \
|
||||
KH2, KG3, KH3, KI3, KJ3, KJ6, KK6, KK3, KL3, KM3, KF3, KF6, KO1, KQ2, KR2, KE2, \
|
||||
KB2, KH6, KG1, KH1, KI1, KJ1, KJ0, KK0, KK1, KL1, KM1, KF0, KB3, KC6, KQ3, KR3, KE3, KC3, \
|
||||
KP4, KD2, KN6, KQ6, KN0, KA3, KM0, KP1, KC0, KQ0, KR0, KR6, KE6 \
|
||||
) { \
|
||||
/* 0 1 2 3 4 5 6 7 */ \
|
||||
/* A 0 */ {KC_NO, KC_NO, KC_NO, KC_##KA3, KC_NO, KC_NO, KC_NO, KC_NO },\
|
||||
/* B 1 */ {KC_NO, KC_NO, KC_##KB2, KC_##KB3, KC_NO, KC_NO, KC_NO, KC_NO },\
|
||||
/* C 2 */ {KC_##KC0, KC_NO, KC_NO, KC_##KC3, KC_##KC4, KC_##KC5, KC_##KC6, KC_##KC7},\
|
||||
/* D 3 */ {KC_NO, KC_NO, KC_##KD2, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO },\
|
||||
/* E 4 */ {KC_##KE0, KC_##KE1, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_##KE7},\
|
||||
/* F 5 */ {KC_##KF0, KC_NO, KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_##KF7},\
|
||||
/* G 6 */ {KC_NO, KC_##KG1, KC_##KG2, KC_##KG3, KC_##KG4, KC_##KG5, KC_##KG6, KC_##KG7},\
|
||||
/* H 7 */ {KC_NO, KC_##KH1, KC_##KH2, KC_##KH3, KC_##KH4, KC_##KH5, KC_##KH6, KC_##KH7},\
|
||||
/* I 8 */ {KC_NO, KC_##KI1, KC_##KI2, KC_##KI3, KC_##KI4, KC_##KI5, KC_##KI6, KC_##KI7},\
|
||||
/* J 9 */ {KC_##KJ0, KC_##KJ1, KC_##KJ2, KC_##KJ3, KC_##KJ4, KC_##KJ5, KC_##KJ6, KC_##KJ7},\
|
||||
/* K 10 */ {KC_##KK0, KC_##KK1, KC_##KK2, KC_##KK3, KC_##KK4, KC_##KK5, KC_##KK6, KC_##KK7},\
|
||||
/* L 11 */ {KC_NO, KC_##KL1, KC_##KL2, KC_##KL3, KC_##KL4, KC_##KL5, KC_##KL6, KC_##KL7},\
|
||||
/* M 12 */ {KC_##KM0, KC_##KM1, KC_##KM2, KC_##KM3, KC_##KM4, KC_##KM5, KC_NO, KC_##KM7},\
|
||||
/* N 13 */ {KC_##KN0, KC_NO, KC_NO, KC_NO, KC_NO, KC_##KN5, KC_##KN6, KC_##KN7},\
|
||||
/* O 14 */ {KC_##KO0, KC_##KO1, KC_##KO2, KC_##KO3, KC_##KO4, KC_##KO5, KC_##KO6, KC_NO },\
|
||||
/* P 15 */ {KC_NO, KC_##KP1, KC_NO, KC_NO, KC_##KP4, KC_##KP5, KC_NO, KC_##KP7},\
|
||||
/* Q 16 */ {KC_##KQ0, KC_##KQ1, KC_##KQ2, KC_##KQ3, KC_##KQ4, KC_NO, KC_##KQ6, KC_##KQ7},\
|
||||
/* R 17 */ {KC_##KR0, KC_##KR1, KC_##KR2, KC_##KR3, KC_##KR4, KC_NO, KC_##KR6, KC_##KR7} \
|
||||
}
|
||||
|
||||
#include "keymap_ansi.h"
|
||||
|
||||
#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
|
||||
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
|
||||
|
||||
/* translates key to keycode */
|
||||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
if (layer < KEYMAPS_SIZE) {
|
||||
return pgm_read_byte(&keymaps[(layer)][(key.col)][(key.row)]);
|
||||
} else {
|
||||
return pgm_read_byte(&keymaps[0][(key.col)][(key.row)]);
|
||||
}
|
||||
}
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint8_t keycode)
|
||||
{
|
||||
action_t action;
|
||||
if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
|
||||
action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
|
||||
} else {
|
||||
action.code = ACTION_NO;
|
||||
}
|
||||
return action;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_COLS][MATRIX_ROWS] = {
|
||||
/* Layer 0: Standard ANSI layer */
|
||||
KEYMAP(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, \
|
||||
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, \
|
||||
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, PENT, \
|
||||
LCTL,LGUI,LALT, SPC, RALT,RGUI, FN0,RCTL, LEFT,DOWN,RGHT, P0, PDOT), \
|
||||
/* Layer 1: Function layer */
|
||||
KEYMAP(\
|
||||
CALC,MYCM,WSCH,WHOM,MAIL,VOLD,VOLU,MSEL,MSTP,MPLY,MPRV,MNXT,TRNS, WAKE, PWR,SLEP, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS)
|
||||
};
|
||||
|
||||
static const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1)
|
||||
};
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "stdint.h"
|
||||
#include "led.h"
|
||||
|
||||
/* LED pin configuration
|
||||
*
|
||||
* Scroll Lock PB7
|
||||
* CAPS PC6
|
||||
* NUMLOCK PC5
|
||||
*
|
||||
*/
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
DDRB |= (1<<7);
|
||||
DDRC |= (1<<5) | (1<<6);
|
||||
|
||||
if (usb_led & (1<<USB_LED_CAPS_LOCK))
|
||||
{
|
||||
PORTC &= ~(1<<6);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTC |= (1<<6);
|
||||
}
|
||||
|
||||
if (usb_led & (1<<USB_LED_NUM_LOCK))
|
||||
{
|
||||
PORTC &= ~(1<<5);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTC |= (1<<5);
|
||||
}
|
||||
|
||||
if (usb_led & (1<<USB_LED_SCROLL_LOCK))
|
||||
{
|
||||
PORTB &= ~(1<<7);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTB |= (1<<7);
|
||||
}
|
||||
}
|
@ -1,237 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 0
|
||||
#endif
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
static uint8_t read_rows(void);
|
||||
static void init_rows(void);
|
||||
static void unselect_cols(void);
|
||||
static void select_col(uint8_t col);
|
||||
|
||||
inline uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
unselect_cols();
|
||||
init_rows();
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
|
||||
select_col(col);
|
||||
_delay_us(3);
|
||||
uint8_t rows = read_rows();
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
|
||||
bool curr_bit = rows & (1<<row);
|
||||
if (prev_bit != curr_bit) {
|
||||
matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
}
|
||||
unselect_cols();
|
||||
}
|
||||
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
_delay_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
if (debouncing) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
return (matrix[row] & ((matrix_row_t)1<<col));
|
||||
}
|
||||
|
||||
inline matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
print("\nr/c 0123456789ABCDEF\n");
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_key_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
count += bitpop32(matrix[i]);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Row pin configuration
|
||||
*
|
||||
* row: 0 1 2 3 4 5 6 7
|
||||
* pin: PB1 PC2 PB6 PB4 PB3 PB5 PB0 PB2
|
||||
*
|
||||
*/
|
||||
static void init_rows(void)
|
||||
{
|
||||
DDRC &= ~0b00000100;
|
||||
DDRB &= ~0b01111111;
|
||||
PORTC |= 0b00000100;
|
||||
PORTB |= 0b01111111;
|
||||
}
|
||||
|
||||
static uint8_t read_rows(void)
|
||||
{
|
||||
return (PINB&(1<<1) ? 0 : (1<<0)) |
|
||||
(PINC&(1<<2) ? 0 : (1<<1)) |
|
||||
(PINB&(1<<6) ? 0 : (1<<2)) |
|
||||
(PINB&(1<<4) ? 0 : (1<<3)) |
|
||||
(PINB&(1<<3) ? 0 : (1<<4)) |
|
||||
(PINB&(1<<5) ? 0 : (1<<5)) |
|
||||
(PINB&(1<<0) ? 0 : (1<<6)) |
|
||||
(PINB&(1<<2) ? 0 : (1<<7));
|
||||
}
|
||||
|
||||
/* These columns uses two 74HC42 4 to 10 bit demultiplexers (low active).
|
||||
*
|
||||
* COL PD6 PD5 PD4 PD3 PD2 PD1
|
||||
* 10 1 1 0 0 0 0
|
||||
* 15 1 1 0 0 0 1
|
||||
* 8 1 1 0 0 1 0
|
||||
* 14 1 1 0 1 0 0
|
||||
* 6 1 1 0 1 0 1
|
||||
* 13 1 1 0 1 1 0
|
||||
* 12 1 1 1 0 0 0
|
||||
* 9 1 1 1 0 1 0
|
||||
* 11 1 1 1 1 0 0
|
||||
* 7 1 1 1 1 1 0
|
||||
*
|
||||
* COL PD1 PD2 PD3 PD4 PD5 PD6
|
||||
* 3 1 1 0 0 0 1
|
||||
* 4 1 1 0 0 1 0
|
||||
* 17 1 1 0 1 0 0
|
||||
* 16 1 1 0 1 1 0
|
||||
* 0 1 1 1 0 0 1
|
||||
* 5 1 1 1 0 1 0
|
||||
* 2 1 1 1 1 0 0
|
||||
* 1 1 1 1 1 1 0
|
||||
*/
|
||||
static void unselect_cols(void)
|
||||
{
|
||||
DDRD |= 0b01111111;
|
||||
PORTD &= ~0b01111111;
|
||||
}
|
||||
|
||||
static void select_col(uint8_t col)
|
||||
{
|
||||
switch (col) {
|
||||
case 0:
|
||||
PORTD |= (1<<6) | (1<<3) | (1<<2) | (1<<1);
|
||||
break;
|
||||
case 1:
|
||||
PORTD |= (1<<5) | (1<<4) | (1<<3) | (1<<2) | (1<<1);
|
||||
break;
|
||||
case 2:
|
||||
PORTD |= (1<<4) | (1<<3) | (1<<2) | (1<<1);
|
||||
break;
|
||||
case 3:
|
||||
PORTD |= (1<<6) | (1<<2) | (1<<1);
|
||||
break;
|
||||
case 4:
|
||||
PORTD |= (1<<5) | (1<<2) | (1<<1);
|
||||
break;
|
||||
case 5:
|
||||
PORTD |= (1<<5) | (1<<3) | (1<<2) | (1<<1);
|
||||
break;
|
||||
case 6:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<3) | (1<<1);
|
||||
break;
|
||||
case 7:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<4) | (1<<3) | (1<<2);
|
||||
break;
|
||||
case 8:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<2);
|
||||
break;
|
||||
case 9:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<4) | (1<<2);
|
||||
break;
|
||||
case 10:
|
||||
PORTD |= (1<<6) | (1<<5);
|
||||
break;
|
||||
case 11:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<4) | (1<<3);
|
||||
break;
|
||||
case 12:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<4);
|
||||
break;
|
||||
case 13:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<3) | (1<<2);
|
||||
break;
|
||||
case 14:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<3);
|
||||
break;
|
||||
case 15:
|
||||
PORTD |= (1<<6) | (1<<5) | (1<<1);
|
||||
break;
|
||||
case 16:
|
||||
PORTD |= (1<<5) | (1<<4) | (1<<2) | (1<<1);
|
||||
break;
|
||||
case 17:
|
||||
PORTD |= (1<<4) | (1<<2) | (1<<1);
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = hbkb_lufa
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
|
||||
# List C source files here. (C dependencies are automatically generated.)
|
||||
SRC += keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name
|
||||
#MCU = at90usb1287
|
||||
MCU = atmega32u4
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
|
||||
|
||||
# Boot Section Size in bytes
|
||||
# Teensy halfKay 512
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
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 0xBB00
|
||||
#define MANUFACTURER t.m.k.
|
||||
#define DEVICE_VER 0x0100
|
||||
#define PRODUCT Happy Buckling Keyboard
|
||||
|
||||
#define DESCRIPTION mod version of IBM Model M keyboard
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 12
|
||||
#define MATRIX_COLS 8
|
||||
|
||||
/* define if matrix has ghost */
|
||||
#define MATRIX_HAS_GHOST
|
||||
|
||||
/* Set 0 if need no debouncing */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
/* legacy keymap support */
|
||||
#define USE_LEGACY_KEYMAP
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_LCTRL) | MOD_BIT(KC_LALT) | MOD_BIT(KC_LGUI)) || \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) \
|
||||
)
|
||||
|
||||
#endif
|
@ -1,231 +0,0 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Keymap for Macway mod
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "keycode.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "keymap.h"
|
||||
|
||||
|
||||
/*
|
||||
* Layout: 59key
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| BS |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Ctrl | |Alt | Fn4 |Alt | |Fn1 |
|
||||
* `-----' `---------------------------------------' `-----'
|
||||
*
|
||||
* Matrix: 12x8
|
||||
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
|
||||
* ---+---------+---------+---------+---------+---------+---------+---------+---------
|
||||
* 0 | | | LCTRL | | | | RCTRL |
|
||||
* 1 | | LSHIFT | | | | | RSHIFT |
|
||||
* 2 | | Tab | Grave | 1 | Q | A | Z |
|
||||
* 3 | | Cpslck | | 2 | W | S | X |
|
||||
* 4 | | | | 3 | E | D | C |
|
||||
* 5 | G | T | 5 | 4 | R | F | V | B
|
||||
* 6 | | Bckspc | | | Key*1 | Bckslsh | Enter | Space
|
||||
* 7 | H | Y | 6 | 7 | U | J | M | N
|
||||
* 8 | | Rbrckt | Equal | 8 | I | K | Comma |
|
||||
* 9 | | | | 9 | O | L | Dot |
|
||||
* A | | Lbrckt | Minus | 0 | P | Smcolon | | Slash
|
||||
* B | LALT | | | | | | | RALT
|
||||
* Key*1 This key locates between Equal and Backspace.
|
||||
*
|
||||
* Original matrix here: http://geekhack.org/showthread.php?7767-Wireless-Model-M&p=133911&viewfull=1#post133911
|
||||
*/
|
||||
#define KEYMAP( \
|
||||
K22, K23, K33, K43, K53, K52, K72, K73, K83, K93, KA3, KA2, K82, K64, K61, \
|
||||
K21, K24, K34, K44, K54, K51, K71, K74, K84, K94, KA4, KA1, K81, K65, \
|
||||
K31, K25, K35, K45, K55, K50, K70, K75, K85, K95, KA5, KA0, K66, \
|
||||
K11, K26, K36, K46, K56, K57, K77, K76, K86, K96, KA7, K16, \
|
||||
K02, KB0, K67, KB7, K06 \
|
||||
) { \
|
||||
{ KC_NO, KC_NO, KC_##K02, KC_NO, KC_NO, KC_NO, KC_##K06, KC_NO }, \
|
||||
{ KC_NO, KC_##K11, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K16, KC_NO }, \
|
||||
{ KC_NO, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \
|
||||
{ KC_NO, KC_##K31, KC_NO, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_NO, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \
|
||||
{ KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
|
||||
{ KC_NO, KC_##K61, KC_NO, KC_NO, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \
|
||||
{ KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \
|
||||
{ KC_NO, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_NO, KC_##K93, KC_##K94, KC_##K95, KC_##K96, KC_NO }, \
|
||||
{ KC_##KA0, KC_##KA1, KC_##KA2, KC_##KA3, KC_##KA4, KC_##KA5, KC_NO, KC_##KA7 }, \
|
||||
{ KC_##KB0, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##KB7 }, \
|
||||
}
|
||||
|
||||
#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
|
||||
|
||||
|
||||
// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
|
||||
static const uint8_t PROGMEM fn_layer[] = {
|
||||
0, // Fn0
|
||||
1, // Fn1
|
||||
2, // Fn2
|
||||
3, // Fn3
|
||||
4, // Fn4
|
||||
0, // Fn5
|
||||
0, // Fn6
|
||||
0 // Fn7
|
||||
};
|
||||
|
||||
// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
|
||||
// See layer.c for details.
|
||||
static const uint8_t PROGMEM fn_keycode[] = {
|
||||
KC_NO, // Fn0
|
||||
KC_NO, // Fn1
|
||||
KC_SLSH, // Fn2
|
||||
KC_SCLN, // Fn3
|
||||
KC_SPC, // Fn4
|
||||
KC_NO, // Fn5
|
||||
KC_NO, // Fn6
|
||||
KC_NO // Fn7
|
||||
};
|
||||
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Layer 0: Default Layer
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| BS |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Ctrl | |Alt | Fn4 |Alt | |Fn1 |
|
||||
* `-----' `---------------------------------------' `-----'
|
||||
*/
|
||||
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \
|
||||
LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,ENT, \
|
||||
LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN2, FN1, \
|
||||
LGUI, LALT, FN4, RALT, FN1),
|
||||
|
||||
|
||||
/* Layer 1: HHKB mode (HHKB Fn)
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Caps | | | | | | | |Psc|Slk|Pus|Up | | |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig| |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | | | | | | +| -|End|PgD|Dow|Shift |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Ctrl | |Alt | Space |Alt | |Fn1 |
|
||||
* `-----' `---------------------------------------' `-----'
|
||||
*/
|
||||
KEYMAP(ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
||||
CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,BRK, UP, NO, NO, \
|
||||
LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,NO, \
|
||||
LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,FN1, \
|
||||
LGUI, LALT, SPC, RALT, FN1),
|
||||
|
||||
|
||||
/* Layer 2: Vi mode (Quote/Rmeta)
|
||||
* ,-----------------------------------------------------------.
|
||||
* | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| | |
|
||||
* |-----------------------------------------------------------|
|
||||
* | \ |Hom|PgD|Up |PgU|End|Hom|PgD|PgU|End| | | | |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | | |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | | | | | |Hom|PgD|PgU|End|xxx|Shift |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Ctrl | |Alt | Space |Alt | |Fn1 |
|
||||
* `-----' `---------------------------------------' `-----'
|
||||
*/
|
||||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, NO, NO, \
|
||||
BSLS,HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, NO, \
|
||||
LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, NO, \
|
||||
LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT, \
|
||||
LGUI, LALT, SPC, RALT, NO),
|
||||
|
||||
|
||||
|
||||
/* Layer 3: Mouse mode (Semicolon)
|
||||
* ,-----------------------------------------------------------.
|
||||
* | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| | |
|
||||
* |-----------------------------------------------------------|
|
||||
* | \ |MwL|MwD|McU|MwU|MwR|MwL|MwD|MwU|MwR| | | | |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro| |McL|McD|McR| |McL|McD|McU|McR|xxx| | |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | | |Mb1|Mb2|Mb3|Mb2|Mb1| | | |Shift |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Ctrl | |Alt | Space |Alt | | |
|
||||
* `-----' `---------------------------------------' `-----'
|
||||
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
||||
*/
|
||||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, NO, NO, \
|
||||
BSLS,WH_L,WH_D,MS_U,WH_U,WH_R,WH_L,WH_D,WH_U,WH_R,NO, NO, NO, NO, \
|
||||
LCTL,NO, MS_L,MS_D,MS_R,NO, MS_L,MS_D,MS_U,MS_R,FN3, NO, NO, \
|
||||
LSFT,NO, NO, BTN1,BTN2,BTN3,BTN2,BTN1,NO, NO, NO, RSFT, \
|
||||
LGUI, LALT, BTN1, RALT, NO),
|
||||
|
||||
|
||||
/* Layer 4: Matias half keyboard style (Space)
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Backs| P| O| I| U| Y| T| R| E| W| Q| | |Tab |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro| ;| L| K| J| H| G| F| D| S| A|Con|Control |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | /| .| ,| M| N| B| V| C| X| Z|Shift |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Ctrl | |Alt | Fn4 |Alt | | |
|
||||
* `-----' `---------------------------------------' `-----'
|
||||
*/
|
||||
KEYMAP(MINS,0, 9, 8, 7, 6, 5, 4, 3, 2, 1, NO, NO, NO, ESC, \
|
||||
BSPC,P, O, I, U, Y, T, R, E, W, Q, NO, NO, TAB, \
|
||||
LCTL,SCLN,L, K, J, H, G, F, D, S, A, RCTL,RCTL, \
|
||||
LSFT,SLSH,DOT, COMM,M, N, B, V, C, X, Z, RSFT, \
|
||||
LGUI, LALT, FN4, RALT, NO),
|
||||
|
||||
};
|
||||
|
||||
|
||||
uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
|
||||
{
|
||||
return KEYCODE(layer, row, col);
|
||||
}
|
||||
|
||||
uint8_t keymap_fn_layer(uint8_t index)
|
||||
{
|
||||
return pgm_read_byte(&fn_layer[index]);
|
||||
}
|
||||
|
||||
uint8_t keymap_fn_keycode(uint8_t index)
|
||||
{
|
||||
return pgm_read_byte(&fn_keycode[index]);
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "stdint.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
}
|
@ -1,206 +0,0 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
|
||||
|
||||
/*
|
||||
* Happy Buckling Keyboard(IBM Model M mod)
|
||||
*
|
||||
* Pin usage:
|
||||
* COL: PD0-7
|
||||
* ROW: PB0-7, PF4-7
|
||||
*/
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 10
|
||||
#endif
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
/* matrix state(1:on, 0:off) */
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
#ifdef MATRIX_HAS_GHOST
|
||||
static bool matrix_has_ghost_in_row(uint8_t row);
|
||||
#endif
|
||||
static matrix_row_t read_cols(void);
|
||||
static void unselect_rows(void);
|
||||
static void select_row(uint8_t row);
|
||||
|
||||
|
||||
inline
|
||||
uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
// JTAG disable for PORT F. write JTD bit twice within four cycles.
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
|
||||
// initialize rows
|
||||
unselect_rows();
|
||||
|
||||
// initialize columns to input with pull-up(DDR:0, PORT:1)
|
||||
DDRD = 0x00;
|
||||
PORTD = 0xFF;
|
||||
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
select_row(i);
|
||||
_delay_us(30); // without this wait read unstable value.
|
||||
matrix_row_t cols = read_cols();
|
||||
if (matrix_debouncing[i] != cols) {
|
||||
matrix_debouncing[i] = cols;
|
||||
if (debouncing) {
|
||||
debug("bounce!: "); debug_hex(debouncing); debug("\n");
|
||||
}
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
unselect_rows();
|
||||
}
|
||||
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
_delay_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
if (debouncing) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
return (matrix[row] & ((matrix_row_t)1<<col));
|
||||
}
|
||||
|
||||
inline
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
print("\nr/c 01234567\n");
|
||||
for (uint8_t row = 0; row < matrix_rows(); row++) {
|
||||
phex(row); print(": ");
|
||||
pbin_reverse(matrix_get_row(row));
|
||||
#ifdef MATRIX_HAS_GHOST
|
||||
if (matrix_has_ghost_in_row(row)) {
|
||||
print(" <ghost");
|
||||
}
|
||||
#endif
|
||||
print("\n");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MATRIX_HAS_GHOST
|
||||
inline
|
||||
static bool matrix_has_ghost_in_row(uint8_t row)
|
||||
{
|
||||
// no ghost exists in case less than 2 keys on
|
||||
if (((matrix[row] - 1) & matrix[row]) == 0)
|
||||
return false;
|
||||
|
||||
// ghost exists in case same state as other row
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
if (i != row && (matrix[i] & matrix[row]))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline
|
||||
static matrix_row_t read_cols(void)
|
||||
{
|
||||
return ~PIND;
|
||||
}
|
||||
|
||||
inline
|
||||
static void unselect_rows(void)
|
||||
{
|
||||
// Hi-Z(DDR:0, PORT:0) to unselect
|
||||
DDRB &= ~0b11111111;
|
||||
PORTB &= ~0b11111111;
|
||||
DDRF &= ~0b11110000;
|
||||
PORTF &= ~0b11110000;
|
||||
}
|
||||
|
||||
inline
|
||||
static void select_row(uint8_t row)
|
||||
{
|
||||
// Output low(DDR:1, PORT:0) to select
|
||||
switch (row) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
DDRB |= (1<<row);
|
||||
PORTB &= ~(1<<row);
|
||||
break;
|
||||
case 8:
|
||||
DDRF |= (1<<4);
|
||||
PORTF &= ~(1<<4);
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
DDRF |= (1<<(row-4));
|
||||
PORTF &= ~(1<<(row-4));
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
HHKB_JP = yes
|
||||
include Makefile
|
@ -1,68 +0,0 @@
|
||||
#
|
||||
# Makefile for PJRC Teensy
|
||||
#
|
||||
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = hhkb_pjrc
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# keyboard dependent files
|
||||
SRC = keymap_common.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
ifdef KEYMAP
|
||||
SRC := keymaps/$(KEYMAP).c $(SRC)
|
||||
else
|
||||
SRC := keymaps/hasu.c $(SRC)
|
||||
endif
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name, you MUST set this to match the board you are using
|
||||
# type "make clean" after changing this, so all files will be rebuilt
|
||||
#MCU = at90usb162 # Teensy 1.0
|
||||
MCU = atmega32u4 # Teensy 2.0
|
||||
#MCU = at90usb646 # Teensy++ 1.0
|
||||
#MCU = at90usb1286 # Teensy++ 2.0
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# Normally the first thing your program should do is set the clock prescaler,
|
||||
# so your program will run at the correct speed. You should also set this
|
||||
# variable to same clock speed. The _delay_ms() macro uses this, and many
|
||||
# examples use this variable to calculate timings. Do not add a "UL" here.
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes # USB Nkey Rollover
|
||||
|
||||
|
||||
|
||||
#---------------- Programming Options --------------------------
|
||||
PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
|
||||
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/pjrc.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
@ -1,155 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = hhkb_rn42
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
|
||||
# List C source files here. (C dependencies are automatically generated.)
|
||||
SRC += keymap_common.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config_rn42.h
|
||||
|
||||
|
||||
# MCU name
|
||||
MCU = atmega32u4
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
# Interrupt driven control endpoint task
|
||||
#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||
|
||||
|
||||
# Boot Section Size in *bytes*
|
||||
# Teensy halfKay 512
|
||||
# Teensy++ halfKay 1024
|
||||
# Atmel DFU loader 4096 (TMK Alt Controller)
|
||||
# LUFA bootloader 4096
|
||||
# USBaspLoader 2048
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover
|
||||
#KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
|
||||
#HHKB_JP = yes # HHKB JP support
|
||||
|
||||
|
||||
#
|
||||
# Keymap file
|
||||
#
|
||||
ifdef KEYMAP
|
||||
SRC := keymaps/$(KEYMAP).c $(SRC)
|
||||
else
|
||||
ifdef HHKB_JP
|
||||
SRC := keymaps/jp.c $(SRC)
|
||||
else
|
||||
SRC := keymaps/hhkb.c $(SRC)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
ifneq (, $(or $(findstring jp.c, $(SRC)), $(findstring yes, $(HHKB_JP))))
|
||||
OPT_DEFS += -DHHKB_JP
|
||||
endif
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include rn42.mk
|
||||
include $(TMK_DIR)/protocol.mk
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
||||
|
||||
debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION
|
||||
debug-on: all
|
||||
|
||||
debug-off: EXTRAFLAGS += -DNO_DEBUG -DNO_PRINT
|
||||
debug-off: OPT_DEFS := $(filter-out -DCONSOLE_ENABLE,$(OPT_DEFS))
|
||||
debug-off: all
|
@ -1,102 +1,180 @@
|
||||
Alternative Controller for HHKB Pro
|
||||
===================================
|
||||
I wanted to add some features like vi cursor and mouse keys to my [HHKB][HHKB] but its controller is not programmable and firmware source code is not open, of course. This means customizing this keyboard needs to replace original controller with programmable one.
|
||||
hhkb_qmk keyboard firmware
|
||||
======================
|
||||
|
||||
This controller can work with HHKB **Professional**, **Professional** 2, **JP** and **Type-S**.
|
||||
## Quantum MK Firmware
|
||||
|
||||
See [this thread][AltController] in geekhack.org.
|
||||
You have access to a bunch of goodies! Check out the Makefile to enable/disable some of the features. Uncomment the `#` to enable them. Setting them to `no` does nothing and will only confuse future you.
|
||||
|
||||
[HHKB]: http://www.pfu.fujitsu.com/hhkeyboard/
|
||||
[AltController]: http://geekhack.org/index.php?topic=12047.0
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
MIDI_ENABLE = yes # MIDI controls
|
||||
# UNICODE_ENABLE = yes # Unicode support - this is commented out, just as an example. You have to use #, not //
|
||||
BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
|
||||
## Quick aliases to common actions
|
||||
|
||||
## Update
|
||||
* Bluetooth module RN-42 is supported.(2015/01)
|
||||
* V-USB and iWRAP are no longer supported now, but still it'll works with a little fix. See not_supported directory.(2015/01)
|
||||
Your keymap can include shortcuts to common operations (called "function actions" in tmk).
|
||||
|
||||
### Switching and toggling layers
|
||||
|
||||
##Features
|
||||
* Customizable keymap
|
||||
* More keymap layers(more Fn keys)
|
||||
* Mouse keys
|
||||
* USB NKRO
|
||||
* Bluetooth(RN-42)
|
||||
`MO(layer)` - momentary switch to *layer*. As soon as you let go of the key, the layer is deactivated and you pop back out to the previous layer. When you apply this to a key, that same key must be set as `KC_TRNS` on the destination layer. Otherwise, you won't make it back to the original layer when you release the key (and you'll get a keycode sent). You can only switch to layers *above* your current layer. If you're on layer 0 and you use `MO(1)`, that will switch to layer 1 just fine. But if you include `MO(3)` on layer 5, that won't do anything for you -- because layer 3 is lower than layer 5 on the stack.
|
||||
|
||||
See README of [tmk_keyboard] for more.
|
||||
`LT(layer, kc)` - momentary switch to *layer* when held, and *kc* when tapped. Like `MO()`, this only works upwards in the layer stack (`layer` must be higher than the current layer).
|
||||
|
||||
[tmk_keyboard]: http://github.com/tmk/tmk_keyboard
|
||||
`TG(layer)` - toggles a layer on or off. As with `MO()`, you should set this key as `KC_TRNS` in the destination layer so that tapping it again actually toggles back to the original layer. Only works upwards in the layer stack.
|
||||
|
||||
###Pros
|
||||
* No risks: Everything is all reversible
|
||||
* No need for PCB trace patching, case cutting or any other destructive mod
|
||||
* Can keep original controller intact
|
||||
* Can change all HHKB behavior as you like
|
||||
### Fun with modifier keys
|
||||
|
||||
###Cons
|
||||
* Void your warranty
|
||||
* Lose USB hub function of Pro2
|
||||
* `LSFT(kc)` - applies left Shift to *kc* (keycode) - `S(kc)` is an alias
|
||||
* `RSFT(kc)` - applies right Shift to *kc*
|
||||
* `LCTL(kc)` - applies left Control to *kc*
|
||||
* `RCTL(kc)` - applies right Control to *kc*
|
||||
* `LALT(kc)` - applies left Alt to *kc*
|
||||
* `RALT(kc)` - applies right Alt to *kc*
|
||||
* `LGUI(kc)` - applies left GUI (command/win) to *kc*
|
||||
* `RGUI(kc)` - applies right GUI (command/win) to *kc*
|
||||
|
||||
##DISCLAIMER
|
||||
I'm not a professional of electronics nor MCU programming. This may damage your HHKB.
|
||||
And my English writing is poor, I'm not sure I can convey my notions accurately.
|
||||
You can also chain these, like this:
|
||||
|
||||
LALT(LCTL(KC_DEL)) -- this makes a key that sends Alt, Control, and Delete in a single keypress.
|
||||
|
||||
##Documents
|
||||
See [doc/HHKB.txt](doc/HHKB.txt) and files under [doc/](doc/) for internal of HHKB and this controller.
|
||||
The following shortcuts automatically add `LSFT()` to keycodes to get commonly used symbols. Their long names are also available and documented in `/quantum/keymap_common.h`.
|
||||
|
||||
KC_TILD ~
|
||||
KC_EXLM !
|
||||
KC_AT @
|
||||
KC_HASH #
|
||||
KC_DLR $
|
||||
KC_PERC %
|
||||
KC_CIRC ^
|
||||
KC_AMPR &
|
||||
KC_ASTR *
|
||||
KC_LPRN (
|
||||
KC_RPRN )
|
||||
KC_UNDS _
|
||||
KC_PLUS +
|
||||
KC_LCBR {
|
||||
KC_RCBR }
|
||||
KC_PIPE |
|
||||
KC_COLN :
|
||||
|
||||
##Build Firmware & Program
|
||||
See [this document](../../doc/build.md) first.
|
||||
`MT(mod, kc)` - is *mod* (modifier key - MOD_LCTL, MOD_LSFT) when held, and *kc* when tapped. In other words, you can have a key that sends Esc (or the letter O or whatever) when you tap it, but works as a Control key or a Shift key when you hold it down.
|
||||
|
||||
### Configuration
|
||||
If your target is **HHKB JP** you need to set `HHKB_JP` build option in `Makefile` or use `Makefile.jp` instead of `Makefile`.
|
||||
These are the values you can use for the `mod` in `MT()` (right-hand modifiers are not available):
|
||||
|
||||
If you use other than **TMK Alt Controller Board** set proper `MCU`, `BOOTLOADER_SIZE` and other build options in `Makefile` and `config.h`. At least PJRC Teensy requires changing `BOOTLOADER_SIZE` to 512.
|
||||
* MOD_LCTL
|
||||
* MOD_LSFT
|
||||
* MOD_LALT
|
||||
* MOD_LGUI
|
||||
|
||||
### Build
|
||||
Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. Just `make` with `KEYMAP` option like:
|
||||
These can also be combined like `MOD_LCTL | MOD_LSFT` e.g. `MT(MOD_LCTL | MOD_LSFT, KC_ESC)` which would activate Control and Shift when held, and send Escape when tapped.
|
||||
|
||||
$ make -f Makefile.<jp|pjrc|rn42> KEYMAP=(hasu|hhkb|spacefn|<name>)
|
||||
We've added shortcuts to make common modifier/tap (mod-tap) mappings more compact:
|
||||
|
||||
You can omit `-f` option when you use `Makefile`. `Makefile` is used for **Pro2 and Pro**, `Makefile.jp` fits for **JP** model and `Makefile.rn42` supports Bluetooth module **RN-42**. `Makefile.pjrc` uses **PJRC** as output protocol instead of **LUFA**.
|
||||
* `CTL_T(kc)` - is LCTL when held and *kc* when tapped
|
||||
* `SFT_T(kc)` - is LSFT when held and *kc* when tapped
|
||||
* `ALT_T(kc)` - is LALT when held and *kc* when tapped
|
||||
* `GUI_T(kc)` - is LGUI when held and *kc* when tapped
|
||||
* `ALL_T(kc)` - is Hyper (all mods) when held and *kc* when tapped. To read more about what you can do with a Hyper key, see [this blog post by Brett Terpstra](http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/)
|
||||
|
||||
### Temporarily setting the default layer
|
||||
|
||||
### Program
|
||||
First, push reset button on board to start bootloader.
|
||||
`DF(layer)` - sets default layer to *layer*. The default layer is the one at the "bottom" of the layer stack - the ultimate fallback layer. This currently does not persist over power loss. When you plug the keyboard back in, layer 0 will always be the default. It is theoretically possible to work around that, but that's not what `DF` does.
|
||||
|
||||
This command programs the controller with [dfu-programmer] if the tool is installed and configured properly.
|
||||
### Remember: These are just aliases
|
||||
|
||||
$ make -f Makefile.<variant> KEYMAP=<name> dfu
|
||||
These functions work the same way that their `ACTION_*` functions do - they're just quick aliases. To dig into all of the tmk ACTION_* functions, please see the [TMK documentation](https://github.com/jackhumbert/qmk_firmware/blob/master/tmk_core/doc/keymap.md#2-action).
|
||||
|
||||
Or you can also use [FLIP] command to program. Also the tool should be installed and configured properly. FLIP GUI application is also available.
|
||||
Instead of using `FNx` when defining `ACTION_*` functions, you can use `F(x)` - the benefit here is being able to use more than 32 function actions (up to 4096), if you happen to need them.
|
||||
|
||||
$ make -f Makefile.<variant> KEYMAP=<name> flip
|
||||
## Macro shortcuts: Send a whole string when pressing just one key
|
||||
|
||||
Use [Teensy Loader] if your controller is Teensy/Teensy++.
|
||||
Instead of using the `ACTION_MACRO` function, you can simply use `M(n)` to access macro *n* - *n* will get passed into the `action_get_macro` as the `id`, and you can use a switch statement to trigger it. This gets called on the keydown and keyup, so you'll need to use an if statement testing `record->event.pressed` (see keymap_default.c).
|
||||
|
||||
```c
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) // this is the function signature -- just copy/paste it into your keymap file as it is.
|
||||
{
|
||||
switch(id) {
|
||||
case 0: // this would trigger when you hit a key mapped as M(0)
|
||||
if (record->event.pressed) {
|
||||
return MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END ); // this sends the string 'hello' when the macro executes
|
||||
}
|
||||
break;
|
||||
}
|
||||
return MACRO_NONE;
|
||||
};
|
||||
```
|
||||
A macro can include the following commands:
|
||||
|
||||
##Keymap
|
||||
To define your own keymap create a file in the keymaps folder named `<name>.c` and see keymap document (you can find in top README.md) and existent keymap files.
|
||||
* I() change interval of stroke in milliseconds.
|
||||
* D() press key.
|
||||
* U() release key.
|
||||
* T() type key(press and release).
|
||||
* W() wait (milliseconds).
|
||||
* END end mark.
|
||||
|
||||
So above you can see the stroke interval changed to 255ms between each keystroke, then a bunch of keys being typed, waits a while, then the macro ends.
|
||||
|
||||
##Hardware
|
||||
You have some options for hardware. Development boards with USB AVR family(ATMega32U4, AT90USB1286) like Teensy will work while MegaAVR with [V-USB] library is also cheaper option for DIY.
|
||||
Note: Using macros to have your keyboard send passwords for you is a bad idea.
|
||||
|
||||
###1. TMK Alt Controller Board
|
||||
Design files are available at [Keyboard Controller Board for HHKB(KiCad project)](https://github.com/tmk/HHKB_controller) and see [Controller Distribution thread](http://geekhack.org/index.php?topic=56494.0) if you get an assembled one.
|
||||
### Additional keycode aliases for software-implemented layouts (Colemak, Dvorak, etc)
|
||||
|
||||
Everything is assuming you're in Qwerty (in software) by default, but there is built-in support for using a Colemak or Dvorak layout by including this at the top of your keymap:
|
||||
|
||||
###2. PJRC Teensy
|
||||
See [this thread](http://geekhack.org/index.php?topic=57008.0).
|
||||
#include "keymap_<layout>.h"
|
||||
|
||||
Where <layout> is "colemak" or "dvorak". After including this line, you will get access to:
|
||||
|
||||
###3. V-USB version
|
||||
See [V-USB controller for HHKB](doc/V-USB.md).
|
||||
* `CM_*` for all of the Colemak-equivalent characters
|
||||
* `DV_*` for all of the Dvorak-equivalent characters
|
||||
|
||||
These implementations assume you're using Colemak or Dvorak on your OS, not on your keyboard - this is referred to as a software-implemented layout. If your computer is in Qwerty and your keymap is in Colemak or Dvorak, this is referred to as a firmware-implemented layout, and you won't need these features.
|
||||
|
||||
[LUFA]: http://www.fourwalledcubicle.com/LUFA.php
|
||||
[PJRC]: http://www.pjrc.com/teensy/usb_keyboard.html
|
||||
[dfu-programmer]: http://dfu-programmer.sourceforge.net/
|
||||
[FLIP]: http://www.atmel.com/tools/FLIP.aspx
|
||||
[Teensy Loader]: http://www.pjrc.com/teensy/loader.html
|
||||
[V-USB]: http://www.obdev.at/products/vusb/index.html
|
||||
To give an example, if you're using software-implemented Colemak, and want to get an `F`, you would use `CM_F` - `KC_F` under these same circumstances would result in `T`.
|
||||
|
||||
## Additional language support
|
||||
|
||||
In `quantum/keymap_extras/`, you'll see various language files - these work the same way as the alternative layout ones do. Most are defined by their two letter country/language code followed by an underscore and a 4-letter abbreviation of its name. `FR_UGRV` which will result in a `ù` when using a software-implemented AZERTY layout. It's currently difficult to send such characters in just the firmware (but it's being worked on - see Unicode support).
|
||||
|
||||
## Unicode support
|
||||
|
||||
You can currently send 4 hex digits with your OS-specific modifier key (RALT for OSX with the "Unicode Hex Input" layout) - this is currently limited to supporting one OS at a time, and requires a recompile for switching. 8 digit hex codes are being worked on. The keycode function is `UC(n)`, where *n* is a 4 digit hexidecimal. Enable from the Makefile.
|
||||
|
||||
## Other firmware shortcut keycodes
|
||||
|
||||
* `RESET` - puts the MCU in DFU mode for flashing new firmware (with `make dfu`)
|
||||
* `DEBUG` - the firmware into debug mode - you'll need hid_listen to see things
|
||||
* `BL_ON` - turns the backlight on
|
||||
* `BL_OFF` - turns the backlight off
|
||||
* `BL_<n>` - sets the backlight to level *n*
|
||||
* `BL_INC` - increments the backlight level by one
|
||||
* `BL_DEC` - decrements the backlight level by one
|
||||
* `BL_TOGG` - toggles the backlight
|
||||
* `BL_STEP` - steps through the backlight levels
|
||||
|
||||
Enable the backlight from the Makefile.
|
||||
|
||||
## MIDI functionalty
|
||||
|
||||
This is still a WIP, but check out `quantum/keymap_midi.c` to see what's happening. Enable from the Makefile.
|
||||
|
||||
## Bluetooth functionality
|
||||
|
||||
This requires [some hardware changes](https://www.reddit.com/r/MechanicalKeyboards/comments/3psx0q/the_planck_keyboard_with_bluetooth_guide_and/?ref=search_posts), but can be enabled via the Makefile. The firmware will still output characters via USB, so be aware of this when charging via a computer. It would make sense to have a switch on the Bluefruit to turn it off at will.
|
||||
|
||||
## Building
|
||||
|
||||
Download or clone the whole firmware and navigate to the keyboard/planck folder. Once your dev env is setup, you'll be able to type `make` to generate your .hex - you can then use `make dfu` to program your PCB once you hit the reset button.
|
||||
|
||||
Depending on which keymap you would like to use, you will have to compile slightly differently.
|
||||
|
||||
### Default
|
||||
To build with the default keymap, simply run `make`.
|
||||
|
||||
### Other Keymaps
|
||||
Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create a file in the keymaps folder named `<name>.c` and see keymap document (you can find in top README.md) and existent keymap files.
|
||||
|
||||
To build the firmware binary hex file with a keymap just do `make` with `KEYMAP` option like:
|
||||
```
|
||||
$ make KEYMAP=[default|jack|<name>]
|
||||
```
|
||||
Keymaps follow the format **__\<name\>.c__** and are stored in the `keymaps` folder.
|
||||
|
@ -1,112 +0,0 @@
|
||||
/*
|
||||
Copyright 2011 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 0x4242
|
||||
#define DEVICE_VER 0x0104
|
||||
#define MANUFACTURER t.m.k.
|
||||
#define PRODUCT HHKB mod
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for HHKB mod
|
||||
|
||||
|
||||
/* matrix size */
|
||||
#ifdef HHKB_JP
|
||||
# define MATRIX_ROWS 16
|
||||
#else
|
||||
# define MATRIX_ROWS 8
|
||||
#endif
|
||||
#define MATRIX_COLS 8
|
||||
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
|
||||
|
||||
|
||||
/* period of tapping(ms) */
|
||||
#define TAPPING_TERM 300
|
||||
/* tap count needed for toggling a feature */
|
||||
#define TAPPING_TOGGLE 5
|
||||
/* Oneshot timeout(ms) */
|
||||
#define ONESHOT_TIMEOUT 300
|
||||
|
||||
/* Boot Magic salt key: Space */
|
||||
#define BOOTMAGIC_KEY_SALT KC_FN6
|
||||
|
||||
/* power control of key switch board */
|
||||
#define HHKB_POWER_SAVING
|
||||
|
||||
/*
|
||||
* Hardware Serial(UART)
|
||||
* Baud rate are calculated with round off(+0.5).
|
||||
*/
|
||||
#ifdef __AVR_ATmega32U4__
|
||||
/* iom32u4.h has no definition of UCSR1D. copy from iom32u2.h */
|
||||
#define UCSR1D _SFR_MEM8(0xCB)
|
||||
#define RTSEN 0
|
||||
#define CTSEN 1
|
||||
|
||||
#define SERIAL_UART_BAUD 115200
|
||||
#define SERIAL_UART_DATA UDR1
|
||||
#define SERIAL_UART_UBRR ((F_CPU/(16.0*SERIAL_UART_BAUD)-1+0.5))
|
||||
#define SERIAL_UART_RXD_VECT USART1_RX_vect
|
||||
#define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1))
|
||||
#define SERIAL_UART_INIT() do { \
|
||||
UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \
|
||||
UBRR1H = ((uint16_t)SERIAL_UART_UBRR>>8); /* baud rate */ \
|
||||
UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); /* RX interrupt, RX: enable */ \
|
||||
UCSR1B |= (0<<TXCIE1) | (1<<TXEN1); /* TX interrupt, TX: enable */ \
|
||||
UCSR1C |= (0<<UPM11) | (0<<UPM10); /* parity: none(00), even(01), odd(11) */ \
|
||||
UCSR1D |= (0<<RTSEN) | (0<<CTSEN); /* RTS, CTS(no flow control by hardware) */ \
|
||||
DDRD |= (1<<5); PORTD &= ~(1<<5); /* RTS for flow control by firmware */ \
|
||||
sei(); \
|
||||
} while(0)
|
||||
#define SERIAL_UART_RTS_LO() do { PORTD &= ~(1<<5); } while (0)
|
||||
#define SERIAL_UART_RTS_HI() do { PORTD |= (1<<5); } while (0)
|
||||
#else
|
||||
#error "USART configuration is needed."
|
||||
#endif
|
||||
|
||||
|
||||
/* for debug */
|
||||
#define SUART_OUT_PORT PORTD
|
||||
#define SUART_OUT_BIT 0
|
||||
#define SUART_IN_PIN PIND
|
||||
#define SUART_IN_BIT 1
|
||||
|
||||
|
||||
/*
|
||||
* Feature disable options
|
||||
* These options are also useful to firmware size reduction.
|
||||
*/
|
||||
/* disable debug print */
|
||||
//#define NO_DEBUG
|
||||
|
||||
/* disable print */
|
||||
//#define NO_PRINT
|
||||
|
||||
/* disable action features */
|
||||
//#define NO_ACTION_LAYER
|
||||
//#define NO_ACTION_TAPPING
|
||||
//#define NO_ACTION_ONESHOT
|
||||
//#define NO_ACTION_MACRO
|
||||
//#define NO_ACTION_FUNCTION
|
||||
|
||||
#endif
|
@ -1,39 +0,0 @@
|
||||
HHKB Bluetooth mod
|
||||
==================
|
||||
See this article:
|
||||
http://geekhack.org/showwiki.php?title=Island:20851
|
||||
|
||||
|
||||
|
||||
Power consume
|
||||
=============
|
||||
Switch board
|
||||
------------
|
||||
5V
|
||||
18mA full scan/no power control
|
||||
16.5mA full scan with power control of POWER_ON/POWER_OFF in matrix.c
|
||||
3.5-6mA 60ms watchdog timer sleep iwrap/main.c
|
||||
|
||||
- the longer sleep time the less power is consumed.
|
||||
- power control of swtich board must be needed.
|
||||
FET switch may be better, though 18mA is with in port sink current limit. In current design switch board ground is connected to PB5 pin and power it on by making the pin low.
|
||||
|
||||
Blueguiga WT12
|
||||
--------------
|
||||
3.3V
|
||||
-42mA startup/searching/connecting
|
||||
19-23mA connected
|
||||
4mA -8mA not connected
|
||||
|
||||
iWRAP sleep command may not work. to be looked into.
|
||||
|
||||
Power Over all
|
||||
--------------
|
||||
5V
|
||||
-65mA startup
|
||||
17-24mA idle/not connected
|
||||
-42mA connecting
|
||||
32-37mA idle/connecting(with sleep)
|
||||
50-53mA typing/connecting(no sleep)
|
||||
|
||||
2013/06/07
|
Before Width: | Height: | Size: 490 KiB |
@ -1,204 +0,0 @@
|
||||
Internal of HHKB pro
|
||||
=====================
|
||||
HHKB pro has MCU and some chips on separate two PCBs.
|
||||
|
||||
Controller PCB
|
||||
--------------
|
||||
M38K07M4 Renesas MCU with USB function
|
||||
http://documentation.renesas.com/eng/products/mpumcu/rej03b0192_38k0ds.pdf
|
||||
|
||||
(HHKB_controller.jpg)
|
||||
|
||||
Keyswitch PCB
|
||||
-------------
|
||||
HC4051 Analog Multiplexer: select a row line.
|
||||
http://www.ti.com/lit/ds/schs122j/schs122j.pdf
|
||||
LS145 BCD Decoder: select a column line.
|
||||
http://www.ti.com/lit/ds/symlink/sn74ls145.pdf
|
||||
BU9831 Non-volatile electronic potentiometer: for calibration?
|
||||
https://www.spezial.com/doc/rohm-a/bu9831.pdf
|
||||
TP1683/4 Capacitive Sensing controller: no datasheet available.
|
||||
|
||||
(HHKB_keyswitch.jpg)
|
||||
|
||||
Topre original chip?
|
||||
(HHKB_TP1684.jpg)
|
||||
|
||||
|
||||
Connector Cable
|
||||
---------------
|
||||
Two PCBs are connected by 15 lines(13 in case of Pro2).
|
||||
Vcc and GND use 3(2) lines each, other lines are for keyboard signaling.
|
||||
|
||||
HHKB connector lines:
|
||||
JP Pro2 Pro Function Description TMK pin usage
|
||||
--------------------------------------------------------------------------------------------
|
||||
1 Vcc(5V) 5V
|
||||
1 1 2 Vcc(5V) 5V
|
||||
2 2 3 Vcc(5V) 5V
|
||||
3 3 4 TP1684 ~KEY: Low(0) when key is pressed PD7 input(with pullup)
|
||||
4 4 5 TP1684 HYS: High(1) when key is pressed PB7 output
|
||||
5 5 6 HC4051 A(bit0)\ PB0 output
|
||||
6 6 7 HC4051 B(bit1) > select row 0-7 PB1 output
|
||||
7 7 8 HC4051 C(bit2)/ PB2 output
|
||||
8 8 9 LS145 A(bit0)\ PB3 output
|
||||
9 9 10 LS145 B(bit1) > select column 0-7 PB4 output
|
||||
10 10 11 LS145 C(bit2)/ PB5 output
|
||||
11 11 12 LS145 ~D(enable) Low(0) enables selected column PB6 output
|
||||
12 12 13 GND GND
|
||||
13 13 14 GND GND
|
||||
15 GND
|
||||
14 HC4051(Z2) ~Enable of Z2 row0-7 PC6
|
||||
15 HC4051(Z3) ~Enable of Z3 row8-15 PC7
|
||||
|
||||
NOTE: Probably HYS changes threshold for upstroke and makes hysteresis in the result.
|
||||
NOTE: HYS should be given High(1) when previous KEY state is Low(0).
|
||||
NOTE: 1KOhm didn't work as pullup resistor on KEY. AVR internal pullup or 10KOhm resistor was OK.
|
||||
NOTE: JP has two HC4051(Z2,Z3) and line 5, 6 and 7 are connected to both of them.
|
||||
|
||||
(HHKB_connector.jpg)
|
||||
|
||||
|
||||
Keyswitch matrix
|
||||
----------------
|
||||
HHKB switch matrix is ghost-free and bounce-free.
|
||||
|
||||
Pro/Pro2(8x8):
|
||||
COL 0 1 2 3 4 5 6 7
|
||||
ROW ---------------------------------------------------------------
|
||||
0| 2 q w s a z x c
|
||||
1| 3 4 r e d f v b
|
||||
2| 5 6 y t g h n _NONE_
|
||||
3| 1 Esc Tab Control LShift LAlt LMeta Space
|
||||
4| 7 8 u i k j m _NONE_
|
||||
5| \ ` Delete Return Fn RShift RAlt RMeta
|
||||
6| 9 0 o p ; l , _NONE_
|
||||
7| - + ] [ ' / . _NONE_
|
||||
|
||||
|
||||
JP(16x8):
|
||||
COL 0 1 2 3 4 5 6 7
|
||||
ROW ---------------------------------------------------------------
|
||||
0| ESC TAB LFn LShift LCtrl
|
||||
1| 4 E MuHKN C D
|
||||
2| 3 W LAlt X S
|
||||
3| 1 HHK
|
||||
4|
|
||||
5| 5 R V F
|
||||
6| 2 Q LGui Z A
|
||||
7| 6 T Space B G
|
||||
8| 9 I Kana , K
|
||||
9| 8 U Henkan M J
|
||||
A| 7 Y N H
|
||||
B| 0 O RAlt . L
|
||||
C| BS Right RShift Enter
|
||||
D| \ [ Down Up ]
|
||||
E| - P RFn / ;
|
||||
F| ~ @ Left Ro :
|
||||
|
||||
|
||||
Matrix diagram:
|
||||
|
||||
Pro/Pro2:
|
||||
+-------------------------+-+-+-+-+-+-+-+ Vcc
|
||||
|bias control? - - - - - - - - ---
|
||||
| 3.9K*8 R R R R R R R R |
|
||||
+--------^+ +--------+ - - - - - - - - |
|
||||
| 2| | HC4051 <0-------|-|-|-|-|-|-|-|--|R|-+
|
||||
| |capa. | <1-------|-|-|-|-|-|-|-|--|R|-+
|
||||
| TP1684 |sense | <2-------|-|-|-|-|-|-|-|--|R|-+
|
||||
| 11<------| <3-------|-|-|-|-|-|-|-|--|R|-+
|
||||
| | | <4-------|-|-|-|-|-|-|-|--|R|-+
|
||||
| | | <5-------|-|-|-|-|-|-|-|--|R|-+
|
||||
| <-+ | <6-------|-|-|-|-|-|-|-|--|R|-+
|
||||
| 1 4 | | | <7-------|-|-|-|-|-|-|-|--|R|-+
|
||||
+---V---^-+ | +-^-^-^--+ 0 1 2 3 4 5 6 7 33K*8
|
||||
KEY HYS | A B C +-----------------+
|
||||
| | +-^----+ | | | | LS145 |
|
||||
Vcc | | |BU9831| | | | +-^--^--^--^------+
|
||||
--- | | +------+ | | | A B C D +-------+
|
||||
| | | | | | | | | | | |
|
||||
1-3 4 5 6 7 8 9 10 11 12 13-15 Pro |
|
||||
1-2 3 4 5 6 7 8 9 10 11 12-13 Pro2|
|
||||
+--------------------------------------------------+ |
|
||||
| connector | ---
|
||||
+--------------------------------------------------+ GND
|
||||
|
||||
|
||||
JP:
|
||||
+-----------------------------+-+-+-+-+ Vcc
|
||||
|bias control? - - - - - ---
|
||||
| 3.9K*5 R R R R R |
|
||||
+--------^+ +--------+ - - - - - |
|
||||
| | | HC4051 <0-----------|-|-|-|-|----|R|-+
|
||||
| |capa. | Z2 <1-----------|-|-|-|-|----|R|-+
|
||||
| TP1684 |sense | <2-----------|-|-|-|-|----|R|-+
|
||||
| <---+--| <3-----------|-|-|-|-|----|R|-+
|
||||
| | | | <4-----------|-|-|-|-|----|R|-+
|
||||
| | ~En| <5-----------|-|-|-|-|----|R|-+
|
||||
| | +----> <6-----------|-|-|-|-|----|R|-+
|
||||
| | | | | A B C <7-----------|-|-|-|-|----|R|-+
|
||||
+---V---^-+ | | +-^-^-^--+ | | | | | |
|
||||
KEY HYS | | | | | | | | | | |
|
||||
| | | | +--------+ | | | | | |
|
||||
| | | | | HC4051 <8-----------|-|-|-|-|----|R|-+
|
||||
| | | | | Z3 <9-----------|-|-|-|-|----|R|-+
|
||||
| | | +--| <A-----------|-|-|-|-|----|R|-+
|
||||
| | | | <B-----------|-|-|-|-|----|R|-+
|
||||
| | | | <C-----------|-|-|-|-|----|R|-+
|
||||
| | | ~En| <D-----------|-|-|-|-|----|R|-+
|
||||
| | | +-> <E-----------|-|-|-|-|----|R|-+
|
||||
| | | | | A B C <F-----------|-|-|-|-|----|R|-+
|
||||
| | | | +-^-^-^--+ 0 1 2 3 4 5 6 7 33K*8
|
||||
| | | | | | | +-----------------+
|
||||
| | | | | | | | LS145 |
|
||||
Vcc | | | | | | | +-^--^--^--^------+
|
||||
--- | | | | | | | A B C D +-------+
|
||||
| | | | | | | | | | | | | |
|
||||
1-2 3 4 14 15 5 6 7 8 9 10 11 12-13 |
|
||||
+--------------------------------------------------+ |
|
||||
| connector | ---
|
||||
+--------------------------------------------------+ GND
|
||||
|
||||
|
||||
Signals charts
|
||||
--------------
|
||||
While pressing space bar, watched HHKB Pro original controller signals by logic analyzer.
|
||||
Row and column is looping between 0-7 each for selecting a key.
|
||||
A key is scaned every about 15ms, so scan rate is 66Hz.
|
||||
|
||||
(HHKB_chart1.jpg)
|
||||
|
||||
Space bar locate at ROW:3 COL:7. A key is selected by HC4051(C,B,A) and LS145(C,B,A).
|
||||
Key state can be read on TP1684(4/KEY) while asserting low on LS145(D).
|
||||
|
||||
(HHKB_chart2.jpg)
|
||||
|
||||
|
||||
Signal of JP:
|
||||
|
||||
1) Select row
|
||||
rowC ____~~~~____~~~~ 3.8/3.8ms(JP) 7.7/7.7ms(Pro) S2 of HC4051
|
||||
rowB __~~__~~__~~__~~ 1.9/1.9ms(JP) 3.8/3.8ms(Pro) S1 of HC4051
|
||||
rowA _~_~_~_~_~_~_~_~ 1.0/1.0ms(JP) 1.9/1.9ms(Pro) S0 of HC4051
|
||||
0123456701234567 selected row(Pro)
|
||||
0123456789ABCDEF selected row(JP)
|
||||
rowEn0 ________~~~~~~~~ 7.7/7.7ms(JP only) ~Enable of Z2 HC4051(JP only)
|
||||
rowEn1 ~~~~~~~~________ 7.7/7.7ms(JP only) ~Enable of Z3 HC4051(JP only)
|
||||
|
||||
2) Select column
|
||||
colC ____~~~~____~~~~ 550/410us(JP) / us(Pro)
|
||||
colB __~~__~~__~~__~~ 200/210us(JP) 450/460us(Pro)
|
||||
colA _~_~_~_~_~_~_~_~ 100/110us(JP) 220/230us(Pro)
|
||||
0123456701234567 selected column
|
||||
|
||||
3) Wait 5us after column select, then set prev, strobe colD to spit out key status and read it.
|
||||
hys _~~~~_____ 20us if previous key state is low
|
||||
colD ~~~__~~~~~ 10us strobe
|
||||
key ~~~____~~~ 22us indicates current state of the key
|
||||
|
||||
NOTE: JP scans twice fast as Pro/Pro2 does. So Pro/Pro2 scans 8x8 matrix in 15.4ms while JP scans 16x8 in that time.
|
||||
|
||||
|
||||
|
||||
EOF
|
Before Width: | Height: | Size: 146 KiB |
Before Width: | Height: | Size: 152 KiB |
Before Width: | Height: | Size: 145 KiB |
Before Width: | Height: | Size: 189 KiB |
Before Width: | Height: | Size: 132 KiB |
Before Width: | Height: | Size: 168 KiB |
Before Width: | Height: | Size: 188 KiB |
Before Width: | Height: | Size: 166 KiB |
Before Width: | Height: | Size: 204 KiB |
Before Width: | Height: | Size: 133 KiB |
Before Width: | Height: | Size: 151 KiB |
@ -1,69 +0,0 @@
|
||||
HHKB keycodes
|
||||
=============
|
||||
2015/10/03
|
||||
Looked into unclear keycodes(usages) of Fn-chording-key on HHKB.
|
||||
Followings are usages of Keyboard/Keypad Page(0x07) that HHKB spits out when Fn key is down.
|
||||
|
||||
## HHK mode(Off-Off)
|
||||
Key Usage
|
||||
------------------------
|
||||
⌘ / ◇ 0x78 Stop
|
||||
|
||||
## Lite Ext. mode(On-Off)
|
||||
|
||||
|
||||
## Mac mode(Off-On)
|
||||
Key Usage
|
||||
------------------------
|
||||
Esc 0x66 Power
|
||||
A 0x81 Volume Down
|
||||
S 0x80 Volume Up
|
||||
D 0x7F Mute
|
||||
F 0x6F F20
|
||||
Delete 0x53 Num Lock and Clear
|
||||
|
||||
|
||||
## Secret mode(On-On)
|
||||
Key Usage
|
||||
------------------------
|
||||
Esc 0x66 Power
|
||||
Q 0x78 Stop
|
||||
W 0x7E Find
|
||||
E 0x74 Execute
|
||||
R 0x77 Select
|
||||
T 0x76 Menu
|
||||
Y 0x75 Help
|
||||
Z 0x7A Undo
|
||||
X 0x7B Cut
|
||||
C 0x7C Copy
|
||||
V 0x7D Paste
|
||||
B 0x79 Again
|
||||
|
||||
|
||||
## Matrix Key-Mode
|
||||
|
||||
|
||||
Mode
|
||||
-------------------------------
|
||||
Key HHK Lite Mac Secret Desc
|
||||
---------------------------------------------------------------------------------------
|
||||
⌘ / ◇ 0x78 - - - Stop
|
||||
Esc - - 0x66 0x66 Power
|
||||
A - - 0x81 - Volume Down
|
||||
S - - 0x80 - Volume Up
|
||||
D - - 0x7F - Mute
|
||||
F - - 0x6F - F20
|
||||
Delete 0x2A 0x2A 0x53 0x2A Num Lock and Clear(0x53)/Backspace(0x2A)
|
||||
Q - - - 0x78 Stop
|
||||
W - - - 0x7E Find
|
||||
E - - - 0x74 Execute
|
||||
R - - - 0x77 Select
|
||||
T - - - 0x76 Menu
|
||||
Y - - - 0x75 Help
|
||||
Z - - - 0x7A Undo
|
||||
X - - - 0x7B Cut
|
||||
C - - - 0x7C Copy
|
||||
V - - - 0x7D Paste
|
||||
B - - - 0x79 Again
|
||||
|
||||
EOF
|
@ -1,48 +0,0 @@
|
||||
HHKB Power consumption
|
||||
----------------------
|
||||
|
||||
**Power consumption
|
||||
board clock/prescaler keyswitch power ctrl current
|
||||
--------------------------------------------------------------------------
|
||||
tmk 16MHz no no 26.4mA
|
||||
tmk 16MHz pro1 no 45.1mA
|
||||
tmk 16MHz/2 no no 18.1mA
|
||||
tmk 16MHz/2 pro1 no 37.3mA
|
||||
tmk 8MHz no no 18.9mA
|
||||
tmk 8MHz pro2 no(w/o FET) 32.1mA
|
||||
tmk 8MHz pro2 no(w FET) 32.1mA withou POWER_ON/FF
|
||||
tmk 8MHz pro2 no(w FET) 32.6mA with POWR_ON/OFF
|
||||
tmk 8MHz pro2 15ms(w FET) 21.3mA with POWR_ON/OFF, enumerated but error -32
|
||||
tmk 8MHz pro2 60ms(w FET) 13.3mA with POWR_ON/OFF, not enumerated
|
||||
|
||||
gh60 16MHz 25.8mA
|
||||
gh60 16MHz USB suspend w LED breathing 17.6-29.1mA
|
||||
gh60 16MHz USB suspend w/o LED 0.2mA(0.231-0.276mA)
|
||||
Poker 5.6mA
|
||||
Poker USB suspend 0.3mA(0.301mA)
|
||||
gh60 16MHz stock firmware by komar 26.8mA
|
||||
|
||||
|
||||
HHKB pro2 Over All 139.4mA
|
||||
HHKB pro2 Controller 115.1mA
|
||||
HHKB pro1 Controller 25.9mA
|
||||
|
||||
|
||||
keyswitch power consumption:
|
||||
pro1: 45.1-26.4=18.7mA
|
||||
37.3-18.1=19.2mA
|
||||
pro2: 32.1-18.9=13.2mA
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
**Low Freq Crystal or Prescaler?
|
||||
No advantage of Low Freq Crystal against Prescaled.
|
||||
|
||||
Clock routing
|
||||
X'tal --+---->Prescaler-------> System Clock
|
||||
|
|
||||
+---------------------> USB PLL
|
||||
|
||||
Design Decision: Install 16MHz crystal on board with using clock rescaler.
|
@ -1,39 +0,0 @@
|
||||
V-USB controller for HHKB
|
||||
=========================
|
||||
Not supported actively any more.
|
||||
|
||||
## Build
|
||||
Use `Makefile.vusb` for [V-USB] controller.
|
||||
$ make -f Makefile.vusb
|
||||
|
||||
##Hardware
|
||||
###3. V-USB connection
|
||||
+---+ +---------------+
|
||||
USB GND | | ATmega328p |
|
||||
~~~ C3 | |
|
||||
5V <-------+--------+---|Vcc,AVCC | HHKB pro pro2
|
||||
R1 | | ~~~~~~~~ ~~~~
|
||||
D- <----+--+-----R2-----|INT1 PB2-4|------->ROW (6-8) (5-7)
|
||||
D+ <----|---+----R3-----|INT0 PC0-2|------->COL (9-11) (8-10)
|
||||
Z1 Z2 | PC3|------->ENABLE (12) (11)
|
||||
GND<----+---+-----------|GND PB0|<-------KEY (4) (3)
|
||||
| PB1|------->PREV (5) (4)
|
||||
| |
|
||||
GND+-C2--+--|XTAL1 RXD|------->Debug Console
|
||||
X1 | TXD|<-------Debug Console
|
||||
GND+-C3--+--|XTAL2 RST|---SW--+GND
|
||||
+---------------+
|
||||
R1: 1.5K Ohm
|
||||
R2,R3: 68 Ohm
|
||||
Z1,Z2: Zener 3.6V
|
||||
C1,C2: 22pF
|
||||
C3: 0.1uF
|
||||
X1: Crystal 12MHz
|
||||
SW: Push Switch(for bootloader)
|
||||
|
||||
- NOTE: See [V-USB] documentation for more detail of hardware and the USB stack.
|
||||
- NOTE: [USBaspLoader] is very useful for firmware update.
|
||||
|
||||
|
||||
[V-USB]: http://www.obdev.at/products/vusb/index.html
|
||||
[USBaspLoader]: http://www.obdev.at/products/vusb/usbasploader.html
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
Copyright 2012,2013 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/>.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include "action.h"
|
||||
#include <avr/pgmspace.h>
|
||||
#include "keymap_common.h"
|
||||
|
||||
|
||||
/* translates key to keycode */
|
||||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||
}
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint8_t keycode)
|
||||
{
|
||||
return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
/*
|
||||
Copyright 2012,2013 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 KEYMAP_COMMON_H
|
||||
#define KEYMAP_COMMON_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
#include "action_code.h"
|
||||
#include "action_layer.h"
|
||||
#include "action_macro.h"
|
||||
#include "action_util.h"
|
||||
#include "report.h"
|
||||
#include "host.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "keymap.h"
|
||||
|
||||
|
||||
extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
|
||||
extern const uint16_t fn_actions[];
|
||||
|
||||
|
||||
#define KEYMAP( \
|
||||
K31, K30, K00, K10, K11, K20, K21, K40, K41, K60, K61, K70, K71, K50, K51, \
|
||||
K32, K01, K02, K13, K12, K23, K22, K42, K43, K62, K63, K73, K72, K52, \
|
||||
K33, K04, K03, K14, K15, K24, K25, K45, K44, K65, K64, K74, K53, \
|
||||
K34, K05, K06, K07, K16, K17, K26, K46, K66, K76, K75, K55, K54, \
|
||||
K35, K36, K37, K57, K56 \
|
||||
) \
|
||||
{ \
|
||||
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
|
||||
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
|
||||
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \
|
||||
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \
|
||||
{ KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \
|
||||
{ KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
|
||||
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_NO }, \
|
||||
{ KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO } \
|
||||
}
|
||||
|
||||
|
||||
#define KEYMAP_JP( \
|
||||
K02, K32, K62, K22, K12, K52, K72, KA2, K92, K82, KB2, KE2, KF2, KD2, KC2, \
|
||||
K03, K63, K23, K13, K53, K73, KA3, K93, K83, KB3, KE3, KF3, KD3, \
|
||||
K06, K66, K26, K16, K56, K76, KA6, K96, K86, KB6, KE6, KF6, KD6, KC6, \
|
||||
K05, K65, K25, K15, K55, K75, KA5, K95, K85, KB5, KE5, KF5, KD5, KC5, \
|
||||
K04, K34, K64, K24, K14, K74, K94, K84, KB4, KE4, KF4, KD4, KC4 \
|
||||
) \
|
||||
{ \
|
||||
{ KC_NO, KC_NO, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_##K32, KC_NO, KC_##K34, KC_NO, KC_NO, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_##K52, KC_##K53, KC_NO, KC_##K55, KC_##K56, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_##K92, KC_##K93, KC_##K94, KC_##K95, KC_##K96, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_##KA2, KC_##KA3, KC_NO, KC_##KA5, KC_##KA6, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_##KB2, KC_##KB3, KC_##KB4, KC_##KB5, KC_##KB6, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_##KC2, KC_NO, KC_##KC4, KC_##KC5, KC_##KC6, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_##KD2, KC_##KD3, KC_##KD4, KC_##KD5, KC_##KD6, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_NO }, \
|
||||
{ KC_NO, KC_NO, KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_NO } \
|
||||
}
|
||||
|
||||
#endif
|
@ -1,282 +0,0 @@
|
||||
/*
|
||||
* Hasu: my personal keymap
|
||||
*/
|
||||
#include "keymap_common.h"
|
||||
|
||||
|
||||
#ifdef KEYMAP_SECTION_ENABLE
|
||||
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
|
||||
#else
|
||||
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
|
||||
#endif
|
||||
/* Layer 0: Default Layer
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Fn6 |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Fn7 | Z| X| C| V| B| N| M| ,| .|Fn2|Shift |Fn1|
|
||||
* `-----------------------------------------------------------'
|
||||
* |Gui|Alt | Fn4 |Fn5 |Gui|
|
||||
* `-------------------------------------------'
|
||||
*/
|
||||
[0] = \
|
||||
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \
|
||||
LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN6, \
|
||||
FN7, Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,FN1, \
|
||||
LGUI,LALT, FN4, FN5, RGUI),
|
||||
|
||||
/* Layer 1: HHKB mode[HHKB Fn]
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | | | | | | +| -|End|PgD|Dow|Shift | |
|
||||
* `-----------------------------------------------------------'
|
||||
* |Gui|Alt | Space |Alt |Gui|
|
||||
* `-------------------------------------------'
|
||||
*/
|
||||
[1] = \
|
||||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
||||
CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, UP, NO, BSPC, \
|
||||
LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \
|
||||
LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \
|
||||
LGUI,LALT, TRNS, RALT,RGUI),
|
||||
|
||||
/* Layer 2: Vi mode[Slash]
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgUlEnd| | | |Backs|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | | | | | |Hom|PgD|PgUlEnd|Fn0|Shift | |
|
||||
* `-----------------------------------------------------------'
|
||||
* |Gui|Alt | Space |Alt |Gui|
|
||||
* `-------------------------------------------'
|
||||
*/
|
||||
[2] = \
|
||||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
||||
TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC, \
|
||||
LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \
|
||||
LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT,TRNS, \
|
||||
LGUI,LALT, SPC, RALT,RGUI),
|
||||
|
||||
/* Layer 3: Mouse mode(IJKL)[Semicolon]
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro| | | | | |Mb2|McL|McD|McR|Fn | |Return |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
|
||||
* `-----------------------------------------------------------'
|
||||
* |Gui |Alt | Mb1 |Fn |Fn |
|
||||
* `--------------------------------------------'
|
||||
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
||||
*/
|
||||
[3] = \
|
||||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
||||
FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,FN9, FN10,FN8, \
|
||||
LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,FN3, NO, ENT, \
|
||||
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \
|
||||
LGUI,LALT, BTN1, TRNS,TRNS),
|
||||
|
||||
/* Layer 4: Mouse mode(IJKL)[Space]
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro| | | | | |Mb2|McL|McD|McR|Mb1| |Return |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
|
||||
* `-----------------------------------------------------------'
|
||||
* |Gui |Alt | Mb1 |Fn |Fn |
|
||||
* `--------------------------------------------'
|
||||
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
||||
*/
|
||||
[4] = \
|
||||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
||||
FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BTN4,BTN5,FN8, \
|
||||
LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, \
|
||||
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \
|
||||
LGUI,LALT, TRNS, TRNS,TRNS),
|
||||
|
||||
#if 0
|
||||
/* Layer 3: Mouse mode(HJKL)[Semicolon]
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Tab | | | | | |MwL|MwD|MwU|MwR| | | |Backs|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro| | | | | |McL|McD|McU|McR|Fn0| |Return |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
|
||||
* `-----------------------------------------------------------'
|
||||
* |Gui |Alt | Mb1 |Alt |Fn0|
|
||||
* `--------------------------------------------'
|
||||
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
||||
*/
|
||||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
||||
TAB, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, NO, NO, BSPC, \
|
||||
LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,TRNS,QUOT,ENT, \
|
||||
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,SLSH,RSFT,NO, \
|
||||
LGUI,LALT, BTN1, RALT,TRNS),
|
||||
|
||||
/* Layer4: Mouse mode(HJKL)[Space]
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Tab | | | | | |MwL|MwD|MwU|MwR| |Wbk|Wfr|Alt-T|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro| | | | | |McL|McD|McU|McR|Fn0| |Return |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
|
||||
* `-----------------------------------------------------------'
|
||||
* |Gui |Alt | Fn0 |Alt |Fn0|
|
||||
* `--------------------------------------------'
|
||||
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
||||
*/
|
||||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
||||
FN8, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, FN9, FN10,FN8, \
|
||||
LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,BTN1,NO, ENT, \
|
||||
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,NO, \
|
||||
LGUI,LALT, TRNS, RALT,RGUI),
|
||||
#endif
|
||||
#if 0
|
||||
/* Layer x: Matias half-qwerty keyboard style[Space]
|
||||
* ,-----------------------------------------------------------.
|
||||
* | -| 0| 9| 8| 7| 6| 5| 4| 3| 2| 1| | | |Esc|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Backs| P| O| I| U| Y| T| R| E| W| Q| | |Tab |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro| ;| L| K| J| H| G| F| D| S| A|Con|Control |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | /| .| ,| M| N| B| V| C| X| Z|Shift | |
|
||||
* `-----------------------------------------------------------'
|
||||
* |Gui |Alt | Fn0 |Alt |Gui|
|
||||
* `--------------------------------------------'
|
||||
*/
|
||||
KEYMAP(MINS,0, 9, 8, 7, 6, 5, 4, 3, 2, 1, NO, NO, NO, ESC, \
|
||||
BSPC,P, O, I, U, Y, T, R, E, W, Q, NO, NO, TAB, \
|
||||
LCTL,SCLN,L, K, J, H, G, F, D, S, A, RCTL,RCTL, \
|
||||
LSFT,SLSH,DOT, COMM,M, N, B, V, C, X, Z, RSFT,NO, \
|
||||
LGUI,LALT, TRNS, RALT,RGUI),
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* id for user defined functions */
|
||||
enum function_id {
|
||||
LSHIFT_LPAREN,
|
||||
};
|
||||
|
||||
enum macro_id {
|
||||
HELLO,
|
||||
VOLUP,
|
||||
ALT_TAB,
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Fn action definition
|
||||
*/
|
||||
#ifdef KEYMAP_SECTION_ENABLE
|
||||
const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
|
||||
#else
|
||||
const uint16_t fn_actions[] PROGMEM = {
|
||||
#endif
|
||||
[0] = ACTION_DEFAULT_LAYER_SET(0), // Default layer(not used)
|
||||
[1] = ACTION_LAYER_TAP_TOGGLE(1), // HHKB layer(toggle with 5 taps)
|
||||
[2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash*
|
||||
[3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon*
|
||||
[4] = ACTION_LAYER_TAP_KEY(4, KC_SPC), // Mousekey layer with Space
|
||||
[5] = ACTION_LAYER_MOMENTARY(4), // Mousekey layer(IJKL)
|
||||
[6] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT), // RControl with tap Enter
|
||||
[7] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift
|
||||
[8] = ACTION_MACRO(ALT_TAB), // Application switching
|
||||
[9] = ACTION_MODS_KEY(MOD_LALT, KC_LEFT),
|
||||
[10] = ACTION_MODS_KEY(MOD_LALT, KC_RIGHT),
|
||||
|
||||
// [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // LControl with tap Backspace
|
||||
// [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC), // LControl with tap Esc
|
||||
// [x] = ACTION_FUNCTION_TAP(LSHIFT_LPAREN), // Function: LShift with tap '('
|
||||
// [x] = ACTION_MACRO(HELLO), // Macro: say hello
|
||||
// [x] = ACTION_MACRO(VOLUP), // Macro: media key
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Macro definition
|
||||
*/
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
switch (id) {
|
||||
case HELLO:
|
||||
return (record->event.pressed ?
|
||||
MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) :
|
||||
MACRO_NONE );
|
||||
case VOLUP:
|
||||
return (record->event.pressed ?
|
||||
MACRO( D(VOLU), U(VOLU), END ) :
|
||||
MACRO_NONE );
|
||||
case ALT_TAB:
|
||||
return (record->event.pressed ?
|
||||
MACRO( D(LALT), D(TAB), END ) :
|
||||
MACRO( U(TAB), END ));
|
||||
}
|
||||
return MACRO_NONE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* user defined action function
|
||||
*/
|
||||
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
if (record->event.pressed) dprint("P"); else dprint("R");
|
||||
dprintf("%d", record->tap.count);
|
||||
if (record->tap.interrupted) dprint("i");
|
||||
dprint("\n");
|
||||
|
||||
switch (id) {
|
||||
case LSHIFT_LPAREN:
|
||||
// Shift parentheses example: LShft + tap '('
|
||||
// http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#shift-parentheses
|
||||
// http://geekhack.org/index.php?topic=41989.msg1304899#msg1304899
|
||||
if (record->event.pressed) {
|
||||
if (record->tap.count > 0 && !record->tap.interrupted) {
|
||||
if (record->tap.interrupted) {
|
||||
dprint("tap interrupted\n");
|
||||
register_mods(MOD_BIT(KC_LSHIFT));
|
||||
}
|
||||
} else {
|
||||
register_mods(MOD_BIT(KC_LSHIFT));
|
||||
}
|
||||
} else {
|
||||
if (record->tap.count > 0 && !(record->tap.interrupted)) {
|
||||
add_weak_mods(MOD_BIT(KC_LSHIFT));
|
||||
send_keyboard_report();
|
||||
register_code(KC_9);
|
||||
unregister_code(KC_9);
|
||||
del_weak_mods(MOD_BIT(KC_LSHIFT));
|
||||
send_keyboard_report();
|
||||
record->tap.count = 0; // ad hoc: cancel tap
|
||||
} else {
|
||||
unregister_mods(MOD_BIT(KC_LSHIFT));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
/*
|
||||
* HHKB Layout
|
||||
*/
|
||||
#include "keymap_common.h"
|
||||
|
||||
|
||||
#ifdef KEYMAP_SECTION_ENABLE
|
||||
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
|
||||
#else
|
||||
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
|
||||
#endif
|
||||
/* Layer 0: Default Layer
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro| A| S| D| F| G| H| J| K| L| ;| '|Enter |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0|
|
||||
* `-----------------------------------------------------------'
|
||||
* |Alt|Gui | Space |Gui |Alt|
|
||||
* `-------------------------------------------'
|
||||
*/
|
||||
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \
|
||||
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \
|
||||
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, \
|
||||
LALT,LGUI, SPC, RGUI,RALT),
|
||||
|
||||
/* Layer 1: HHKB mode (HHKB Fn)
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs|
|
||||
* |-----------------------------------------------------------|
|
||||
* | |VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter |
|
||||
* |-----------------------------------------------------------|
|
||||
* | | | | | | | +| -|End|PgD|Dow| | |
|
||||
* `-----------------------------------------------------------'
|
||||
* | | | | | |
|
||||
* `-------------------------------------------'
|
||||
*/
|
||||
KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
||||
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, BSPC, \
|
||||
TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,PENT, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS, \
|
||||
TRNS,TRNS, TRNS, TRNS,TRNS),
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Fn action definition
|
||||
*/
|
||||
#ifdef KEYMAP_SECTION_ENABLE
|
||||
const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1),
|
||||
[1] = ACTION_LAYER_MOMENTARY(2),
|
||||
[2] = ACTION_LAYER_MOMENTARY(3),
|
||||
[3] = ACTION_LAYER_MOMENTARY(4),
|
||||
[4] = ACTION_LAYER_MOMENTARY(5),
|
||||
[5] = ACTION_LAYER_MOMENTARY(6),
|
||||
[6] = ACTION_LAYER_MOMENTARY(7),
|
||||
[7] = ACTION_LAYER_TOGGLE(1),
|
||||
[8] = ACTION_LAYER_TOGGLE(2),
|
||||
[9] = ACTION_LAYER_TOGGLE(3),
|
||||
[10] = ACTION_LAYER_TAP_TOGGLE(1),
|
||||
[11] = ACTION_LAYER_TAP_TOGGLE(2),
|
||||
[12] = ACTION_LAYER_TAP_TOGGLE(3),
|
||||
[13] = ACTION_LAYER_TAP_KEY(1, KC_A),
|
||||
[14] = ACTION_LAYER_TAP_KEY(2, KC_F),
|
||||
[15] = ACTION_LAYER_TAP_KEY(3, KC_J),
|
||||
[16] = ACTION_LAYER_TAP_KEY(4, KC_SPACE),
|
||||
[17] = ACTION_LAYER_TAP_KEY(5, KC_SCOLON),
|
||||
[18] = ACTION_LAYER_TAP_KEY(6, KC_QUOTE),
|
||||
[19] = ACTION_LAYER_TAP_KEY(7, KC_SLASH),
|
||||
[20] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_SPACE),
|
||||
[21] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_SPACE),
|
||||
[22] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_QUOTE),
|
||||
[23] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENTER),
|
||||
[24] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_ESC),
|
||||
[25] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_BSPACE),
|
||||
[26] = ACTION_MODS_ONESHOT(MOD_LCTL),
|
||||
[27] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_ESC),
|
||||
[28] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_BSPACE),
|
||||
[29] = ACTION_MODS_ONESHOT(MOD_LSFT),
|
||||
[30] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_ESC),
|
||||
[31] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_BSPACE),
|
||||
};
|
||||
#else
|
||||
const uint16_t fn_actions[] PROGMEM = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1),
|
||||
};
|
||||
#endif
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* HHKB JP Layout
|
||||
*/
|
||||
#include "keymap_common.h"
|
||||
|
||||
|
||||
#ifdef KEYMAP_SECTION_ENABLE
|
||||
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
|
||||
#else
|
||||
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
|
||||
#endif
|
||||
/* Layer 0: Default Layer */
|
||||
KEYMAP_JP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, \
|
||||
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,BSLS,ENT, \
|
||||
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RO, UP, RSFT, \
|
||||
FN0, ZKHK,LGUI,LALT,MHEN, SPC, HENK,KANA,RALT,FN0, LEFT,DOWN,RGHT),
|
||||
|
||||
/* Layer 1: HHKB mode (HHKB Fn)
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Caps | | | | | | | |Psc|Slk|Pus|Up | | |
|
||||
* |------------------------------------------------------` |
|
||||
* | |VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig| | |
|
||||
* |-----------------------------------------------------------|
|
||||
* | | | | | | | +| -|End|PgD|Dow| | | |
|
||||
* |-----------------------------------------------------------|
|
||||
* | || | | | | | | | | || | | |
|
||||
* `-----------------------------------------------------------'
|
||||
*/
|
||||
KEYMAP_JP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
||||
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, \
|
||||
TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,TRNS,PENT, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS),
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Fn action definition
|
||||
*/
|
||||
#ifdef KEYMAP_SECTION_ENABLE
|
||||
const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
|
||||
#else
|
||||
const uint16_t fn_actions[] PROGMEM = {
|
||||
#endif
|
||||
[0] = ACTION_LAYER_MOMENTARY(1),
|
||||
};
|
@ -1,116 +0,0 @@
|
||||
/*
|
||||
* SpaceFN
|
||||
* http://geekhack.org/index.php?topic=51069.0
|
||||
*/
|
||||
#include "keymap_common.h"
|
||||
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Layer 0: Default Layer
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| `|BSp|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro| A| S| D| F| G| H| J| K| L| ;| '|Enter |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0|
|
||||
* `-----------------------------------------------------------'
|
||||
* |Gui|Alt | SpaceFN |Alt |Gui|
|
||||
* `-------------------------------------------'
|
||||
*/
|
||||
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, GRV, BSPC, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \
|
||||
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \
|
||||
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, \
|
||||
LGUI,LALT, FN1, RALT,RGUI),
|
||||
|
||||
/* Layer 1: HHKB mode (HHKB Fn)
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs|
|
||||
* |-----------------------------------------------------------|
|
||||
* | |VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter |
|
||||
* |-----------------------------------------------------------|
|
||||
* | | | | | | | +| -|End|PgD|Dow| | |
|
||||
* `-----------------------------------------------------------'
|
||||
* | | | | | |
|
||||
* `-------------------------------------------'
|
||||
*/
|
||||
KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
||||
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, BSPC, \
|
||||
TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,PENT, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS, \
|
||||
TRNS,TRNS, SPC, TRNS,TRNS),
|
||||
|
||||
/* Layer 2: SpaceFN
|
||||
* ,-----------------------------------------------------------.
|
||||
* |` | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| |Del|
|
||||
* |-----------------------------------------------------------|
|
||||
* | | | |Esc| | | |Hom|Up |End|Psc|Slk|Pau|Ins |
|
||||
* |-----------------------------------------------------------|
|
||||
* | | | | | | |PgU|Lef|Dow|Rig| | | |
|
||||
* |-----------------------------------------------------------|
|
||||
* | | | | | |Spc|PgD|` |~ | | | | |
|
||||
* `-----------------------------------------------------------'
|
||||
* | | | | | |
|
||||
* `-------------------------------------------'
|
||||
*/
|
||||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS,DEL, \
|
||||
TRNS,TRNS,TRNS,ESC, TRNS,TRNS,TRNS,HOME,FN3, END, PSCR,SLCK,PAUS,INS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP,LEFT,DOWN,RGHT,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,SPC, PGDN,GRV, FN2, TRNS,TRNS,TRNS,NO, \
|
||||
TRNS,TRNS, TRNS, TRNS,TRNS),
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* user defined action function
|
||||
*/
|
||||
enum function_id {
|
||||
CTRL_SPACE_I, // Ctrl + Up(SpaceFN) -> PgUp
|
||||
};
|
||||
|
||||
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
# define MODS_CTRL_MASK (MOD_BIT(KC_LCTRL)|MOD_BIT(KC_RCTRL))
|
||||
static uint8_t ctrl_space_i_prev_ctrl;
|
||||
|
||||
switch (id) {
|
||||
// Ctrl + Up(SpaceFN) -> PgUp
|
||||
case CTRL_SPACE_I:
|
||||
ctrl_space_i_prev_ctrl = get_mods()&MODS_CTRL_MASK;
|
||||
if (record->event.pressed) {
|
||||
if (ctrl_space_i_prev_ctrl) {
|
||||
del_mods(ctrl_space_i_prev_ctrl); // remove Ctrl
|
||||
add_key(KC_PGUP);
|
||||
send_keyboard_report(); // send PgUp without Ctrl
|
||||
add_mods(ctrl_space_i_prev_ctrl); // return Ctrl but not sent
|
||||
} else {
|
||||
add_key(KC_UP);
|
||||
send_keyboard_report();
|
||||
}
|
||||
} else {
|
||||
if (ctrl_space_i_prev_ctrl) {
|
||||
del_key(KC_PGUP);
|
||||
send_keyboard_report();
|
||||
} else {
|
||||
del_key(KC_UP);
|
||||
send_keyboard_report();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Fn action definition
|
||||
*/
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1),
|
||||
[1] = ACTION_LAYER_TAP_KEY(2, KC_SPACE),
|
||||
[2] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV), // tilde
|
||||
[3] = ACTION_FUNCTION(CTRL_SPACE_I), // Ctrl + Up(SpaceFN) -> PgUp
|
||||
};
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
Copyright 2011 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/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "stdint.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
/* HHKB has no LEDs */
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
|
||||
DDRD |= (1<<6);
|
||||
PORTD |= (1<<6);
|
||||
} else {
|
||||
DDRD |= (1<<6);
|
||||
PORTD &= ~(1<<6);
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
#
|
||||
# Makefile for iWRAP
|
||||
#
|
||||
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = hhkb_iwrap
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# keyboard dependent files
|
||||
SRC = \
|
||||
keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config_iwrap.h
|
||||
|
||||
|
||||
# V-USB debug level: To use ps2_usart.c level must be 0
|
||||
# ps2_usart.c requires USART to receive PS/2 signal.
|
||||
OPT_DEFS = -DDEBUG_LEVEL=0
|
||||
|
||||
|
||||
# MCU name, you MUST set this to match the board you are using
|
||||
# type "make clean" after changing this, so all files will be rebuilt
|
||||
MCU = atmega328p
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# Normally the first thing your program should do is set the clock prescaler,
|
||||
# so your program will run at the correct speed. You should also set this
|
||||
# variable to same clock speed. The _delay_ms() macro uses this, and many
|
||||
# examples use this variable to calculate timings. Do not add a "UL" here.
|
||||
F_CPU = 12000000
|
||||
|
||||
|
||||
# Boot Section Size in *bytes*
|
||||
# Teensy halfKay 512
|
||||
# Teensy++ halfKay 1024
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
# USBaspLoader 2048
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=2048
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover
|
||||
|
||||
|
||||
|
||||
#---------------- Programming Options --------------------------
|
||||
AVRDUDE = avrdude
|
||||
# Type: avrdude -c ? to get a full listing.
|
||||
AVRDUDE_PROGRAMMER = usbasp
|
||||
AVRDUDE_PORT =
|
||||
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
|
||||
|
||||
# Uncomment the following if you want avrdude's erase cycle counter.
|
||||
# Note that this counter needs to be initialized first using -Yn,
|
||||
# see avrdude manual.
|
||||
#AVRDUDE_ERASE_COUNTER = -y
|
||||
|
||||
# Uncomment the following if you do /not/ wish a verification to be
|
||||
# performed after programming the device.
|
||||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
#AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
|
||||
AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
|
||||
|
||||
PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/iwrap.mk
|
||||
# TODO: to be selectable: V-USB, LUFA or PJRC
|
||||
#include $(TMK_DIR)/protocol/vusb.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
@ -1,97 +0,0 @@
|
||||
#
|
||||
# Makefile for V-USB
|
||||
#
|
||||
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = hhkb_vusb
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# keyboard dependent files
|
||||
SRC = \
|
||||
keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config_vusb.h
|
||||
|
||||
|
||||
# V-USB debug level: To use ps2_usart.c level must be 0
|
||||
# ps2_usart.c requires USART to receive PS/2 signal.
|
||||
OPT_DEFS = -DDEBUG_LEVEL=0
|
||||
|
||||
|
||||
# MCU name, you MUST set this to match the board you are using
|
||||
# type "make clean" after changing this, so all files will be rebuilt
|
||||
MCU = atmega328p
|
||||
# avrdude doesn't know atmega168p
|
||||
AVRDUDE_MCU = $(MCU)
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# Normally the first thing your program should do is set the clock prescaler,
|
||||
# so your program will run at the correct speed. You should also set this
|
||||
# variable to same clock speed. The _delay_ms() macro uses this, and many
|
||||
# examples use this variable to calculate timings. Do not add a "UL" here.
|
||||
F_CPU = 12000000
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover
|
||||
|
||||
|
||||
|
||||
#---------------- Programming Options --------------------------
|
||||
AVRDUDE = avrdude
|
||||
# Type: avrdude -c ? to get a full listing.
|
||||
AVRDUDE_PROGRAMMER = usbasp
|
||||
AVRDUDE_PORT =
|
||||
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
|
||||
|
||||
# Uncomment the following if you want avrdude's erase cycle counter.
|
||||
# Note that this counter needs to be initialized first using -Yn,
|
||||
# see avrdude manual.
|
||||
#AVRDUDE_ERASE_COUNTER = -y
|
||||
|
||||
# Uncomment the following if you do /not/ wish a verification to be
|
||||
# performed after programming the device.
|
||||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
#AVRDUDE_FLAGS = -p $(AVRDUDE_MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
|
||||
AVRDUDE_FLAGS = -p $(AVRDUDE_MCU) -c $(AVRDUDE_PROGRAMMER)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
|
||||
|
||||
PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/vusb.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
||||
|
||||
debug-on: EXTRAFLAGS += -DDEBUG
|
||||
debug-on: all
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
Copyright 2011 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 0xBEEA
|
||||
// TODO: share these strings with usbconfig.h
|
||||
// Edit usbconfig.h to change these.
|
||||
#define MANUFACTURER t.m.k.
|
||||
#define PRODUCT HHKB mod
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for HHKB mod
|
||||
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 8
|
||||
#define MATRIX_COLS 8
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
|
||||
|
||||
/* pins for Software UART */
|
||||
#define SUART_IN_PIN PINC
|
||||
#define SUART_IN_BIT 5
|
||||
#define SUART_OUT_PORT PORTC
|
||||
#define SUART_OUT_BIT 4
|
||||
|
||||
|
||||
#define DEBUG_LED 1
|
||||
#define DEBUG_LED_CONFIG (DDRD |= (1<<4))
|
||||
#define DEBUG_LED_OFF (PORTD |= (1<<4))
|
||||
#define DEBUG_LED_ON (PORTD &= ~(1<<4))
|
||||
|
||||
/* period of tapping(ms) */
|
||||
#define TAPPING_TERM 300
|
||||
/* tap count needed for toggling a feature */
|
||||
#define TAPPING_TOGGLE 5
|
||||
|
||||
#endif
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
Copyright 2011 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 0xC0FE
|
||||
// TODO: share these strings with usbconfig.h
|
||||
// Edit usbconfig.h to change these.
|
||||
#define MANUFACTURER t.m.k.
|
||||
#define PRODUCT HHKB mod
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for HHKB mod
|
||||
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 8
|
||||
#define MATRIX_COLS 8
|
||||
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
|
||||
|
||||
#endif
|
@ -1,32 +0,0 @@
|
||||
|
||||
iWRAP
|
||||
-----
|
||||
+---------------+ WT12
|
||||
5V | ATmega168 | 5V/3.3V~~~~
|
||||
+-----+---|Vcc,AVCC PC4|---/--->iWRAP(RxD)
|
||||
USB | C3 | PC5|<--/----iWRAP(TxD)
|
||||
~~~ | + | |
|
||||
5V <--BATT + GND | | HHKB
|
||||
R1 | | ~~~~
|
||||
D- <----+-----+--R2-----|INT1 PB2-4|------->ROW(6-8)
|
||||
D+ <----|---+----R3-----|INT0 PC0-2|------->COL(9-11)
|
||||
Z1 Z2 | PC3|------->ENABLE(12)
|
||||
GND<----+---+-----------|GND PB0|<-------KEY(4)
|
||||
| PB1|------->PREV(5)
|
||||
| |
|
||||
GND+-C2--+--|XTAL1 RXD|------->Debug Console
|
||||
X1 | TXD|<-------Debug Console
|
||||
GND+-C3--+--|XTAL2 RST|---SW--+GND
|
||||
+---------------+
|
||||
|
||||
R1: 1.5K Ohm
|
||||
R2,R3: 68 Ohm
|
||||
Z1,Z2: Zener 3.6V
|
||||
C1,C2: 22pF
|
||||
C3: 0.1uF
|
||||
X1: Crystal 12MHz
|
||||
SW: Push Switch(Optional)
|
||||
BATT: Li-Po Battery, Battery Charger and Voltage Regulator(5V and 3.3V).
|
||||
|
||||
|
||||
|
@ -1,388 +0,0 @@
|
||||
/* Name: usbconfig.h
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2005-04-01
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||
* This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $
|
||||
*/
|
||||
|
||||
#ifndef __usbconfig_h_included__
|
||||
#define __usbconfig_h_included__
|
||||
|
||||
#include "config_vusb.h"
|
||||
|
||||
/*
|
||||
General Description:
|
||||
This file is an example configuration (with inline documentation) for the USB
|
||||
driver. It configures V-USB for USB D+ connected to Port D bit 2 (which is
|
||||
also hardware interrupt 0 on many devices) and USB D- to Port D bit 4. You may
|
||||
wire the lines to any other port, as long as D+ is also wired to INT0 (or any
|
||||
other hardware interrupt, as long as it is the highest level interrupt, see
|
||||
section at the end of this file).
|
||||
*/
|
||||
|
||||
/* ---------------------------- Hardware Config ---------------------------- */
|
||||
|
||||
#define USB_CFG_IOPORTNAME D
|
||||
/* This is the port where the USB bus is connected. When you configure it to
|
||||
* "B", the registers PORTB, PINB and DDRB will be used.
|
||||
*/
|
||||
#define USB_CFG_DMINUS_BIT 3
|
||||
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
|
||||
* This may be any bit in the port.
|
||||
*/
|
||||
#define USB_CFG_DPLUS_BIT 2
|
||||
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
|
||||
* This may be any bit in the port. Please note that D+ must also be connected
|
||||
* to interrupt pin INT0! [You can also use other interrupts, see section
|
||||
* "Optional MCU Description" below, or you can connect D- to the interrupt, as
|
||||
* it is required if you use the USB_COUNT_SOF feature. If you use D- for the
|
||||
* interrupt, the USB interrupt will also be triggered at Start-Of-Frame
|
||||
* markers every millisecond.]
|
||||
*/
|
||||
#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
|
||||
/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000,
|
||||
* 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code
|
||||
* require no crystal, they tolerate +/- 1% deviation from the nominal
|
||||
* frequency. All other rates require a precision of 2000 ppm and thus a
|
||||
* crystal!
|
||||
* Since F_CPU should be defined to your actual clock rate anyway, you should
|
||||
* not need to modify this setting.
|
||||
*/
|
||||
#define USB_CFG_CHECK_CRC 0
|
||||
/* Define this to 1 if you want that the driver checks integrity of incoming
|
||||
* data packets (CRC checks). CRC checks cost quite a bit of code size and are
|
||||
* currently only available for 18 MHz crystal clock. You must choose
|
||||
* USB_CFG_CLOCK_KHZ = 18000 if you enable this option.
|
||||
*/
|
||||
|
||||
/* ----------------------- Optional Hardware Config ------------------------ */
|
||||
|
||||
/* #define USB_CFG_PULLUP_IOPORTNAME D */
|
||||
/* If you connect the 1.5k pullup resistor from D- to a port pin instead of
|
||||
* V+, you can connect and disconnect the device from firmware by calling
|
||||
* the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
|
||||
* This constant defines the port on which the pullup resistor is connected.
|
||||
*/
|
||||
/* #define USB_CFG_PULLUP_BIT 4 */
|
||||
/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
|
||||
* above) where the 1.5k pullup resistor is connected. See description
|
||||
* above for details.
|
||||
*/
|
||||
|
||||
/* --------------------------- Functional Range ---------------------------- */
|
||||
|
||||
#define USB_CFG_HAVE_INTRIN_ENDPOINT 1
|
||||
/* Define this to 1 if you want to compile a version with two endpoints: The
|
||||
* default control endpoint 0 and an interrupt-in endpoint (any other endpoint
|
||||
* number).
|
||||
*/
|
||||
#define USB_CFG_HAVE_INTRIN_ENDPOINT3 1
|
||||
/* Define this to 1 if you want to compile a version with three endpoints: The
|
||||
* default control endpoint 0, an interrupt-in endpoint 3 (or the number
|
||||
* configured below) and a catch-all default interrupt-in endpoint as above.
|
||||
* You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature.
|
||||
*/
|
||||
#define USB_CFG_EP3_NUMBER 3
|
||||
/* If the so-called endpoint 3 is used, it can now be configured to any other
|
||||
* endpoint number (except 0) with this macro. Default if undefined is 3.
|
||||
*/
|
||||
/* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */
|
||||
/* The above macro defines the startup condition for data toggling on the
|
||||
* interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1.
|
||||
* Since the token is toggled BEFORE sending any data, the first packet is
|
||||
* sent with the oposite value of this configuration!
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_HALT 0
|
||||
/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature
|
||||
* for endpoint 1 (interrupt endpoint). Although you may not need this feature,
|
||||
* it is required by the standard. We have made it a config option because it
|
||||
* bloats the code considerably.
|
||||
*/
|
||||
#define USB_CFG_SUPPRESS_INTR_CODE 0
|
||||
/* Define this to 1 if you want to declare interrupt-in endpoints, but don't
|
||||
* want to send any data over them. If this macro is defined to 1, functions
|
||||
* usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if
|
||||
* you need the interrupt-in endpoints in order to comply to an interface
|
||||
* (e.g. HID), but never want to send any data. This option saves a couple
|
||||
* of bytes in flash memory and the transmit buffers in RAM.
|
||||
*/
|
||||
#define USB_CFG_INTR_POLL_INTERVAL 10
|
||||
/* If you compile a version with endpoint 1 (interrupt-in), this is the poll
|
||||
* interval. The value is in milliseconds and must not be less than 10 ms for
|
||||
* low speed devices.
|
||||
*/
|
||||
#define USB_CFG_IS_SELF_POWERED 0
|
||||
/* Define this to 1 if the device has its own power supply. Set it to 0 if the
|
||||
* device is powered from the USB bus.
|
||||
*/
|
||||
#define USB_CFG_MAX_BUS_POWER 100
|
||||
/* Set this variable to the maximum USB bus power consumption of your device.
|
||||
* The value is in milliamperes. [It will be divided by two since USB
|
||||
* communicates power requirements in units of 2 mA.]
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_FN_WRITE 1
|
||||
/* Set this to 1 if you want usbFunctionWrite() to be called for control-out
|
||||
* transfers. Set it to 0 if you don't need it and want to save a couple of
|
||||
* bytes.
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_FN_READ 0
|
||||
/* Set this to 1 if you need to send control replies which are generated
|
||||
* "on the fly" when usbFunctionRead() is called. If you only want to send
|
||||
* data from a static buffer, set it to 0 and return the data from
|
||||
* usbFunctionSetup(). This saves a couple of bytes.
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_FN_WRITEOUT 0
|
||||
/* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints.
|
||||
* You must implement the function usbFunctionWriteOut() which receives all
|
||||
* interrupt/bulk data sent to any endpoint other than 0. The endpoint number
|
||||
* can be found in 'usbRxToken'.
|
||||
*/
|
||||
#define USB_CFG_HAVE_FLOWCONTROL 0
|
||||
/* Define this to 1 if you want flowcontrol over USB data. See the definition
|
||||
* of the macros usbDisableAllRequests() and usbEnableAllRequests() in
|
||||
* usbdrv.h.
|
||||
*/
|
||||
#define USB_CFG_DRIVER_FLASH_PAGE 0
|
||||
/* If the device has more than 64 kBytes of flash, define this to the 64 k page
|
||||
* where the driver's constants (descriptors) are located. Or in other words:
|
||||
* Define this to 1 for boot loaders on the ATMega128.
|
||||
*/
|
||||
#define USB_CFG_LONG_TRANSFERS 0
|
||||
/* Define this to 1 if you want to send/receive blocks of more than 254 bytes
|
||||
* in a single control-in or control-out transfer. Note that the capability
|
||||
* for long transfers increases the driver size.
|
||||
*/
|
||||
/* #define USB_RX_USER_HOOK(data, len) if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(); */
|
||||
/* This macro is a hook if you want to do unconventional things. If it is
|
||||
* defined, it's inserted at the beginning of received message processing.
|
||||
* If you eat the received message and don't want default processing to
|
||||
* proceed, do a return after doing your things. One possible application
|
||||
* (besides debugging) is to flash a status LED on each packet.
|
||||
*/
|
||||
/* #define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();} */
|
||||
/* This macro is a hook if you need to know when an USB RESET occurs. It has
|
||||
* one parameter which distinguishes between the start of RESET state and its
|
||||
* end.
|
||||
*/
|
||||
/* #define USB_SET_ADDRESS_HOOK() hadAddressAssigned(); */
|
||||
/* This macro (if defined) is executed when a USB SET_ADDRESS request was
|
||||
* received.
|
||||
*/
|
||||
#define USB_COUNT_SOF 1
|
||||
/* define this macro to 1 if you need the global variable "usbSofCount" which
|
||||
* counts SOF packets. This feature requires that the hardware interrupt is
|
||||
* connected to D- instead of D+.
|
||||
*/
|
||||
/* #ifdef __ASSEMBLER__
|
||||
* macro myAssemblerMacro
|
||||
* in YL, TCNT0
|
||||
* sts timer0Snapshot, YL
|
||||
* endm
|
||||
* #endif
|
||||
* #define USB_SOF_HOOK myAssemblerMacro
|
||||
* This macro (if defined) is executed in the assembler module when a
|
||||
* Start Of Frame condition is detected. It is recommended to define it to
|
||||
* the name of an assembler macro which is defined here as well so that more
|
||||
* than one assembler instruction can be used. The macro may use the register
|
||||
* YL and modify SREG. If it lasts longer than a couple of cycles, USB messages
|
||||
* immediately after an SOF pulse may be lost and must be retried by the host.
|
||||
* What can you do with this hook? Since the SOF signal occurs exactly every
|
||||
* 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in
|
||||
* designs running on the internal RC oscillator.
|
||||
* Please note that Start Of Frame detection works only if D- is wired to the
|
||||
* interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES!
|
||||
*/
|
||||
#define USB_CFG_CHECK_DATA_TOGGLING 0
|
||||
/* define this macro to 1 if you want to filter out duplicate data packets
|
||||
* sent by the host. Duplicates occur only as a consequence of communication
|
||||
* errors, when the host does not receive an ACK. Please note that you need to
|
||||
* implement the filtering yourself in usbFunctionWriteOut() and
|
||||
* usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable
|
||||
* for each control- and out-endpoint to check for duplicate packets.
|
||||
*/
|
||||
#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0
|
||||
/* define this macro to 1 if you want the function usbMeasureFrameLength()
|
||||
* compiled in. This function can be used to calibrate the AVR's RC oscillator.
|
||||
*/
|
||||
#define USB_USE_FAST_CRC 0
|
||||
/* The assembler module has two implementations for the CRC algorithm. One is
|
||||
* faster, the other is smaller. This CRC routine is only used for transmitted
|
||||
* messages where timing is not critical. The faster routine needs 31 cycles
|
||||
* per byte while the smaller one needs 61 to 69 cycles. The faster routine
|
||||
* may be worth the 32 bytes bigger code size if you transmit lots of data and
|
||||
* run the AVR close to its limit.
|
||||
*/
|
||||
|
||||
/* -------------------------- Device Description --------------------------- */
|
||||
|
||||
#define USB_CFG_VENDOR_ID (VENDOR_ID & 0xFF), ((VENDOR_ID >> 8) & 0xFF)
|
||||
/* USB vendor ID for the device, low byte first. If you have registered your
|
||||
* own Vendor ID, define it here. Otherwise you may use one of obdev's free
|
||||
* shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules!
|
||||
* *** IMPORTANT NOTE ***
|
||||
* This template uses obdev's shared VID/PID pair for Vendor Class devices
|
||||
* with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand
|
||||
* the implications!
|
||||
*/
|
||||
#define USB_CFG_DEVICE_ID (PRODUCT_ID & 0xFF), ((PRODUCT_ID >> 8) & 0xFF)
|
||||
/* This is the ID of the product, low byte first. It is interpreted in the
|
||||
* scope of the vendor ID. If you have registered your own VID with usb.org
|
||||
* or if you have licensed a PID from somebody else, define it here. Otherwise
|
||||
* you may use one of obdev's free shared VID/PID pairs. See the file
|
||||
* USB-IDs-for-free.txt for details!
|
||||
* *** IMPORTANT NOTE ***
|
||||
* This template uses obdev's shared VID/PID pair for Vendor Class devices
|
||||
* with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand
|
||||
* the implications!
|
||||
*/
|
||||
#define USB_CFG_DEVICE_VERSION 0x00, 0x01
|
||||
/* Version number of the device: Minor number first, then major number.
|
||||
*/
|
||||
#define USB_CFG_VENDOR_NAME 't', '.', 'm', '.', 'k', '.'
|
||||
#define USB_CFG_VENDOR_NAME_LEN 6
|
||||
/* These two values define the vendor name returned by the USB device. The name
|
||||
* must be given as a list of characters under single quotes. The characters
|
||||
* are interpreted as Unicode (UTF-16) entities.
|
||||
* If you don't want a vendor name string, undefine these macros.
|
||||
* ALWAYS define a vendor name containing your Internet domain name if you use
|
||||
* obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for
|
||||
* details.
|
||||
*/
|
||||
#define USB_CFG_DEVICE_NAME 'H', 'H', 'K', 'B', ' ', 'm', 'o', 'd'
|
||||
#define USB_CFG_DEVICE_NAME_LEN 8
|
||||
/* Same as above for the device name. If you don't want a device name, undefine
|
||||
* the macros. See the file USB-IDs-for-free.txt before you assign a name if
|
||||
* you use a shared VID/PID.
|
||||
*/
|
||||
/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */
|
||||
/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */
|
||||
/* Same as above for the serial number. If you don't want a serial number,
|
||||
* undefine the macros.
|
||||
* It may be useful to provide the serial number through other means than at
|
||||
* compile time. See the section about descriptor properties below for how
|
||||
* to fine tune control over USB descriptors such as the string descriptor
|
||||
* for the serial number.
|
||||
*/
|
||||
#define USB_CFG_DEVICE_CLASS 0
|
||||
#define USB_CFG_DEVICE_SUBCLASS 0
|
||||
/* See USB specification if you want to conform to an existing device class.
|
||||
* Class 0xff is "vendor specific".
|
||||
*/
|
||||
#define USB_CFG_INTERFACE_CLASS 3 /* HID */
|
||||
#define USB_CFG_INTERFACE_SUBCLASS 1 /* Boot */
|
||||
#define USB_CFG_INTERFACE_PROTOCOL 1 /* Keyboard */
|
||||
/* See USB specification if you want to conform to an existing device class or
|
||||
* protocol. The following classes must be set at interface level:
|
||||
* HID class is 3, no subclass and protocol required (but may be useful!)
|
||||
* CDC class is 2, use subclass 2 and protocol 1 for ACM
|
||||
*/
|
||||
#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 0
|
||||
/* Define this to the length of the HID report descriptor, if you implement
|
||||
* an HID device. Otherwise don't define it or define it to 0.
|
||||
* If you use this define, you must add a PROGMEM character array named
|
||||
* "usbHidReportDescriptor" to your code which contains the report descriptor.
|
||||
* Don't forget to keep the array and this define in sync!
|
||||
*/
|
||||
|
||||
/* #define USB_PUBLIC static */
|
||||
/* Use the define above if you #include usbdrv.c instead of linking against it.
|
||||
* This technique saves a couple of bytes in flash memory.
|
||||
*/
|
||||
|
||||
/* ------------------- Fine Control over USB Descriptors ------------------- */
|
||||
/* If you don't want to use the driver's default USB descriptors, you can
|
||||
* provide our own. These can be provided as (1) fixed length static data in
|
||||
* flash memory, (2) fixed length static data in RAM or (3) dynamically at
|
||||
* runtime in the function usbFunctionDescriptor(). See usbdrv.h for more
|
||||
* information about this function.
|
||||
* Descriptor handling is configured through the descriptor's properties. If
|
||||
* no properties are defined or if they are 0, the default descriptor is used.
|
||||
* Possible properties are:
|
||||
* + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched
|
||||
* at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is
|
||||
* used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if
|
||||
* you want RAM pointers.
|
||||
* + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found
|
||||
* in static memory is in RAM, not in flash memory.
|
||||
* + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash),
|
||||
* the driver must know the descriptor's length. The descriptor itself is
|
||||
* found at the address of a well known identifier (see below).
|
||||
* List of static descriptor names (must be declared PROGMEM if in flash):
|
||||
* char usbDescriptorDevice[];
|
||||
* char usbDescriptorConfiguration[];
|
||||
* char usbDescriptorHidReport[];
|
||||
* char usbDescriptorString0[];
|
||||
* int usbDescriptorStringVendor[];
|
||||
* int usbDescriptorStringDevice[];
|
||||
* int usbDescriptorStringSerialNumber[];
|
||||
* Other descriptors can't be provided statically, they must be provided
|
||||
* dynamically at runtime.
|
||||
*
|
||||
* Descriptor properties are or-ed or added together, e.g.:
|
||||
* #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18))
|
||||
*
|
||||
* The following descriptors are defined:
|
||||
* USB_CFG_DESCR_PROPS_DEVICE
|
||||
* USB_CFG_DESCR_PROPS_CONFIGURATION
|
||||
* USB_CFG_DESCR_PROPS_STRINGS
|
||||
* USB_CFG_DESCR_PROPS_STRING_0
|
||||
* USB_CFG_DESCR_PROPS_STRING_VENDOR
|
||||
* USB_CFG_DESCR_PROPS_STRING_PRODUCT
|
||||
* USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER
|
||||
* USB_CFG_DESCR_PROPS_HID
|
||||
* USB_CFG_DESCR_PROPS_HID_REPORT
|
||||
* USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver)
|
||||
*
|
||||
* Note about string descriptors: String descriptors are not just strings, they
|
||||
* are Unicode strings prefixed with a 2 byte header. Example:
|
||||
* int serialNumberDescriptor[] = {
|
||||
* USB_STRING_DESCRIPTOR_HEADER(6),
|
||||
* 'S', 'e', 'r', 'i', 'a', 'l'
|
||||
* };
|
||||
*/
|
||||
|
||||
#define USB_CFG_DESCR_PROPS_DEVICE 0
|
||||
#define USB_CFG_DESCR_PROPS_CONFIGURATION USB_PROP_IS_DYNAMIC
|
||||
//#define USB_CFG_DESCR_PROPS_CONFIGURATION 0
|
||||
#define USB_CFG_DESCR_PROPS_STRINGS 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_0 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0
|
||||
#define USB_CFG_DESCR_PROPS_HID USB_PROP_IS_DYNAMIC
|
||||
//#define USB_CFG_DESCR_PROPS_HID 0
|
||||
#define USB_CFG_DESCR_PROPS_HID_REPORT USB_PROP_IS_DYNAMIC
|
||||
//#define USB_CFG_DESCR_PROPS_HID_REPORT 0
|
||||
#define USB_CFG_DESCR_PROPS_UNKNOWN 0
|
||||
|
||||
/* ----------------------- Optional MCU Description ------------------------ */
|
||||
|
||||
/* The following configurations have working defaults in usbdrv.h. You
|
||||
* usually don't need to set them explicitly. Only if you want to run
|
||||
* the driver on a device which is not yet supported or with a compiler
|
||||
* which is not fully supported (such as IAR C) or if you use a differnt
|
||||
* interrupt than INT0, you may have to define some of these.
|
||||
*/
|
||||
/* #define USB_INTR_CFG MCUCR */
|
||||
/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */
|
||||
/* #define USB_INTR_CFG_CLR 0 */
|
||||
/* #define USB_INTR_ENABLE GIMSK */
|
||||
/* #define USB_INTR_ENABLE_BIT INT0 */
|
||||
/* #define USB_INTR_PENDING GIFR */
|
||||
/* #define USB_INTR_PENDING_BIT INTF0 */
|
||||
/* #define USB_INTR_VECTOR INT0_vect */
|
||||
|
||||
/* Set INT1 for D- falling edge to count SOF */
|
||||
/* #define USB_INTR_CFG EICRA */
|
||||
#define USB_INTR_CFG_SET ((1 << ISC11) | (0 << ISC10))
|
||||
/* #define USB_INTR_CFG_CLR 0 */
|
||||
/* #define USB_INTR_ENABLE EIMSK */
|
||||
#define USB_INTR_ENABLE_BIT INT1
|
||||
/* #define USB_INTR_PENDING EIFR */
|
||||
#define USB_INTR_PENDING_BIT INTF1
|
||||
#define USB_INTR_VECTOR INT1_vect
|
||||
|
||||
#endif /* __usbconfig_h_included__ */
|
@ -1,12 +0,0 @@
|
||||
RN42_DIR = rn42
|
||||
|
||||
SRC += serial_uart.c \
|
||||
rn42/suart.S \
|
||||
rn42/rn42.c \
|
||||
rn42/rn42_task.c \
|
||||
rn42/battery.c \
|
||||
rn42/main.c
|
||||
|
||||
OPT_DEFS += -DPROTOCOL_RN42
|
||||
|
||||
VPATH += $(RN42_DIR)
|
@ -1,255 +0,0 @@
|
||||
Memo of deveopment
|
||||
==================
|
||||
just memo, NOT WORTH READING
|
||||
|
||||
Bug:
|
||||
- Factory Reset PIO4 doesn't work
|
||||
- the reason is unclear - 12/08 NOT LOOK INTO ANY MORE
|
||||
- WORKAROUND: use serial pins(3.3V, GND, RX and TX)
|
||||
- SF,1 and R,1 to set factory defalult
|
||||
|
||||
|
||||
Todo:
|
||||
- LED cover and switch knob and new Slide Switch
|
||||
- RN42 auto configuration
|
||||
- configure the module as HID device every time powering up
|
||||
- this'll reduce work load of assembly
|
||||
|
||||
- move rn42 to protocol directory when it becomes reusable stack
|
||||
|
||||
- sendchar() in lufa.c no buffer
|
||||
- no buffering. character lost can be caused.
|
||||
- LUFA sendchar should be buffered and serial_uart.c buffur size is too large(256).
|
||||
|
||||
- BT operations
|
||||
- disconnect
|
||||
- new connection
|
||||
- remove connection
|
||||
|
||||
- sendchar() in lufa.c block loop - DONE 11/29
|
||||
- block loop when powered with AC adapter
|
||||
- FrameNumber is not updated when adapter powered
|
||||
|
||||
Improving:
|
||||
- ADC resolution
|
||||
AVR120
|
||||
AVR32138
|
||||
- Enhancing ADC resolution by oversampling
|
||||
AVR121 http://www.atmel.com/images/doc8003.pdf
|
||||
- disable digital input buffer DIDR(7.8.6)
|
||||
|
||||
Design:
|
||||
- suspend.h - DONE 11/26
|
||||
- remove argument from suspend_power_down() for backward compatitibility
|
||||
- remove MCU dependent power saving code from core/keyboard - DONE 11/23
|
||||
- it should be located in project matrix.c
|
||||
- HHKB matrix.c needs matrix_prev?
|
||||
- is_modified() is obsolete now. really needs?
|
||||
- ADC: removing AREF capacitor C10
|
||||
- seems to be better while usb powered
|
||||
- still bad while battery powered
|
||||
http://electronics.stackexchange.com/questions/105849/avcc-and-capacitor-using-adc
|
||||
- ADC: smaller resistors for voltage dividor
|
||||
- 1K + 1K: not improved. - 11/27
|
||||
|
||||
|
||||
LUFA:
|
||||
USB connection check: state of USB deivce
|
||||
- USB_DeviceState:
|
||||
USB_Deivce_State_t { Unattached, Powered, Default, Addressed, Configured*, Suspended* }
|
||||
Unattached: unpluged
|
||||
Powered: pluged with power adapter
|
||||
Default: enumerate process bigin
|
||||
Addressed: addressed
|
||||
Configured: enumerated
|
||||
Suspended: suspended
|
||||
|
||||
- USB_IsInitialized: state of LUFA core setup
|
||||
becomes true in USB_Init() USBController_AVR8.c
|
||||
becomes false in USB_Disable() USBController_AVR8.c
|
||||
- USB_VBUS_GetStatus(): state of VBUS(power/connection)
|
||||
- USB_Disable() detaches, disables all interrupts, controller, PLL, regulater.
|
||||
|
||||
- When connect to power adapter
|
||||
- event happened: CW or CSW or C or DDC
|
||||
- USB state: not configured
|
||||
|
||||
- USB evnets
|
||||
- USB connect: CSWRWRW
|
||||
- USB connect but fail to enumeration: CWRWRWRWS
|
||||
- USB disconnect: D
|
||||
- Power adapter connect: CW, CSW, C
|
||||
- Power adapter disconnect: D
|
||||
|
||||
|
||||
Power saving:
|
||||
- Pro2 current consumption
|
||||
- active: 138.2mA(no device on Hub)
|
||||
- suspended: 30.9mA(WakeUp enabled DIPSW6)
|
||||
- suspended: 0mA->46.0mA(WakeUp disabled DIPSW6)
|
||||
- Pro current consumption
|
||||
- active: 54.0mA
|
||||
- suspended: 40.5mA(WakeUp enabled DIPSW6)
|
||||
- suspended: 0.3mA(WakeUp disabled DIPSW6)
|
||||
|
||||
- RN42 3.3V
|
||||
- disconnected(Idle): 5mA (config mode)
|
||||
- connected(Active):
|
||||
SW,0000: 23-26mA
|
||||
SW,0010: 27-29mA worse than 0000 for unknown reason
|
||||
SW,0020: 17-19mA mouse NG
|
||||
SW,0030: 13-16mA laggy mouse NG
|
||||
SW,0050: 10-13mA laggy mouse NG
|
||||
|
||||
- matrix power saving
|
||||
- power saving while externally powered and not while unpluged
|
||||
- confirm suspend mode lufa.c: matrix_power_*, suspend_wakeup_condition
|
||||
- 8MHz clock
|
||||
- When not connected in a few minutes get into deep sleep to save battery life
|
||||
- CTS is needed for waking up from deep sleep? How deep sleep is activated?
|
||||
- firmware controlled 3.3V DC converter to switch on/off BT module
|
||||
- sleep MCU and BT module(keyboard is not used)
|
||||
- deep sleep MCU and BT module(keyboard is not used for long time)
|
||||
- deep sleep MCU and turn off BT module(keyboard is not used and not connected)
|
||||
- Battery ADC; switching, high resistance
|
||||
- switching gnd end of divider with PF4
|
||||
- high resistor 100K/1M?
|
||||
capacitor 10nF
|
||||
http://www.eevblog.com/forum/beginners/measuring-battery-voltage-without-consuming-current/
|
||||
- During USB suspend change clock source to internal RC from external Xtal(6.8)
|
||||
- FRZCLK: you can freeze clock for power saving. still WAKEUPI and VBUSTI interrupts are available while freezing.(21.7.3)
|
||||
- Suspend: Clear Suspend Bit, Freeze clock, disable PLL, MCU sleep(21.13)
|
||||
- Voltage reference(8.1.1)
|
||||
- to reduce power consumption while power down mode
|
||||
- unset ADEN before sleep(24.7)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Lipo
|
||||
----
|
||||
850mA lasts around 9 hours(07/28)
|
||||
|
||||
Sparkfun Polymer Lithium Ion Battery 850mAh:
|
||||
https://www.sparkfun.com/products/341
|
||||
Lipo Cell spec:
|
||||
https://www.sparkfun.com/datasheets/Batteries/063048%20Li-polymer.pdf
|
||||
Protection spec:
|
||||
http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Prototyping/BatteryProtection.pdf
|
||||
min typical max
|
||||
over-charge 4.255 4.280 4.305
|
||||
over-charge discover? 4.030 4.080 4.130
|
||||
over-discharge 2.827 2.900 2.973
|
||||
over-discharge discover 3.022 3.100 3.178
|
||||
|
||||
ADC voltage monitor: voltage divider 10K+10K(0.5)
|
||||
ADC=V*0.5/2.56*1024
|
||||
|
||||
V ADC
|
||||
------------------
|
||||
4.20 0x347(839)
|
||||
3.10 0x26b(619)
|
||||
|
||||
|
||||
|
||||
|
||||
TROUBLE SHOOT
|
||||
-------------
|
||||
07/16 After fix of voltage dividor on GPIO6, had a trouble that it could not send a char to BT module, though could receive.
|
||||
Found R8 had wrong 1K resistor and changed to 10K, after that it can send to the module again. Not sure how it had sent with the wrong 1K before.
|
||||
|
||||
07/18 On Linux, had an USB related trouble; keyboard or console didn't work for some reason. Changing PID cured this problem. Very annoying, took very long time before resolved it.
|
||||
|
||||
12/07 rn42_rts() read 1 every time. R12 broke in open mode(no coductive), idk why, too much heat with soldering? and PF1 pin was not soldered.
|
||||
It resolved with resoldering PF1 and new resistor on R12.
|
||||
|
||||
|
||||
|
||||
|
||||
Done:
|
||||
- low battery alert(solid light) 09/04
|
||||
- *** Rev.E BT test *** - DONE
|
||||
- with MCP73832, new Schottky, tantalum caps - DONE 12/07
|
||||
* MCP73832 doesn't leak from Vcc pin when unpluged and battery powered
|
||||
34mV vs 2.07V(MCP73831) at Vcc pin
|
||||
MCP73832 doesn't need revese protection diode D5
|
||||
* PMEG2010ER is very low VF while reverse current/voltage is high
|
||||
VF=0.96 vs 1.98(RB160M-30TR)with Fluke 175
|
||||
Anode of D11 is 680mV vs 20mV(RB160M-30TR)
|
||||
780mV is still low < 1.4V VBUS plugin detection(21.11)
|
||||
this doesn't cause false VBUS detect
|
||||
and 780mV on MCP73832 Vcc pin is also no problem.
|
||||
D5 can be removed.
|
||||
- ADC divider switching - DONE 12/07
|
||||
* Drain and Source of Q4 Pch was reversed wrongly on Rev.E.
|
||||
|
||||
- reverse current from Lipo charger - DONE 12/07
|
||||
* MCP73832 has no recverse current from Vcc pin unlike MCP73831
|
||||
|
||||
|
||||
- Rev.F design - DONE
|
||||
- current measure point - DONE 12/08
|
||||
- change value of cap 68->47 - DONE 12/08
|
||||
- PPTC land pattern: no solder jumper, use 0Ohm resistor instead - CANCEL 12/08
|
||||
- Q4 Pch FET: wrong Drain and Source - DONE 12/08
|
||||
- D5 can be removed. - DONE 12/08
|
||||
|
||||
|
||||
|
||||
- BT_INDICATOR LED turns on wrongly when touching line or pin. -- pull-up enabled on PF6/GPIO2 08/30
|
||||
- Lipo charger configuration: fast charge time: USB charger spec? -- used 2kohm
|
||||
- use LED of charger to alarm low battery. LED should be powered directly from Lipo? - cancel; powered from VUSB
|
||||
- Use RTS in serial_uart.c to resolve missing chars from help message of RN-42 - done
|
||||
- CTS/RTS lines are needed? just connect in loop back if no flow control is needed. - done
|
||||
- add IO pin to charger status CHRG; LED control(low) and detect charge status(input HiZ) 07.24
|
||||
- LINKED: add trace on PIO2 to PF6 07.24
|
||||
- Lipo voltage ADC sensing
|
||||
- Lipo charger MCP73831: needs capacitor 4.7uF *2
|
||||
- USB connection check - 07.01
|
||||
- BT on/off check: whether RX line is pulled up? - checking RTS 07.01
|
||||
- USB/BT switching BT is on -> BT, BT is off -> USB - 07.01
|
||||
- Under voltage lock out UVLO for protection of Lipo - Lipo has discharge protection at 3.100V 07.01
|
||||
- Power saving: HHKB scan, BT radio control - 9h with 850mAh, this is enough 07.01
|
||||
- Power selector doesn't work; Q4 MOSFET leaks from Lipo to USB power line. -- use Schottky instead 07/04
|
||||
|
||||
- wrongly suspended when powered from adapter without USB connection - DONE
|
||||
- suspend event may occur when plug into adapter
|
||||
- and never wake until conected to real USB line
|
||||
- without debug print via USB no problem; CSW(wake just after suspend as real USB line)
|
||||
- seems like USB print causes this problem after suspended
|
||||
|
||||
- lose USB connection during power-down mode - DONE
|
||||
- USB initialize code in main() causes this - WRONG
|
||||
- Do not power-down during USB connection is active - DONE 11/11
|
||||
(USB_DeviceState == USB_DEVICE_Configured) is used to check USB connection
|
||||
matrix_power_down() matrix.c - 11/23
|
||||
|
||||
- with Nexus5 keyboard and mouse are very laggy.
|
||||
Not confirmed. 01/15
|
||||
|
||||
- switch BT host connections - CANCEL 01/15
|
||||
- switch next connection
|
||||
cannot switch connection with version 6.15 at least
|
||||
|
||||
- When given power only from wall wart adapter - DONE? not confirmed 01/15
|
||||
- it sleeps. it should not sleep
|
||||
- Configured state without USB connection?
|
||||
|
||||
- timer is slow while power down - DONE 11/26
|
||||
- time out interrupt is lost while power down?
|
||||
- interrupt of watchdog timer compensates timer counter(avr/suspend.c)
|
||||
|
||||
- repeated CHARGING/FULL_CHARGED - No longer problem 01/15
|
||||
- In LTC sharp pulses are observed.
|
||||
- MCP has no pulse but still has a problem.
|
||||
- needs more wait before read pin state? - NO
|
||||
|
||||
- USB plug-in fails while BT - No longer problem 01/15
|
||||
- it ends in suspend state
|
||||
- maybe, not responsive to host enumeration process due to power-down.
|
||||
- matrix_power_down() only when state is unattached - 11/26
|
||||
- need to observe a while
|
||||
|
@ -1,88 +0,0 @@
|
||||
Power Saving
|
||||
============
|
||||
|
||||
|
||||
MCU+HHKB Power Comsumption
|
||||
--------------------------
|
||||
Battery drive:
|
||||
idle 18.9mA
|
||||
active 35.8mA
|
||||
|
||||
USB powered:
|
||||
40.0mA
|
||||
52mA 01/17
|
||||
|
||||
Other keyboards:
|
||||
HHKB Pro 55mA
|
||||
HHKB Pro2 140mA
|
||||
HHKB Pro 42mA(Alt)
|
||||
HHKB Pro2 52mA(Alt BT controller USB mode)
|
||||
HHKB Pro2 88mA(Alt BT controller BT mode connected)
|
||||
HHKB Pro2 68mA(Alt BT controller BT mode config mode)
|
||||
Poker X 6mA
|
||||
Infinity 24mA(TMK)
|
||||
65mA(kiibohd)
|
||||
|
||||
|
||||
HHKB key switch power control
|
||||
-----------------------------
|
||||
MOS FET Nch: BSS138 or IRLML6344T, either works and no apparent difference.
|
||||
Normally on(pull-up) or off(pull-down)? interms of power saving it prefers pull-down?
|
||||
|
||||
Pull-down will be better for power saving, normally off.
|
||||
|
||||
|
||||
|
||||
Used Timer
|
||||
----------
|
||||
|
||||
8MHz clock
|
||||
----------
|
||||
1) 16MHz xtal with system prescaler div2: F_CPU=8MHz, F_USB=16MHz
|
||||
2) 8MHz xtal with div1: F_CPU=8MHz, F_USB=8MHz
|
||||
Hardware USART doesn't work at 115200bps with 8MHz(F_CPU).
|
||||
|
||||
workaround:
|
||||
a) use Sotwre serial for communcation with RN-42
|
||||
b) reduce baud of RN-42 to lower rate;(factory default is 115200bps)
|
||||
10/03
|
||||
|
||||
|
||||
|
||||
Slave mode
|
||||
----------
|
||||
Discovery/Inquire
|
||||
Connect/Page
|
||||
|
||||
SI,0012
|
||||
SJ,0012
|
||||
InqWindw=0100
|
||||
PagWindw=0100
|
||||
|
||||
|
||||
Sniff mode
|
||||
----------
|
||||
0.625ms * <hex>
|
||||
SW,0320 Very sluggish. Type is not lost but very slow to register.
|
||||
SW,0160 Still sluggish. may transposed? can type but ...
|
||||
Mouse point move intermittently
|
||||
SW,0020 feel a bit late like stumble(20ms)
|
||||
SW,0010 feel no latency(10ms)
|
||||
|
||||
|
||||
Deep sleep
|
||||
----------
|
||||
SW,8010
|
||||
|
||||
|
||||
TX power
|
||||
--------
|
||||
SY,fff4
|
||||
|
||||
|
||||
IO pins
|
||||
-------
|
||||
S%,1000 status led and connection control don't work
|
||||
GPIO5: status LED
|
||||
GPIO6: Connection control
|
||||
GPIO2: linked status
|
@ -1,408 +0,0 @@
|
||||
RN-42 Bluetooth Module Support
|
||||
==============================
|
||||
Bluetooth controller board works with HHKB Pro2, JP, Type-S and Type-S JP and it supports both USB and Bluetooth as keyboard output protocol. Bluetooth module Roving Networks/Microchip RN-42 is installed on the board.
|
||||
|
||||
|
||||
RN-42:
|
||||
http://www.microchip.com/wwwproducts/Devices.aspx?product=RN42
|
||||
|
||||
|
||||
Capabitlities:
|
||||
- USB keyboard functions
|
||||
completely equivarent to USB controller including mouse keys and NKRO.
|
||||
- Switching between USB and Bluetooth
|
||||
You can switch the two connections with BT switch or key combination.
|
||||
- RN-42 config mode
|
||||
You can change power/connection configuration of the module if needed.
|
||||
- Low battery alert
|
||||
Red LED turns on when low voltage.
|
||||
- RN-42 status indicator
|
||||
LED indicates status of Bluetooth connection.
|
||||
- Pairing
|
||||
The module stores up to 8 connections.
|
||||
- Auto connect
|
||||
The module connects the last connected device automatically.
|
||||
- iOS support
|
||||
works as keyboard with iPhone5. No tested completely.
|
||||
- Android support
|
||||
works as keyboard and mouse with Nexus5. No tested completely.
|
||||
- Mouse keys over BT
|
||||
Note that iOS doesn't accept mouse device.
|
||||
|
||||
|
||||
Limitations:
|
||||
- Short battery life
|
||||
Around 12hr with 1000mAh
|
||||
- No connection switching
|
||||
RN-42 auto-connects to the last connected device.
|
||||
Some of consumer products can switch between devices, for example Logitech K480.
|
||||
http://www.logitech.com/en-us/product/multi-device-keyboard-k480?crid=26
|
||||
- HHKB JP requires case modification for BT switch and LEDs.
|
||||
without switch power controlled by MCU? Probably using 3.3V regulator enable pin power of RN-42 can be controlled.
|
||||
|
||||
NOTE:
|
||||
- LIPO BATTERY IS VERY DANGEROUS, TAKE EXTRA CARE OF YOUR SAFETY AND PROPERTY.
|
||||
- RN-42 version 6.15 is supported.
|
||||
- No NKRO over Bluetooth
|
||||
- Check you country's wiress regulation and certification of RN-42.
|
||||
|
||||
Bugs:
|
||||
|
||||
Todos:
|
||||
|
||||
|
||||
Lipo Battery
|
||||
------------
|
||||
You can use 3.7V Lithium Ion battery with JST PH 2pin connector and protection circuit.
|
||||
Battery space inside HHKB is around 54mm x 50mm and its height is 7mm.
|
||||
|
||||
Sparkfun 850mAh
|
||||
https://www.sparkfun.com/products/341
|
||||
Sparkfun 1000mAh
|
||||
https://www.sparkfun.com/products/339
|
||||
|
||||
Sparkfun 2000mAh battery won't fit due to its size.
|
||||
|
||||
Learn about Lipo battery:
|
||||
https://learn.adafruit.com/li-ion-and-lipoly-batteries
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
LED Status
|
||||
----------
|
||||
Configuring 10 times per sec
|
||||
Startup/configuration timer 2 times per sec
|
||||
Discoverable/Inquiring/Idle once per sec
|
||||
Connected solid on
|
||||
|
||||
|
||||
RN-42 Magic Command
|
||||
--------------------
|
||||
Magic key combination is 'LShift+RShift' by default in case of HHKB.
|
||||
|
||||
Here is help.
|
||||
|
||||
----- Bluetooth RN-42 Help -----
|
||||
i: RN-42 info
|
||||
b: battery voltage
|
||||
Del: enter/exit RN-42 config mode
|
||||
Slck: RN-42 initialize
|
||||
p: pairing
|
||||
u: toggle Force USB mode
|
||||
|
||||
RN-42 info: displays information of the module on console.
|
||||
battery voltage: displays current voltage of battery and uptime.
|
||||
RN-42 initialize: does factory reset and configures RN-42
|
||||
pairing: enters Pairing mode.
|
||||
toggle Force USB mode: switch between USB and Bluetooth
|
||||
|
||||
|
||||
RN-42 Config mode
|
||||
-----------------
|
||||
You can tune/operate RN-42 yourself with config(command) mode.
|
||||
|
||||
1. hook up USB cable
|
||||
2. run `hid_listen` command in console
|
||||
3. turn on Bluetooth switch
|
||||
4. press LShift+RShift+Delete(Fn+~) you will see output like followings:
|
||||
|
||||
Entering config mode ...
|
||||
CMD
|
||||
v
|
||||
Ver 6.15 04/26/2013
|
||||
(c) Roving Networks
|
||||
|
||||
5. do config with RN-42 commands. See documentations of RN-42.
|
||||
6. to exit also press LShift+RShift+Delete(Fn+~)
|
||||
|
||||
Exiting config mode ...
|
||||
---
|
||||
END
|
||||
|
||||
|
||||
RN-42 Initial Configuration
|
||||
---------------------------
|
||||
RN-42 is configured as SPP device at factory reset, you need to configure it as HID device. This is needed just once first time.
|
||||
|
||||
1. hook up USB cable
|
||||
2. run `hid_listen` command in console
|
||||
3. turn on Bluetooth switch
|
||||
4. press LShift+RShift+ScrLk(Fn+O) you will see output like followings:
|
||||
|
||||
Entering config mode ...
|
||||
CMD
|
||||
Ver 6.15 04/26/2013
|
||||
(c) Roving Networks
|
||||
ECHO ON
|
||||
SF,1
|
||||
AOK
|
||||
S-,TmkBT
|
||||
AOK
|
||||
SS,Keyboard/Mouse
|
||||
AOK
|
||||
SM,4
|
||||
AOK
|
||||
SW,8000
|
||||
AOK
|
||||
S~,6
|
||||
AOK
|
||||
SH,003C
|
||||
AOK
|
||||
SY,FFF4
|
||||
AOK
|
||||
R,1
|
||||
Reboot!
|
||||
Exiting config mode ...
|
||||
|
||||
5. output of command 'X' after cofiguration
|
||||
|
||||
Ver 6.15 04/26/2013
|
||||
(c) Roving Networks
|
||||
***Settings***
|
||||
BTA=00066667BBE9
|
||||
BTName=TmkBT-BBE9
|
||||
Baudrt(SW4)=115K
|
||||
Mode =DTR
|
||||
Authen=1
|
||||
PinCod=1234
|
||||
Bonded=0
|
||||
Rem=NONE SET
|
||||
***ADVANCED Settings***
|
||||
SrvName= Keyboard/Mouse
|
||||
SrvClass=0000
|
||||
DevClass=1F00
|
||||
InqWindw=0100
|
||||
PagWindw=0100
|
||||
CfgTimer=255
|
||||
StatuStr=NULL
|
||||
HidFlags=3c
|
||||
DTRtimer=8
|
||||
KeySwapr=0
|
||||
***OTHER Settings***
|
||||
Profile= HID
|
||||
CfgChar= $
|
||||
SniffEna=8000
|
||||
LowPower=0
|
||||
TX Power=fff4
|
||||
IOPorts= 0
|
||||
IOValues=0
|
||||
Sleeptmr=0
|
||||
DebugMod=0
|
||||
RoleSwch=0
|
||||
|
||||
|
||||
Switch to USB mode
|
||||
------------------
|
||||
You can switch between USB and Bluetooth with pressing 'LShift+RShift+u'.
|
||||
|
||||
|
||||
Pairing mode
|
||||
------------
|
||||
This disconnects current connect and enter pairing mode.
|
||||
|
||||
|
||||
|
||||
|
||||
For deveropment
|
||||
===============
|
||||
|
||||
RN-42 Serial Connection
|
||||
-----------------------
|
||||
UART: 115200bps, 8bit, 1-stopbit, non-parity, no flow control
|
||||
SSP: 115200bps, 8bit, 1-stopbit, non-parity, no flow control(via Bluetooth)
|
||||
|
||||
To enter command mode disconnect the module from host and type '$$$'.(you will see 'CMD') and type '+' to get local echo. To exit type '---'(you will see 'END').
|
||||
|
||||
|
||||
RN-42 Commands
|
||||
--------------
|
||||
S-,tmkBT // Device name
|
||||
SS,keyboard/mouse // service name
|
||||
SM,4 // Auto Connect DTR mode
|
||||
SW,8010 // Sniff enable 0x10*0.625ms=10ms; 50ms is laggish and not much power save
|
||||
S~,6 // HID profile
|
||||
S~,0 // SPP profile
|
||||
SH,003C // HID register
|
||||
SY,0004 // Transmit power
|
||||
SC,0000 // COD: 000005C0 (see HID spec/Bluegiga doc)
|
||||
SD,05C0 // bit 12-8 7 6 5-0
|
||||
// 00101 1 1 0
|
||||
// peripheral pointing keybaord joystick, gamepad, ...
|
||||
SM,6 // Pairing mode: auto connect
|
||||
SM,4 // Master mode: Connection can be controled with GPIO6
|
||||
SF,1 // Factroy reset
|
||||
R,1 // reboot
|
||||
SR,Z // removes all remote addresses for reconnecting.
|
||||
// can be used to connect another host
|
||||
SR,I // registers last inquiry address
|
||||
|
||||
|
||||
Operation Modes
|
||||
---------------
|
||||
SM,3 Auto Connect Master mode
|
||||
SM,4 Auto Connect DTR Mode uses GPIO6 to make and break connection(Mode =DTR)
|
||||
confirm: auto connect works and control connection with GPIO6
|
||||
SM,5 Auto Connect ANY Mode (Mode =ANY)
|
||||
each time GPIO is set, make inquiry and connect to the first found device
|
||||
SM,6 automatically reconnect(Mode =Pair)
|
||||
confirm: auto connect works well but difficult to enter command mode.
|
||||
|
||||
|
||||
HID flag register
|
||||
-----------------
|
||||
SH,0200
|
||||
GH
|
||||
|
||||
10 0000 0000(0200) default
|
||||
00 0011 1000(0038) Combo
|
||||
|| | | |\_\____ number of paired devices to which the module can reconnect
|
||||
|| | | \_______ send out reports over UART (0xFF <len> <data>)
|
||||
|| \__\_________ descriptor type
|
||||
|\______________ toggle virtual keyboard on iOS when first connected
|
||||
\_______________ Force HID mode if GPIO11 is high on power-up
|
||||
|
||||
Descriptor type:
|
||||
0000: keybaord
|
||||
0001: Game Pad
|
||||
0010: Mouse
|
||||
0011: Combo
|
||||
0100: Joystick
|
||||
1xxx: reserved
|
||||
|
||||
|
||||
Out report - Indicator
|
||||
----------------------
|
||||
0xFE 0x02 0x01 <LED_state>
|
||||
|
||||
|
||||
Apple iOS
|
||||
---------
|
||||
Keyboard can be used with iPhone, but mouse cannot.
|
||||
|
||||
|
||||
Android
|
||||
-------
|
||||
3.7.1.5 Note: To connect with Android phone the modules must wake up 11ms every 2.5seconds.
|
||||
|
||||
|
||||
Power Management
|
||||
----------------
|
||||
Inquiry and Page window Idle or Active (3.1.1)
|
||||
Downside: delay in discovery or connection time
|
||||
SI, // set inquiry scan window(discovery) on/off duty?
|
||||
SJ, // set page scan window(connection)
|
||||
This reduces averaege power >20mA to 5mA(3mA in Sniff mode)
|
||||
|
||||
Sniff mode Transmit
|
||||
Sniff mode is disabled by default and radio is active continuously when connected.(25-30mA)
|
||||
In Sniff mode the radio wakes up intermittently and sleeps in very low power mode.(2mA)
|
||||
SW,<val> // set interval timer(*0.625ms) 0000-7FFF
|
||||
|
||||
Deep sleep Idle (3.1.2)
|
||||
In this mode the module shuts down completly and only draws about 300uA. To enable this set the most signifant bit(0x8000) of Sniff interaval timer.
|
||||
SW,8320 // deep sleep enable(interval=0x320*0.625=500ms)
|
||||
In normal sleep the firmware is still running in idle mode, and wakes up about 20 times per second to check ports, update LEDs, etc. During deep sleep, the firmware actually stops runnig some tasks and the LEDs only update about once per second.
|
||||
To wake from deep sleep there are three ways: (in worst case wake up takes 5ms)
|
||||
*send a charactor to the UART(first charactor will be lost)
|
||||
*toggle CTS low to high and wait 5ms
|
||||
*wake automatically every slot time(<val>*0.625ms)
|
||||
Once the radio is awake it stay active for exactly 1 second of inactivity and then sleeps again.
|
||||
Downside: latency and data loss
|
||||
|
||||
Disable Output driver Idle or Active (3.1.3)
|
||||
S%,1000 // set all GPIO pins(0-11) to inputs.
|
||||
|
||||
Lower Transmit Power Idle or Active (3.1.4)
|
||||
SY,<hex> // transmit power setting(takes effect after a power cycle and reboot)
|
||||
Downside: reducing effective range
|
||||
|
||||
|
||||
Optimizig for Latency
|
||||
---------------------
|
||||
By default the firmware is optimized for throughput.
|
||||
SQ,16 // set latency bit
|
||||
SQ,0 // unset latency bit
|
||||
|
||||
|
||||
Configuration timer settings
|
||||
----------------------------
|
||||
Remote configuration is used for the module to be configured with various commands over Bluetooth(SPP profile only?).
|
||||
|
||||
The module has remote configuration timer to allow remote configuration over Bluetooth after power up in Slave mode. In Master modes the remote configuration timer is set to 0(no remote configuration). (In Trigger Master mode the timer is used as an idle timer to break the connection after time expires with no charactors receive.)
|
||||
ST,0 // no remote, no local when connected
|
||||
ST,<1-252> // local and remote with timeout in seconds from power up
|
||||
ST,253 // local only without timeout
|
||||
ST,254 // remote only without timeout
|
||||
ST,255 // local and remote without timeout
|
||||
|
||||
|
||||
Commands
|
||||
--------
|
||||
S7, 7bit mode
|
||||
SA, Authenticaiton
|
||||
SB, Send break
|
||||
SC, Service class
|
||||
SD, Device class
|
||||
SM,<val> Operation mode
|
||||
SP,<string> Pin code(alpahnumeric)
|
||||
SQ,<mask> Special configuration(GPIO, discovery mode, low latency, reboot, UART)
|
||||
SR,<hex> Store remote address
|
||||
SR,Z Erase all address
|
||||
SS,<string> Set service name(1-20)**
|
||||
ST,<val> Remote configuration timer(Master:0, Slave:0-255, Triger:as idle timer)
|
||||
SU,<val> UART baud rate
|
||||
SW,<val> low-power sniff mode** deep sleep and wake up every 625us * <val>
|
||||
SX,<0|1> bonding enable only acceps device that matches the stored address
|
||||
SY,<hex> power setting**
|
||||
SZ,<val> non-standard raw baud rate <val>=baud*0.004096
|
||||
S~,<val> Profile 0:SPP, 5:APL, 6:HID
|
||||
S-,<string> Device name -15 alphanumeric charactors
|
||||
S?,<0|1> role switch enable
|
||||
S$,<char> command mode char
|
||||
$|,<hex> low-power connect mode deep sleep/active(discoverable and connectable) cycle
|
||||
D display basic setting
|
||||
E display extended setting
|
||||
GB display the device's Bluetooth address
|
||||
GF display Bluetooth address of connected device
|
||||
GK show connection status
|
||||
GR show remote address for reconnecting
|
||||
G& show GPIO pin
|
||||
G<char> show stored setting
|
||||
+ toggle local echo on/off
|
||||
& show GPIO 3,4,6,7(DIP switch)
|
||||
C connect to stored remote address
|
||||
C,<address> connect last address
|
||||
CFI connect and go into fast data mode
|
||||
CFR connect and go into fast data mode
|
||||
CT,<address>,<val> connect to the address and disconnect after val?
|
||||
F,1 fast data mod:
|
||||
H display help
|
||||
I,<time>,<cod> inquiry scan with <cod>
|
||||
IN,<time>,<cod> inquiry scan with <cod>, return without BT name
|
||||
IR inquiry scan with 0055AA
|
||||
IS inquiry scan with 001F00
|
||||
J hide pin code
|
||||
K, kill disconnects current connection
|
||||
L link quality
|
||||
M show modem signlal status
|
||||
O display other settings
|
||||
P,<char> pass through?
|
||||
Q quiet mode make the module not discoverable
|
||||
Q,0 discoverable and connectable
|
||||
Q,1 not discoverable and not connectable
|
||||
Q,2 not discoverable and connectable
|
||||
Q,? display current quiet mode
|
||||
R,1 reboot
|
||||
T,<0|1> pass received data while in command mode
|
||||
U,<baud>,<parity> change UART setting tentatively
|
||||
V display firmware version
|
||||
W wake from quiet mode enable discovery and connection
|
||||
Z deep sleep mode(<2mA)
|
||||
|
||||
|
||||
Reset to Factory Default
|
||||
------------------------
|
||||
SF,1
|
||||
R,1
|
@ -1,130 +0,0 @@
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "battery.h"
|
||||
|
||||
|
||||
/*
|
||||
* Battery
|
||||
*/
|
||||
void battery_init(void)
|
||||
{
|
||||
// blink
|
||||
battery_led(LED_ON); _delay_ms(500);
|
||||
battery_led(LED_OFF); _delay_ms(500);
|
||||
battery_led(LED_ON); _delay_ms(500);
|
||||
battery_led(LED_OFF); _delay_ms(500);
|
||||
// LED indicates charger status
|
||||
battery_led(LED_CHARGER);
|
||||
|
||||
// ADC setting for voltage monitor
|
||||
// Ref:2.56V band-gap, Input:ADC0(PF0), Prescale:128(16MHz/128=125KHz)
|
||||
ADMUX = (1<<REFS1) | (1<<REFS0);
|
||||
ADCSRA = (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0);
|
||||
// digital input buffer disable(24.9.5)
|
||||
DIDR0 = (1<<ADC0D) | (1<<ADC4D) | (1<<ADC7D);
|
||||
DIDR1 = (1<<AIN0D);
|
||||
DIDR2 = (1<<ADC8D) | (1<<ADC9D) | (1<<ADC11D) | (1<<ADC12D) | (1<<ADC13D);
|
||||
|
||||
// ADC disable voltate divider(PF4)
|
||||
DDRF |= (1<<4);
|
||||
PORTF &= ~(1<<4);
|
||||
}
|
||||
|
||||
// Indicator for battery
|
||||
void battery_led(battery_led_t val)
|
||||
{
|
||||
if (val == LED_TOGGLE) {
|
||||
// Toggle LED
|
||||
DDRF |= (1<<5);
|
||||
PINF |= (1<<5);
|
||||
} else if (val == LED_ON) {
|
||||
// On overriding charger status
|
||||
DDRF |= (1<<5);
|
||||
PORTF &= ~(1<<5);
|
||||
} else if (val == LED_OFF) {
|
||||
// Off overriding charger status
|
||||
DDRF |= (1<<5);
|
||||
PORTF |= (1<<5);
|
||||
} else {
|
||||
// Display charger status
|
||||
DDRF &= ~(1<<5);
|
||||
PORTF &= ~(1<<5);
|
||||
}
|
||||
}
|
||||
|
||||
bool battery_charging(void)
|
||||
{
|
||||
if (!(USBSTA&(1<<VBUS))) return false;
|
||||
|
||||
// Charger Status:
|
||||
// MCP73831 MCP73832 LTC4054 Status
|
||||
// Hi-Z Hi-Z Hi-Z Shutdown/No Battery
|
||||
// Low Low Low Charging
|
||||
// Hi Hi-Z Hi-Z Charged
|
||||
|
||||
// preserve last register status
|
||||
uint8_t ddrf_prev = DDRF;
|
||||
uint8_t portf_prev = PORTF;
|
||||
|
||||
// Input with pullup
|
||||
DDRF &= ~(1<<5);
|
||||
PORTF |= (1<<5);
|
||||
_delay_ms(1);
|
||||
bool charging = PINF&(1<<5) ? false : true;
|
||||
|
||||
// restore last register status
|
||||
DDRF = (DDRF&~(1<<5)) | (ddrf_prev&(1<<5));
|
||||
PORTF = (PORTF&~(1<<5)) | (portf_prev&(1<<5));
|
||||
|
||||
// TODO: With MCP73831 this can not get stable status when charging.
|
||||
// LED is powered from PSEL line(USB or Lipo)
|
||||
// due to weak low output of STAT pin?
|
||||
// due to pull-up'd via resitor and LED?
|
||||
return charging;
|
||||
}
|
||||
|
||||
// Returns voltage in mV
|
||||
uint16_t battery_voltage(void)
|
||||
{
|
||||
// ADC disable voltate divider(PF4)
|
||||
DDRF |= (1<<4);
|
||||
PORTF |= (1<<4);
|
||||
|
||||
volatile uint16_t bat;
|
||||
ADCSRA |= (1<<ADEN);
|
||||
_delay_ms(1); // wait for charging S/H capacitance
|
||||
|
||||
ADCSRA |= (1<<ADSC);
|
||||
while (ADCSRA & (1<<ADSC)) ;
|
||||
bat = ADC;
|
||||
|
||||
ADCSRA &= ~(1<<ADEN);
|
||||
|
||||
// ADC disable voltate divider(PF4)
|
||||
DDRF |= (1<<4);
|
||||
PORTF &= ~(1<<4);
|
||||
|
||||
return (bat - BATTERY_ADC_OFFSET) * BATTERY_ADC_RESOLUTION;
|
||||
}
|
||||
|
||||
static bool low_voltage(void) {
|
||||
static bool low = false;
|
||||
uint16_t v = battery_voltage();
|
||||
if (v < BATTERY_VOLTAGE_LOW_LIMIT) {
|
||||
low = true;
|
||||
} else if (v > BATTERY_VOLTAGE_LOW_RECOVERY) {
|
||||
low = false;
|
||||
}
|
||||
return low;
|
||||
}
|
||||
|
||||
battery_status_t battery_status(void)
|
||||
{
|
||||
if (USBSTA&(1<<VBUS)) {
|
||||
/* powered */
|
||||
return battery_charging() ? CHARGING : FULL_CHARGED;
|
||||
} else {
|
||||
/* not powered */
|
||||
return low_voltage() ? LOW_VOLTAGE : DISCHARGING;
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
#ifndef POWER_H
|
||||
#define POWER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef enum {
|
||||
FULL_CHARGED,
|
||||
CHARGING,
|
||||
DISCHARGING,
|
||||
LOW_VOLTAGE,
|
||||
UNKNOWN,
|
||||
} battery_status_t;
|
||||
|
||||
typedef enum {
|
||||
LED_CHARGER = 0,
|
||||
LED_ON,
|
||||
LED_OFF,
|
||||
LED_TOGGLE,
|
||||
} battery_led_t;
|
||||
|
||||
/* Battery API */
|
||||
void battery_init(void);
|
||||
void battery_led(battery_led_t val);
|
||||
bool battery_charging(void);
|
||||
uint16_t battery_voltage(void);
|
||||
battery_status_t battery_status(void);
|
||||
|
||||
#define BATTERY_VOLTAGE_LOW_LIMIT 3500
|
||||
#define BATTERY_VOLTAGE_LOW_RECOVERY 3700
|
||||
// ADC offset:16, resolution:5mV
|
||||
#define BATTERY_ADC_OFFSET 16
|
||||
#define BATTERY_ADC_RESOLUTION 5
|
||||
|
||||
#endif
|
@ -1,111 +0,0 @@
|
||||
#include <avr/io.h>
|
||||
#include <avr/power.h>
|
||||
#include <avr/wdt.h>
|
||||
#include "lufa.h"
|
||||
#include "print.h"
|
||||
#include "sendchar.h"
|
||||
#include "rn42.h"
|
||||
#include "rn42_task.h"
|
||||
#include "serial.h"
|
||||
#include "keyboard.h"
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
#include "action_util.h"
|
||||
#include "wait.h"
|
||||
#include "suart.h"
|
||||
#include "suspend.h"
|
||||
|
||||
static int8_t sendchar_func(uint8_t c)
|
||||
{
|
||||
xmit(c); // SUART
|
||||
sendchar(c); // LUFA
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SetupHardware(void)
|
||||
{
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
|
||||
// Leonardo needs. Without this USB device is not recognized.
|
||||
USB_Disable();
|
||||
|
||||
USB_Init();
|
||||
|
||||
// for Console_Task
|
||||
USB_Device_EnableSOFEvents();
|
||||
print_set_sendchar(sendchar_func);
|
||||
|
||||
// SUART PD0:output, PD1:input
|
||||
DDRD |= (1<<0);
|
||||
PORTD |= (1<<0);
|
||||
DDRD &= ~(1<<1);
|
||||
PORTD |= (1<<1);
|
||||
}
|
||||
|
||||
int main(void) __attribute__ ((weak));
|
||||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
sei();
|
||||
|
||||
/* wait for USB startup to get ready for debug output */
|
||||
uint8_t timeout = 255; // timeout when USB is not available(Bluetooth)
|
||||
while (timeout-- && USB_DeviceState != DEVICE_STATE_Configured) {
|
||||
wait_ms(4);
|
||||
#if defined(INTERRUPT_CONTROL_ENDPOINT)
|
||||
;
|
||||
#else
|
||||
USB_USBTask();
|
||||
#endif
|
||||
}
|
||||
print("\nUSB init\n");
|
||||
|
||||
rn42_init();
|
||||
rn42_task_init();
|
||||
print("RN-42 init\n");
|
||||
|
||||
/* init modules */
|
||||
keyboard_init();
|
||||
|
||||
if (!rn42_rts()) {
|
||||
host_set_driver(&rn42_driver);
|
||||
} else {
|
||||
host_set_driver(&lufa_driver);
|
||||
}
|
||||
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
sleep_led_init();
|
||||
#endif
|
||||
|
||||
print("Keyboard start\n");
|
||||
while (1) {
|
||||
while (rn42_rts() && // RN42 is off
|
||||
USB_DeviceState == DEVICE_STATE_Suspended) {
|
||||
print("[s]");
|
||||
matrix_power_down();
|
||||
suspend_power_down();
|
||||
suspend_power_down();
|
||||
suspend_power_down();
|
||||
suspend_power_down();
|
||||
suspend_power_down();
|
||||
suspend_power_down();
|
||||
suspend_power_down();
|
||||
if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
|
||||
USB_Device_SendRemoteWakeup();
|
||||
}
|
||||
}
|
||||
|
||||
keyboard_task();
|
||||
|
||||
#if !defined(INTERRUPT_CONTROL_ENDPOINT)
|
||||
USB_USBTask();
|
||||
#endif
|
||||
|
||||
rn42_task();
|
||||
}
|
||||
}
|
@ -1,237 +0,0 @@
|
||||
#include <avr/io.h>
|
||||
#include "host.h"
|
||||
#include "host_driver.h"
|
||||
#include "serial.h"
|
||||
#include "rn42.h"
|
||||
#include "print.h"
|
||||
#include "timer.h"
|
||||
#include "wait.h"
|
||||
|
||||
|
||||
/* Host driver */
|
||||
static uint8_t keyboard_leds(void);
|
||||
static void send_keyboard(report_keyboard_t *report);
|
||||
static void send_mouse(report_mouse_t *report);
|
||||
static void send_system(uint16_t data);
|
||||
static void send_consumer(uint16_t data);
|
||||
|
||||
host_driver_t rn42_driver = {
|
||||
keyboard_leds,
|
||||
send_keyboard,
|
||||
send_mouse,
|
||||
send_system,
|
||||
send_consumer
|
||||
};
|
||||
|
||||
|
||||
void rn42_init(void)
|
||||
{
|
||||
// JTAG disable for PORT F. write JTD bit twice within four cycles.
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
|
||||
// PF7: BT connection control(high: connect, low: disconnect)
|
||||
rn42_autoconnect();
|
||||
|
||||
// PF6: linked(input without pull-up)
|
||||
DDRF &= ~(1<<6);
|
||||
PORTF |= (1<<6);
|
||||
|
||||
// PF1: RTS(low: allowed to send, high: not allowed)
|
||||
DDRF &= ~(1<<1);
|
||||
PORTF &= ~(1<<1);
|
||||
|
||||
// PD5: CTS(low: allow to send, high:not allow)
|
||||
DDRD |= (1<<5);
|
||||
PORTD &= ~(1<<5);
|
||||
|
||||
serial_init();
|
||||
}
|
||||
|
||||
int16_t rn42_getc(void)
|
||||
{
|
||||
return serial_recv2();
|
||||
}
|
||||
|
||||
const char *rn42_gets(uint16_t timeout)
|
||||
{
|
||||
static char s[24];
|
||||
uint16_t t = timer_read();
|
||||
uint8_t i = 0;
|
||||
int16_t c;
|
||||
while (i < 23 && timer_elapsed(t) < timeout) {
|
||||
if ((c = rn42_getc()) != -1) {
|
||||
if ((char)c == '\r') continue;
|
||||
if ((char)c == '\n') break;
|
||||
s[i++] = c;
|
||||
}
|
||||
}
|
||||
s[i] = '\0';
|
||||
return s;
|
||||
}
|
||||
|
||||
void rn42_putc(uint8_t c)
|
||||
{
|
||||
serial_send(c);
|
||||
}
|
||||
|
||||
void rn42_puts(char *s)
|
||||
{
|
||||
while (*s)
|
||||
serial_send(*s++);
|
||||
}
|
||||
|
||||
bool rn42_autoconnecting(void)
|
||||
{
|
||||
// GPIO6 for control connection(high: auto connect, low: disconnect)
|
||||
// Note that this needs config: SM,4(Auto-Connect DTR Mode)
|
||||
return (PORTF & (1<<7) ? true : false);
|
||||
}
|
||||
|
||||
void rn42_autoconnect(void)
|
||||
{
|
||||
// hi to auto connect
|
||||
DDRF |= (1<<7);
|
||||
PORTF |= (1<<7);
|
||||
}
|
||||
|
||||
void rn42_disconnect(void)
|
||||
{
|
||||
// low to disconnect
|
||||
DDRF |= (1<<7);
|
||||
PORTF &= ~(1<<7);
|
||||
}
|
||||
|
||||
bool rn42_rts(void)
|
||||
{
|
||||
// low when RN-42 is powered and ready to receive
|
||||
return PINF&(1<<1);
|
||||
}
|
||||
|
||||
void rn42_cts_hi(void)
|
||||
{
|
||||
// not allow to send
|
||||
PORTD |= (1<<5);
|
||||
}
|
||||
|
||||
void rn42_cts_lo(void)
|
||||
{
|
||||
// allow to send
|
||||
PORTD &= ~(1<<5);
|
||||
}
|
||||
|
||||
bool rn42_linked(void)
|
||||
{
|
||||
// RN-42 GPIO2
|
||||
// Hi-Z: Not powered
|
||||
// High: Linked
|
||||
// Low: Connecting
|
||||
return PINF&(1<<6);
|
||||
}
|
||||
|
||||
|
||||
static uint8_t leds = 0;
|
||||
static uint8_t keyboard_leds(void) { return leds; }
|
||||
void rn42_set_leds(uint8_t l) { leds = l; }
|
||||
|
||||
static void send_keyboard(report_keyboard_t *report)
|
||||
{
|
||||
// wake from deep sleep
|
||||
/*
|
||||
PORTD |= (1<<5); // high
|
||||
wait_ms(5);
|
||||
PORTD &= ~(1<<5); // low
|
||||
*/
|
||||
|
||||
serial_send(0xFD); // Raw report mode
|
||||
serial_send(9); // length
|
||||
serial_send(1); // descriptor type
|
||||
serial_send(report->mods);
|
||||
serial_send(0x00);
|
||||
serial_send(report->keys[0]);
|
||||
serial_send(report->keys[1]);
|
||||
serial_send(report->keys[2]);
|
||||
serial_send(report->keys[3]);
|
||||
serial_send(report->keys[4]);
|
||||
serial_send(report->keys[5]);
|
||||
}
|
||||
|
||||
static void send_mouse(report_mouse_t *report)
|
||||
{
|
||||
// wake from deep sleep
|
||||
/*
|
||||
PORTD |= (1<<5); // high
|
||||
wait_ms(5);
|
||||
PORTD &= ~(1<<5); // low
|
||||
*/
|
||||
|
||||
serial_send(0xFD); // Raw report mode
|
||||
serial_send(5); // length
|
||||
serial_send(2); // descriptor type
|
||||
serial_send(report->buttons);
|
||||
serial_send(report->x);
|
||||
serial_send(report->y);
|
||||
serial_send(report->v);
|
||||
}
|
||||
|
||||
static void send_system(uint16_t data)
|
||||
{
|
||||
// Table 5-6 of RN-BT-DATA-UB
|
||||
// 81,82,83 scan codes can be used?
|
||||
}
|
||||
|
||||
|
||||
static uint16_t usage2bits(uint16_t usage)
|
||||
{
|
||||
switch (usage) {
|
||||
case AC_HOME: return 0x01;
|
||||
case AL_EMAIL: return 0x02;
|
||||
case AC_SEARCH: return 0x04;
|
||||
//case AL_KBD_LAYOUT: return 0x08; // Apple virtual keybaord toggle
|
||||
case AUDIO_VOL_UP: return 0x10;
|
||||
case AUDIO_VOL_DOWN: return 0x20;
|
||||
case AUDIO_MUTE: return 0x40;
|
||||
case TRANSPORT_PLAY_PAUSE: return 0x80;
|
||||
case TRANSPORT_NEXT_TRACK: return 0x100;
|
||||
case TRANSPORT_PREV_TRACK: return 0x200;
|
||||
case TRANSPORT_STOP: return 0x400;
|
||||
case TRANSPORT_STOP_EJECT: return 0x800;
|
||||
//case return 0x1000; // Fast forward
|
||||
//case return 0x2000; // Rewind
|
||||
//case return 0x4000; // Stop/eject
|
||||
//case return 0x8000; // Internet browser
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void send_consumer(uint16_t data)
|
||||
{
|
||||
uint16_t bits = usage2bits(data);
|
||||
serial_send(0xFD); // Raw report mode
|
||||
serial_send(3); // length
|
||||
serial_send(3); // descriptor type
|
||||
serial_send(bits&0xFF);
|
||||
serial_send((bits>>8)&0xFF);
|
||||
}
|
||||
|
||||
|
||||
/* Null driver for config_mode */
|
||||
static uint8_t config_keyboard_leds(void);
|
||||
static void config_send_keyboard(report_keyboard_t *report);
|
||||
static void config_send_mouse(report_mouse_t *report);
|
||||
static void config_send_system(uint16_t data);
|
||||
static void config_send_consumer(uint16_t data);
|
||||
|
||||
host_driver_t rn42_config_driver = {
|
||||
config_keyboard_leds,
|
||||
config_send_keyboard,
|
||||
config_send_mouse,
|
||||
config_send_system,
|
||||
config_send_consumer
|
||||
};
|
||||
|
||||
static uint8_t config_keyboard_leds(void) { return leds; }
|
||||
static void config_send_keyboard(report_keyboard_t *report) {}
|
||||
static void config_send_mouse(report_mouse_t *report) {}
|
||||
static void config_send_system(uint16_t data) {}
|
||||
static void config_send_consumer(uint16_t data) {}
|
@ -1,23 +0,0 @@
|
||||
#ifndef RN42_H
|
||||
#define RN42_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
host_driver_t rn42_driver;
|
||||
host_driver_t rn42_config_driver;
|
||||
|
||||
void rn42_init(void);
|
||||
int16_t rn42_getc(void);
|
||||
const char *rn42_gets(uint16_t timeout);
|
||||
void rn42_putc(uint8_t c);
|
||||
void rn42_puts(char *s);
|
||||
bool rn42_autoconnecting(void);
|
||||
void rn42_autoconnect(void);
|
||||
void rn42_disconnect(void);
|
||||
bool rn42_rts(void);
|
||||
void rn42_cts_hi(void);
|
||||
void rn42_cts_lo(void);
|
||||
bool rn42_linked(void);
|
||||
void rn42_set_leds(uint8_t l);
|
||||
|
||||
#endif
|
@ -1,478 +0,0 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include "keycode.h"
|
||||
#include "serial.h"
|
||||
#include "host.h"
|
||||
#include "action.h"
|
||||
#include "action_util.h"
|
||||
#include "lufa.h"
|
||||
#include "rn42_task.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "timer.h"
|
||||
#include "wait.h"
|
||||
#include "command.h"
|
||||
#include "battery.h"
|
||||
|
||||
static bool config_mode = false;
|
||||
static bool force_usb = false;
|
||||
|
||||
static void status_led(bool on)
|
||||
{
|
||||
if (on) {
|
||||
DDRE |= (1<<6);
|
||||
PORTE &= ~(1<<6);
|
||||
} else {
|
||||
DDRE |= (1<<6);
|
||||
PORTE |= (1<<6);
|
||||
}
|
||||
}
|
||||
|
||||
void rn42_task_init(void)
|
||||
{
|
||||
battery_init();
|
||||
}
|
||||
|
||||
void rn42_task(void)
|
||||
{
|
||||
int16_t c;
|
||||
// Raw mode: interpret output report of LED state
|
||||
while ((c = rn42_getc()) != -1) {
|
||||
// LED Out report: 0xFE, 0x02, 0x01, <leds>
|
||||
// To get the report over UART set bit3 with SH, command.
|
||||
static enum {LED_INIT, LED_FE, LED_02, LED_01} state = LED_INIT;
|
||||
switch (state) {
|
||||
case LED_INIT:
|
||||
if (c == 0xFE) state = LED_FE;
|
||||
else {
|
||||
if (0x0 <= c && c <= 0x7f) xprintf("%c", c);
|
||||
else xprintf(" %02X", c);
|
||||
}
|
||||
break;
|
||||
case LED_FE:
|
||||
if (c == 0x02) state = LED_02;
|
||||
else state = LED_INIT;
|
||||
break;
|
||||
case LED_02:
|
||||
if (c == 0x01) state = LED_01;
|
||||
else state = LED_INIT;
|
||||
break;
|
||||
case LED_01:
|
||||
dprintf("LED status: %02X\n", c);
|
||||
rn42_set_leds(c);
|
||||
state = LED_INIT;
|
||||
break;
|
||||
default:
|
||||
state = LED_INIT;
|
||||
}
|
||||
}
|
||||
|
||||
/* Bluetooth mode when ready */
|
||||
if (!config_mode && !force_usb) {
|
||||
if (!rn42_rts() && host_get_driver() != &rn42_driver) {
|
||||
clear_keyboard();
|
||||
host_set_driver(&rn42_driver);
|
||||
} else if (rn42_rts() && host_get_driver() != &lufa_driver) {
|
||||
clear_keyboard();
|
||||
host_set_driver(&lufa_driver);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static uint16_t prev_timer = 0;
|
||||
uint16_t e = timer_elapsed(prev_timer);
|
||||
if (e > 1000) {
|
||||
/* every second */
|
||||
prev_timer += e/1000*1000;
|
||||
|
||||
/* Low voltage alert */
|
||||
uint8_t bs = battery_status();
|
||||
if (bs == LOW_VOLTAGE) {
|
||||
battery_led(LED_ON);
|
||||
} else {
|
||||
battery_led(LED_CHARGER);
|
||||
}
|
||||
|
||||
/* every minute */
|
||||
uint32_t t = timer_read32()/1000;
|
||||
if (t%60 == 0) {
|
||||
uint16_t v = battery_voltage();
|
||||
uint8_t h = t/3600;
|
||||
uint8_t m = t%3600/60;
|
||||
uint8_t s = t%60;
|
||||
dprintf("%02u:%02u:%02u\t%umV\n", h, m, s, v);
|
||||
/* TODO: xprintf doesn't work for this.
|
||||
xprintf("%02u:%02u:%02u\t%umV\n", (t/3600), (t%3600/60), (t%60), v);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Connection monitor */
|
||||
if (!rn42_rts() && rn42_linked()) {
|
||||
status_led(true);
|
||||
} else {
|
||||
status_led(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Command
|
||||
******************************************************************************/
|
||||
static host_driver_t *prev_driver = &rn42_driver;
|
||||
|
||||
static void print_rn42(void)
|
||||
{
|
||||
int16_t c;
|
||||
while ((c = rn42_getc()) != -1) {
|
||||
xprintf("%c", c);
|
||||
}
|
||||
}
|
||||
|
||||
static void clear_rn42(void)
|
||||
{
|
||||
while (rn42_getc() != -1) ;
|
||||
}
|
||||
|
||||
#define SEND_STR(str) send_str(PSTR(str))
|
||||
#define SEND_COMMAND(cmd) send_command(PSTR(cmd))
|
||||
|
||||
static void send_str(const char *str)
|
||||
{
|
||||
uint8_t c;
|
||||
while ((c = pgm_read_byte(str++)))
|
||||
rn42_putc(c);
|
||||
}
|
||||
|
||||
static const char *send_command(const char *cmd)
|
||||
{
|
||||
static const char *s;
|
||||
send_str(cmd);
|
||||
wait_ms(500);
|
||||
s = rn42_gets(100);
|
||||
xprintf("%s\r\n", s);
|
||||
print_rn42();
|
||||
return s;
|
||||
}
|
||||
|
||||
static void enter_command_mode(void)
|
||||
{
|
||||
prev_driver = host_get_driver();
|
||||
clear_keyboard();
|
||||
host_set_driver(&rn42_config_driver); // null driver; not to send a key to host
|
||||
rn42_disconnect();
|
||||
while (rn42_linked()) ;
|
||||
|
||||
print("Entering config mode ...\n");
|
||||
wait_ms(1100); // need 1 sec
|
||||
SEND_COMMAND("$$$");
|
||||
wait_ms(600); // need 1 sec
|
||||
print_rn42();
|
||||
const char *s = SEND_COMMAND("v\r\n");
|
||||
if (strncmp("v", s, 1) != 0) SEND_COMMAND("+\r\n"); // local echo on
|
||||
}
|
||||
|
||||
static void exit_command_mode(void)
|
||||
{
|
||||
print("Exiting config mode ...\n");
|
||||
SEND_COMMAND("---\r\n"); // exit
|
||||
|
||||
rn42_autoconnect();
|
||||
clear_keyboard();
|
||||
host_set_driver(prev_driver);
|
||||
}
|
||||
|
||||
static void init_rn42(void)
|
||||
{
|
||||
// RN-42 configure
|
||||
if (!config_mode) enter_command_mode();
|
||||
SEND_COMMAND("SF,1\r\n"); // factory defaults
|
||||
SEND_COMMAND("S-,TmkBT\r\n");
|
||||
SEND_COMMAND("SS,Keyboard/Mouse\r\n");
|
||||
SEND_COMMAND("SM,4\r\n"); // auto connect(DTR)
|
||||
SEND_COMMAND("SW,8000\r\n"); // Sniff disable
|
||||
SEND_COMMAND("S~,6\r\n"); // HID profile
|
||||
SEND_COMMAND("SH,003C\r\n"); // combo device, out-report, 4-reconnect
|
||||
SEND_COMMAND("SY,FFF4\r\n"); // transmit power -12
|
||||
SEND_COMMAND("R,1\r\n");
|
||||
if (!config_mode) exit_command_mode();
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Switching connections
|
||||
// NOTE: Remote Address doesn't work in the way manual says.
|
||||
// EEPROM address for link store
|
||||
#define RN42_LINK0 (uint8_t *)128
|
||||
#define RN42_LINK1 (uint8_t *)140
|
||||
#define RN42_LINK2 (uint8_t *)152
|
||||
#define RN42_LINK3 (uint8_t *)164
|
||||
static void store_link(uint8_t *eeaddr)
|
||||
{
|
||||
enter_command_mode();
|
||||
SEND_STR("GR\r\n"); // remote address
|
||||
const char *s = rn42_gets(500);
|
||||
if (strcmp("GR", s) == 0) s = rn42_gets(500); // ignore local echo
|
||||
xprintf("%s(%d)\r\n", s, strlen(s));
|
||||
if (strlen(s) == 12) {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
eeprom_update_byte(eeaddr+i, *(s+i));
|
||||
dprintf("%c ", *(s+i));
|
||||
}
|
||||
dprint("\r\n");
|
||||
}
|
||||
exit_command_mode();
|
||||
}
|
||||
|
||||
static void restore_link(const uint8_t *eeaddr)
|
||||
{
|
||||
enter_command_mode();
|
||||
SEND_COMMAND("SR,Z\r\n"); // remove remote address
|
||||
SEND_STR("SR,"); // set remote address from EEPROM
|
||||
for (int i = 0; i < 12; i++) {
|
||||
uint8_t c = eeprom_read_byte(eeaddr+i);
|
||||
rn42_putc(c);
|
||||
dprintf("%c ", c);
|
||||
}
|
||||
dprintf("\r\n");
|
||||
SEND_COMMAND("\r\n");
|
||||
SEND_COMMAND("R,1\r\n"); // reboot
|
||||
exit_command_mode();
|
||||
}
|
||||
|
||||
static const char *get_link(uint8_t * eeaddr)
|
||||
{
|
||||
static char s[13];
|
||||
for (int i = 0; i < 12; i++) {
|
||||
uint8_t c = eeprom_read_byte(eeaddr+i);
|
||||
s[i] = c;
|
||||
}
|
||||
s[12] = '\0';
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void pairing(void)
|
||||
{
|
||||
enter_command_mode();
|
||||
SEND_COMMAND("SR,Z\r\n"); // remove remote address
|
||||
SEND_COMMAND("R,1\r\n"); // reboot
|
||||
exit_command_mode();
|
||||
}
|
||||
|
||||
bool command_extra(uint8_t code)
|
||||
{
|
||||
uint32_t t;
|
||||
uint16_t b;
|
||||
switch (code) {
|
||||
case KC_H:
|
||||
case KC_SLASH: /* ? */
|
||||
print("\n\n----- Bluetooth RN-42 Help -----\n");
|
||||
print("i: RN-42 info\n");
|
||||
print("b: battery voltage\n");
|
||||
print("Del: enter/exit RN-42 config mode\n");
|
||||
print("Slck: RN-42 initialize\n");
|
||||
#if 0
|
||||
print("1-4: restore link\n");
|
||||
print("F1-F4: store link\n");
|
||||
#endif
|
||||
print("p: pairing\n");
|
||||
|
||||
if (config_mode) {
|
||||
return true;
|
||||
} else {
|
||||
print("u: toggle Force USB mode\n");
|
||||
return false; // to display default command help
|
||||
}
|
||||
case KC_P:
|
||||
pairing();
|
||||
return true;
|
||||
#if 0
|
||||
/* Store link address to EEPROM */
|
||||
case KC_F1:
|
||||
store_link(RN42_LINK0);
|
||||
return true;
|
||||
case KC_F2:
|
||||
store_link(RN42_LINK1);
|
||||
return true;
|
||||
case KC_F3:
|
||||
store_link(RN42_LINK2);
|
||||
return true;
|
||||
case KC_F4:
|
||||
store_link(RN42_LINK3);
|
||||
return true;
|
||||
/* Restore link address to EEPROM */
|
||||
case KC_1:
|
||||
restore_link(RN42_LINK0);
|
||||
return true;
|
||||
case KC_2:
|
||||
restore_link(RN42_LINK1);
|
||||
return true;
|
||||
case KC_3:
|
||||
restore_link(RN42_LINK2);
|
||||
return true;
|
||||
case KC_4:
|
||||
restore_link(RN42_LINK3);
|
||||
return true;
|
||||
#endif
|
||||
case KC_I:
|
||||
print("\n----- RN-42 info -----\n");
|
||||
xprintf("protocol: %s\n", (host_get_driver() == &rn42_driver) ? "RN-42" : "LUFA");
|
||||
xprintf("force_usb: %X\n", force_usb);
|
||||
xprintf("rn42: %s\n", rn42_rts() ? "OFF" : (rn42_linked() ? "CONN" : "ON"));
|
||||
xprintf("rn42_autoconnecting(): %X\n", rn42_autoconnecting());
|
||||
xprintf("config_mode: %X\n", config_mode);
|
||||
xprintf("USB State: %s\n",
|
||||
(USB_DeviceState == DEVICE_STATE_Unattached) ? "Unattached" :
|
||||
(USB_DeviceState == DEVICE_STATE_Powered) ? "Powered" :
|
||||
(USB_DeviceState == DEVICE_STATE_Default) ? "Default" :
|
||||
(USB_DeviceState == DEVICE_STATE_Addressed) ? "Addressed" :
|
||||
(USB_DeviceState == DEVICE_STATE_Configured) ? "Configured" :
|
||||
(USB_DeviceState == DEVICE_STATE_Suspended) ? "Suspended" : "?");
|
||||
xprintf("battery: ");
|
||||
switch (battery_status()) {
|
||||
case FULL_CHARGED: xprintf("FULL"); break;
|
||||
case CHARGING: xprintf("CHARG"); break;
|
||||
case DISCHARGING: xprintf("DISCHG"); break;
|
||||
case LOW_VOLTAGE: xprintf("LOW"); break;
|
||||
default: xprintf("?"); break;
|
||||
};
|
||||
xprintf("\n");
|
||||
xprintf("RemoteWakeupEnabled: %X\n", USB_Device_RemoteWakeupEnabled);
|
||||
xprintf("VBUS: %X\n", USBSTA&(1<<VBUS));
|
||||
t = timer_read32()/1000;
|
||||
uint8_t d = t/3600/24;
|
||||
uint8_t h = t/3600;
|
||||
uint8_t m = t%3600/60;
|
||||
uint8_t s = t%60;
|
||||
xprintf("uptime: %02u %02u:%02u:%02u\n", d, h, m, s);
|
||||
#if 0
|
||||
xprintf("LINK0: %s\r\n", get_link(RN42_LINK0));
|
||||
xprintf("LINK1: %s\r\n", get_link(RN42_LINK1));
|
||||
xprintf("LINK2: %s\r\n", get_link(RN42_LINK2));
|
||||
xprintf("LINK3: %s\r\n", get_link(RN42_LINK3));
|
||||
#endif
|
||||
return true;
|
||||
case KC_B:
|
||||
// battery monitor
|
||||
t = timer_read32()/1000;
|
||||
b = battery_voltage();
|
||||
xprintf("BAT: %umV\t", b);
|
||||
xprintf("%02u:", t/3600);
|
||||
xprintf("%02u:", t%3600/60);
|
||||
xprintf("%02u\n", t%60);
|
||||
return true;
|
||||
case KC_U:
|
||||
if (config_mode) return false;
|
||||
if (force_usb) {
|
||||
print("Auto mode\n");
|
||||
force_usb = false;
|
||||
} else {
|
||||
print("USB mode\n");
|
||||
force_usb = true;
|
||||
clear_keyboard();
|
||||
host_set_driver(&lufa_driver);
|
||||
}
|
||||
return true;
|
||||
case KC_DELETE:
|
||||
/* RN-42 Command mode */
|
||||
if (rn42_autoconnecting()) {
|
||||
enter_command_mode();
|
||||
|
||||
command_state = CONSOLE;
|
||||
config_mode = true;
|
||||
} else {
|
||||
exit_command_mode();
|
||||
|
||||
command_state = ONESHOT;
|
||||
config_mode = false;
|
||||
}
|
||||
return true;
|
||||
case KC_SCROLLLOCK:
|
||||
init_rn42();
|
||||
return true;
|
||||
default:
|
||||
if (config_mode)
|
||||
return true;
|
||||
else
|
||||
return false; // yield to default command
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* RN-42 Command mode
|
||||
* sends charactors to the module
|
||||
*/
|
||||
static uint8_t code2asc(uint8_t code);
|
||||
bool command_console_extra(uint8_t code)
|
||||
{
|
||||
rn42_putc(code2asc(code));
|
||||
return true;
|
||||
}
|
||||
|
||||
// convert keycode into ascii charactor
|
||||
static uint8_t code2asc(uint8_t code)
|
||||
{
|
||||
bool shifted = (get_mods() & (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT))) ? true : false;
|
||||
switch (code) {
|
||||
case KC_A: return (shifted ? 'A' : 'a');
|
||||
case KC_B: return (shifted ? 'B' : 'b');
|
||||
case KC_C: return (shifted ? 'C' : 'c');
|
||||
case KC_D: return (shifted ? 'D' : 'd');
|
||||
case KC_E: return (shifted ? 'E' : 'e');
|
||||
case KC_F: return (shifted ? 'F' : 'f');
|
||||
case KC_G: return (shifted ? 'G' : 'g');
|
||||
case KC_H: return (shifted ? 'H' : 'h');
|
||||
case KC_I: return (shifted ? 'I' : 'i');
|
||||
case KC_J: return (shifted ? 'J' : 'j');
|
||||
case KC_K: return (shifted ? 'K' : 'k');
|
||||
case KC_L: return (shifted ? 'L' : 'l');
|
||||
case KC_M: return (shifted ? 'M' : 'm');
|
||||
case KC_N: return (shifted ? 'N' : 'n');
|
||||
case KC_O: return (shifted ? 'O' : 'o');
|
||||
case KC_P: return (shifted ? 'P' : 'p');
|
||||
case KC_Q: return (shifted ? 'Q' : 'q');
|
||||
case KC_R: return (shifted ? 'R' : 'r');
|
||||
case KC_S: return (shifted ? 'S' : 's');
|
||||
case KC_T: return (shifted ? 'T' : 't');
|
||||
case KC_U: return (shifted ? 'U' : 'u');
|
||||
case KC_V: return (shifted ? 'V' : 'v');
|
||||
case KC_W: return (shifted ? 'W' : 'w');
|
||||
case KC_X: return (shifted ? 'X' : 'x');
|
||||
case KC_Y: return (shifted ? 'Y' : 'y');
|
||||
case KC_Z: return (shifted ? 'Z' : 'z');
|
||||
case KC_1: return (shifted ? '!' : '1');
|
||||
case KC_2: return (shifted ? '@' : '2');
|
||||
case KC_3: return (shifted ? '#' : '3');
|
||||
case KC_4: return (shifted ? '$' : '4');
|
||||
case KC_5: return (shifted ? '%' : '5');
|
||||
case KC_6: return (shifted ? '^' : '6');
|
||||
case KC_7: return (shifted ? '&' : '7');
|
||||
case KC_8: return (shifted ? '*' : '8');
|
||||
case KC_9: return (shifted ? '(' : '9');
|
||||
case KC_0: return (shifted ? ')' : '0');
|
||||
case KC_ENTER: return '\n';
|
||||
case KC_ESCAPE: return 0x1B;
|
||||
case KC_BSPACE: return '\b';
|
||||
case KC_TAB: return '\t';
|
||||
case KC_SPACE: return ' ';
|
||||
case KC_MINUS: return (shifted ? '_' : '-');
|
||||
case KC_EQUAL: return (shifted ? '+' : '=');
|
||||
case KC_LBRACKET: return (shifted ? '{' : '[');
|
||||
case KC_RBRACKET: return (shifted ? '}' : ']');
|
||||
case KC_BSLASH: return (shifted ? '|' : '\\');
|
||||
case KC_NONUS_HASH: return (shifted ? '|' : '\\');
|
||||
case KC_SCOLON: return (shifted ? ':' : ';');
|
||||
case KC_QUOTE: return (shifted ? '"' : '\'');
|
||||
case KC_GRAVE: return (shifted ? '~' : '`');
|
||||
case KC_COMMA: return (shifted ? '<' : ',');
|
||||
case KC_DOT: return (shifted ? '>' : '.');
|
||||
case KC_SLASH: return (shifted ? '?' : '/');
|
||||
case KC_DELETE: return '\0'; // Delete to disconnect
|
||||
default: return ' ';
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
#ifndef RN42_TASK_H
|
||||
#define RN42_TASK_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "rn42.h"
|
||||
|
||||
void rn42_task_init(void);
|
||||
void rn42_task(void);
|
||||
|
||||
#endif
|
@ -1,156 +0,0 @@
|
||||
;---------------------------------------------------------------------------;
|
||||
; Software implemented UART module ;
|
||||
; (C)ChaN, 2005 (http://elm-chan.org/) ;
|
||||
;---------------------------------------------------------------------------;
|
||||
; Bit rate settings:
|
||||
;
|
||||
; 1MHz 2MHz 4MHz 6MHz 8MHz 10MHz 12MHz 16MHz 20MHz
|
||||
; 2.4kbps 138 - - - - - - - -
|
||||
; 4.8kbps 68 138 - - - - - - -
|
||||
; 9.6kbps 33 68 138 208 - - - - -
|
||||
; 19.2kbps - 33 68 102 138 173 208 - -
|
||||
; 38.4kbps - - 33 50 68 85 102 138 172
|
||||
; 57.6kbps - - 21 33 44 56 68 91 114
|
||||
; 115.2kbps - - - - 21 27 33 44 56
|
||||
|
||||
.nolist
|
||||
#include <avr/io.h>
|
||||
.list
|
||||
|
||||
#define BPS 44 /* Bit delay. (see above table) */
|
||||
#define BIDIR 0 /* 0:Separated Tx/Rx, 1:Shared Tx/Rx */
|
||||
|
||||
#define OUT_1 sbi _SFR_IO_ADDR(SUART_OUT_PORT), SUART_OUT_BIT /* Output 1 */
|
||||
#define OUT_0 cbi _SFR_IO_ADDR(SUART_OUT_PORT), SUART_OUT_BIT /* Output 0 */
|
||||
#define SKIP_IN_1 sbis _SFR_IO_ADDR(SUART_IN_PIN), SUART_IN_BIT /* Skip if 1 */
|
||||
#define SKIP_IN_0 sbic _SFR_IO_ADDR(SUART_IN_PIN), SUART_IN_BIT /* Skip if 0 */
|
||||
|
||||
|
||||
|
||||
#ifdef SPM_PAGESIZE
|
||||
.macro _LPMI reg
|
||||
lpm \reg, Z+
|
||||
.endm
|
||||
.macro _MOVW dh,dl, sh,sl
|
||||
movw \dl, \sl
|
||||
.endm
|
||||
#else
|
||||
.macro _LPMI reg
|
||||
lpm
|
||||
mov \reg, r0
|
||||
adiw ZL, 1
|
||||
.endm
|
||||
.macro _MOVW dh,dl, sh,sl
|
||||
mov \dl, \sl
|
||||
mov \dh, \sh
|
||||
.endm
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
;---------------------------------------------------------------------------;
|
||||
; Transmit a byte in serial format of N81
|
||||
;
|
||||
;Prototype: void xmit (uint8_t data);
|
||||
;Size: 16 words
|
||||
|
||||
.global xmit
|
||||
.func xmit
|
||||
xmit:
|
||||
#if BIDIR
|
||||
ldi r23, BPS-1 ;Pre-idle time for bidirectional data line
|
||||
5: dec r23 ;
|
||||
brne 5b ;/
|
||||
#endif
|
||||
in r0, _SFR_IO_ADDR(SREG) ;Save flags
|
||||
|
||||
com r24 ;C = start bit
|
||||
ldi r25, 10 ;Bit counter
|
||||
cli ;Start critical section
|
||||
|
||||
1: ldi r23, BPS-1 ;----- Bit transferring loop
|
||||
2: dec r23 ;Wait for a bit time
|
||||
brne 2b ;/
|
||||
brcs 3f ;MISO = bit to be sent
|
||||
OUT_1 ;
|
||||
3: brcc 4f ;
|
||||
OUT_0 ;/
|
||||
4: lsr r24 ;Get next bit into C
|
||||
dec r25 ;All bits sent?
|
||||
brne 1b ; no, coutinue
|
||||
|
||||
out _SFR_IO_ADDR(SREG), r0 ;End of critical section
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
|
||||
|
||||
;---------------------------------------------------------------------------;
|
||||
; Receive a byte
|
||||
;
|
||||
;Prototype: uint8_t rcvr (void);
|
||||
;Size: 19 words
|
||||
|
||||
.global rcvr
|
||||
.func rcvr
|
||||
rcvr:
|
||||
in r0, _SFR_IO_ADDR(SREG) ;Save flags
|
||||
|
||||
ldi r24, 0x80 ;Receiving shift reg
|
||||
cli ;Start critical section
|
||||
|
||||
1: SKIP_IN_1 ;Wait for idle
|
||||
rjmp 1b
|
||||
2: SKIP_IN_0 ;Wait for start bit
|
||||
rjmp 2b
|
||||
ldi r25, BPS/2 ;Wait for half bit time
|
||||
3: dec r25
|
||||
brne 3b
|
||||
|
||||
4: ldi r25, BPS ;----- Bit receiving loop
|
||||
5: dec r25 ;Wait for a bit time
|
||||
brne 5b ;/
|
||||
lsr r24 ;Next bit
|
||||
SKIP_IN_0 ;Get a data bit into r24.7
|
||||
ori r24, 0x80
|
||||
brcc 4b ;All bits received? no, continue
|
||||
|
||||
out _SFR_IO_ADDR(SREG), r0 ;End of critical section
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
|
||||
; Not wait for start bit. This should be called after detecting start bit.
|
||||
.global recv
|
||||
.func recv
|
||||
recv:
|
||||
in r0, _SFR_IO_ADDR(SREG) ;Save flags
|
||||
|
||||
ldi r24, 0x80 ;Receiving shift reg
|
||||
cli ;Start critical section
|
||||
|
||||
;1: SKIP_IN_1 ;Wait for idle
|
||||
; rjmp 1b
|
||||
;2: SKIP_IN_0 ;Wait for start bit
|
||||
; rjmp 2b
|
||||
ldi r25, BPS/2 ;Wait for half bit time
|
||||
3: dec r25
|
||||
brne 3b
|
||||
|
||||
4: ldi r25, BPS ;----- Bit receiving loop
|
||||
5: dec r25 ;Wait for a bit time
|
||||
brne 5b ;/
|
||||
lsr r24 ;Next bit
|
||||
SKIP_IN_0 ;Get a data bit into r24.7
|
||||
ori r24, 0x80
|
||||
brcc 4b ;All bits received? no, continue
|
||||
|
||||
ldi r25, BPS/2 ;Wait for half bit time
|
||||
6: dec r25
|
||||
brne 6b
|
||||
7: SKIP_IN_1 ;Wait for stop bit
|
||||
rjmp 7b
|
||||
|
||||
out _SFR_IO_ADDR(SREG), r0 ;End of critical section
|
||||
ret
|
||||
.endfunc
|
@ -1,8 +0,0 @@
|
||||
#ifndef SUART
|
||||
#define SUART
|
||||
|
||||
void xmit(uint8_t);
|
||||
uint8_t rcvr(void);
|
||||
uint8_t recv(void);
|
||||
|
||||
#endif /* SUART */
|
@ -1,149 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = hhkb_qmk
|
||||
|
||||
|
||||
# Directory common source filess exist
|
||||
TOP_DIR = ../..
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# # project specific files
|
||||
SRC = hhkb_qmk.c \
|
||||
matrix.c
|
||||
|
||||
ifdef KEYMAP
|
||||
SRC := keymaps/keymaps/$(KEYMAP).c $(SRC)
|
||||
else
|
||||
SRC := keymaps/keymaps/default.c $(SRC)
|
||||
endif
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
# MCU name
|
||||
#MCU = at90usb1287
|
||||
MCU = atmega32u4
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
# Interrupt driven control endpoint task(+60)
|
||||
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||
|
||||
|
||||
# Boot Section Size in *bytes*
|
||||
# Teensy halfKay 512
|
||||
# Teensy++ halfKay 1024
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
# USBaspLoader 2048
|
||||
#OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
# as per original hasu settings
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=512
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
CUSTOM_MATRIX = yes # Custom matrix file for the HHKB
|
||||
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
|
||||
# SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
# NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
|
||||
# BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
# MIDI_ENABLE = YES # MIDI controls
|
||||
# UNICODE_ENABLE = YES # Unicode
|
||||
# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
|
||||
|
||||
# Optimize size but this may cause error "relocation truncated to fit"
|
||||
#EXTRALDFLAGS = -Wl,--relax
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TOP_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION
|
||||
debug-on: all
|
||||
|
||||
debug-off: EXTRAFLAGS += -DNO_DEBUG -DNO_PRINT
|
||||
debug-off: OPT_DEFS := $(filter-out -DCONSOLE_ENABLE,$(OPT_DEFS))
|
||||
debug-off: all
|
||||
|
||||
include $(TOP_DIR)/quantum/quantum.mk
|
@ -1,180 +0,0 @@
|
||||
hhkb_qmk keyboard firmware
|
||||
======================
|
||||
|
||||
## Quantum MK Firmware
|
||||
|
||||
You have access to a bunch of goodies! Check out the Makefile to enable/disable some of the features. Uncomment the `#` to enable them. Setting them to `no` does nothing and will only confuse future you.
|
||||
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
MIDI_ENABLE = yes # MIDI controls
|
||||
# UNICODE_ENABLE = yes # Unicode support - this is commented out, just as an example. You have to use #, not //
|
||||
BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
|
||||
## Quick aliases to common actions
|
||||
|
||||
Your keymap can include shortcuts to common operations (called "function actions" in tmk).
|
||||
|
||||
### Switching and toggling layers
|
||||
|
||||
`MO(layer)` - momentary switch to *layer*. As soon as you let go of the key, the layer is deactivated and you pop back out to the previous layer. When you apply this to a key, that same key must be set as `KC_TRNS` on the destination layer. Otherwise, you won't make it back to the original layer when you release the key (and you'll get a keycode sent). You can only switch to layers *above* your current layer. If you're on layer 0 and you use `MO(1)`, that will switch to layer 1 just fine. But if you include `MO(3)` on layer 5, that won't do anything for you -- because layer 3 is lower than layer 5 on the stack.
|
||||
|
||||
`LT(layer, kc)` - momentary switch to *layer* when held, and *kc* when tapped. Like `MO()`, this only works upwards in the layer stack (`layer` must be higher than the current layer).
|
||||
|
||||
`TG(layer)` - toggles a layer on or off. As with `MO()`, you should set this key as `KC_TRNS` in the destination layer so that tapping it again actually toggles back to the original layer. Only works upwards in the layer stack.
|
||||
|
||||
### Fun with modifier keys
|
||||
|
||||
* `LSFT(kc)` - applies left Shift to *kc* (keycode) - `S(kc)` is an alias
|
||||
* `RSFT(kc)` - applies right Shift to *kc*
|
||||
* `LCTL(kc)` - applies left Control to *kc*
|
||||
* `RCTL(kc)` - applies right Control to *kc*
|
||||
* `LALT(kc)` - applies left Alt to *kc*
|
||||
* `RALT(kc)` - applies right Alt to *kc*
|
||||
* `LGUI(kc)` - applies left GUI (command/win) to *kc*
|
||||
* `RGUI(kc)` - applies right GUI (command/win) to *kc*
|
||||
|
||||
You can also chain these, like this:
|
||||
|
||||
LALT(LCTL(KC_DEL)) -- this makes a key that sends Alt, Control, and Delete in a single keypress.
|
||||
|
||||
The following shortcuts automatically add `LSFT()` to keycodes to get commonly used symbols. Their long names are also available and documented in `/quantum/keymap_common.h`.
|
||||
|
||||
KC_TILD ~
|
||||
KC_EXLM !
|
||||
KC_AT @
|
||||
KC_HASH #
|
||||
KC_DLR $
|
||||
KC_PERC %
|
||||
KC_CIRC ^
|
||||
KC_AMPR &
|
||||
KC_ASTR *
|
||||
KC_LPRN (
|
||||
KC_RPRN )
|
||||
KC_UNDS _
|
||||
KC_PLUS +
|
||||
KC_LCBR {
|
||||
KC_RCBR }
|
||||
KC_PIPE |
|
||||
KC_COLN :
|
||||
|
||||
`MT(mod, kc)` - is *mod* (modifier key - MOD_LCTL, MOD_LSFT) when held, and *kc* when tapped. In other words, you can have a key that sends Esc (or the letter O or whatever) when you tap it, but works as a Control key or a Shift key when you hold it down.
|
||||
|
||||
These are the values you can use for the `mod` in `MT()` (right-hand modifiers are not available):
|
||||
|
||||
* MOD_LCTL
|
||||
* MOD_LSFT
|
||||
* MOD_LALT
|
||||
* MOD_LGUI
|
||||
|
||||
These can also be combined like `MOD_LCTL | MOD_LSFT` e.g. `MT(MOD_LCTL | MOD_LSFT, KC_ESC)` which would activate Control and Shift when held, and send Escape when tapped.
|
||||
|
||||
We've added shortcuts to make common modifier/tap (mod-tap) mappings more compact:
|
||||
|
||||
* `CTL_T(kc)` - is LCTL when held and *kc* when tapped
|
||||
* `SFT_T(kc)` - is LSFT when held and *kc* when tapped
|
||||
* `ALT_T(kc)` - is LALT when held and *kc* when tapped
|
||||
* `GUI_T(kc)` - is LGUI when held and *kc* when tapped
|
||||
* `ALL_T(kc)` - is Hyper (all mods) when held and *kc* when tapped. To read more about what you can do with a Hyper key, see [this blog post by Brett Terpstra](http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/)
|
||||
|
||||
### Temporarily setting the default layer
|
||||
|
||||
`DF(layer)` - sets default layer to *layer*. The default layer is the one at the "bottom" of the layer stack - the ultimate fallback layer. This currently does not persist over power loss. When you plug the keyboard back in, layer 0 will always be the default. It is theoretically possible to work around that, but that's not what `DF` does.
|
||||
|
||||
### Remember: These are just aliases
|
||||
|
||||
These functions work the same way that their `ACTION_*` functions do - they're just quick aliases. To dig into all of the tmk ACTION_* functions, please see the [TMK documentation](https://github.com/jackhumbert/qmk_firmware/blob/master/tmk_core/doc/keymap.md#2-action).
|
||||
|
||||
Instead of using `FNx` when defining `ACTION_*` functions, you can use `F(x)` - the benefit here is being able to use more than 32 function actions (up to 4096), if you happen to need them.
|
||||
|
||||
## Macro shortcuts: Send a whole string when pressing just one key
|
||||
|
||||
Instead of using the `ACTION_MACRO` function, you can simply use `M(n)` to access macro *n* - *n* will get passed into the `action_get_macro` as the `id`, and you can use a switch statement to trigger it. This gets called on the keydown and keyup, so you'll need to use an if statement testing `record->event.pressed` (see keymap_default.c).
|
||||
|
||||
```c
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) // this is the function signature -- just copy/paste it into your keymap file as it is.
|
||||
{
|
||||
switch(id) {
|
||||
case 0: // this would trigger when you hit a key mapped as M(0)
|
||||
if (record->event.pressed) {
|
||||
return MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END ); // this sends the string 'hello' when the macro executes
|
||||
}
|
||||
break;
|
||||
}
|
||||
return MACRO_NONE;
|
||||
};
|
||||
```
|
||||
A macro can include the following commands:
|
||||
|
||||
* I() change interval of stroke in milliseconds.
|
||||
* D() press key.
|
||||
* U() release key.
|
||||
* T() type key(press and release).
|
||||
* W() wait (milliseconds).
|
||||
* END end mark.
|
||||
|
||||
So above you can see the stroke interval changed to 255ms between each keystroke, then a bunch of keys being typed, waits a while, then the macro ends.
|
||||
|
||||
Note: Using macros to have your keyboard send passwords for you is a bad idea.
|
||||
|
||||
### Additional keycode aliases for software-implemented layouts (Colemak, Dvorak, etc)
|
||||
|
||||
Everything is assuming you're in Qwerty (in software) by default, but there is built-in support for using a Colemak or Dvorak layout by including this at the top of your keymap:
|
||||
|
||||
#include "keymap_<layout>.h"
|
||||
|
||||
Where <layout> is "colemak" or "dvorak". After including this line, you will get access to:
|
||||
|
||||
* `CM_*` for all of the Colemak-equivalent characters
|
||||
* `DV_*` for all of the Dvorak-equivalent characters
|
||||
|
||||
These implementations assume you're using Colemak or Dvorak on your OS, not on your keyboard - this is referred to as a software-implemented layout. If your computer is in Qwerty and your keymap is in Colemak or Dvorak, this is referred to as a firmware-implemented layout, and you won't need these features.
|
||||
|
||||
To give an example, if you're using software-implemented Colemak, and want to get an `F`, you would use `CM_F` - `KC_F` under these same circumstances would result in `T`.
|
||||
|
||||
## Additional language support
|
||||
|
||||
In `quantum/keymap_extras/`, you'll see various language files - these work the same way as the alternative layout ones do. Most are defined by their two letter country/language code followed by an underscore and a 4-letter abbreviation of its name. `FR_UGRV` which will result in a `ù` when using a software-implemented AZERTY layout. It's currently difficult to send such characters in just the firmware (but it's being worked on - see Unicode support).
|
||||
|
||||
## Unicode support
|
||||
|
||||
You can currently send 4 hex digits with your OS-specific modifier key (RALT for OSX with the "Unicode Hex Input" layout) - this is currently limited to supporting one OS at a time, and requires a recompile for switching. 8 digit hex codes are being worked on. The keycode function is `UC(n)`, where *n* is a 4 digit hexidecimal. Enable from the Makefile.
|
||||
|
||||
## Other firmware shortcut keycodes
|
||||
|
||||
* `RESET` - puts the MCU in DFU mode for flashing new firmware (with `make dfu`)
|
||||
* `DEBUG` - the firmware into debug mode - you'll need hid_listen to see things
|
||||
* `BL_ON` - turns the backlight on
|
||||
* `BL_OFF` - turns the backlight off
|
||||
* `BL_<n>` - sets the backlight to level *n*
|
||||
* `BL_INC` - increments the backlight level by one
|
||||
* `BL_DEC` - decrements the backlight level by one
|
||||
* `BL_TOGG` - toggles the backlight
|
||||
* `BL_STEP` - steps through the backlight levels
|
||||
|
||||
Enable the backlight from the Makefile.
|
||||
|
||||
## MIDI functionalty
|
||||
|
||||
This is still a WIP, but check out `quantum/keymap_midi.c` to see what's happening. Enable from the Makefile.
|
||||
|
||||
## Bluetooth functionality
|
||||
|
||||
This requires [some hardware changes](https://www.reddit.com/r/MechanicalKeyboards/comments/3psx0q/the_planck_keyboard_with_bluetooth_guide_and/?ref=search_posts), but can be enabled via the Makefile. The firmware will still output characters via USB, so be aware of this when charging via a computer. It would make sense to have a switch on the Bluefruit to turn it off at will.
|
||||
|
||||
## Building
|
||||
|
||||
Download or clone the whole firmware and navigate to the keyboard/planck folder. Once your dev env is setup, you'll be able to type `make` to generate your .hex - you can then use `make dfu` to program your PCB once you hit the reset button.
|
||||
|
||||
Depending on which keymap you would like to use, you will have to compile slightly differently.
|
||||
|
||||
### Default
|
||||
To build with the default keymap, simply run `make`.
|
||||
|
||||
### Other Keymaps
|
||||
Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create a file in the keymaps folder named `<name>.c` and see keymap document (you can find in top README.md) and existent keymap files.
|
||||
|
||||
To build the firmware binary hex file with a keymap just do `make` with `KEYMAP` option like:
|
||||
```
|
||||
$ make KEYMAP=[default|jack|<name>]
|
||||
```
|
||||
Keymaps follow the format **__\<name\>.c__** and are stored in the `keymaps` folder.
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
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
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0xCAFE
|
||||
#define DEVICE_VER 0x0104
|
||||
#define MANUFACTURER q.m.k
|
||||
#define PRODUCT HHKB mod
|
||||
#define DESCRIPTION q.m.k keyboard firmware for HHKB
|
||||
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 8
|
||||
#define MATRIX_COLS 8
|
||||
|
||||
#define TAPPING_TERM 200
|
||||
|
||||
/* number of backlight levels */
|
||||
#define BACKLIGHT_LEVELS 3
|
||||
|
||||
/* Set 0 if debouncing isn't needed */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||
//#define LOCKING_SUPPORT_ENABLE
|
||||
/* Locking resynchronize hack */
|
||||
//#define LOCKING_RESYNC_ENABLE
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
/*
|
||||
* Feature disable options
|
||||
* These options are also useful to firmware size reduction.
|
||||
*/
|
||||
|
||||
/* disable debug print */
|
||||
//#define NO_DEBUG
|
||||
|
||||
/* disable print */
|
||||
//#define NO_PRINT
|
||||
|
||||
/* disable action features */
|
||||
//#define NO_ACTION_LAYER
|
||||
//#define NO_ACTION_TAPPING
|
||||
//#define NO_ACTION_ONESHOT
|
||||
//#define NO_ACTION_MACRO
|
||||
//#define NO_ACTION_FUNCTION
|
||||
|
||||
#endif
|
@ -1,167 +0,0 @@
|
||||
#ifndef HHKB_AVR_H
|
||||
#define HHKB_AVR_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
|
||||
// Timer resolution check
|
||||
#if (1000000/TIMER_RAW_FREQ > 20)
|
||||
# error "Timer resolution(>20us) is not enough for HHKB matrix scan tweak on V-USB."
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* HHKB Matrix I/O
|
||||
*
|
||||
* row: HC4051[A,B,C] selects scan row0-7
|
||||
* row-ext: [En0,En1] row extention for JP
|
||||
* col: LS145[A,B,C,D] selects scan col0-7 and enable(D)
|
||||
* key: on: 0/off: 1
|
||||
* prev: hysteresis control: assert(1) when previous key state is on
|
||||
*/
|
||||
|
||||
|
||||
#if defined(__AVR_ATmega32U4__)
|
||||
/*
|
||||
* For TMK HHKB alt controller(ATMega32U4)
|
||||
*
|
||||
* row: PB0-2
|
||||
* col: PB3-5,6
|
||||
* key: PD7(pull-uped)
|
||||
* prev: PB7
|
||||
* power: PD4(L:off/H:on)
|
||||
* row-ext: PC6,7 for HHKB JP(active low)
|
||||
*/
|
||||
static inline void KEY_ENABLE(void) { (PORTB &= ~(1<<6)); }
|
||||
static inline void KEY_UNABLE(void) { (PORTB |= (1<<6)); }
|
||||
static inline bool KEY_STATE(void) { return (PIND & (1<<7)); }
|
||||
static inline void KEY_PREV_ON(void) { (PORTB |= (1<<7)); }
|
||||
static inline void KEY_PREV_OFF(void) { (PORTB &= ~(1<<7)); }
|
||||
#ifdef HHKB_POWER_SAVING
|
||||
static inline void KEY_POWER_ON(void) {
|
||||
DDRB = 0xFF; PORTB = 0x40; // change pins output
|
||||
DDRD |= (1<<4); PORTD |= (1<<4); // MOS FET switch on
|
||||
/* Without this wait you will miss or get false key events. */
|
||||
_delay_ms(5); // wait for powering up
|
||||
}
|
||||
static inline void KEY_POWER_OFF(void) {
|
||||
/* input with pull-up consumes less than without it when pin is open. */
|
||||
DDRB = 0x00; PORTB = 0xFF; // change pins input with pull-up
|
||||
DDRD |= (1<<4); PORTD &= ~(1<<4); // MOS FET switch off
|
||||
}
|
||||
static inline bool KEY_POWER_STATE(void) { return PORTD & (1<<4); }
|
||||
#else
|
||||
static inline void KEY_POWER_ON(void) {}
|
||||
static inline void KEY_POWER_OFF(void) {}
|
||||
static inline bool KEY_POWER_STATE(void) { return true; }
|
||||
#endif
|
||||
static inline void KEY_INIT(void)
|
||||
{
|
||||
/* row,col,prev: output */
|
||||
DDRB = 0xFF;
|
||||
PORTB = 0x40; // unable
|
||||
/* key: input with pull-up */
|
||||
DDRD &= ~0x80;
|
||||
PORTD |= 0x80;
|
||||
#ifdef HHKB_JP
|
||||
/* row extention for HHKB JP */
|
||||
DDRC |= (1<<6|1<<7);
|
||||
PORTC |= (1<<6|1<<7);
|
||||
#endif
|
||||
KEY_UNABLE();
|
||||
KEY_PREV_OFF();
|
||||
|
||||
KEY_POWER_OFF();
|
||||
}
|
||||
static inline void KEY_SELECT(uint8_t ROW, uint8_t COL)
|
||||
{
|
||||
PORTB = (PORTB & 0xC0) | (((COL) & 0x07)<<3) | ((ROW) & 0x07);
|
||||
#ifdef HHKB_JP
|
||||
if ((ROW) & 0x08) PORTC = (PORTC & ~(1<<6|1<<7)) | (1<<6);
|
||||
else PORTC = (PORTC & ~(1<<6|1<<7)) | (1<<7);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#elif defined(__AVR_AT90USB1286__)
|
||||
/*
|
||||
* For Teensy++(AT90USB1286)
|
||||
*
|
||||
* HHKB pro HHKB pro2
|
||||
* row: PB0-2 (6-8) (5-7)
|
||||
* col: PB3-5,6 (9-12) (8-11)
|
||||
* key: PE6(pull-uped) (4) (3)
|
||||
* prev: PE7 (5) (4)
|
||||
*
|
||||
* TODO: convert into 'staitc inline' function
|
||||
*/
|
||||
#define KEY_INIT() do { \
|
||||
DDRB |= 0x7F; \
|
||||
DDRE |= (1<<7); \
|
||||
DDRE &= ~(1<<6); \
|
||||
PORTE |= (1<<6); \
|
||||
} while (0)
|
||||
#define KEY_SELECT(ROW, COL) (PORTB = (PORTB & 0xC0) | \
|
||||
(((COL) & 0x07)<<3) | \
|
||||
((ROW) & 0x07))
|
||||
#define KEY_ENABLE() (PORTB &= ~(1<<6))
|
||||
#define KEY_UNABLE() (PORTB |= (1<<6))
|
||||
#define KEY_STATE() (PINE & (1<<6))
|
||||
#define KEY_PREV_ON() (PORTE |= (1<<7))
|
||||
#define KEY_PREV_OFF() (PORTE &= ~(1<<7))
|
||||
#define KEY_POWER_ON()
|
||||
#define KEY_POWER_OFF()
|
||||
#define KEY_POWER_STATE() true
|
||||
|
||||
|
||||
#else
|
||||
# error "define code for matrix scan"
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
// For ATMega328P with V-USB
|
||||
//
|
||||
// #elif defined(__AVR_ATmega328P__)
|
||||
// Ports for V-USB
|
||||
// key: PB0(pull-uped)
|
||||
// prev: PB1
|
||||
// row: PB2-4
|
||||
// col: PC0-2,3
|
||||
// power: PB5(Low:on/Hi-z:off)
|
||||
#define KEY_INIT() do { \
|
||||
DDRB |= 0x3E; \
|
||||
DDRB &= ~(1<<0); \
|
||||
PORTB |= 1<<0; \
|
||||
DDRC |= 0x0F; \
|
||||
KEY_UNABLE(); \
|
||||
KEY_PREV_OFF(); \
|
||||
} while (0)
|
||||
#define KEY_SELECT(ROW, COL) do { \
|
||||
PORTB = (PORTB & 0xE3) | ((ROW) & 0x07)<<2; \
|
||||
PORTC = (PORTC & 0xF8) | ((COL) & 0x07); \
|
||||
} while (0)
|
||||
#define KEY_ENABLE() (PORTC &= ~(1<<3))
|
||||
#define KEY_UNABLE() (PORTC |= (1<<3))
|
||||
#define KEY_STATE() (PINB & (1<<0))
|
||||
#define KEY_PREV_ON() (PORTB |= (1<<1))
|
||||
#define KEY_PREV_OFF() (PORTB &= ~(1<<1))
|
||||
// Power supply switching
|
||||
#define KEY_POWER_ON() do { \
|
||||
KEY_INIT(); \
|
||||
PORTB &= ~(1<<5); \
|
||||
_delay_ms(1); \
|
||||
} while (0)
|
||||
#define KEY_POWER_OFF() do { \
|
||||
DDRB &= ~0x3F; \
|
||||
PORTB &= ~0x3F; \
|
||||
DDRC &= ~0x0F; \
|
||||
PORTC &= ~0x0F; \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,196 +0,0 @@
|
||||
/*
|
||||
Copyright 2011 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* scan matrix
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "timer.h"
|
||||
#include "matrix.h"
|
||||
#include "hhkb_avr.h"
|
||||
#include <avr/wdt.h>
|
||||
#include "suspend.h"
|
||||
#include "lufa.h"
|
||||
|
||||
|
||||
// matrix power saving
|
||||
#define MATRIX_POWER_SAVE 10000
|
||||
static uint32_t matrix_last_modified = 0;
|
||||
|
||||
// matrix state buffer(1:on, 0:off)
|
||||
static matrix_row_t *matrix;
|
||||
static matrix_row_t *matrix_prev;
|
||||
static matrix_row_t _matrix0[MATRIX_ROWS];
|
||||
static matrix_row_t _matrix1[MATRIX_ROWS];
|
||||
|
||||
|
||||
inline
|
||||
uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
debug_enable = true;
|
||||
debug_keyboard = true;
|
||||
#endif
|
||||
|
||||
KEY_INIT();
|
||||
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00;
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix1[i] = 0x00;
|
||||
matrix = _matrix0;
|
||||
matrix_prev = _matrix1;
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
uint8_t *tmp;
|
||||
|
||||
tmp = matrix_prev;
|
||||
matrix_prev = matrix;
|
||||
matrix = tmp;
|
||||
|
||||
// power on
|
||||
if (!KEY_POWER_STATE()) KEY_POWER_ON();
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
|
||||
KEY_SELECT(row, col);
|
||||
_delay_us(5);
|
||||
|
||||
// Not sure this is needed. This just emulates HHKB controller's behaviour.
|
||||
if (matrix_prev[row] & (1<<col)) {
|
||||
KEY_PREV_ON();
|
||||
}
|
||||
_delay_us(10);
|
||||
|
||||
// NOTE: KEY_STATE is valid only in 20us after KEY_ENABLE.
|
||||
// If V-USB interrupts in this section we could lose 40us or so
|
||||
// and would read invalid value from KEY_STATE.
|
||||
uint8_t last = TIMER_RAW;
|
||||
|
||||
KEY_ENABLE();
|
||||
|
||||
// Wait for KEY_STATE outputs its value.
|
||||
// 1us was ok on one HHKB, but not worked on another.
|
||||
// no wait doesn't work on Teensy++ with pro(1us works)
|
||||
// no wait does work on tmk PCB(8MHz) with pro2
|
||||
// 1us wait does work on both of above
|
||||
// 1us wait doesn't work on tmk(16MHz)
|
||||
// 5us wait does work on tmk(16MHz)
|
||||
// 5us wait does work on tmk(16MHz/2)
|
||||
// 5us wait does work on tmk(8MHz)
|
||||
// 10us wait does work on Teensy++ with pro
|
||||
// 10us wait does work on 328p+iwrap with pro
|
||||
// 10us wait doesn't work on tmk PCB(8MHz) with pro2(very lagged scan)
|
||||
_delay_us(5);
|
||||
|
||||
if (KEY_STATE()) {
|
||||
matrix[row] &= ~(1<<col);
|
||||
} else {
|
||||
matrix[row] |= (1<<col);
|
||||
}
|
||||
|
||||
// Ignore if this code region execution time elapses more than 20us.
|
||||
// MEMO: 20[us] * (TIMER_RAW_FREQ / 1000000)[count per us]
|
||||
// MEMO: then change above using this rule: a/(b/c) = a*1/(b/c) = a*(c/b)
|
||||
if (TIMER_DIFF_RAW(TIMER_RAW, last) > 20/(1000000/TIMER_RAW_FREQ)) {
|
||||
matrix[row] = matrix_prev[row];
|
||||
}
|
||||
|
||||
_delay_us(5);
|
||||
KEY_PREV_OFF();
|
||||
KEY_UNABLE();
|
||||
|
||||
// NOTE: KEY_STATE keep its state in 20us after KEY_ENABLE.
|
||||
// This takes 25us or more to make sure KEY_STATE returns to idle state.
|
||||
#ifdef HHKB_JP
|
||||
// Looks like JP needs faster scan due to its twice larger matrix
|
||||
// or it can drop keys in fast key typing
|
||||
_delay_us(30);
|
||||
#else
|
||||
_delay_us(75);
|
||||
#endif
|
||||
}
|
||||
if (matrix[row] ^ matrix_prev[row]) matrix_last_modified = timer_read32();
|
||||
}
|
||||
// power off
|
||||
if (KEY_POWER_STATE() &&
|
||||
(USB_DeviceState == DEVICE_STATE_Suspended ||
|
||||
USB_DeviceState == DEVICE_STATE_Unattached ) &&
|
||||
timer_elapsed32(matrix_last_modified) > MATRIX_POWER_SAVE) {
|
||||
KEY_POWER_OFF();
|
||||
suspend_power_down();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
if (matrix[i] != matrix_prev[i])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_has_ghost(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
return (matrix[row] & (1<<col));
|
||||
}
|
||||
|
||||
inline
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
print("\nr/c 01234567\n");
|
||||
for (uint8_t row = 0; row < matrix_rows(); row++) {
|
||||
xprintf("%02X: %08b\n", row, bitrev(matrix_get_row(row)));
|
||||
}
|
||||
}
|
||||
|
||||
void matrix_power_up(void) {
|
||||
KEY_POWER_ON();
|
||||
}
|
||||
void matrix_power_down(void) {
|
||||
KEY_POWER_OFF();
|
||||
}
|
@ -1,138 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = hid_liber_lufa
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
|
||||
# List C source files here. (C dependencies are automatically generated.)
|
||||
SRC += keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name
|
||||
#MCU = at90usb1287
|
||||
MCU = atmega32u4
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
# Interrupt driven control endpoint task(+60)
|
||||
#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||
|
||||
|
||||
# Boot Section Size in bytes
|
||||
# Teensy halfKay 512
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
||||
|
||||
ansi: OPT_DEFS += -DLAYOUT_ANSI
|
||||
ansi: all
|
||||
|
||||
iso: OPT_DEFS += -DLAYOUT_ISO
|
||||
iso: all
|
||||
|
||||
custom: OPT_DEFS += -DLAYOUT_CUSTOM
|
||||
custom: all
|
||||
|
||||
alaricljs: OPT_DEFS += -DLAYOUT_ALARICLJS
|
||||
alaricljs: all
|
@ -1,111 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = hid_liber_pjrc
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# keyboard dependent files
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name, you MUST set this to match the board you are using
|
||||
# type "make clean" after changing this, so all files will be rebuilt
|
||||
#MCU = at90usb162 # Teensy 1.0
|
||||
MCU = atmega32u4 # Teensy 2.0
|
||||
#MCU = at90usb646 # Teensy++ 1.0
|
||||
#MCU = at90usb1286 # Teensy++ 2.0
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# Normally the first thing your program should do is set the clock prescaler,
|
||||
# so your program will run at the correct speed. You should also set this
|
||||
# variable to same clock speed. The _delay_ms() macro uses this, and many
|
||||
# examples use this variable to calculate timings. Do not add a "UL" here.
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
# Boot Section Size in bytes
|
||||
# Teensy halfKay 512
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/pjrc.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
||||
|
||||
ansi: OPT_DEFS += -DLAYOUT_ANSI
|
||||
ansi: all
|
||||
|
||||
iso: OPT_DEFS += -DLAYOUT_ISO
|
||||
iso: all
|
||||
|
||||
custom: OPT_DEFS += -DLAYOUT_CUSTOM
|
||||
custom: all
|
||||
|
||||
alaricljs: OPT_DEFS += -DLAYOUT_ALARICLJS
|
||||
alaricljs: all
|
@ -1,17 +0,0 @@
|
||||
hid_liberation firmware
|
||||
======================
|
||||
DIY daughterboard for Filco Majestouch TKL developed by Geekhack and Deskthority communities.
|
||||
The PCB was engineered by bpiphany.
|
||||
|
||||
## Wiki on Deskthority.net
|
||||
- [Instructions](http://deskthority.net/wiki/HID_Liberation_Device_-_Instructions)
|
||||
- [Assembly Instructions](http://deskthority.net/wiki/HID_Liberation_Device_-_DIY_Instructions)
|
||||
|
||||
|
||||
Build
|
||||
-----
|
||||
Move to this directory then just run `make` like:
|
||||
|
||||
$ make -f Makefile.[pjrc|lufa] [ansi|iso|custom|alaricljs]
|
||||
|
||||
Use `Makefile.pjrc` if you want to use PJRC stack or use `Makefile.lufa` for LUFA stack.
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
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
|
||||
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0xB919
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER t.m.k.
|
||||
#define PRODUCT HID Liberation
|
||||
|
||||
|
||||
/* message strings */
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for HID Liberation
|
||||
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 18
|
||||
#define MATRIX_COLS 8
|
||||
|
||||
/* define if matrix has ghost */
|
||||
//#define MATRIX_HAS_GHOST
|
||||
|
||||
/* Set 0 if need no debouncing */
|
||||
#define DEBOUNCE 8
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
#endif
|
@ -1,125 +0,0 @@
|
||||
/*
|
||||
Copyright 2011 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Keymap for HID Liberator controller
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
#include "action_macro.h"
|
||||
#include "report.h"
|
||||
#include "host.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "keymap.h"
|
||||
|
||||
|
||||
// Convert physical keyboard layout to matrix array.
|
||||
// This is a macro to define keymap easily in keyboard layout form.
|
||||
#define KEYMAP( \
|
||||
KG1, KH7, KJ7, KJ6, KJ1, KO5, KL1, KA6, KA7, KD7, KD5, KD1, KD2, KB5, KB3, KO3, \
|
||||
KG7, KG5, KH5, KJ5, KI5, KI7, KK7, KK5, KL5, KA5, KC5, KC7, KL7, KD6, KQ7, KN7, KM7, \
|
||||
KG6, KG3, KH3, KJ3, KI3, KI6, KK6, KK3, KL3, KA3, KC3, KC6, KL6, KD4, KP7, KN5, KM5, \
|
||||
KH6, KG4, KH4, KJ4, KI4, KI1, KK1, KK4, KL4, KA4, KC4, KC1, KD0, \
|
||||
KF6, KH1, KG0, KH0, KJ0, KI0, KI2, KK2, KK0, KL0, KA0, KC2, KF4, KN1, \
|
||||
KO7, KE6, KB1, KP1, KB2, KR4, KA2, KO0, KN2, KP2, KQ2 \
|
||||
) { \
|
||||
/* 0 1 2 3 4 5 6 7 */ \
|
||||
/* A */ { KC_##KA0, KC_NO , KC_##KA2, KC_##KA3, KC_##KA4, KC_##KA5, KC_##KA6, KC_##KA7 }, \
|
||||
/* B */ { KC_NO , KC_##KB1, KC_##KB2, KC_##KB3, KC_NO , KC_##KB5, KC_NO , KC_NO }, \
|
||||
/* C */ { KC_NO , KC_##KC1, KC_##KC2, KC_##KC3, KC_##KC4, KC_##KC5, KC_##KC6, KC_##KC7 }, \
|
||||
/* D */ { KC_##KD0, KC_##KD1, KC_##KD2, KC_NO , KC_##KD4, KC_##KD5, KC_##KD6, KC_##KD7 }, \
|
||||
/* E */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_##KE6, KC_NO }, \
|
||||
/* F */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_##KF4, KC_NO , KC_##KF6, KC_NO }, \
|
||||
/* G */ { KC_##KG0, KC_##KG1, KC_NO , KC_##KG3, KC_##KG4, KC_##KG5, KC_##KG6, KC_##KG7 }, \
|
||||
/* H */ { KC_##KH0, KC_##KH1, KC_NO , KC_##KH3, KC_##KH4, KC_##KH5, KC_##KH6, KC_##KH7 }, \
|
||||
/* I */ { KC_##KI0, KC_##KI1, KC_##KI2, KC_##KI3, KC_##KI4, KC_##KI5, KC_##KI6, KC_##KI7 }, \
|
||||
/* J */ { KC_##KJ0, KC_##KJ1, KC_NO , KC_##KJ3, KC_##KJ4, KC_##KJ5, KC_##KJ6, KC_##KJ7 }, \
|
||||
/* K */ { KC_##KK0, KC_##KK1, KC_##KK2, KC_##KK3, KC_##KK4, KC_##KK5, KC_##KK6, KC_##KK7 }, \
|
||||
/* L */ { KC_##KL0, KC_##KL1, KC_NO , KC_##KL3, KC_##KL4, KC_##KL5, KC_##KL6, KC_##KL7 }, \
|
||||
/* M */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_##KM5, KC_NO , KC_##KM7 }, \
|
||||
/* N */ { KC_NO , KC_##KN1, KC_##KN2, KC_NO , KC_NO , KC_##KN5, KC_NO , KC_##KN7 }, \
|
||||
/* O */ { KC_##KO0, KC_NO , KC_NO , KC_##KO3, KC_NO , KC_##KO5, KC_NO , KC_##KO7 }, \
|
||||
/* P */ { KC_NO , KC_##KP1, KC_##KP2, KC_NO , KC_NO , KC_NO , KC_NO , KC_##KP7 }, \
|
||||
/* Q */ { KC_NO , KC_NO , KC_##KQ2, KC_NO , KC_NO , KC_NO , KC_NO , KC_##KQ7 }, \
|
||||
/* R */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_##KR4, KC_NO , KC_NO , KC_NO } \
|
||||
}
|
||||
|
||||
/*
|
||||
* Tenkeyless keyboard default layout, ISO & ANSI (ISO is between Left Shift
|
||||
* and Z, and the ANSI \ key above Return/Enter is used for the additional ISO
|
||||
* switch in the ASD row next to enter. Use NUBS as keycode for the first and
|
||||
* NUHS as the keycode for the second.
|
||||
*
|
||||
* ,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
|
||||
* `---' `---------------' `---------------' `---------------' `-----------'
|
||||
* ,-----------------------------------------------------------. ,-----------.
|
||||
* |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
|
||||
* |-----------------------------------------------------------| |-----------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
|
||||
* |-----------------------------------------------------------| `-----------'
|
||||
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
|
||||
* |-----------------------------------------------------------| ,---.
|
||||
* |Shft|ISO| Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
|
||||
* |-----------------------------------------------------------| ,-----------.
|
||||
* |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig|
|
||||
* `-----------------------------------------------------------' `-----------'
|
||||
*/
|
||||
|
||||
/*
|
||||
* Add different layouts. If no layout is defined the default layout will be set to ANSI.
|
||||
*/
|
||||
#if defined(LAYOUT_CUSTOM)
|
||||
#include "keymap_custom.h"
|
||||
#elif defined(LAYOUT_ALARICLJS)
|
||||
#include "keymap_alaricljs.h"
|
||||
#elif defined(LAYOUT_ISO)
|
||||
#include "keymap_iso.h"
|
||||
#elif defined(LAYOUT_ANSI)
|
||||
#include "keymap_ansi.h"
|
||||
#else
|
||||
#include "keymap_ansi.h"
|
||||
#endif
|
||||
|
||||
#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
|
||||
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
|
||||
|
||||
/* translates key to keycode */
|
||||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
if (layer < KEYMAPS_SIZE) {
|
||||
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||
} else {
|
||||
return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
|
||||
}
|
||||
}
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint8_t keycode)
|
||||
{
|
||||
action_t action;
|
||||
if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
|
||||
action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
|
||||
} else {
|
||||
action.code = ACTION_NO;
|
||||
}
|
||||
return action;
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
// hid_liber alaricljs
|
||||
// this was the standard layout when hid_liber was merged into tmk's firmware
|
||||
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Layer 0: Default ANSI
|
||||
*
|
||||
* ,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
|
||||
* `---' `---------------' `---------------' `---------------' `-----------'
|
||||
* ,-----------------------------------------------------------. ,-----------.
|
||||
* |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
|
||||
* |-----------------------------------------------------------| |-----------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
|
||||
* |-----------------------------------------------------------| `-----------'
|
||||
* |FN1 | A| S| D| F| G| H| J| K| L| ;| '|Return |
|
||||
* |-----------------------------------------------------------| ,---.
|
||||
* |Shft|iso| Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
|
||||
* |-----------------------------------------------------------| ,-----------.
|
||||
* |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig|
|
||||
* `-----------------------------------------------------------' `-----------'
|
||||
*/
|
||||
|
||||
KEYMAP(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, BRK, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, INS, HOME, PGUP, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, BSLS, DEL, END, PGDN, \
|
||||
FN1, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, \
|
||||
LSFT, NUBS, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, UP, \
|
||||
LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT),
|
||||
|
||||
/* Layer 1:
|
||||
*
|
||||
* ,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Slp|
|
||||
* `---' `---------------' `---------------' `---------------' `-----------'
|
||||
* ,-----------------------------------------------------------. ,-----------.
|
||||
* |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9|Mut|V- |V+ |Backsp | |Ins|Hom|PgU|
|
||||
* |-----------------------------------------------------------| |-----------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I|MSt|Ply|Prv|Nxt|Media| |Del|End|PgD|
|
||||
* |-----------------------------------------------------------| `-----------'
|
||||
* |FN1 | A| S| D| F| G| H| J| K| L| ;| '|Return |
|
||||
* |-----------------------------------------------------------| ,---.
|
||||
* |Shft|iso| Z| X|Clc| V| B| N| M| ,| .| /|Caps | |Up |
|
||||
* |-----------------------------------------------------------| ,-----------.
|
||||
* |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig|
|
||||
* `-----------------------------------------------------------' `-----------'
|
||||
*/
|
||||
|
||||
KEYMAP(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, SLEP, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9,MUTE, VOLD, VOLU, BSPC, INS, HOME, PGUP, \
|
||||
TAB, Q, W, E, R, T, Y, U, I,MSTP,MPLY, MPRV, MNXT, MSEL, DEL, END, PGDN, \
|
||||
FN1, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, \
|
||||
LSFT, NUBS, Z, X,CALC, V, B, N, M, COMM, DOT, SLSH, CAPS, UP, \
|
||||
LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT),
|
||||
|
||||
};
|
||||
|
||||
static const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_MOMENTARY(1), // activate layer 1 when FN1 pressed
|
||||
};
|
@ -1,32 +0,0 @@
|
||||
// hid_liber ANSI
|
||||
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Layer 0: Default ANSI
|
||||
*
|
||||
* ,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
|
||||
* `---' `---------------' `---------------' `---------------' `-----------'
|
||||
* ,-----------------------------------------------------------. ,-----------.
|
||||
* |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
|
||||
* |-----------------------------------------------------------| |-----------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
|
||||
* |-----------------------------------------------------------| `-----------'
|
||||
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
|
||||
* |-----------------------------------------------------------| ,---.
|
||||
* |Shft|iso| Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
|
||||
* |-----------------------------------------------------------| ,-----------.
|
||||
* |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig|
|
||||
* `-----------------------------------------------------------' `-----------'
|
||||
*/
|
||||
|
||||
KEYMAP(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, BRK, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, INS, HOME, PGUP, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, BSLS, DEL, END, PGDN, \
|
||||
CAPS, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, \
|
||||
LSFT, NUBS, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, UP, \
|
||||
LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT),
|
||||
|
||||
};
|
||||
|
||||
static const uint16_t PROGMEM fn_actions[] = {};
|
@ -1,64 +0,0 @@
|
||||
// hid_liber custom
|
||||
// ANSI layout with FN key instead of APP button
|
||||
// Layer 1 has mediakeys on the nav cluster and keypad numbers for alt-codes
|
||||
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Layer 0: Default ANSI
|
||||
*
|
||||
* ,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
|
||||
* `---' `---------------' `---------------' `---------------' `-----------'
|
||||
* ,-----------------------------------------------------------. ,-----------.
|
||||
* |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
|
||||
* |-----------------------------------------------------------| |-----------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
|
||||
* |-----------------------------------------------------------| `-----------'
|
||||
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
|
||||
* |-----------------------------------------------------------| ,---.
|
||||
* |Shft|iso| Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
|
||||
* |-----------------------------------------------------------| ,-----------.
|
||||
* |Ctl|Gui|Alt| Space |Alt|Gui|FN1|Ctl| |Lef|Dow|Rig|
|
||||
* `-----------------------------------------------------------' `-----------'
|
||||
*/
|
||||
|
||||
KEYMAP(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, BRK, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, INS, HOME, PGUP, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, BSLS, DEL, END, PGDN, \
|
||||
CAPS, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, \
|
||||
LSFT, NUBS, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, UP, \
|
||||
LCTL, LGUI, LALT, SPC, RALT, RGUI, FN1, RCTL, LEFT, DOWN, RGHT),
|
||||
|
||||
/*
|
||||
* Layer 1: Media Keys
|
||||
* Keypad numbers instead of normal numbers
|
||||
*
|
||||
* ,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
|
||||
* `---' `---------------' `---------------' `---------------' `-----------'
|
||||
* ,-----------------------------------------------------------. ,-----------.
|
||||
* |~ |KP1|KP2|KP3|KP4|KP5|KP6|KP7|KP8|KP9|KP0| -| =|Backsp | |Ins|Med|Vl+|
|
||||
* |-----------------------------------------------------------| |-----------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|Mut|Vl-|
|
||||
* |-----------------------------------------------------------| `-----------'
|
||||
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
|
||||
* |-----------------------------------------------------------| ,---.
|
||||
* |Shft|iso| Z| X| C| V| B| N| M| ,| .| /|Shift | |Ply|
|
||||
* |-----------------------------------------------------------| ,-----------.
|
||||
* |Ctl|Gui|Alt| Space |Alt|Gui|FN1|Ctl| |Prv|Stp|Nxt|
|
||||
* `-----------------------------------------------------------' `-----------'
|
||||
*/
|
||||
|
||||
KEYMAP(\
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
|
||||
TRNS, P1, P2, P3, P4, P5, P6, P7, P8, P9, P0, TRNS, TRNS, TRNS, TRNS, MSEL, VOLU, \
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MUTE, VOLD, \
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MPLY, \
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN1, TRNS, MPRV, MSTP, MNXT),
|
||||
|
||||
};
|
||||
|
||||
static const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_MOMENTARY(1), // activate layer 1 when FN1 pressed
|
||||
};
|
@ -1,32 +0,0 @@
|
||||
// hid_liber ISO
|
||||
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Layer 0: Default ISO
|
||||
*
|
||||
* ,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
|
||||
* `---' `---------------' `---------------' `---------------' `-----------'
|
||||
* ,-----------------------------------------------------------. ,-----------.
|
||||
* |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
|
||||
* |-----------------------------------------------------------| |-----------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
|
||||
* |-----------------------------------------------------------| `-----------'
|
||||
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
|
||||
* |-----------------------------------------------------------| ,---.
|
||||
* |Shft|iso| Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
|
||||
* |-----------------------------------------------------------| ,-----------.
|
||||
* |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig|
|
||||
* `-----------------------------------------------------------' `-----------'
|
||||
*/
|
||||
|
||||
KEYMAP(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, BRK, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, INS, HOME, PGUP, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, NUHS, DEL, END, PGDN, \
|
||||
CAPS, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, \
|
||||
LSFT, NUBS, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, UP, \
|
||||
LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT),
|
||||
|
||||
};
|
||||
|
||||
static const uint16_t PROGMEM fn_actions[] = {};
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "stdint.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
if (usb_led & (1<<USB_LED_CAPS_LOCK))
|
||||
PORTB &= ~(1<<5);
|
||||
else
|
||||
PORTB |= (1<<5);
|
||||
|
||||
if (usb_led & (1<<USB_LED_SCROLL_LOCK))
|
||||
PORTB &= ~(1<<6);
|
||||
else
|
||||
PORTB |= (1<<6);
|
||||
}
|
@ -1,231 +0,0 @@
|
||||
/* Copyright 2012 Jun Wako <wakojun@gmail.com>
|
||||
*
|
||||
* This is heavily based on hid_liber/board.{c|h}.
|
||||
* https://github.com/BathroomEpiphanies/AVR-Keyboard
|
||||
*
|
||||
* Copyright (c) 2012 Fredrik Atmer, Bathroom Epiphanies Inc
|
||||
* http://bathroomepiphanies.com
|
||||
*
|
||||
* As for liscensing consult with the original files or its author.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 0
|
||||
#endif
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
// bit array of key state(1:on, 0:off)
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
|
||||
#define _DDRA (uint8_t *const)&DDRA
|
||||
#define _DDRB (uint8_t *const)&DDRB
|
||||
#define _DDRC (uint8_t *const)&DDRC
|
||||
#define _DDRD (uint8_t *const)&DDRD
|
||||
#define _DDRE (uint8_t *const)&DDRE
|
||||
#define _DDRF (uint8_t *const)&DDRF
|
||||
|
||||
#define _PINA (uint8_t *const)&PINA
|
||||
#define _PINB (uint8_t *const)&PINB
|
||||
#define _PINC (uint8_t *const)&PINC
|
||||
#define _PIND (uint8_t *const)&PIND
|
||||
#define _PINE (uint8_t *const)&PINE
|
||||
#define _PINF (uint8_t *const)&PINF
|
||||
|
||||
#define _PORTA (uint8_t *const)&PORTA
|
||||
#define _PORTB (uint8_t *const)&PORTB
|
||||
#define _PORTC (uint8_t *const)&PORTC
|
||||
#define _PORTD (uint8_t *const)&PORTD
|
||||
#define _PORTE (uint8_t *const)&PORTE
|
||||
#define _PORTF (uint8_t *const)&PORTF
|
||||
|
||||
#define _BIT0 0x01
|
||||
#define _BIT1 0x02
|
||||
#define _BIT2 0x04
|
||||
#define _BIT3 0x08
|
||||
#define _BIT4 0x10
|
||||
#define _BIT5 0x20
|
||||
#define _BIT6 0x40
|
||||
#define _BIT7 0x80
|
||||
|
||||
/* Specifies the ports and pin numbers for the rows */
|
||||
static
|
||||
uint8_t *const row_ddr[MATRIX_ROWS] = {
|
||||
_DDRB, _DDRB,
|
||||
_DDRC, _DDRC,
|
||||
_DDRD, _DDRD, _DDRD, _DDRD, _DDRD, _DDRD, _DDRD, _DDRD,
|
||||
_DDRF, _DDRF, _DDRF, _DDRF, _DDRF, _DDRF};
|
||||
|
||||
static
|
||||
uint8_t *const row_port[MATRIX_ROWS] = {
|
||||
_PORTB, _PORTB,
|
||||
_PORTC, _PORTC,
|
||||
_PORTD, _PORTD, _PORTD, _PORTD, _PORTD, _PORTD, _PORTD, _PORTD,
|
||||
_PORTF, _PORTF, _PORTF, _PORTF, _PORTF, _PORTF};
|
||||
|
||||
static
|
||||
uint8_t *const row_pin[MATRIX_ROWS] = {
|
||||
_PINB, _PINB,
|
||||
_PINC, _PINC,
|
||||
_PIND, _PIND, _PIND, _PIND, _PIND, _PIND, _PIND, _PIND,
|
||||
_PINF, _PINF, _PINF, _PINF, _PINF, _PINF};
|
||||
|
||||
static
|
||||
const uint8_t row_bit[MATRIX_ROWS] = {
|
||||
_BIT4, _BIT7,
|
||||
_BIT6, _BIT7,
|
||||
_BIT0, _BIT1, _BIT2, _BIT3, _BIT4, _BIT5, _BIT6, _BIT7,
|
||||
_BIT0, _BIT1, _BIT4, _BIT5, _BIT6, _BIT7};
|
||||
|
||||
static
|
||||
const uint8_t mask = 0x0E;
|
||||
|
||||
/* Specifies the ports and pin numbers for the columns */
|
||||
static
|
||||
const uint8_t col_bit[MATRIX_COLS] = { 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E};
|
||||
|
||||
static
|
||||
inline void pull_column(int col) {
|
||||
PORTB = col_bit[col] | (PORTB & ~mask);
|
||||
}
|
||||
|
||||
static
|
||||
inline void release_column(int col) {
|
||||
}
|
||||
|
||||
/* PORTB is set as input with pull-up resistors
|
||||
PORTC,D,E,F are set to high output */
|
||||
static
|
||||
void setup_io_pins(void) {
|
||||
uint8_t row;
|
||||
DDRB |= 0x0E;
|
||||
PORTB &= ~0x0E;
|
||||
for(row = 0; row < MATRIX_ROWS; row++) {
|
||||
*row_ddr[row] &= ~row_bit[row];
|
||||
*row_port[row] &= ~row_bit[row];
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void setup_leds(void) {
|
||||
DDRB |= 0x60;
|
||||
PORTB |= 0x60;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
// To use PORTF disable JTAG with writing JTD bit twice within four cycles.
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
|
||||
// initialize row and col
|
||||
setup_io_pins();
|
||||
setup_leds();
|
||||
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++) { // 0-7
|
||||
pull_column(col); // output hi on theline
|
||||
_delay_us(5); // without this wait it won't read stable value.
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) { // 0-17
|
||||
bool prev_bit = matrix_debouncing[row] & (1<<col);
|
||||
bool curr_bit = *row_pin[row] & row_bit[row];
|
||||
if (prev_bit != curr_bit) {
|
||||
matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
|
||||
if (debouncing) {
|
||||
dprintf("bounce!: %02X\n", debouncing);
|
||||
}
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
}
|
||||
release_column(col);
|
||||
}
|
||||
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
_delay_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
// NOTE: no longer used
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_has_ghost(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
return (matrix[row] & ((matrix_row_t)1<<col));
|
||||
}
|
||||
|
||||
inline
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
print("\nr/c 01234567\n");
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
phex(row); print(": ");
|
||||
pbin_reverse(matrix_get_row(row));
|
||||
print("\n");
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_key_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
for (uint8_t j = 0; j < MATRIX_COLS; j++) {
|
||||
if (matrix_is_on(i, j))
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
PROJECT = infinity
|
||||
|
||||
TMK_DIR = ../../tmk_core
|
||||
MBED_DIR = $(TMK_DIR)/tool/mbed/mbed-sdk
|
||||
|
||||
#VPATH += $(MBED_DIR):$(TMK_DIR)
|
||||
vpath %.s .:$(MBED_DIR):$(TMK_DIR)
|
||||
vpath %.c .:$(MBED_DIR):$(TMK_DIR)
|
||||
vpath %.cpp .:$(MBED_DIR):$(TMK_DIR)
|
||||
|
||||
OBJDIR = ./build
|
||||
|
||||
OBJECTS = \
|
||||
$(OBJDIR)/matrix.o \
|
||||
$(OBJDIR)/keymap_common.o \
|
||||
$(OBJDIR)/led.o \
|
||||
$(OBJDIR)/main.o
|
||||
|
||||
ifdef KEYMAP
|
||||
OBJECTS := $(OBJDIR)/keymap_$(KEYMAP).o $(OBJECTS)
|
||||
else
|
||||
OBJECTS := $(OBJDIR)/keymap.o $(OBJECTS)
|
||||
endif
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
INCLUDE_PATHS = -I.
|
||||
|
||||
|
||||
# Build Options
|
||||
# Comment out to disable
|
||||
#BOOTMAGIC_ENABLE = yes
|
||||
#MOUSEKEY_ENABLE = yes
|
||||
|
||||
|
||||
include mbed-infinity.mk
|
||||
include $(TMK_DIR)/tool/mbed/mbed.mk
|
||||
include $(TMK_DIR)/tool/mbed/common.mk
|
||||
include $(TMK_DIR)/tool/mbed/gcc.mk
|
||||
|
||||
program: $(OBJDIR)/$(PROJECT).bin
|
||||
dfu-util -D $(OBJDIR)/$(PROJECT).bin
|
@ -1,81 +0,0 @@
|
||||
Infinity
|
||||
========
|
||||
Massdrop Infinity Keyboard:
|
||||
https://www.massdrop.com/buy/infinity-keyboard-kit
|
||||
|
||||
kiibohd controller(MD1):
|
||||
https://github.com/kiibohd/controller
|
||||
|
||||
DFU bootloader:
|
||||
https://github.com/kiibohd/controller/tree/master/Bootloader
|
||||
|
||||
Program with bootloader:
|
||||
$ dfu-util -D kiibohd.dfu.bin
|
||||
|
||||
Pinout:
|
||||
https://github.com/kiibohd/controller/blob/master/Scan/MD1/pinout
|
||||
|
||||
MCHCK compatible:
|
||||
https://mchck.org/about/
|
||||
|
||||
MCU Freescale MK20DX128VLF5 48-QFP:
|
||||
http://cache.freescale.com/files/32bit/doc/data_sheet/K20P48M50SF0.pdf
|
||||
|
||||
|
||||
|
||||
Pin Usage
|
||||
=========
|
||||
Key Matrix:
|
||||
Strobe(output high): PTB0 PTB1 PTB2 PTB3 PTB16 PTB17 PTC4 PTC5 PTD0
|
||||
Sense(input with pull-down): PTD1 PTD2 PTD3 PTD4 PTD5 PTD6 PTD7
|
||||
|
||||
|
||||
SWD pinout:
|
||||
SWD_CLK(PTA0) SWD_DIO(PTA3)
|
||||
SWD pins are placed next to reset button; SWD_CLK, SWD_DIO, GND, VCC from top.
|
||||
Note that RESET is also needed to get full control with OpenOCD.
|
||||
|
||||
LED:
|
||||
PTA19(turns on with output high)
|
||||
|
||||
|
||||
|
||||
Memory map
|
||||
==========
|
||||
kiibohd bootloader: Lib/mk20dx128vlf5.bootloader.ld
|
||||
0x0000_0000 +-------------------+ -----------------+---------------+ Vector table
|
||||
| .vectors | ------------. | StackPointer0 | of Bootloader
|
||||
| .startup | \ | ResetHandler1 |
|
||||
| .rodata | `--+---------------+ 0xF8
|
||||
0x0000_0400 | .flashconfig(0x10)|
|
||||
_0410 | .text |
|
||||
| .init |
|
||||
0x0000_1000 +-------------------+ -----------------+---------------+ Vector table
|
||||
| _app_rom | ------------. | | of App
|
||||
| | \ | |
|
||||
| | `--+---------------+
|
||||
| |
|
||||
~ ~
|
||||
| |
|
||||
0x07FF_FFFF +-------------------+ 128KB
|
||||
|
||||
|
||||
0x1FFF_E000 +-------------------+ -----------------+---------------+ Vector table
|
||||
_E0F8 | | ------------. | | of App(copied)
|
||||
| | \ | |
|
||||
| | `--+---------------+ mbed NVIC
|
||||
| |
|
||||
| RAM |
|
||||
| 8KB|
|
||||
0x2000_0000 +-------------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| RAM |
|
||||
| 8KB|
|
||||
0x2000_2000 +-------------------+ _estack
|
||||
|
||||
|
||||
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 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
|
||||
|
||||
#if 0
|
||||
// duplicated name against mbed USBDeivce
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x3BED
|
||||
#endif
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER tmk.
|
||||
#define PRODUCT Infinitiy
|
||||
#define DESCRIPTION Massdrop Infinity keyboard firmware by tmk
|
||||
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 9 // Strobe
|
||||
#define MATRIX_COLS 7 // Sense
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
|
||||
|
||||
|
||||
/* for prototype */
|
||||
//#define INFINITY_PROTOTYPE
|
||||
|
||||
#endif
|
@ -1,48 +0,0 @@
|
||||
#include "keymap_common.h"
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Layer 0: Default Layer
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| `|BSp|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Contro| A| S| D| F| G| H| J| K| L| ;| '|Enter |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0|
|
||||
* |-----------------------------------------------------------'
|
||||
* | |Gui|Alt | Space |Alt |Gui| | |
|
||||
* `-----------------------------------------------------------'
|
||||
*/
|
||||
[0] =
|
||||
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS, GRV, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \
|
||||
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \
|
||||
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, \
|
||||
NO, LGUI,LALT, SPC, RALT,RGUI,NO, NO),
|
||||
|
||||
/* Layer 1: HHKB mode (HHKB Fn)
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs|
|
||||
* |-----------------------------------------------------------|
|
||||
* | |VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter |
|
||||
* |-----------------------------------------------------------|
|
||||
* | | | | | | | +| -|End|PgD|Dow| | |
|
||||
* `-----------------------------------------------------------'
|
||||
* | |Gui|Alt | Space |Alt |Gui| | |
|
||||
* `-----------------------------------------------------------'
|
||||
*/
|
||||
[1] =
|
||||
KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
||||
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, BSPC, \
|
||||
TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,PENT, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS),
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1),
|
||||
};
|
||||
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
Copyright 2012,2013 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/>.
|
||||
*/
|
||||
#include "keymap_common.h"
|
||||
|
||||
|
||||
/* translates key to keycode */
|
||||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||
}
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint8_t keycode)
|
||||
{
|
||||
return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 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 KEYMAP_COMMON_H
|
||||
#define KEYMAP_COMMON_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
#include "action_macro.h"
|
||||
#include "report.h"
|
||||
#include "host.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "keymap.h"
|
||||
|
||||
|
||||
extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
|
||||
extern const uint16_t fn_actions[];
|
||||
|
||||
|
||||
#ifdef INFINITY_PROTOTYPE
|
||||
|
||||
/* Infinity prototype */
|
||||
#define KEYMAP( \
|
||||
K00, K10, K20, K30, K40, K50, K60, K70, K80, K01, K11, K21, K31, K41, K86, \
|
||||
K51, K61, K71, K81, K02, K12, K22, K32, K42, K52, K62, K72, K82, K03, \
|
||||
K13, K23, K33, K43, K53, K63, K73, K83, K04, K14, K24, K34, K44, \
|
||||
K54, K64, K74, K84, K05, K15, K25, K35, K45, K55, K65, K75, K85, \
|
||||
K06, K16, K26, K36, K46, K56, K66, K76 \
|
||||
) { \
|
||||
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06 }, \
|
||||
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16 }, \
|
||||
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26 }, \
|
||||
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36 }, \
|
||||
{ KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46 }, \
|
||||
{ KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56 }, \
|
||||
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66 }, \
|
||||
{ KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76 }, \
|
||||
{ KC_##K80, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86 } \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* Infinity production */
|
||||
#define KEYMAP( \
|
||||
K00, K10, K20, K30, K40, K50, K60, K70, K80, K01, K11, K21, K31, K41, K51, \
|
||||
K61, K71, K81, K02, K12, K22, K32, K42, K52, K62, K72, K82, K03, K13, \
|
||||
K23, K33, K43, K53, K63, K73, K83, K04, K14, K24, K34, K44, K54, \
|
||||
K64, K74, K84, K05, K15, K25, K35, K45, K55, K65, K75, K85, K06, \
|
||||
K16, K26, K36, K46, K56, K66, K76, K86 \
|
||||
) { \
|
||||
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06 }, \
|
||||
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16 }, \
|
||||
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26 }, \
|
||||
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36 }, \
|
||||
{ KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46 }, \
|
||||
{ KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56 }, \
|
||||
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66 }, \
|
||||
{ KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76 }, \
|
||||
{ KC_##K80, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86 } \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
Copyright 2011 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/>.
|
||||
*/
|
||||
|
||||
#include "stdint.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
/* HHKB has no LEDs */
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
#include "MK20D5.h"
|
||||
#include "wait.h"
|
||||
#include "gpio_api.h"
|
||||
#include "PinNames.h"
|
||||
#include "matrix.h"
|
||||
#include "timer.h"
|
||||
|
||||
#include "action.h"
|
||||
#include "keycode.h"
|
||||
#include "host.h"
|
||||
#include "host_driver.h"
|
||||
#include "mbed_driver.h"
|
||||
|
||||
|
||||
int main() {
|
||||
gpio_t led;
|
||||
gpio_init_out(&led, PTA19);
|
||||
|
||||
uint16_t t = 0;
|
||||
|
||||
host_set_driver(&mbed_driver);
|
||||
keyboard_init();
|
||||
|
||||
while(1) {
|
||||
keyboard_task();
|
||||
|
||||
bool matrix_on = false;
|
||||
matrix_scan();
|
||||
for (int i = 0; i < MATRIX_ROWS; i++) {
|
||||
if (matrix_get_row(i)) {
|
||||
matrix_on = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (matrix_on)
|
||||
gpio_write(&led, 1);
|
||||
else {
|
||||
if (timer_elapsed(t) > 500) {
|
||||
gpio_write(&led, !gpio_read(&led));
|
||||
t = timer_read();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "gpio_api.h"
|
||||
#include "timer.h"
|
||||
#include "wait.h"
|
||||
#include "matrix.h"
|
||||
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
#define DEBOUNCE 5
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Infinity Pinusage:
|
||||
* Column pins are input with internal pull-down. Row pins are output and strobe with high.
|
||||
* Key is high or 1 when it turns on.
|
||||
*
|
||||
* col: { PTD1, PTD2, PTD3, PTD4, PTD5, PTD6, PTD7 }
|
||||
* row: { PTB0, PTB1, PTB2, PTB3, PTB16, PTB17, PTC4, PTC5, PTD0 }
|
||||
*/
|
||||
static gpio_t col[MATRIX_COLS];
|
||||
static gpio_t row[MATRIX_ROWS];
|
||||
|
||||
/* matrix state(1:on, 0:off) */
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
static bool debouncing = false;
|
||||
static uint16_t debouncing_time = 0;
|
||||
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
/* Column(sense) */
|
||||
gpio_init_in_ex(&col[0], PTD1, PullDown);
|
||||
gpio_init_in_ex(&col[1], PTD2, PullDown);
|
||||
gpio_init_in_ex(&col[2], PTD3, PullDown);
|
||||
gpio_init_in_ex(&col[3], PTD4, PullDown);
|
||||
gpio_init_in_ex(&col[4], PTD5, PullDown);
|
||||
gpio_init_in_ex(&col[5], PTD6, PullDown);
|
||||
gpio_init_in_ex(&col[6], PTD7, PullDown);
|
||||
|
||||
/* Row(strobe) */
|
||||
gpio_init_out_ex(&row[0], PTB0, 0);
|
||||
gpio_init_out_ex(&row[1], PTB1, 0);
|
||||
gpio_init_out_ex(&row[2], PTB2, 0);
|
||||
gpio_init_out_ex(&row[3], PTB3, 0);
|
||||
gpio_init_out_ex(&row[4], PTB16, 0);
|
||||
gpio_init_out_ex(&row[5], PTB17, 0);
|
||||
gpio_init_out_ex(&row[6], PTC4, 0);
|
||||
gpio_init_out_ex(&row[7], PTC5, 0);
|
||||
gpio_init_out_ex(&row[8], PTD0, 0);
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (int i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix_row_t r = 0;
|
||||
|
||||
gpio_write(&row[i], 1);
|
||||
wait_us(1); // need wait to settle pin state
|
||||
for (int j = 0; j < MATRIX_COLS; j++) {
|
||||
if (gpio_read(&col[j])) {
|
||||
r |= (1<<j);
|
||||
}
|
||||
}
|
||||
gpio_write(&row[i], 0);
|
||||
|
||||
if (matrix_debouncing[i] != r) {
|
||||
matrix_debouncing[i] = r;
|
||||
debouncing = true;
|
||||
debouncing_time = timer_read();
|
||||
}
|
||||
}
|
||||
|
||||
if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) {
|
||||
for (int i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
debouncing = false;
|
||||
}
|
||||
/*
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
return 0;
|
||||
} else {
|
||||
for (int i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
return (matrix[row] & (1<<col));
|
||||
}
|
||||
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
# based on Makefile exported form mbed.org
|
||||
# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded
|
||||
|
||||
CPU = -mcpu=cortex-m4 -mthumb
|
||||
|
||||
CC_SYMBOLS += \
|
||||
-DTARGET_INFINITY \
|
||||
-DTARGET_K20D50M \
|
||||
-DTARGET_M4 \
|
||||
-DTARGET_CORTEX_M \
|
||||
-DTARGET_Freescale \
|
||||
-DTOOLCHAIN_GCC_ARM \
|
||||
-DTOOLCHAIN_GCC \
|
||||
-D__CORTEX_M4 \
|
||||
-DARM_MATH_CM4 \
|
||||
-D__MBED__=1
|
||||
|
||||
OBJECTS += \
|
||||
$(OBJDIR)/mbed-infinity/cmsis_nvic.o \
|
||||
$(OBJDIR)/mbed-infinity/system_MK20D5.o \
|
||||
$(OBJDIR)/mbed-infinity/USBHAL_KL25Z.o \
|
||||
$(OBJDIR)/mbed-infinity/startup_MK20D5.o \
|
||||
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/analogin_api.o \
|
||||
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/gpio_api.o \
|
||||
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/gpio_irq_api.o \
|
||||
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/i2c_api.o \
|
||||
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/pinmap.o \
|
||||
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/port_api.o \
|
||||
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/pwmout_api.o \
|
||||
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/rtc_api.o \
|
||||
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/serial_api.o \
|
||||
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/sleep.o \
|
||||
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/spi_api.o \
|
||||
$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/us_ticker.o
|
||||
|
||||
INCLUDE_PATHS += \
|
||||
-Imbed \
|
||||
-I$(MBED_DIR)/libraries/mbed/targets \
|
||||
-I$(MBED_DIR)/libraries/mbed/targets/cmsis \
|
||||
-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale \
|
||||
-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20XX \
|
||||
-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20XX/TARGET_K20D50M \
|
||||
-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20XX/TARGET_K20D50M/TOOLCHAIN_GCC_ARM \
|
||||
-I$(MBED_DIR)/libraries/mbed/targets/hal \
|
||||
-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_Freescale \
|
||||
-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX \
|
||||
-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/TARGET_K20D50M
|
||||
|
||||
LINKER_SCRIPT = mbed-infinity/infinity.ld
|
@ -1,83 +0,0 @@
|
||||
mbed fix for Infinity
|
||||
=====================
|
||||
Without linker script patch it doesn't place vector table in final binary.
|
||||
And clock is configured to 48MHz using internal clock reference and FLL multiplication.
|
||||
|
||||
|
||||
mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c
|
||||
Fix SystemInit: clock setup for internal clock. Inifinity has no external Xtal.
|
||||
|
||||
mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/cmsis_nvic.c
|
||||
Fix NVIC vector address of firmware 0x1000 instead of 0x0
|
||||
|
||||
mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld
|
||||
Fix memory map for Infinity bootloader
|
||||
Flash starts at 0x1000
|
||||
No flash config bytes sector
|
||||
|
||||
USBDevice/USBDevice/USBHAL_KL25Z.cpp
|
||||
Fix USB clock setup, see below.
|
||||
|
||||
|
||||
2015/01/04 Based on mbed-sdk @2f63fa7d78a26.
|
||||
|
||||
|
||||
|
||||
Kinetis USB config
|
||||
==================
|
||||
Clock source: Internal reference clock wth FLL
|
||||
SIM_SOPT[USBSRC] = 1(MCGPLLCLK/MCGFLLCLK)
|
||||
SIM_SOPT[PLLSEL] = 0(MCGFLLCLK)
|
||||
|
||||
Clock dividor:
|
||||
SIM_CLKDIV2[USBDIV] = 0
|
||||
SIM_CLKDIV2[USBFAC] = 0
|
||||
|
||||
Clock enable:
|
||||
SIM_SCGC4[USBOTG] = 1
|
||||
|
||||
|
||||
|
||||
Infinity bootloader change
|
||||
==========================
|
||||
After @2c7542e(2015/01) Infinity bootloader doesn't disable watchdog timer and keyboard firmware has to do it itself. mbed disables watchdog in startup sequence but unfortunately timer is timed out bofore that.
|
||||
|
||||
We have to do that in earlier phase of mbed startup sequence.
|
||||
|
||||
|
||||
mbed starup sequence files:
|
||||
mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/startup_M20D5.s
|
||||
mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c
|
||||
|
||||
Infinity booloader change commit:
|
||||
https://github.com/kiibohd/controller/commit/2c7542e2e7f0b8a99edf563dc53164fe1a439483
|
||||
|
||||
discussion:
|
||||
https://geekhack.org/index.php?topic=41989.msg1686616#msg1686616
|
||||
|
||||
|
||||
WORKAROUND
|
||||
----------
|
||||
Call SystemInit early in Reset_Handler.
|
||||
|
||||
$ diff -u ../../mbed-sdk/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/startup_MK20D5.s mbed-infinity
|
||||
--- ../../mbed-sdk/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/startup_MK20D5.s 2015-03-22 10:33:22.779866000 +0900
|
||||
+++ mbed-infinity/startup_MK20D5.s 2015-03-22 10:32:56.483866000 +0900
|
||||
@@ -147,6 +147,8 @@
|
||||
* __etext: End of code section, i.e., begin of data sections to copy from.
|
||||
* __data_start__/__data_end__: RAM address range that data should be
|
||||
* copied to. Both must be aligned to 4 bytes boundary. */
|
||||
+ ldr r0, =SystemInit
|
||||
+ blx r0
|
||||
|
||||
ldr r1, =__etext
|
||||
ldr r2, =__data_start__
|
||||
@@ -161,8 +163,6 @@
|
||||
|
||||
.Lflash_to_ram_loop_end:
|
||||
|
||||
- ldr r0, =SystemInit
|
||||
- blx r0
|
||||
ldr r0, =_start
|
||||
bx r0
|
||||
.pool
|
@ -1,557 +0,0 @@
|
||||
/* Copyright (c) 2010-2011 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#if defined(TARGET_KL25Z) | defined(TARGET_KL43Z) | defined(TARGET_KL46Z) | defined(TARGET_K20D50M) | defined(TARGET_K64F) | defined(TARGET_K22F)
|
||||
|
||||
#include "USBHAL.h"
|
||||
|
||||
USBHAL * USBHAL::instance;
|
||||
|
||||
static volatile int epComplete = 0;
|
||||
|
||||
// Convert physical endpoint number to register bit
|
||||
#define EP(endpoint) (1<<(endpoint))
|
||||
|
||||
// Convert physical to logical
|
||||
#define PHY_TO_LOG(endpoint) ((endpoint)>>1)
|
||||
|
||||
// Get endpoint direction
|
||||
#define IN_EP(endpoint) ((endpoint) & 1U ? true : false)
|
||||
#define OUT_EP(endpoint) ((endpoint) & 1U ? false : true)
|
||||
|
||||
#define BD_OWN_MASK (1<<7)
|
||||
#define BD_DATA01_MASK (1<<6)
|
||||
#define BD_KEEP_MASK (1<<5)
|
||||
#define BD_NINC_MASK (1<<4)
|
||||
#define BD_DTS_MASK (1<<3)
|
||||
#define BD_STALL_MASK (1<<2)
|
||||
|
||||
#define TX 1
|
||||
#define RX 0
|
||||
#define ODD 0
|
||||
#define EVEN 1
|
||||
// this macro waits a physical endpoint number
|
||||
#define EP_BDT_IDX(ep, dir, odd) (((ep * 4) + (2 * dir) + (1 * odd)))
|
||||
|
||||
#define SETUP_TOKEN 0x0D
|
||||
#define IN_TOKEN 0x09
|
||||
#define OUT_TOKEN 0x01
|
||||
#define TOK_PID(idx) ((bdt[idx].info >> 2) & 0x0F)
|
||||
|
||||
// for each endpt: 8 bytes
|
||||
typedef struct BDT {
|
||||
uint8_t info; // BD[0:7]
|
||||
uint8_t dummy; // RSVD: BD[8:15]
|
||||
uint16_t byte_count; // BD[16:32]
|
||||
uint32_t address; // Addr
|
||||
} BDT;
|
||||
|
||||
|
||||
// there are:
|
||||
// * 16 bidirectionnal endpt -> 32 physical endpt
|
||||
// * as there are ODD and EVEN buffer -> 32*2 bdt
|
||||
__attribute__((__aligned__(512))) BDT bdt[NUMBER_OF_PHYSICAL_ENDPOINTS * 2];
|
||||
uint8_t * endpoint_buffer[(NUMBER_OF_PHYSICAL_ENDPOINTS - 2) * 2];
|
||||
uint8_t * endpoint_buffer_iso[2*2];
|
||||
|
||||
static uint8_t set_addr = 0;
|
||||
static uint8_t addr = 0;
|
||||
|
||||
static uint32_t Data1 = 0x55555555;
|
||||
|
||||
static uint32_t frameNumber() {
|
||||
return((USB0->FRMNUML | (USB0->FRMNUMH << 8)) & 0x07FF);
|
||||
}
|
||||
|
||||
uint32_t USBHAL::endpointReadcore(uint8_t endpoint, uint8_t *buffer) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
USBHAL::USBHAL(void) {
|
||||
// Disable IRQ
|
||||
NVIC_DisableIRQ(USB0_IRQn);
|
||||
|
||||
#if defined(TARGET_K64F)
|
||||
MPU->CESR=0;
|
||||
#endif
|
||||
// fill in callback array
|
||||
epCallback[0] = &USBHAL::EP1_OUT_callback;
|
||||
epCallback[1] = &USBHAL::EP1_IN_callback;
|
||||
epCallback[2] = &USBHAL::EP2_OUT_callback;
|
||||
epCallback[3] = &USBHAL::EP2_IN_callback;
|
||||
epCallback[4] = &USBHAL::EP3_OUT_callback;
|
||||
epCallback[5] = &USBHAL::EP3_IN_callback;
|
||||
epCallback[6] = &USBHAL::EP4_OUT_callback;
|
||||
epCallback[7] = &USBHAL::EP4_IN_callback;
|
||||
epCallback[8] = &USBHAL::EP5_OUT_callback;
|
||||
epCallback[9] = &USBHAL::EP5_IN_callback;
|
||||
epCallback[10] = &USBHAL::EP6_OUT_callback;
|
||||
epCallback[11] = &USBHAL::EP6_IN_callback;
|
||||
epCallback[12] = &USBHAL::EP7_OUT_callback;
|
||||
epCallback[13] = &USBHAL::EP7_IN_callback;
|
||||
epCallback[14] = &USBHAL::EP8_OUT_callback;
|
||||
epCallback[15] = &USBHAL::EP8_IN_callback;
|
||||
epCallback[16] = &USBHAL::EP9_OUT_callback;
|
||||
epCallback[17] = &USBHAL::EP9_IN_callback;
|
||||
epCallback[18] = &USBHAL::EP10_OUT_callback;
|
||||
epCallback[19] = &USBHAL::EP10_IN_callback;
|
||||
epCallback[20] = &USBHAL::EP11_OUT_callback;
|
||||
epCallback[21] = &USBHAL::EP11_IN_callback;
|
||||
epCallback[22] = &USBHAL::EP12_OUT_callback;
|
||||
epCallback[23] = &USBHAL::EP12_IN_callback;
|
||||
epCallback[24] = &USBHAL::EP13_OUT_callback;
|
||||
epCallback[25] = &USBHAL::EP13_IN_callback;
|
||||
epCallback[26] = &USBHAL::EP14_OUT_callback;
|
||||
epCallback[27] = &USBHAL::EP14_IN_callback;
|
||||
epCallback[28] = &USBHAL::EP15_OUT_callback;
|
||||
epCallback[29] = &USBHAL::EP15_IN_callback;
|
||||
|
||||
#if defined(TARGET_KL43Z)
|
||||
// enable USBFS clock
|
||||
SIM->SCGC4 |= SIM_SCGC4_USBFS_MASK;
|
||||
|
||||
// enable the IRC48M clock
|
||||
USB0->CLK_RECOVER_IRC_EN |= USB_CLK_RECOVER_IRC_EN_IRC_EN_MASK;
|
||||
|
||||
// enable the USB clock recovery tuning
|
||||
USB0->CLK_RECOVER_CTRL |= USB_CLK_RECOVER_CTRL_CLOCK_RECOVER_EN_MASK;
|
||||
|
||||
// choose usb src clock
|
||||
SIM->SOPT2 |= SIM_SOPT2_USBSRC_MASK;
|
||||
#elif defined(TARGET_INFINITY)
|
||||
// USB clock source: FLL
|
||||
SIM->SOPT2 |= SIM_SOPT2_USBSRC_MASK;
|
||||
|
||||
// enable OTG clock
|
||||
SIM->SCGC4 |= SIM_SCGC4_USBOTG_MASK;
|
||||
#else
|
||||
// choose usb src as PLL
|
||||
SIM->SOPT2 &= ~SIM_SOPT2_PLLFLLSEL_MASK;
|
||||
SIM->SOPT2 |= (SIM_SOPT2_USBSRC_MASK | (1 << SIM_SOPT2_PLLFLLSEL_SHIFT));
|
||||
|
||||
// enable OTG clock
|
||||
SIM->SCGC4 |= SIM_SCGC4_USBOTG_MASK;
|
||||
#endif
|
||||
|
||||
// Attach IRQ
|
||||
instance = this;
|
||||
NVIC_SetVector(USB0_IRQn, (uint32_t)&_usbisr);
|
||||
NVIC_EnableIRQ(USB0_IRQn);
|
||||
|
||||
// USB Module Configuration
|
||||
// Reset USB Module
|
||||
USB0->USBTRC0 |= USB_USBTRC0_USBRESET_MASK;
|
||||
while(USB0->USBTRC0 & USB_USBTRC0_USBRESET_MASK);
|
||||
|
||||
// Set BDT Base Register
|
||||
USB0->BDTPAGE1 = (uint8_t)((uint32_t)bdt>>8);
|
||||
USB0->BDTPAGE2 = (uint8_t)((uint32_t)bdt>>16);
|
||||
USB0->BDTPAGE3 = (uint8_t)((uint32_t)bdt>>24);
|
||||
|
||||
// Clear interrupt flag
|
||||
USB0->ISTAT = 0xff;
|
||||
|
||||
// USB Interrupt Enablers
|
||||
USB0->INTEN |= USB_INTEN_TOKDNEEN_MASK |
|
||||
USB_INTEN_SOFTOKEN_MASK |
|
||||
USB_INTEN_ERROREN_MASK |
|
||||
USB_INTEN_USBRSTEN_MASK;
|
||||
|
||||
// Disable weak pull downs
|
||||
USB0->USBCTRL &= ~(USB_USBCTRL_PDE_MASK | USB_USBCTRL_SUSP_MASK);
|
||||
|
||||
USB0->USBTRC0 |= 0x40;
|
||||
}
|
||||
|
||||
USBHAL::~USBHAL(void) { }
|
||||
|
||||
void USBHAL::connect(void) {
|
||||
// enable USB
|
||||
USB0->CTL |= USB_CTL_USBENSOFEN_MASK;
|
||||
// Pull up enable
|
||||
USB0->CONTROL |= USB_CONTROL_DPPULLUPNONOTG_MASK;
|
||||
}
|
||||
|
||||
void USBHAL::disconnect(void) {
|
||||
// disable USB
|
||||
USB0->CTL &= ~USB_CTL_USBENSOFEN_MASK;
|
||||
// Pull up disable
|
||||
USB0->CONTROL &= ~USB_CONTROL_DPPULLUPNONOTG_MASK;
|
||||
|
||||
//Free buffers if required:
|
||||
for (int i = 0; i<(NUMBER_OF_PHYSICAL_ENDPOINTS - 2) * 2; i++) {
|
||||
free(endpoint_buffer[i]);
|
||||
endpoint_buffer[i] = NULL;
|
||||
}
|
||||
free(endpoint_buffer_iso[2]);
|
||||
endpoint_buffer_iso[2] = NULL;
|
||||
free(endpoint_buffer_iso[0]);
|
||||
endpoint_buffer_iso[0] = NULL;
|
||||
}
|
||||
|
||||
void USBHAL::configureDevice(void) {
|
||||
// not needed
|
||||
}
|
||||
|
||||
void USBHAL::unconfigureDevice(void) {
|
||||
// not needed
|
||||
}
|
||||
|
||||
void USBHAL::setAddress(uint8_t address) {
|
||||
// we don't set the address now otherwise the usb controller does not ack
|
||||
// we set a flag instead
|
||||
// see usbisr when an IN token is received
|
||||
set_addr = 1;
|
||||
addr = address;
|
||||
}
|
||||
|
||||
bool USBHAL::realiseEndpoint(uint8_t endpoint, uint32_t maxPacket, uint32_t flags) {
|
||||
uint32_t handshake_flag = 0;
|
||||
uint8_t * buf;
|
||||
|
||||
if (endpoint > NUMBER_OF_PHYSICAL_ENDPOINTS - 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t log_endpoint = PHY_TO_LOG(endpoint);
|
||||
|
||||
if ((flags & ISOCHRONOUS) == 0) {
|
||||
handshake_flag = USB_ENDPT_EPHSHK_MASK;
|
||||
if (IN_EP(endpoint)) {
|
||||
if (endpoint_buffer[EP_BDT_IDX(log_endpoint, TX, ODD)] == NULL)
|
||||
endpoint_buffer[EP_BDT_IDX(log_endpoint, TX, ODD)] = (uint8_t *) malloc (64*2);
|
||||
buf = &endpoint_buffer[EP_BDT_IDX(log_endpoint, TX, ODD)][0];
|
||||
} else {
|
||||
if (endpoint_buffer[EP_BDT_IDX(log_endpoint, RX, ODD)] == NULL)
|
||||
endpoint_buffer[EP_BDT_IDX(log_endpoint, RX, ODD)] = (uint8_t *) malloc (64*2);
|
||||
buf = &endpoint_buffer[EP_BDT_IDX(log_endpoint, RX, ODD)][0];
|
||||
}
|
||||
} else {
|
||||
if (IN_EP(endpoint)) {
|
||||
if (endpoint_buffer_iso[2] == NULL)
|
||||
endpoint_buffer_iso[2] = (uint8_t *) malloc (1023*2);
|
||||
buf = &endpoint_buffer_iso[2][0];
|
||||
} else {
|
||||
if (endpoint_buffer_iso[0] == NULL)
|
||||
endpoint_buffer_iso[0] = (uint8_t *) malloc (1023*2);
|
||||
buf = &endpoint_buffer_iso[0][0];
|
||||
}
|
||||
}
|
||||
|
||||
// IN endpt -> device to host (TX)
|
||||
if (IN_EP(endpoint)) {
|
||||
USB0->ENDPOINT[log_endpoint].ENDPT |= handshake_flag | // ep handshaking (not if iso endpoint)
|
||||
USB_ENDPT_EPTXEN_MASK; // en TX (IN) tran
|
||||
bdt[EP_BDT_IDX(log_endpoint, TX, ODD )].address = (uint32_t) buf;
|
||||
bdt[EP_BDT_IDX(log_endpoint, TX, EVEN)].address = 0;
|
||||
}
|
||||
// OUT endpt -> host to device (RX)
|
||||
else {
|
||||
USB0->ENDPOINT[log_endpoint].ENDPT |= handshake_flag | // ep handshaking (not if iso endpoint)
|
||||
USB_ENDPT_EPRXEN_MASK; // en RX (OUT) tran.
|
||||
bdt[EP_BDT_IDX(log_endpoint, RX, ODD )].byte_count = maxPacket;
|
||||
bdt[EP_BDT_IDX(log_endpoint, RX, ODD )].address = (uint32_t) buf;
|
||||
bdt[EP_BDT_IDX(log_endpoint, RX, ODD )].info = BD_OWN_MASK | BD_DTS_MASK;
|
||||
bdt[EP_BDT_IDX(log_endpoint, RX, EVEN)].info = 0;
|
||||
}
|
||||
|
||||
Data1 |= (1 << endpoint);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// read setup packet
|
||||
void USBHAL::EP0setup(uint8_t *buffer) {
|
||||
uint32_t sz;
|
||||
endpointReadResult(EP0OUT, buffer, &sz);
|
||||
}
|
||||
|
||||
void USBHAL::EP0readStage(void) {
|
||||
Data1 &= ~1UL; // set DATA0
|
||||
bdt[0].info = (BD_DTS_MASK | BD_OWN_MASK);
|
||||
}
|
||||
|
||||
void USBHAL::EP0read(void) {
|
||||
uint32_t idx = EP_BDT_IDX(PHY_TO_LOG(EP0OUT), RX, 0);
|
||||
bdt[idx].byte_count = MAX_PACKET_SIZE_EP0;
|
||||
}
|
||||
|
||||
uint32_t USBHAL::EP0getReadResult(uint8_t *buffer) {
|
||||
uint32_t sz;
|
||||
endpointReadResult(EP0OUT, buffer, &sz);
|
||||
return sz;
|
||||
}
|
||||
|
||||
void USBHAL::EP0write(uint8_t *buffer, uint32_t size) {
|
||||
endpointWrite(EP0IN, buffer, size);
|
||||
}
|
||||
|
||||
void USBHAL::EP0getWriteResult(void) {
|
||||
}
|
||||
|
||||
void USBHAL::EP0stall(void) {
|
||||
stallEndpoint(EP0OUT);
|
||||
}
|
||||
|
||||
EP_STATUS USBHAL::endpointRead(uint8_t endpoint, uint32_t maximumSize) {
|
||||
endpoint = PHY_TO_LOG(endpoint);
|
||||
uint32_t idx = EP_BDT_IDX(endpoint, RX, 0);
|
||||
bdt[idx].byte_count = maximumSize;
|
||||
return EP_PENDING;
|
||||
}
|
||||
|
||||
EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t * buffer, uint32_t *bytesRead) {
|
||||
uint32_t n, sz, idx, setup = 0;
|
||||
uint8_t not_iso;
|
||||
uint8_t * ep_buf;
|
||||
|
||||
uint32_t log_endpoint = PHY_TO_LOG(endpoint);
|
||||
|
||||
if (endpoint > NUMBER_OF_PHYSICAL_ENDPOINTS - 1) {
|
||||
return EP_INVALID;
|
||||
}
|
||||
|
||||
// if read on a IN endpoint -> error
|
||||
if (IN_EP(endpoint)) {
|
||||
return EP_INVALID;
|
||||
}
|
||||
|
||||
idx = EP_BDT_IDX(log_endpoint, RX, 0);
|
||||
sz = bdt[idx].byte_count;
|
||||
not_iso = USB0->ENDPOINT[log_endpoint].ENDPT & USB_ENDPT_EPHSHK_MASK;
|
||||
|
||||
//for isochronous endpoint, we don't wait an interrupt
|
||||
if ((log_endpoint != 0) && not_iso && !(epComplete & EP(endpoint))) {
|
||||
return EP_PENDING;
|
||||
}
|
||||
|
||||
if ((log_endpoint == 0) && (TOK_PID(idx) == SETUP_TOKEN)) {
|
||||
setup = 1;
|
||||
}
|
||||
|
||||
// non iso endpoint
|
||||
if (not_iso) {
|
||||
ep_buf = endpoint_buffer[idx];
|
||||
} else {
|
||||
ep_buf = endpoint_buffer_iso[0];
|
||||
}
|
||||
|
||||
for (n = 0; n < sz; n++) {
|
||||
buffer[n] = ep_buf[n];
|
||||
}
|
||||
|
||||
if (((Data1 >> endpoint) & 1) == ((bdt[idx].info >> 6) & 1)) {
|
||||
if (setup && (buffer[6] == 0)) // if no setup data stage,
|
||||
Data1 &= ~1UL; // set DATA0
|
||||
else
|
||||
Data1 ^= (1 << endpoint);
|
||||
}
|
||||
|
||||
if (((Data1 >> endpoint) & 1)) {
|
||||
bdt[idx].info = BD_DTS_MASK | BD_DATA01_MASK | BD_OWN_MASK;
|
||||
}
|
||||
else {
|
||||
bdt[idx].info = BD_DTS_MASK | BD_OWN_MASK;
|
||||
}
|
||||
|
||||
USB0->CTL &= ~USB_CTL_TXSUSPENDTOKENBUSY_MASK;
|
||||
*bytesRead = sz;
|
||||
|
||||
epComplete &= ~EP(endpoint);
|
||||
return EP_COMPLETED;
|
||||
}
|
||||
|
||||
EP_STATUS USBHAL::endpointWrite(uint8_t endpoint, uint8_t *data, uint32_t size) {
|
||||
uint32_t idx, n;
|
||||
uint8_t * ep_buf;
|
||||
|
||||
if (endpoint > NUMBER_OF_PHYSICAL_ENDPOINTS - 1) {
|
||||
return EP_INVALID;
|
||||
}
|
||||
|
||||
// if write on a OUT endpoint -> error
|
||||
if (OUT_EP(endpoint)) {
|
||||
return EP_INVALID;
|
||||
}
|
||||
|
||||
idx = EP_BDT_IDX(PHY_TO_LOG(endpoint), TX, 0);
|
||||
bdt[idx].byte_count = size;
|
||||
|
||||
|
||||
// non iso endpoint
|
||||
if (USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT & USB_ENDPT_EPHSHK_MASK) {
|
||||
ep_buf = endpoint_buffer[idx];
|
||||
} else {
|
||||
ep_buf = endpoint_buffer_iso[2];
|
||||
}
|
||||
|
||||
for (n = 0; n < size; n++) {
|
||||
ep_buf[n] = data[n];
|
||||
}
|
||||
|
||||
if ((Data1 >> endpoint) & 1) {
|
||||
bdt[idx].info = BD_OWN_MASK | BD_DTS_MASK;
|
||||
} else {
|
||||
bdt[idx].info = BD_OWN_MASK | BD_DTS_MASK | BD_DATA01_MASK;
|
||||
}
|
||||
|
||||
Data1 ^= (1 << endpoint);
|
||||
|
||||
return EP_PENDING;
|
||||
}
|
||||
|
||||
EP_STATUS USBHAL::endpointWriteResult(uint8_t endpoint) {
|
||||
if (epComplete & EP(endpoint)) {
|
||||
epComplete &= ~EP(endpoint);
|
||||
return EP_COMPLETED;
|
||||
}
|
||||
|
||||
return EP_PENDING;
|
||||
}
|
||||
|
||||
void USBHAL::stallEndpoint(uint8_t endpoint) {
|
||||
USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT |= USB_ENDPT_EPSTALL_MASK;
|
||||
}
|
||||
|
||||
void USBHAL::unstallEndpoint(uint8_t endpoint) {
|
||||
USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT &= ~USB_ENDPT_EPSTALL_MASK;
|
||||
}
|
||||
|
||||
bool USBHAL::getEndpointStallState(uint8_t endpoint) {
|
||||
uint8_t stall = (USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT & USB_ENDPT_EPSTALL_MASK);
|
||||
return (stall) ? true : false;
|
||||
}
|
||||
|
||||
void USBHAL::remoteWakeup(void) {
|
||||
// [TODO]
|
||||
}
|
||||
|
||||
|
||||
void USBHAL::_usbisr(void) {
|
||||
instance->usbisr();
|
||||
}
|
||||
|
||||
|
||||
void USBHAL::usbisr(void) {
|
||||
uint8_t i;
|
||||
uint8_t istat = USB0->ISTAT;
|
||||
|
||||
// reset interrupt
|
||||
if (istat & USB_ISTAT_USBRST_MASK) {
|
||||
// disable all endpt
|
||||
for(i = 0; i < 16; i++) {
|
||||
USB0->ENDPOINT[i].ENDPT = 0x00;
|
||||
}
|
||||
|
||||
// enable control endpoint
|
||||
realiseEndpoint(EP0OUT, MAX_PACKET_SIZE_EP0, 0);
|
||||
realiseEndpoint(EP0IN, MAX_PACKET_SIZE_EP0, 0);
|
||||
|
||||
Data1 = 0x55555555;
|
||||
USB0->CTL |= USB_CTL_ODDRST_MASK;
|
||||
|
||||
USB0->ISTAT = 0xFF; // clear all interrupt status flags
|
||||
USB0->ERRSTAT = 0xFF; // clear all error flags
|
||||
USB0->ERREN = 0xFF; // enable error interrupt sources
|
||||
USB0->ADDR = 0x00; // set default address
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// resume interrupt
|
||||
if (istat & USB_ISTAT_RESUME_MASK) {
|
||||
USB0->ISTAT = USB_ISTAT_RESUME_MASK;
|
||||
}
|
||||
|
||||
// SOF interrupt
|
||||
if (istat & USB_ISTAT_SOFTOK_MASK) {
|
||||
USB0->ISTAT = USB_ISTAT_SOFTOK_MASK;
|
||||
// SOF event, read frame number
|
||||
SOF(frameNumber());
|
||||
}
|
||||
|
||||
// stall interrupt
|
||||
if (istat & 1<<7) {
|
||||
if (USB0->ENDPOINT[0].ENDPT & USB_ENDPT_EPSTALL_MASK)
|
||||
USB0->ENDPOINT[0].ENDPT &= ~USB_ENDPT_EPSTALL_MASK;
|
||||
USB0->ISTAT |= USB_ISTAT_STALL_MASK;
|
||||
}
|
||||
|
||||
// token interrupt
|
||||
if (istat & 1<<3) {
|
||||
uint32_t num = (USB0->STAT >> 4) & 0x0F;
|
||||
uint32_t dir = (USB0->STAT >> 3) & 0x01;
|
||||
uint32_t ev_odd = (USB0->STAT >> 2) & 0x01;
|
||||
|
||||
// setup packet
|
||||
if ((num == 0) && (TOK_PID((EP_BDT_IDX(num, dir, ev_odd))) == SETUP_TOKEN)) {
|
||||
Data1 &= ~0x02;
|
||||
bdt[EP_BDT_IDX(0, TX, EVEN)].info &= ~BD_OWN_MASK;
|
||||
bdt[EP_BDT_IDX(0, TX, ODD)].info &= ~BD_OWN_MASK;
|
||||
|
||||
// EP0 SETUP event (SETUP data received)
|
||||
EP0setupCallback();
|
||||
|
||||
} else {
|
||||
// OUT packet
|
||||
if (TOK_PID((EP_BDT_IDX(num, dir, ev_odd))) == OUT_TOKEN) {
|
||||
if (num == 0)
|
||||
EP0out();
|
||||
else {
|
||||
epComplete |= (1 << EP(num));
|
||||
if ((instance->*(epCallback[EP(num) - 2]))()) {
|
||||
epComplete &= ~(1 << EP(num));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// IN packet
|
||||
if (TOK_PID((EP_BDT_IDX(num, dir, ev_odd))) == IN_TOKEN) {
|
||||
if (num == 0) {
|
||||
EP0in();
|
||||
if (set_addr == 1) {
|
||||
USB0->ADDR = addr & 0x7F;
|
||||
set_addr = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
epComplete |= (1 << (EP(num) + 1));
|
||||
if ((instance->*(epCallback[EP(num) + 1 - 2]))()) {
|
||||
epComplete &= ~(1 << (EP(num) + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
USB0->ISTAT = USB_ISTAT_TOKDNE_MASK;
|
||||
}
|
||||
|
||||
// sleep interrupt
|
||||
if (istat & 1<<4) {
|
||||
USB0->ISTAT |= USB_ISTAT_SLEEP_MASK;
|
||||
}
|
||||
|
||||
// error interrupt
|
||||
if (istat & USB_ISTAT_ERROR_MASK) {
|
||||
USB0->ERRSTAT = 0xFF;
|
||||
USB0->ISTAT |= USB_ISTAT_ERROR_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
@ -1,55 +0,0 @@
|
||||
/* mbed Microcontroller Library
|
||||
* CMSIS-style functionality to support dynamic vectors
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2011 ARM Limited. All rights reserved.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of ARM Limited nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "cmsis_nvic.h"
|
||||
|
||||
#define NVIC_RAM_VECTOR_ADDRESS (0x1FFFE000) // Vectors positioned at start of RAM
|
||||
#define NVIC_FLASH_VECTOR_ADDRESS (0x1000) // Initial vector position in flash
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
||||
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t i;
|
||||
|
||||
// Copy and switch to dynamic vectors if the first time called
|
||||
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
|
||||
uint32_t *old_vectors = vectors;
|
||||
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
for (i=0; i<NVIC_NUM_VECTORS; i++) {
|
||||
vectors[i] = old_vectors[i];
|
||||
}
|
||||
SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
|
||||
}
|
||||
vectors[IRQn + 16] = vector;
|
||||
}
|
||||
|
||||
uint32_t NVIC_GetVector(IRQn_Type IRQn) {
|
||||
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||
return vectors[IRQn + 16];
|
||||
}
|
@ -1,156 +0,0 @@
|
||||
/*
|
||||
* Linker script for Massdrop Infinity
|
||||
* Infinity has bootloader in top 4KB sector of flash and app should be placed after the area.
|
||||
*
|
||||
* based on mbed.org K20 ARM GCC linker script file: MK20D5.ld
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
/* Infinity blootloader uses 4KB */
|
||||
FLASH (rx) : ORIGIN = 4K, LENGTH = 128K - 4K
|
||||
RAM (rwx) : ORIGIN = 0x1FFFE0F8, LENGTH = 16K - 0xF8
|
||||
}
|
||||
|
||||
/* Linker script to place sections and symbol values. Should be used together
|
||||
* with other linker script that defines memory regions FLASH and RAM.
|
||||
* It references following symbols, which must be defined in code:
|
||||
* _reset_init : Entry of reset handler
|
||||
*
|
||||
* It defines following symbols, which code can use without definition:
|
||||
* __exidx_start
|
||||
* __exidx_end
|
||||
* __etext
|
||||
* __data_start__
|
||||
* __preinit_array_start
|
||||
* __preinit_array_end
|
||||
* __init_array_start
|
||||
* __init_array_end
|
||||
* __fini_array_start
|
||||
* __fini_array_end
|
||||
* __data_end__
|
||||
* __bss_start__
|
||||
* __bss_end__
|
||||
* __end__
|
||||
* end
|
||||
* __HeapLimit
|
||||
* __StackLimit
|
||||
* __StackTop
|
||||
* __stack
|
||||
*/
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
__vector_table = .;
|
||||
KEEP(*(.isr_vector))
|
||||
*(.text.Reset_Handler)
|
||||
*(.text.System_Init)
|
||||
. = ALIGN(4);
|
||||
|
||||
*(.text*)
|
||||
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* .ctors */
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
|
||||
/* .dtors */
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
|
||||
*(.rodata*)
|
||||
|
||||
KEEP(*(.eh_frame*))
|
||||
} > FLASH
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > FLASH
|
||||
|
||||
__exidx_start = .;
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
} > FLASH
|
||||
__exidx_end = .;
|
||||
|
||||
__etext = .;
|
||||
|
||||
.data : AT (__etext)
|
||||
{
|
||||
__data_start__ = .;
|
||||
*(vtable)
|
||||
*(.data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* All data end */
|
||||
__data_end__ = .;
|
||||
|
||||
} > RAM
|
||||
|
||||
.bss :
|
||||
{
|
||||
__bss_start__ = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
__bss_end__ = .;
|
||||
} > RAM
|
||||
|
||||
.heap :
|
||||
{
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
*(.heap*)
|
||||
__HeapLimit = .;
|
||||
} > RAM
|
||||
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of stack sections, and assign
|
||||
* values to stack symbols later */
|
||||
.stack_dummy :
|
||||
{
|
||||
*(.stack)
|
||||
} > RAM
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
PROVIDE(__stack = __StackTop);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
||||
}
|
@ -1,259 +0,0 @@
|
||||
/* File: startup_MK20D5.s
|
||||
* Purpose: startup file for Cortex-M4 devices. Should use with
|
||||
* GCC for ARM Embedded Processors
|
||||
* Version: V1.3
|
||||
* Date: 08 Feb 2012
|
||||
*
|
||||
* Copyright (c) 2012, ARM Limited
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the ARM Limited nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ARM LIMITED BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
.syntax unified
|
||||
.arch armv7-m
|
||||
|
||||
.section .stack
|
||||
.align 3
|
||||
#ifdef __STACK_SIZE
|
||||
.equ Stack_Size, __STACK_SIZE
|
||||
#else
|
||||
.equ Stack_Size, 0x400
|
||||
#endif
|
||||
.globl __StackTop
|
||||
.globl __StackLimit
|
||||
__StackLimit:
|
||||
.space Stack_Size
|
||||
.size __StackLimit, . - __StackLimit
|
||||
__StackTop:
|
||||
.size __StackTop, . - __StackTop
|
||||
|
||||
.section .heap
|
||||
.align 3
|
||||
#ifdef __HEAP_SIZE
|
||||
.equ Heap_Size, __HEAP_SIZE
|
||||
#else
|
||||
.equ Heap_Size, 0xC00
|
||||
#endif
|
||||
.globl __HeapBase
|
||||
.globl __HeapLimit
|
||||
__HeapBase:
|
||||
.if Heap_Size
|
||||
.space Heap_Size
|
||||
.endif
|
||||
.size __HeapBase, . - __HeapBase
|
||||
__HeapLimit:
|
||||
.size __HeapLimit, . - __HeapLimit
|
||||
|
||||
.section .isr_vector
|
||||
.align 2
|
||||
.globl __isr_vector
|
||||
__isr_vector:
|
||||
.long __StackTop /* Top of Stack */
|
||||
.long Reset_Handler /* Reset Handler */
|
||||
.long NMI_Handler /* NMI Handler */
|
||||
.long HardFault_Handler /* Hard Fault Handler */
|
||||
.long MemManage_Handler /* MPU Fault Handler */
|
||||
.long BusFault_Handler /* Bus Fault Handler */
|
||||
.long UsageFault_Handler /* Usage Fault Handler */
|
||||
.long 0 /* Reserved */
|
||||
.long 0 /* Reserved */
|
||||
.long 0 /* Reserved */
|
||||
.long 0 /* Reserved */
|
||||
.long SVC_Handler /* SVCall Handler */
|
||||
.long DebugMon_Handler /* Debug Monitor Handler */
|
||||
.long 0 /* Reserved */
|
||||
.long PendSV_Handler /* PendSV Handler */
|
||||
.long SysTick_Handler /* SysTick Handler */
|
||||
|
||||
/* External interrupts */
|
||||
.long DMA0_IRQHandler /* 0: Watchdog Timer */
|
||||
.long DMA1_IRQHandler /* 1: Real Time Clock */
|
||||
.long DMA2_IRQHandler /* 2: Timer0 / Timer1 */
|
||||
.long DMA3_IRQHandler /* 3: Timer2 / Timer3 */
|
||||
.long DMA_Error_IRQHandler /* 4: MCIa */
|
||||
.long 0 /* 5: MCIb */
|
||||
.long FTFL_IRQHandler /* 6: UART0 - DUT FPGA */
|
||||
.long Read_Collision_IRQHandler /* 7: UART1 - DUT FPGA */
|
||||
.long LVD_LVW_IRQHandler /* 8: UART2 - DUT FPGA */
|
||||
.long LLW_IRQHandler /* 9: UART4 - not connected */
|
||||
.long Watchdog_IRQHandler /* 10: AACI / AC97 */
|
||||
.long I2C0_IRQHandler /* 11: CLCD Combined Interrupt */
|
||||
.long SPI0_IRQHandler /* 12: Ethernet */
|
||||
.long I2S0_Tx_IRQHandler /* 13: USB Device */
|
||||
.long I2S0_Rx_IRQHandler /* 14: USB Host Controller */
|
||||
.long UART0_LON_IRQHandler /* 15: Character LCD */
|
||||
.long UART0_RX_TX_IRQHandler /* 16: Flexray */
|
||||
.long UART0_ERR_IRQHandler /* 17: CAN */
|
||||
.long UART1_RX_TX_IRQHandler /* 18: LIN */
|
||||
.long UART1_ERR_IRQHandler /* 19: I2C ADC/DAC */
|
||||
.long UART2_RX_TX_IRQHandler /* 20: Reserved */
|
||||
.long UART2_ERR_IRQHandler /* 21: Reserved */
|
||||
.long ADC0_IRQHandler /* 22: Reserved */
|
||||
.long CMP0_IRQHandler /* 23: Reserved */
|
||||
.long CMP1_IRQHandler /* 24: Reserved */
|
||||
.long FTM0_IRQHandler /* 25: Reserved */
|
||||
.long FTM1_IRQHandler /* 26: Reserved */
|
||||
.long CMT_IRQHandler /* 27: Reserved */
|
||||
.long RTC_IRQHandler /* 28: Reserved - CPU FPGA CLCD */
|
||||
.long RTC_Seconds_IRQHandler /* 29: Reserved - CPU FPGA */
|
||||
.long PIT0_IRQHandler /* 30: UART3 - CPU FPGA */
|
||||
.long PIT1_IRQHandler /* 31: SPI Touchscreen - CPU FPGA */
|
||||
.long PIT2_IRQHandler
|
||||
.long PIT3_IRQHandler
|
||||
.long PDB0_IRQHandler
|
||||
.long USB0_IRQHandler
|
||||
.long USBDCD_IRQHandler
|
||||
.long TSI0_IRQHandler
|
||||
.long MCG_IRQHandler
|
||||
.long LPTimer_IRQHandler
|
||||
.long PORTA_IRQHandler
|
||||
.long PORTB_IRQHandler
|
||||
.long PORTC_IRQHandler
|
||||
.long PORTD_IRQHandler
|
||||
.long PORTE_IRQHandler
|
||||
.long SWI_IRQHandler
|
||||
.size __isr_vector, . - __isr_vector
|
||||
|
||||
.section .text.Reset_Handler
|
||||
.thumb
|
||||
.thumb_func
|
||||
.align 2
|
||||
.globl Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
/* Loop to copy data from read only memory to RAM. The ranges
|
||||
* of copy from/to are specified by following symbols evaluated in
|
||||
* linker script.
|
||||
* __etext: End of code section, i.e., begin of data sections to copy from.
|
||||
* __data_start__/__data_end__: RAM address range that data should be
|
||||
* copied to. Both must be aligned to 4 bytes boundary. */
|
||||
ldr r0, =SystemInit
|
||||
blx r0
|
||||
|
||||
ldr r1, =__etext
|
||||
ldr r2, =__data_start__
|
||||
ldr r3, =__data_end__
|
||||
|
||||
.Lflash_to_ram_loop:
|
||||
cmp r2, r3
|
||||
ittt lt
|
||||
ldrlt r0, [r1], #4
|
||||
strlt r0, [r2], #4
|
||||
blt .Lflash_to_ram_loop
|
||||
|
||||
.Lflash_to_ram_loop_end:
|
||||
|
||||
ldr r0, =_start
|
||||
bx r0
|
||||
.pool
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
.text
|
||||
/* Macro to define default handlers. Default handler
|
||||
* will be weak symbol and just dead loops. They can be
|
||||
* overwritten by other handlers */
|
||||
.macro def_default_handler handler_name
|
||||
.align 1
|
||||
.thumb_func
|
||||
.weak \handler_name
|
||||
.type \handler_name, %function
|
||||
\handler_name :
|
||||
b .
|
||||
.size \handler_name, . - \handler_name
|
||||
.endm
|
||||
|
||||
def_default_handler NMI_Handler
|
||||
def_default_handler HardFault_Handler
|
||||
def_default_handler MemManage_Handler
|
||||
def_default_handler BusFault_Handler
|
||||
def_default_handler UsageFault_Handler
|
||||
def_default_handler SVC_Handler
|
||||
def_default_handler DebugMon_Handler
|
||||
def_default_handler PendSV_Handler
|
||||
def_default_handler SysTick_Handler
|
||||
def_default_handler Default_Handler
|
||||
|
||||
.macro def_irq_default_handler handler_name
|
||||
.weak \handler_name
|
||||
.set \handler_name, Default_Handler
|
||||
.endm
|
||||
|
||||
def_irq_default_handler DMA0_IRQHandler
|
||||
def_irq_default_handler DMA1_IRQHandler
|
||||
def_irq_default_handler DMA2_IRQHandler
|
||||
def_irq_default_handler DMA3_IRQHandler
|
||||
def_irq_default_handler DMA_Error_IRQHandler
|
||||
def_irq_default_handler FTFL_IRQHandler
|
||||
def_irq_default_handler Read_Collision_IRQHandler
|
||||
def_irq_default_handler LVD_LVW_IRQHandler
|
||||
def_irq_default_handler LLW_IRQHandler
|
||||
def_irq_default_handler Watchdog_IRQHandler
|
||||
def_irq_default_handler I2C0_IRQHandler
|
||||
def_irq_default_handler SPI0_IRQHandler
|
||||
def_irq_default_handler I2S0_Tx_IRQHandler
|
||||
def_irq_default_handler I2S0_Rx_IRQHandler
|
||||
def_irq_default_handler UART0_LON_IRQHandler
|
||||
def_irq_default_handler UART0_RX_TX_IRQHandler
|
||||
def_irq_default_handler UART0_ERR_IRQHandler
|
||||
def_irq_default_handler UART1_RX_TX_IRQHandler
|
||||
def_irq_default_handler UART1_ERR_IRQHandler
|
||||
def_irq_default_handler UART2_RX_TX_IRQHandler
|
||||
def_irq_default_handler UART2_ERR_IRQHandler
|
||||
def_irq_default_handler ADC0_IRQHandler
|
||||
def_irq_default_handler CMP0_IRQHandler
|
||||
def_irq_default_handler CMP1_IRQHandler
|
||||
def_irq_default_handler FTM0_IRQHandler
|
||||
def_irq_default_handler FTM1_IRQHandler
|
||||
def_irq_default_handler CMT_IRQHandler
|
||||
def_irq_default_handler RTC_IRQHandler
|
||||
def_irq_default_handler RTC_Seconds_IRQHandler
|
||||
def_irq_default_handler PIT0_IRQHandler
|
||||
def_irq_default_handler PIT1_IRQHandler
|
||||
def_irq_default_handler PIT2_IRQHandler
|
||||
def_irq_default_handler PIT3_IRQHandler
|
||||
def_irq_default_handler PDB0_IRQHandler
|
||||
def_irq_default_handler USB0_IRQHandler
|
||||
def_irq_default_handler USBDCD_IRQHandler
|
||||
def_irq_default_handler TSI0_IRQHandler
|
||||
def_irq_default_handler MCG_IRQHandler
|
||||
def_irq_default_handler LPTimer_IRQHandler
|
||||
def_irq_default_handler PORTA_IRQHandler
|
||||
def_irq_default_handler PORTB_IRQHandler
|
||||
def_irq_default_handler PORTC_IRQHandler
|
||||
def_irq_default_handler PORTD_IRQHandler
|
||||
def_irq_default_handler PORTE_IRQHandler
|
||||
def_irq_default_handler SWI_IRQHandler
|
||||
def_irq_default_handler DEF_IRQHandler
|
||||
|
||||
/* Flash protection region, placed at 0x400 */
|
||||
.text
|
||||
.thumb
|
||||
.align 2
|
||||
.section .kinetis_flash_config_field,"a",%progbits
|
||||
kinetis_flash_config:
|
||||
.long 0xffffffff
|
||||
.long 0xffffffff
|
||||
.long 0xffffffff
|
||||
.long 0xfffffffe
|
||||
|
||||
.end
|
@ -1,299 +0,0 @@
|
||||
/*
|
||||
** ###################################################################
|
||||
** Compilers: ARM Compiler
|
||||
** Freescale C/C++ for Embedded ARM
|
||||
** GNU C Compiler
|
||||
** IAR ANSI C/C++ Compiler for ARM
|
||||
**
|
||||
** Reference manuals: K20P64M50SF0RM Rev. 1, Oct 2011
|
||||
** K20P32M50SF0RM Rev. 1, Oct 2011
|
||||
** K20P48M50SF0RM Rev. 1, Oct 2011
|
||||
**
|
||||
** Version: rev. 1.0, 2011-12-15
|
||||
**
|
||||
** Abstract:
|
||||
** Provides a system configuration function and a global variable that
|
||||
** contains the system frequency. It configures the device and initializes
|
||||
** the oscillator (PLL) that is part of the microcontroller device.
|
||||
**
|
||||
** Copyright: 2011 Freescale Semiconductor, Inc. All Rights Reserved.
|
||||
**
|
||||
** http: www.freescale.com
|
||||
** mail: support@freescale.com
|
||||
**
|
||||
** Revisions:
|
||||
** - rev. 1.0 (2011-12-15)
|
||||
** Initial version
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file MK20D5
|
||||
* @version 1.0
|
||||
* @date 2011-12-15
|
||||
* @brief Device specific configuration file for MK20D5 (implementation file)
|
||||
*
|
||||
* Provides a system configuration function and a global variable that contains
|
||||
* the system frequency. It configures the device and initializes the oscillator
|
||||
* (PLL) that is part of the microcontroller device.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "MK20D5.h"
|
||||
|
||||
#define DISABLE_WDOG 1
|
||||
|
||||
#define CLOCK_SETUP 3
|
||||
/* Predefined clock setups
|
||||
0 ... Multipurpose Clock Generator (MCG) in FLL Engaged Internal (FEI) mode
|
||||
Reference clock source for MCG module is the slow internal clock source 32.768kHz
|
||||
Core clock = 41.94MHz, BusClock = 41.94MHz
|
||||
1 ... Multipurpose Clock Generator (MCG) in PLL Engaged External (PEE) mode
|
||||
Reference clock source for MCG module is an external crystal 8MHz
|
||||
Core clock = 48MHz, BusClock = 48MHz
|
||||
2 ... Multipurpose Clock Generator (MCG) in Bypassed Low Power External (BLPE) mode
|
||||
Core clock/Bus clock derived directly from an external crystal 8MHz with no multiplication
|
||||
Core clock = 8MHz, BusClock = 8MHz
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Define clock source values
|
||||
*----------------------------------------------------------------------------*/
|
||||
#if (CLOCK_SETUP == 0)
|
||||
#define CPU_XTAL_CLK_HZ 8000000u /* Value of the external crystal or oscillator clock frequency in Hz */
|
||||
#define CPU_XTAL32k_CLK_HZ 32768u /* Value of the external 32k crystal or oscillator clock frequency in Hz */
|
||||
#define CPU_INT_SLOW_CLK_HZ 32768u /* Value of the slow internal oscillator clock frequency in Hz */
|
||||
#define CPU_INT_FAST_CLK_HZ 4000000u /* Value of the fast internal oscillator clock frequency in Hz */
|
||||
#define DEFAULT_SYSTEM_CLOCK 41943040u /* Default System clock value */
|
||||
#elif (CLOCK_SETUP == 1)
|
||||
#define CPU_XTAL_CLK_HZ 8000000u /* Value of the external crystal or oscillator clock frequency in Hz */
|
||||
#define CPU_XTAL32k_CLK_HZ 32768u /* Value of the external 32k crystal or oscillator clock frequency in Hz */
|
||||
#define CPU_INT_SLOW_CLK_HZ 32768u /* Value of the slow internal oscillator clock frequency in Hz */
|
||||
#define CPU_INT_FAST_CLK_HZ 4000000u /* Value of the fast internal oscillator clock frequency in Hz */
|
||||
#define DEFAULT_SYSTEM_CLOCK 48000000u /* Default System clock value */
|
||||
#elif (CLOCK_SETUP == 2)
|
||||
#define CPU_XTAL_CLK_HZ 8000000u /* Value of the external crystal or oscillator clock frequency in Hz */
|
||||
#define CPU_XTAL32k_CLK_HZ 32768u /* Value of the external 32k crystal or oscillator clock frequency in Hz */
|
||||
#define CPU_INT_SLOW_CLK_HZ 32768u /* Value of the slow internal oscillator clock frequency in Hz */
|
||||
#define CPU_INT_FAST_CLK_HZ 4000000u /* Value of the fast internal oscillator clock frequency in Hz */
|
||||
#define DEFAULT_SYSTEM_CLOCK 8000000u /* Default System clock value */
|
||||
#elif (CLOCK_SETUP == 3)
|
||||
/* for Infinity */
|
||||
#define CPU_XTAL_CLK_HZ 8000000u
|
||||
#define CPU_XTAL32k_CLK_HZ 32768u
|
||||
#define CPU_INT_SLOW_CLK_HZ 32768u
|
||||
#define CPU_INT_FAST_CLK_HZ 4000000u
|
||||
#define DEFAULT_SYSTEM_CLOCK 48000000u
|
||||
#endif
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Core clock
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
uint32_t SystemCoreClock = DEFAULT_SYSTEM_CLOCK;
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SystemInit()
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
void SystemInit (void) {
|
||||
#if (DISABLE_WDOG)
|
||||
/* Disable the WDOG module */
|
||||
/* WDOG_UNLOCK: WDOGUNLOCK=0xC520 */
|
||||
WDOG->UNLOCK = (uint16_t)0xC520u; /* Key 1 */
|
||||
/* WDOG_UNLOCK : WDOGUNLOCK=0xD928 */
|
||||
WDOG->UNLOCK = (uint16_t)0xD928u; /* Key 2 */
|
||||
/* WDOG_STCTRLH: ??=0,DISTESTWDOG=0,BYTESEL=0,TESTSEL=0,TESTWDOG=0,??=0,STNDBYEN=1,WAITEN=1,STOPEN=1,DBGEN=0,ALLOWUPDATE=1,WINEN=0,IRQRSTEN=0,CLKSRC=1,WDOGEN=0 */
|
||||
WDOG->STCTRLH = (uint16_t)0x01D2u;
|
||||
#endif /* (DISABLE_WDOG) */
|
||||
#if (CLOCK_SETUP == 0)
|
||||
/* SIM->CLKDIV1: OUTDIV1=0,OUTDIV2=0,OUTDIV3=1,OUTDIV4=1,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
|
||||
SIM->CLKDIV1 = (uint32_t)0x00110000u; /* Update system prescalers */
|
||||
/* Switch to FEI Mode */
|
||||
/* MCG->C1: CLKS=0,FRDIV=0,IREFS=1,IRCLKEN=1,IREFSTEN=0 */
|
||||
MCG->C1 = (uint8_t)0x06u;
|
||||
/* MCG->C2: ??=0,??=0,RANGE0=0,HGO=0,EREFS=0,LP=0,IRCS=0 */
|
||||
MCG->C2 = (uint8_t)0x00u;
|
||||
/* MCG_C4: DMX32=0,DRST_DRS=1 */
|
||||
MCG->C4 = (uint8_t)((MCG->C4 & (uint8_t)~(uint8_t)0xC0u) | (uint8_t)0x20u);
|
||||
/* MCG->C5: ??=0,PLLCLKEN=0,PLLSTEN=0,PRDIV0=0 */
|
||||
MCG->C5 = (uint8_t)0x00u;
|
||||
/* MCG->C6: LOLIE=0,PLLS=0,CME=0,VDIV0=0 */
|
||||
MCG->C6 = (uint8_t)0x00u;
|
||||
while((MCG->S & MCG_S_IREFST_MASK) == 0u) { /* Check that the source of the FLL reference clock is the internal reference clock. */
|
||||
}
|
||||
while((MCG->S & 0x0Cu) != 0x00u) { /* Wait until output of the FLL is selected */
|
||||
}
|
||||
#elif (CLOCK_SETUP == 1)
|
||||
/* SIM->CLKDIV1: OUTDIV1=0,OUTDIV2=0,OUTDIV3=1,OUTDIV4=1,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
|
||||
SIM->CLKDIV1 = (uint32_t)0x00110000u; /* Update system prescalers */
|
||||
/* Switch to FBE Mode */
|
||||
/* OSC0->CR: ERCLKEN=0,??=0,EREFSTEN=0,??=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
|
||||
OSC0->CR = (uint8_t)0x00u;
|
||||
/* MCG->C7: OSCSEL=0 */
|
||||
MCG->C7 = (uint8_t)0x00u;
|
||||
/* MCG->C2: ??=0,??=0,RANGE0=2,HGO=0,EREFS=1,LP=0,IRCS=0 */
|
||||
MCG->C2 = (uint8_t)0x24u;
|
||||
/* MCG->C1: CLKS=2,FRDIV=3,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
|
||||
MCG->C1 = (uint8_t)0x9Au;
|
||||
/* MCG->C4: DMX32=0,DRST_DRS=0 */
|
||||
MCG->C4 &= (uint8_t)~(uint8_t)0xE0u;
|
||||
/* MCG->C5: ??=0,PLLCLKEN=0,PLLSTEN=0,PRDIV0=3 */
|
||||
MCG->C5 = (uint8_t)0x03u;
|
||||
/* MCG->C6: LOLIE=0,PLLS=0,CME=0,VDIV0=0 */
|
||||
MCG->C6 = (uint8_t)0x00u;
|
||||
while((MCG->S & MCG_S_OSCINIT0_MASK) == 0u) { /* Check that the oscillator is running */
|
||||
}
|
||||
#if 0 /* ARM: THIS CHECK IS REMOVED DUE TO BUG WITH SLOW IRC IN REV. 1.0 */
|
||||
while((MCG->S & MCG_S_IREFST_MASK) != 0u) { /* Check that the source of the FLL reference clock is the external reference clock. */
|
||||
}
|
||||
#endif
|
||||
while((MCG->S & 0x0Cu) != 0x08u) { /* Wait until external reference clock is selected as MCG output */
|
||||
}
|
||||
/* Switch to PBE Mode */
|
||||
/* MCG_C5: ??=0,PLLCLKEN=0,PLLSTEN=0,PRDIV0=3 */
|
||||
MCG->C5 = (uint8_t)0x03u;
|
||||
/* MCG->C6: LOLIE=0,PLLS=1,CME=0,VDIV0=0 */
|
||||
MCG->C6 = (uint8_t)0x40u;
|
||||
while((MCG->S & MCG_S_PLLST_MASK) == 0u) { /* Wait until the source of the PLLS clock has switched to the PLL */
|
||||
}
|
||||
while((MCG->S & MCG_S_LOCK0_MASK) == 0u) { /* Wait until locked */
|
||||
}
|
||||
/* Switch to PEE Mode */
|
||||
/* MCG->C1: CLKS=0,FRDIV=3,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
|
||||
MCG->C1 = (uint8_t)0x1Au;
|
||||
while((MCG->S & 0x0Cu) != 0x0Cu) { /* Wait until output of the PLL is selected */
|
||||
}
|
||||
while((MCG->S & MCG_S_LOCK0_MASK) == 0u) { /* Wait until locked */
|
||||
}
|
||||
#elif (CLOCK_SETUP == 2)
|
||||
/* SIM_CLKDIV1: OUTDIV1=0,OUTDIV2=0,OUTDIV3=1,OUTDIV4=1,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
|
||||
SIM->CLKDIV1 = (uint32_t)0x00110000u; /* Update system prescalers */
|
||||
/* Switch to FBE Mode */
|
||||
/* OSC0->CR: ERCLKEN=0,??=0,EREFSTEN=0,??=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
|
||||
OSC0->CR = (uint8_t)0x00u;
|
||||
/* MCG->C7: OSCSEL=0 */
|
||||
MCG->C7 = (uint8_t)0x00u;
|
||||
/* MCG->C2: ??=0,??=0,RANGE0=2,HGO=0,EREFS=1,LP=0,IRCS=0 */
|
||||
MCG->C2 = (uint8_t)0x24u;
|
||||
/* MCG->C1: CLKS=2,FRDIV=3,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
|
||||
MCG->C1 = (uint8_t)0x9Au;
|
||||
/* MCG->C4: DMX32=0,DRST_DRS=0 */
|
||||
MCG->C4 &= (uint8_t)~(uint8_t)0xE0u;
|
||||
/* MCG->C5: ??=0,PLLCLKEN=0,PLLSTEN=0,PRDIV0=0 */
|
||||
MCG->C5 = (uint8_t)0x00u;
|
||||
/* MCG->C6: LOLIE=0,PLLS=0,CME=0,VDIV0=0 */
|
||||
MCG->C6 = (uint8_t)0x00u;
|
||||
while((MCG->S & MCG_S_OSCINIT0_MASK) == 0u) { /* Check that the oscillator is running */
|
||||
}
|
||||
#if 0 /* ARM: THIS CHECK IS REMOVED DUE TO BUG WITH SLOW IRC IN REV. 1.0 */
|
||||
while((MCG->S & MCG_S_IREFST_MASK) != 0u) { /* Check that the source of the FLL reference clock is the external reference clock. */
|
||||
}
|
||||
#endif
|
||||
while((MCG->S & 0x0CU) != 0x08u) { /* Wait until external reference clock is selected as MCG output */
|
||||
}
|
||||
/* Switch to BLPE Mode */
|
||||
/* MCG->C2: ??=0,??=0,RANGE0=2,HGO=0,EREFS=1,LP=0,IRCS=0 */
|
||||
MCG->C2 = (uint8_t)0x24u;
|
||||
|
||||
#elif (CLOCK_SETUP == 3)
|
||||
/* for Infinity FEI: 48MHz */
|
||||
|
||||
/* OUTDIV1(core/system): 48/1, OUTDIV2(bus): 48/1, OUTDIV4(flash): 48/2 */
|
||||
SIM->CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(0) | SIM_CLKDIV1_OUTDIV4(1);
|
||||
MCG->C1 = MCG_C1_IREFS_MASK | MCG_C1_IRCLKEN_MASK;
|
||||
/* 32.768KHz x FLL(1464) = 48MHz */
|
||||
MCG->C4 = MCG_C4_DMX32_MASK | MCG_C4_DRST_DRS(1);
|
||||
/* USB clock source: MCGPLLCLK/MCGFLLCLK */
|
||||
//SIM->SOPT2 = SIM_SOPT2_USBSRC_MASK | SIM_SOPT2_TRACECLKSEL_MASK;
|
||||
|
||||
while((MCG->S & MCG_S_IREFST_MASK) == 0u) { }
|
||||
while((MCG->S & 0x0Cu) != 0x00u) { }
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SystemCoreClockUpdate()
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
void SystemCoreClockUpdate (void) {
|
||||
uint32_t MCGOUTClock; /* Variable to store output clock frequency of the MCG module */
|
||||
uint8_t Divider;
|
||||
|
||||
if ((MCG->C1 & MCG_C1_CLKS_MASK) == 0x0u) {
|
||||
/* Output of FLL or PLL is selected */
|
||||
if ((MCG->C6 & MCG_C6_PLLS_MASK) == 0x0u) {
|
||||
/* FLL is selected */
|
||||
if ((MCG->C1 & MCG_C1_IREFS_MASK) == 0x0u) {
|
||||
/* External reference clock is selected */
|
||||
if ((MCG->C7 & MCG_C7_OSCSEL_MASK) == 0x0u) {
|
||||
MCGOUTClock = CPU_XTAL_CLK_HZ; /* System oscillator drives MCG clock */
|
||||
} else { /* (!((MCG->C7 & MCG_C7_OSCSEL_MASK) == 0x0u)) */
|
||||
MCGOUTClock = CPU_XTAL32k_CLK_HZ; /* RTC 32 kHz oscillator drives MCG clock */
|
||||
} /* (!((MCG->C7 & MCG_C7_OSCSEL_MASK) == 0x0u)) */
|
||||
Divider = (uint8_t)(1u << ((MCG->C1 & MCG_C1_FRDIV_MASK) >> MCG_C1_FRDIV_SHIFT));
|
||||
MCGOUTClock = (MCGOUTClock / Divider); /* Calculate the divided FLL reference clock */
|
||||
if ((MCG->C2 & MCG_C2_RANGE0_MASK) != 0x0u) {
|
||||
MCGOUTClock /= 32u; /* If high range is enabled, additional 32 divider is active */
|
||||
} /* ((MCG->C2 & MCG_C2_RANGE0_MASK) != 0x0u) */
|
||||
} else { /* (!((MCG->C1 & MCG_C1_IREFS_MASK) == 0x0u)) */
|
||||
MCGOUTClock = CPU_INT_SLOW_CLK_HZ; /* The slow internal reference clock is selected */
|
||||
} /* (!((MCG->C1 & MCG_C1_IREFS_MASK) == 0x0u)) */
|
||||
/* Select correct multiplier to calculate the MCG output clock */
|
||||
switch (MCG->C4 & (MCG_C4_DMX32_MASK | MCG_C4_DRST_DRS_MASK)) {
|
||||
case 0x0u:
|
||||
MCGOUTClock *= 640u;
|
||||
break;
|
||||
case 0x20u:
|
||||
MCGOUTClock *= 1280u;
|
||||
break;
|
||||
case 0x40u:
|
||||
MCGOUTClock *= 1920u;
|
||||
break;
|
||||
case 0x60u:
|
||||
MCGOUTClock *= 2560u;
|
||||
break;
|
||||
case 0x80u:
|
||||
MCGOUTClock *= 732u;
|
||||
break;
|
||||
case 0xA0u:
|
||||
MCGOUTClock *= 1464u;
|
||||
break;
|
||||
case 0xC0u:
|
||||
MCGOUTClock *= 2197u;
|
||||
break;
|
||||
case 0xE0u:
|
||||
MCGOUTClock *= 2929u;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else { /* (!((MCG->C6 & MCG_C6_PLLS_MASK) == 0x0u)) */
|
||||
/* PLL is selected */
|
||||
Divider = (1u + (MCG->C5 & MCG_C5_PRDIV0_MASK));
|
||||
MCGOUTClock = (uint32_t)(CPU_XTAL_CLK_HZ / Divider); /* Calculate the PLL reference clock */
|
||||
Divider = ((MCG->C6 & MCG_C6_VDIV0_MASK) + 24u);
|
||||
MCGOUTClock *= Divider; /* Calculate the MCG output clock */
|
||||
} /* (!((MCG->C6 & MCG_C6_PLLS_MASK) == 0x0u)) */
|
||||
} else if ((MCG->C1 & MCG_C1_CLKS_MASK) == 0x40u) {
|
||||
/* Internal reference clock is selected */
|
||||
if ((MCG->C2 & MCG_C2_IRCS_MASK) == 0x0u) {
|
||||
MCGOUTClock = CPU_INT_SLOW_CLK_HZ; /* Slow internal reference clock selected */
|
||||
} else { /* (!((MCG->C2 & MCG_C2_IRCS_MASK) == 0x0u)) */
|
||||
MCGOUTClock = CPU_INT_FAST_CLK_HZ / (1 << ((MCG->SC & MCG_SC_FCRDIV_MASK) >> MCG_SC_FCRDIV_SHIFT)); /* Fast internal reference clock selected */
|
||||
} /* (!((MCG->C2 & MCG_C2_IRCS_MASK) == 0x0u)) */
|
||||
} else if ((MCG->C1 & MCG_C1_CLKS_MASK) == 0x80u) {
|
||||
/* External reference clock is selected */
|
||||
if ((MCG->C7 & MCG_C7_OSCSEL_MASK) == 0x0u) {
|
||||
MCGOUTClock = CPU_XTAL_CLK_HZ; /* System oscillator drives MCG clock */
|
||||
} else { /* (!((MCG->C7 & MCG_C7_OSCSEL_MASK) == 0x0u)) */
|
||||
MCGOUTClock = CPU_XTAL32k_CLK_HZ; /* RTC 32 kHz oscillator drives MCG clock */
|
||||
} /* (!((MCG->C7 & MCG_C7_OSCSEL_MASK) == 0x0u)) */
|
||||
} else { /* (!((MCG->C1 & MCG_C1_CLKS_MASK) == 0x80u)) */
|
||||
/* Reserved value */
|
||||
return;
|
||||
} /* (!((MCG->C1 & MCG_C1_CLKS_MASK) == 0x80u)) */
|
||||
SystemCoreClock = (MCGOUTClock / (1u + ((SIM->CLKDIV1 & SIM_CLKDIV1_OUTDIV1_MASK) >> SIM_CLKDIV1_OUTDIV1_SHIFT)));
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
OpenOCD config files for Kinetis
|
||||
================================
|
||||
http://nemuisan.blog.bai.ne.jp/?eid=192848#OPENOCD
|
||||
|
||||
These are needed for debug and programing bootloader with SWD. To flash keyboard firmware use 'dfu-util'.
|
||||
|
||||
Flash security of Freescale kinetis
|
||||
-----------------------------------
|
||||
If FSEC of flash config is changed accidentally SWD/JTAG you can't get debug access until doing 'mdm mass_erase' with JTAG, CMSIS-DAP or OpenSAD adapter. HLA(high level adapter) like stlink doesn't work for this.
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
Debug:
|
||||
$ openocd -s tool -f tool/openocd.cfg
|
||||
$ arm-none-eabi-gdb build/infinity.elf -ex "target remote localhost:3333"
|
||||
|
||||
Flash bootloader:
|
||||
$ openocd -s tool -f tool/openocd.cfg -c "mt_flash kiibohd_bootloader.bin"
|
||||
|
||||
|
||||
Infinity SWD pinout
|
||||
-------------------
|
||||
SWD pins are placed next to reset button; SWD_CLK, SWD_DIO, GND, 5V from top.
|
||||
Note that RESET is also needed to get full control with OpenOCD.
|
||||
|
||||
--------
|
||||
| ___ o |CLK
|
||||
||RST| o |DIO
|
||||
||BTN| o |GND
|
||||
| --- o |5V
|
||||
--------
|
||||
|
||||
|
||||
Kinetis sercure state
|
||||
----------------------
|
||||
openocd 0.9.0
|
||||
|
||||
Warn : *********** ATTENTION! ATTENTION! ATTENTION! ATTENTION! **********
|
||||
Warn : **** ****
|
||||
Warn : **** Your Kinetis MCU is in secured state, which means that, ****
|
||||
Warn : **** with exception for very basic communication, JTAG/SWD ****
|
||||
Warn : **** interface will NOT work. In order to restore its ****
|
||||
Warn : **** functionality please issue 'kinetis mdm mass_erase' ****
|
||||
Warn : **** command, power cycle the MCU and restart OpenOCD. ****
|
||||
Warn : **** ****
|
||||
Warn : *********** ATTENTION! ATTENTION! ATTENTION! ATTENTION! **********
|
||||
|
||||
|
||||
Info : MDM: Chip is unsecured. Continuing.
|
||||
target state: halted
|
||||
target halted due to debug-request, current mode: Thread
|
||||
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
|
||||
auto erase enabled
|
||||
Info : Probing flash info for bank 0
|
||||
Warn : flash configuration field erased, please reset the device
|
||||
wrote 4096 bytes from file kiibohd_bootloader.bin in 2.442562s (1.638 KiB/s)
|
||||
Info : MDM: Chip is unsecured. Continuing.
|
||||
|
||||
|
||||
|
||||
|
||||
Open On-Chip Debugger 0.9.0-dev-00346-g3e1dfdc-dirty (2015-03-21-20:41)
|
||||
Licensed under GNU GPL v2
|
||||
For bug reports, read
|
||||
http://openocd.sourceforge.net/doc/doxygen/bugs.html
|
||||
Info : only one transport option; autoselect 'cmsis-dap'
|
||||
Kinetis MUST need Hardware SRST Control to Recover Secure-State!
|
||||
adapter_nsrst_delay: 200
|
||||
srst_only separate srst_gates_jtag srst_open_drain connect_deassert_srst
|
||||
Info : add flash_bank kinetis k20.pflash
|
||||
cortex_m reset_config sysresetreq
|
||||
adapter speed: 1000 kHz
|
||||
srst_only separate srst_nogate srst_open_drain connect_assert_srst
|
||||
Info : CMSIS-DAP: SWD Supported
|
||||
Info : CMSIS-DAP: Interface Initialised (SWD)
|
||||
Info : CMSIS-DAP: FW Version = 1.0
|
||||
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
|
||||
Info : Connecting under reset
|
||||
Info : DAP_SWJ Sequence (reset: 50+ '1' followed by 0)
|
||||
Info : CMSIS-DAP: Interface ready
|
||||
Info : clock speed 1000 kHz
|
||||
Info : IDCODE 0x2ba01477
|
||||
Warn : Adapter returned success despite SSTICKYERR being set.
|
||||
Warn : Adapter returned success despite SSTICKYERR being set.
|
||||
Warn : Adapter returned success despite SSTICKYERR being set.
|
||||
Warn : Adapter returned success despite SSTICKYERR being set.
|
||||
Info : k20.cpu: hardware has 6 breakpoints, 4 watchpoints
|
||||
Info : MDM: Chip is unsecured. Continuing.
|
||||
Info : MDM: Chip is unsecured. Continuing.
|
||||
target state: halted
|
||||
target halted due to debug-request, current mode: Thread
|
||||
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
|
||||
auto erase enabled
|
||||
Info : Probing flash info for bank 0
|
||||
Warn : flash configuration field erased, please reset the device
|
||||
wrote 4096 bytes from file kiibohd_bootloader.bin in 2.446902s (1.635 KiB/s)
|
||||
Info : MDM: Chip is unsecured. Continuing.
|
||||
Info : Halt timed out, wake up GDB.
|
||||
Error: timed out while waiting for target halted
|
||||
Runtime Error: tool/k20dx32_flash.cfg:81:
|
||||
in procedure 'mt_flash'
|
||||
in procedure 'halt' called at file "tool/k20dx32_flash.cfg", line 81
|
@ -1,139 +0,0 @@
|
||||
# FreeScale Kinetis K20 devices with 32kB Flash and 8kB Local On-Chip SRAM,
|
||||
# Nemuisan's Special for MK20DN32VFT5,MK20DX32VFT5,MK10DN32VFT5,MK10DX32VFT5
|
||||
|
||||
|
||||
# 0.8.0 has no these procs
|
||||
proc using_jtag {} {
|
||||
set _TRANSPORT [ transport select ]
|
||||
expr { [ string first "jtag" $_TRANSPORT ] != -1 }
|
||||
}
|
||||
|
||||
proc using_swd {} {
|
||||
set _TRANSPORT [ transport select ]
|
||||
expr { [ string first "swd" $_TRANSPORT ] != -1 }
|
||||
}
|
||||
|
||||
proc using_hla {} {
|
||||
set _TRANSPORT [ transport select ]
|
||||
expr { [ string first "hla" $_TRANSPORT ] != -1 }
|
||||
}
|
||||
|
||||
source [find target/swj-dp.tcl]
|
||||
|
||||
if { [info exists CHIPNAME] } {
|
||||
set _CHIPNAME $CHIPNAME
|
||||
} else {
|
||||
set _CHIPNAME k20
|
||||
}
|
||||
|
||||
if { [info exists ENDIAN] } {
|
||||
set _ENDIAN $ENDIAN
|
||||
} else {
|
||||
set _ENDIAN little
|
||||
}
|
||||
|
||||
if { [info exists CPUTAPID] } {
|
||||
set _CPUTAPID $CPUTAPID
|
||||
} else {
|
||||
if { [using_jtag] } {
|
||||
set _CPUTAPID 0x4BA00477
|
||||
} {
|
||||
# this is the SW-DP tap id not the jtag tap id
|
||||
set _CPUTAPID 0x2BA01477
|
||||
}
|
||||
}
|
||||
|
||||
# Work-area is a space in RAM used for flash programming
|
||||
# By default use 8kB
|
||||
if { [info exists WORKAREASIZE] == 0 } {
|
||||
set _WORKAREASIZE 0x2000
|
||||
}
|
||||
|
||||
# Select "srst_only", Nemuisan said so!
|
||||
echo "Kinetis MUST need Hardware SRST Control to Recover Secure-State!"
|
||||
adapter_nsrst_delay 200
|
||||
reset_config srst_only
|
||||
|
||||
swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
|
||||
set _TARGETNAME $_CHIPNAME.cpu
|
||||
target create $_TARGETNAME cortex_m -chain-position $_TARGETNAME
|
||||
|
||||
# It is important that "kinetis mdm check_security" is called for
|
||||
# 'examine-end' event and not 'eximine-start'. Calling it in 'examine-start'
|
||||
# causes "kinetis mdm check_security" to fail the first time openocd
|
||||
# calls it when it tries to connect after the CPU has been power-cycled.
|
||||
$_CHIPNAME.cpu configure -event examine-end {
|
||||
kinetis mdm check_security
|
||||
# Uncomment when gone into s*ck'n secured state!
|
||||
# kinetis mdm mass_erase
|
||||
}
|
||||
|
||||
# K20 has minimun 8kB of SRAM and starts at 1FFFF000.
|
||||
$_TARGETNAME configure -work-area-phys 0x1FFFF000 -work-area-size $_WORKAREASIZE -work-area-backup 0 -rtos auto
|
||||
|
||||
# MK20DN32VFT5,MK20DX32VFT5,MK10DN32VFT5,MK10DX32VFT5 has 32kB of flash memory.
|
||||
flash bank $_CHIPNAME.pflash kinetis 0x00000000 0x8000 0 4 $_TARGETNAME
|
||||
|
||||
|
||||
proc mt_flash {IMGFILE} {
|
||||
flash write_image erase $IMGFILE
|
||||
reset run
|
||||
halt
|
||||
verify_image $IMGFILE
|
||||
reset run
|
||||
shutdown
|
||||
}
|
||||
|
||||
proc mt_flash_bin {IMGFILE OFFSET} {
|
||||
flash write_image erase $IMGFILE $OFFSET bin
|
||||
reset run
|
||||
halt
|
||||
verify_image $IMGFILE $OFFSET bin
|
||||
reset run
|
||||
shutdown
|
||||
}
|
||||
|
||||
proc mt_flash_hex {IMGFILE} {
|
||||
flash write_image erase $IMGFILE 0 ihex
|
||||
reset run
|
||||
halt
|
||||
verify_image $IMGFILE 0 ihex
|
||||
reset run
|
||||
shutdown
|
||||
}
|
||||
|
||||
proc mt_flash_srec {IMGFILE} {
|
||||
flash write_image erase $IMGFILE 0 s19
|
||||
reset run
|
||||
halt
|
||||
verify_image $IMGFILE 0 s19
|
||||
reset run
|
||||
shutdown
|
||||
}
|
||||
|
||||
proc mass_erase {} {
|
||||
kinetis mdm mass_erase
|
||||
}
|
||||
|
||||
proc eraser {} {
|
||||
# Verbose procedure confirmed erase routine
|
||||
flash info 0
|
||||
# CAUTION! "flash erase_sector 0 0 last" goes into secure state!!!
|
||||
# USE "mass_erase" command instead of
|
||||
# flash erase_sector 0 0 last
|
||||
mass_erase
|
||||
shutdown
|
||||
}
|
||||
|
||||
#debug_level 3
|
||||
# HLA doesn't have cortex_m commands
|
||||
if {![using_hla]} {
|
||||
# if srst is not fitted use SYSRESETREQ to
|
||||
# perform a soft reset
|
||||
cortex_m reset_config sysresetreq
|
||||
}
|
||||
adapter_khz 1000
|
||||
reset_config srst_only srst_nogate connect_assert_srst
|
||||
gdb_target_description disable
|
||||
init
|
||||
reset init
|
@ -1,13 +0,0 @@
|
||||
# mchack openocd
|
||||
# https://github.com/mchck/mchck/wiki/Openocd
|
||||
#
|
||||
# adapter: frdm-kl05z with cmsis-dap firmware
|
||||
# inteface: cmsis-dap
|
||||
# transport: hla_swd
|
||||
# target: MK20DX128VLF5 Freescale Kinetis
|
||||
|
||||
# adapter/interface
|
||||
source [find interface/cmsis-dap.cfg]
|
||||
|
||||
# CPU
|
||||
source [find k20dx32_flash.cfg]
|
@ -1,117 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = kittenpaw_lufa
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# List C source files here. (C dependencies are automatically generated.)
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
# MCU name
|
||||
MCU = atmega32u2
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 16000000
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
#CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||
|
||||
|
||||
# Boot Section Size in bytes
|
||||
# Teensy halfKay 512
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
@ -1,20 +0,0 @@
|
||||
Kitten Paw controller firmware
|
||||
======================
|
||||
Custom controller for the Costar Majestouch keyboard designed by bpiphany.
|
||||
|
||||
*Note that this is not the official firmware*
|
||||
|
||||
Build
|
||||
-----
|
||||
Move to this directory then just run `make` like:
|
||||
|
||||
$ make -f Makefile.lufa
|
||||
|
||||
At the moment only the LUFA stack is supported.
|
||||
|
||||
|
||||
Bootloader
|
||||
---------
|
||||
To enter bootloader by hardware use a magnet above the controller before connecting the usb cable.
|
||||
|
||||
It is still possible to use Boot Magic and Command (LSFT+RSFT+PAUS) to access the bootloader though.
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x6050
|
||||
#define DEVICE_VER 0x0104
|
||||
#define MANUFACTURER Costar
|
||||
#define PRODUCT Majestouch
|
||||
|
||||
/* message strings */
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for Majestouch
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 8
|
||||
#define MATRIX_COLS 18
|
||||
|
||||
/* Set 0 if need no debouncing */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
#endif
|
@ -1,102 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
#include "action_macro.h"
|
||||
#include "report.h"
|
||||
#include "host.h"
|
||||
#include "debug.h"
|
||||
#include "keymap.h"
|
||||
|
||||
/*
|
||||
Matrix col/row mapping
|
||||
|
||||
,----. ,-------------------. ,-------------------. ,-------------------. ,--------------.
|
||||
|06/6| |07/4|08/4|08/2|08/6| |15/5|11/6|12/2|12/4| |14/4|14/5|14/6|14/0| |13/5|13/7|15/7|
|
||||
`----' `-------------------' `-------------------' `-------------------' `--------------'
|
||||
,-------------------------------------------------------------------------. ,--------------. ,-------------------.
|
||||
|06/4|06/5|07/5|08/5|09/5|09/4|10/4|10/5|11/5|12/5|05/5|05/4|11/4| 14/2| |17/4|02/4|04/4| |16/1|17/1|04/1|04/0|
|
||||
|-------------------------------------------------------------------------| |--------------| |-------------------|
|
||||
|06/2 |06/7|07/7|08/7|09/7|09/2|10/2|10/7|11/7|12/7|05/7|05/2|11/2| 14/3| |16/4|02/5|04/5| |16/7|17/7|04/7| |
|
||||
|-------------------------------------------------------------------------| '--------------' |-------------- 02/7|
|
||||
|02/7 |06/3|07/3|08/3|09/3|09/6|10/6|10/3|11/3|12/3|05/3|05/6| 14/1| |16/2|17/2|04/2| |
|
||||
|-------------------------------------------------------------------------| ,----. |-------------------|
|
||||
|01/2 |06/1|07/1|08/1|09/1|09/0|10/0|10/1|11/1|12/1|05/0| 01/3| |02/6| |16/3|17/3|04/3| |
|
||||
|-------------------------------------------------------------------------| ,--------------. |-------------- 02/3|
|
||||
|15/4|03/2|13/6| 16/6 |13/0|0/3|12/0|15/1| |02/0|16/0|17/0| | 17/6 |04/6| |
|
||||
`-------------------------------------------------------------------------' `--------------' `-------------------'
|
||||
*/
|
||||
|
||||
#define KEYMAP( \
|
||||
KG6, KH4, KI4, KI2, KI6, KP5, KL6, KM2, KM4, KO4, KO5, KO6, KO0, KN5, KN7, KP7, \
|
||||
KG4, KG5, KH5, KI5, KJ5, KJ4, KK4, KK5, KL5, KM5, KF5, KF4, KL4, KO2, KR4, KC4, KE4, KQ1, KR1, KE1, KE0, \
|
||||
KG2, KG7, KH7, KI7, KJ7, KJ2, KK2, KK7, KL7, KM7, KF7, KF2, KL2, KO3, KQ4, KC5, KE5, KQ7, KR7, KE7, KC7, \
|
||||
KH2, KG3, KH3, KI3, KJ3, KJ6, KK6, KK3, KL3, KM3, KF3, KF6, KO1, KQ2, KR2, KE2, \
|
||||
KB2, KH6, KG1, KH1, KI1, KJ1, KJ0, KK0, KK1, KL1, KM1, KF0, KB3, KC6, KQ3, KR3, KE3, KC3, \
|
||||
KP4, KD2, KN6, KQ6, KN0, KA3, KM0, KP1, KC0, KQ0, KR0, KR6, KE6 \
|
||||
) { \
|
||||
/* 0 1 2 3 4 5 6 7 */ \
|
||||
/* A 0 */ {KC_NO, KC_NO, KC_NO, KC_##KA3, KC_NO, KC_NO, KC_NO, KC_NO },\
|
||||
/* B 1 */ {KC_NO, KC_NO, KC_##KB2, KC_##KB3, KC_NO, KC_NO, KC_NO, KC_NO },\
|
||||
/* C 2 */ {KC_##KC0, KC_NO, KC_NO, KC_##KC3, KC_##KC4, KC_##KC5, KC_##KC6, KC_##KC7},\
|
||||
/* D 3 */ {KC_NO, KC_NO, KC_##KD2, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO },\
|
||||
/* E 4 */ {KC_##KE0, KC_##KE1, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_##KE7},\
|
||||
/* F 5 */ {KC_##KF0, KC_NO, KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_##KF7},\
|
||||
/* G 6 */ {KC_NO, KC_##KG1, KC_##KG2, KC_##KG3, KC_##KG4, KC_##KG5, KC_##KG6, KC_##KG7},\
|
||||
/* H 7 */ {KC_NO, KC_##KH1, KC_##KH2, KC_##KH3, KC_##KH4, KC_##KH5, KC_##KH6, KC_##KH7},\
|
||||
/* I 8 */ {KC_NO, KC_##KI1, KC_##KI2, KC_##KI3, KC_##KI4, KC_##KI5, KC_##KI6, KC_##KI7},\
|
||||
/* J 9 */ {KC_##KJ0, KC_##KJ1, KC_##KJ2, KC_##KJ3, KC_##KJ4, KC_##KJ5, KC_##KJ6, KC_##KJ7},\
|
||||
/* K 10 */ {KC_##KK0, KC_##KK1, KC_##KK2, KC_##KK3, KC_##KK4, KC_##KK5, KC_##KK6, KC_##KK7},\
|
||||
/* L 11 */ {KC_NO, KC_##KL1, KC_##KL2, KC_##KL3, KC_##KL4, KC_##KL5, KC_##KL6, KC_##KL7},\
|
||||
/* M 12 */ {KC_##KM0, KC_##KM1, KC_##KM2, KC_##KM3, KC_##KM4, KC_##KM5, KC_NO, KC_##KM7},\
|
||||
/* N 13 */ {KC_##KN0, KC_NO, KC_NO, KC_NO, KC_NO, KC_##KN5, KC_##KN6, KC_##KN7},\
|
||||
/* O 14 */ {KC_##KO0, KC_##KO1, KC_##KO2, KC_##KO3, KC_##KO4, KC_##KO5, KC_##KO6, KC_NO },\
|
||||
/* P 15 */ {KC_NO, KC_##KP1, KC_NO, KC_NO, KC_##KP4, KC_##KP5, KC_NO, KC_##KP7},\
|
||||
/* Q 16 */ {KC_##KQ0, KC_##KQ1, KC_##KQ2, KC_##KQ3, KC_##KQ4, KC_NO, KC_##KQ6, KC_##KQ7},\
|
||||
/* R 17 */ {KC_##KR0, KC_##KR1, KC_##KR2, KC_##KR3, KC_##KR4, KC_NO, KC_##KR6, KC_##KR7} \
|
||||
}
|
||||
|
||||
#include "keymap_ansi.h"
|
||||
|
||||
#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
|
||||
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
|
||||
|
||||
/* translates key to keycode */
|
||||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
if (layer < KEYMAPS_SIZE) {
|
||||
return pgm_read_byte(&keymaps[(layer)][(key.col)][(key.row)]);
|
||||
} else {
|
||||
return pgm_read_byte(&keymaps[0][(key.col)][(key.row)]);
|
||||
}
|
||||
}
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint8_t keycode)
|
||||
{
|
||||
action_t action;
|
||||
if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
|
||||
action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
|
||||
} else {
|
||||
action.code = ACTION_NO;
|
||||
}
|
||||
return action;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_COLS][MATRIX_ROWS] = {
|
||||
/* Layer 0: Standard ANSI layer */
|
||||
KEYMAP(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, \
|
||||
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, \
|
||||
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, PENT, \
|
||||
LCTL,LGUI,LALT, SPC, RALT,RGUI, FN0,RCTL, LEFT,DOWN,RGHT, P0, PDOT), \
|
||||
/* Layer 1: Function layer */
|
||||
KEYMAP(\
|
||||
CALC,MYCM,WSCH,WHOM,MAIL,VOLD,VOLU,MSEL,MSTP,MPLY,MPRV,MNXT,TRNS, WAKE, PWR,SLEP, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS)
|
||||
};
|
||||
|
||||
static const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1)
|
||||
};
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "stdint.h"
|
||||
#include "led.h"
|
||||
|
||||
/* LED pin configuration
|
||||
*
|
||||
* Scroll Lock PB7
|
||||
* CAPS PC6
|
||||
* NUMLOCK PC5
|
||||
*
|
||||
*/
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
DDRB |= (1<<7);
|
||||
DDRC |= (1<<5) | (1<<6);
|
||||
|
||||
if (usb_led & (1<<USB_LED_CAPS_LOCK))
|
||||
{
|
||||
PORTC &= ~(1<<6);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTC |= (1<<6);
|
||||
}
|
||||
|
||||
if (usb_led & (1<<USB_LED_NUM_LOCK))
|
||||
{
|
||||
PORTC &= ~(1<<5);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTC |= (1<<5);
|
||||
}
|
||||
|
||||
if (usb_led & (1<<USB_LED_SCROLL_LOCK))
|
||||
{
|
||||
PORTB &= ~(1<<7);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTB |= (1<<7);
|
||||
}
|
||||
}
|
@ -1,239 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 0
|
||||
#endif
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
static uint8_t read_rows(void);
|
||||
static void init_rows(void);
|
||||
static void unselect_cols(void);
|
||||
static void select_col(uint8_t col);
|
||||
|
||||
inline uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
unselect_cols();
|
||||
init_rows();
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
|
||||
select_col(col);
|
||||
_delay_us(3);
|
||||
uint8_t rows = read_rows();
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
|
||||
bool curr_bit = rows & (1<<row);
|
||||
if (prev_bit != curr_bit) {
|
||||
matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
}
|
||||
unselect_cols();
|
||||
}
|
||||
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
_delay_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
if (debouncing) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
return (matrix[row] & ((matrix_row_t)1<<col));
|
||||
}
|
||||
|
||||
inline matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
print("\nr/c 0123456789ABCDEF\n");
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_key_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
count += bitpop32(matrix[i]);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Row pin configuration
|
||||
*
|
||||
* row: 0 1 2 3 4 5 6 7
|
||||
* pin: PC2 PB1 PB2 PB3 PC7 PB4 PB5 PB6
|
||||
*
|
||||
*/
|
||||
static void init_rows(void)
|
||||
{
|
||||
DDRC &= ~0b10000100;
|
||||
DDRB &= ~0b01111110;
|
||||
PORTC |= 0b10000100;
|
||||
PORTB |= 0b01111110;
|
||||
}
|
||||
|
||||
static uint8_t read_rows(void)
|
||||
{
|
||||
return (PINC&(1<<2) ? 0 : (1<<0)) |
|
||||
(PINB&(1<<1) ? 0 : (1<<1)) |
|
||||
(PINB&(1<<2) ? 0 : (1<<2)) |
|
||||
(PINB&(1<<3) ? 0 : (1<<3)) |
|
||||
(PINC&(1<<7) ? 0 : (1<<4)) |
|
||||
(PINB&(1<<4) ? 0 : (1<<5)) |
|
||||
(PINB&(1<<5) ? 0 : (1<<6)) |
|
||||
(PINB&(1<<6) ? 0 : (1<<7));
|
||||
}
|
||||
|
||||
/* These columns uses two 74HC42 4 to 10 bit demultiplexers (low active).
|
||||
*
|
||||
* COL PD1 PD0 PD2 PD6 PD5 PD4
|
||||
* 12 1 1 0 0 0 0
|
||||
* 11 1 1 0 0 0 1
|
||||
* 10 1 1 0 0 1 0
|
||||
* 9 1 1 0 0 1 1
|
||||
* 8 1 1 0 1 0 0
|
||||
* 7 1 1 0 1 0 1
|
||||
* 6 1 1 0 1 1 0
|
||||
* 5 1 1 0 1 1 1
|
||||
* 4 1 1 1 0 0 0
|
||||
* 3 1 1 1 0 0 1
|
||||
|
||||
* COL PD2 PD6 PD1 PD0 PD5 PD4
|
||||
* 2 1 1 0 0 0 0
|
||||
* 1 1 1 0 0 0 1
|
||||
* 0 1 1 0 0 1 0
|
||||
* 17 1 1 0 0 1 1
|
||||
* 16 1 1 0 1 0 0
|
||||
* 1 1 0 1 0 1
|
||||
* 1 1 0 1 1 0
|
||||
* 15 1 1 0 1 1 1
|
||||
* 14 1 1 1 0 0 0
|
||||
* 13 1 1 1 0 0 1
|
||||
*/
|
||||
static void unselect_cols(void)
|
||||
{
|
||||
DDRD |= 0b01110111;
|
||||
PORTD &= ~0b01110111;
|
||||
}
|
||||
|
||||
static void select_col(uint8_t col)
|
||||
{
|
||||
switch (col) {
|
||||
case 0:
|
||||
PORTD |= (1<<5) | (1<<6) | (1<<2);
|
||||
break;
|
||||
case 1:
|
||||
PORTD |= (1<<4) | (1<<6) | (1<<2);
|
||||
break;
|
||||
case 2:
|
||||
PORTD |= (1<<6) | (1<<2);
|
||||
break;
|
||||
case 3:
|
||||
PORTD |= (1<<4) | (1<<2) | (1<<0) | (1<<1);
|
||||
break;
|
||||
case 4:
|
||||
PORTD |= (1<<2) | (1<<0) | (1<<1);
|
||||
break;
|
||||
case 5:
|
||||
PORTD |= (1<<4) | (1<<5) | (1<<6) | (1<<0) | (1<<1);
|
||||
break;
|
||||
case 6:
|
||||
PORTD |= (1<<5) | (1<<6) | (1<<0) | (1<<1);
|
||||
break;
|
||||
case 7:
|
||||
PORTD |= (1<<4) | (1<<6) | (1<<0) | (1<<1);
|
||||
break;
|
||||
case 8:
|
||||
PORTD |= (1<<6) | (1<<0) | (1<<1);
|
||||
break;
|
||||
case 9:
|
||||
PORTD |= (1<<4) | (1<<5) | (1<<0) | (1<<1);
|
||||
break;
|
||||
case 10:
|
||||
PORTD |= (1<<5) | (1<<0) | (1<<1);
|
||||
break;
|
||||
case 11:
|
||||
PORTD |= (1<<4) | (1<<0) | (1<<1);
|
||||
break;
|
||||
case 12:
|
||||
PORTD |= (1<<0) | (1<<1);
|
||||
break;
|
||||
case 13:
|
||||
PORTD |= (1<<4) | (1<<1) | (1<<6) | (1<<2);
|
||||
break;
|
||||
case 14:
|
||||
PORTD |= (1<<1) | (1<<6) | (1<<2);
|
||||
break;
|
||||
case 15:
|
||||
PORTD |= (1<<4) | (1<<5) | (1<<0) | (1<<6) | (1<<2);
|
||||
break;
|
||||
case 16:
|
||||
PORTD |= (1<<0) | (1<<6) | (1<<2);
|
||||
break;
|
||||
case 17:
|
||||
PORTD |= (1<<4) | (1<<5) | (1<<6) | (1<<2);
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = kmac_lufa
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
|
||||
# List C source files here. (C dependencies are automatically generated.)
|
||||
SRC += keymap.c \
|
||||
matrix.c \
|
||||
led.c \
|
||||
backlight.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name
|
||||
#MCU = at90usb1287
|
||||
MCU = atmega32u4
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 8000000
|
||||
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
|
||||
|
||||
# Boot Section Size in bytes
|
||||
# Teensy halfKay 512
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
||||
|
||||
winkey: OPT_DEFS += -DLAYOUT_WINKEY
|
||||
winkey: all
|
||||
|
||||
winkeyless: OPT_DEFS += -DLAYOUT_WINKEYLESS
|
||||
winkeyless: all
|
@ -1,101 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = kmac_pjrc
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# keyboard dependent files
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
led.c \
|
||||
backlight.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name, you MUST set this to match the board you are using
|
||||
# type "make clean" after changing this, so all files will be rebuilt
|
||||
#MCU = at90usb162 # Teensy 1.0
|
||||
MCU = atmega32u4 # Teensy 2.0
|
||||
#MCU = at90usb646 # Teensy++ 1.0
|
||||
#MCU = at90usb1286 # Teensy++ 2.0
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# Normally the first thing your program should do is set the clock prescaler,
|
||||
# so your program will run at the correct speed. You should also set this
|
||||
# variable to same clock speed. The _delay_ms() macro uses this, and many
|
||||
# examples use this variable to calculate timings. Do not add a "UL" here.
|
||||
F_CPU = 8000000
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
#MOUSEKEY_ENABLE = yes # Mouse keys(+5000)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+600)
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover(+500)
|
||||
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/pjrc.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
||||
|
||||
winkey: OPT_DEFS += -DLAYOUT_WINKEY
|
||||
winkey: all
|
||||
|
||||
winkeyless: OPT_DEFS += -DLAYOUT_WINKEYLESS
|
||||
winkeyless: all
|
@ -1,110 +0,0 @@
|
||||
KMAC keyboard firmware
|
||||
======================
|
||||
Korean custom keyboard designed by Byungho Kim and KBDMania community.
|
||||
|
||||
*Note that this is not the official firmware*
|
||||
|
||||
Supported models
|
||||
----------------
|
||||
At the moment only the TKL models is supported.
|
||||
|
||||
|
||||
Build
|
||||
-----
|
||||
Move to this directory then just run `make` like:
|
||||
|
||||
$ make -f Makefile.[pjrc|lufa] [winkey|winkeyless]
|
||||
|
||||
Use `Makefile.pjrc` if you want to use PJRC stack or use `Makefile.lufa` for LUFA stack.
|
||||
|
||||
|
||||
Bootloader
|
||||
---------
|
||||
The PCB is hardwired to run the bootloader if the key at the `Caps Lock` position is held down when connecting the keyboard.
|
||||
|
||||
It is still possible to use Boot Magic and Command to access the bootloader though.
|
||||
|
||||
|
||||
Keymap
|
||||
------
|
||||
There are 2 different types of PCB.
|
||||
They each have their own keymap file.
|
||||
|
||||
To customize a keymap:
|
||||
1. Edit the file that corresponds to your PCB.
|
||||
2. Specify your layout when building.
|
||||
|
||||
### 1. Winkey
|
||||
This is the default keymap.
|
||||
|
||||
See [keymap_winkey.h](keymap_winkey.h) for detail.
|
||||
|
||||
#### 1.0. Winkey Default Layer
|
||||
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
|Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
|
||||
`---' `---------------' `---------------' `---------------' `-----------'
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
|~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
|
||||
|-----------------------------------------------------------| '-----------'
|
||||
|Fn0 | A| S| D| F| G| H| J| K| L| ;| '|Return |
|
||||
|-----------------------------------------------------------| ,---.
|
||||
|Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
|
||||
|-----------------------------------------------------------| ,-----------.
|
||||
|Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig|
|
||||
`-----------------------------------------------------------' `-----------'
|
||||
|
||||
#### 1.1. Winkey Media Layer
|
||||
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
|Led| | | | | | | | | | | | | | | | | | |Slp|
|
||||
`---' `---------------' `---------------' `---------------' `-----------'
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
| | | | | | | | | | |Mut|V- |V+ | | | | | |
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
| | | | | | | | | |Stp|Ply|Prv|Nxt|Media| | | | |
|
||||
|-----------------------------------------------------------| '-----------'
|
||||
| | | | | | | | | | | | | |
|
||||
|-----------------------------------------------------------| ,---.
|
||||
| | | |Clc| | | | | | | |Caps | | |
|
||||
|-----------------------------------------------------------| ,-----------.
|
||||
| | | | | | | | | | | | |
|
||||
`-----------------------------------------------------------' `-----------'
|
||||
|
||||
|
||||
### 2. Winkeyless
|
||||
Layout with 1.5 unit modifiers.
|
||||
|
||||
See [keymap_winkeyless.h](keymap_winkeyless.h) for detail.
|
||||
|
||||
#### 2.0. Winkeyless Default Layer
|
||||
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
|Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
|
||||
`---' `---------------' `---------------' `---------------' `-----------'
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
|~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
|
||||
|-----------------------------------------------------------| '-----------'
|
||||
|Fn0 | A| S| D| F| G| H| J| K| L| ;| '|Return |
|
||||
|-----------------------------------------------------------| ,---.
|
||||
|Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
|
||||
|-----------------------------------------------------------| ,-----------.
|
||||
|Ctl |Gui|Alt | Space |Alt |Gui|Ctl | |Lef|Dow|Rig|
|
||||
`-----------------------------------------------------------' `-----------'
|
||||
|
||||
#### 2.1. Winkeyless Media Layer
|
||||
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
|Led| | | | | | | | | | | | | | | | | | |Slp|
|
||||
`---' `---------------' `---------------' `---------------' `-----------'
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
| | | | | | | | | | |Mut|V- |V+ | | | | | |
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
| | | | | | | | | |Stp|Ply|Prv|Nxt|Media| | | | |
|
||||
|-----------------------------------------------------------| '-----------'
|
||||
| | | | | | | | | | | | | |
|
||||
|-----------------------------------------------------------| ,---.
|
||||
| | | |Clc| | | | | | | |Caps | | |
|
||||
|-----------------------------------------------------------| ,-----------.
|
||||
| | | | | | | | | | | |
|
||||
`-----------------------------------------------------------' `-----------'
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
Copyright 2013 Mathias Andersson <wraul@dbox.se>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "backlight.h"
|
||||
|
||||
/* Backlight pin configuration
|
||||
* F-row: High PB1
|
||||
* W: Low PB4
|
||||
* A: Low PB2
|
||||
* S: Low PB3
|
||||
* D: Low PD7
|
||||
*/
|
||||
void backlight_set(uint8_t level)
|
||||
{
|
||||
// Set as output.
|
||||
DDRB |= (1<<1) | (1<<2) | (1<<3) | (1<<4);
|
||||
DDRD |= (1<<7);
|
||||
|
||||
// F-row
|
||||
if(level & (1<<0))
|
||||
{
|
||||
PORTB |= (1<<1);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTB &= ~(1<<1);
|
||||
}
|
||||
// WASD
|
||||
if(level & (1<<1))
|
||||
{
|
||||
PORTB &= ~(1<<4);
|
||||
PORTB &= ~(1<<2);
|
||||
PORTB &= ~(1<<3);
|
||||
PORTD &= ~(1<<7);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTB |= (1<<4);
|
||||
PORTB |= (1<<2);
|
||||
PORTB |= (1<<3);
|
||||
PORTD |= (1<<7);
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
Copyright 2013 Mathias Andersson <wraul@dbox.se>
|
||||
|
||||
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
|
||||
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x6050
|
||||
#define DEVICE_VER 0x0104
|
||||
#define MANUFACTURER KBDMania
|
||||
#define PRODUCT KMAC
|
||||
|
||||
/* message strings */
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for KMAC
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 6
|
||||
#define MATRIX_COLS 17
|
||||
|
||||
/* number of backlight levels */
|
||||
#define BACKLIGHT_LEVELS 3
|
||||
|
||||
/* define if matrix has ghost */
|
||||
//#define MATRIX_HAS_GHOST
|
||||
|
||||
/* Set 0 if need no debouncing */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
#endif
|
@ -1,97 +0,0 @@
|
||||
/*
|
||||
Copyright 2013 Mathias Andersson <wraul@dbox.se>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Keymap for KMAC controller
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
#include "action_macro.h"
|
||||
#include "report.h"
|
||||
#include "host.h"
|
||||
#include "debug.h"
|
||||
#include "keymap.h"
|
||||
|
||||
// Convert physical keyboard layout to matrix array.
|
||||
// This is a macro to define keymap easily in keyboard layout form.
|
||||
#define KEYMAP( \
|
||||
K5A, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, \
|
||||
K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, K4O, K4P, K4Q, \
|
||||
K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3O, K3P, K3Q, \
|
||||
K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2N, \
|
||||
K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1N, K1P, \
|
||||
K0A, K0B, K0C, K0G, K0K, K0L, K0M, K0N, K0O, K0P, K0Q \
|
||||
) { \
|
||||
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */ \
|
||||
/* 5 */ { KC_##K5A, KC_NO, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F, KC_##K5G, KC_##K5H, KC_##K5I, KC_##K5J, KC_##K5K, KC_##K5L, KC_##K5M, KC_##K5N, KC_##K5O, KC_##K5P, KC_##K5Q}, \
|
||||
/* 4 */ { KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F, KC_##K4G, KC_##K4H, KC_##K4I, KC_##K4J, KC_##K4K, KC_##K4L, KC_##K4M, KC_##K4N, KC_##K4O, KC_##K4P, KC_##K4Q}, \
|
||||
/* 3 */ { KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F, KC_##K3G, KC_##K3H, KC_##K3I, KC_##K3J, KC_##K3K, KC_##K3L, KC_##K3M, KC_##K3N, KC_##K3O, KC_##K3P, KC_##K3Q}, \
|
||||
/* 2 */ { KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F, KC_##K2G, KC_##K2H, KC_##K2I, KC_##K2J, KC_##K2K, KC_##K2L, KC_NO, KC_##K2N, KC_NO, KC_NO, KC_NO }, \
|
||||
/* 1 */ { KC_##K1A, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F, KC_##K1G, KC_##K1H, KC_##K1I, KC_##K1J, KC_##K1K, KC_##K1L, KC_NO, KC_NO, KC_##K1N, KC_NO, KC_##K1P, KC_NO }, \
|
||||
/* 0 */ { KC_##K0A, KC_##K0B, KC_##K0C, KC_NO, KC_NO, KC_##K0G, KC_NO, KC_NO, KC_##K0K, KC_NO, KC_##K0L, KC_NO, KC_##K0M, KC_##K0N, KC_##K0O, KC_##K0P, KC_##K0Q} \
|
||||
}
|
||||
|
||||
#define KEYMAP_WINKEYLESS( \
|
||||
K5A, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, \
|
||||
K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, K4O, K4P, K4Q, \
|
||||
K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3O, K3P, K3Q, \
|
||||
K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2N, \
|
||||
K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1N, K1P, \
|
||||
K0A, K0B, K0C, K0G, K0L, K0M, K0N, K0O, K0P, K0Q \
|
||||
) KEYMAP( \
|
||||
K5A, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, \
|
||||
K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, K4O, K4P, K4Q, \
|
||||
K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3O, K3P, K3Q, \
|
||||
K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2N, \
|
||||
K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1N, K1P, \
|
||||
K0A, K0B, K0C, K0G, K0L, K0M, NO, K0N, K0O, K0P, K0Q \
|
||||
)
|
||||
|
||||
#if defined(LAYOUT_WINKEYLESS)
|
||||
#include "keymap_winkeyless.h"
|
||||
#else
|
||||
#include "keymap_winkey.h"
|
||||
#endif
|
||||
|
||||
#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
|
||||
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
|
||||
|
||||
/* translates key to keycode */
|
||||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
if (layer < KEYMAPS_SIZE) {
|
||||
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||
} else {
|
||||
// fall back to layer 0
|
||||
return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
|
||||
}
|
||||
}
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint8_t keycode)
|
||||
{
|
||||
action_t action;
|
||||
if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
|
||||
action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
|
||||
} else {
|
||||
action.code = ACTION_NO;
|
||||
}
|
||||
return action;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
// KMAC Winkey
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* 0: qwerty */
|
||||
KEYMAP(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, \
|
||||
FN0, A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, \
|
||||
LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, \
|
||||
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT),
|
||||
/* 1: media keys */
|
||||
KEYMAP(\
|
||||
FN1, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,SLEP, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MUTE,VOLD,VOLU,TRNS, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MSTP,MPLY,MPRV,MNXT,MSEL, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
|
||||
TRNS, TRNS,TRNS,CALC,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, CAPS, TRNS, \
|
||||
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS)
|
||||
};
|
||||
static const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1),
|
||||
[1] = ACTION_BACKLIGHT_STEP()
|
||||
};
|
||||
|
@ -1,24 +0,0 @@
|
||||
// KMAC Winkeyless
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* 0: qwerty */
|
||||
KEYMAP_WINKEYLESS(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, \
|
||||
FN0, A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, \
|
||||
LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, \
|
||||
LCTL,LGUI,LALT, SPC, RALT,RGUI,RCTL, LEFT,DOWN,RGHT),
|
||||
/* 1: media keys */
|
||||
KEYMAP_WINKEYLESS(\
|
||||
FN1, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,SLEP, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MUTE,VOLD,VOLU,TRNS, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MSTP,MPLY,MPRV,MNXT,MSEL, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
|
||||
TRNS, TRNS,TRNS,CALC,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, CAPS, TRNS, \
|
||||
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS)
|
||||
};
|
||||
static const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1),
|
||||
[1] = ACTION_BACKLIGHT_STEP()
|
||||
};
|
||||
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "stdint.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
/* LED pin configuration
|
||||
* Scroll Lock: Low PE6
|
||||
* Caps Lock: Low PB0
|
||||
*/
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
// Set as output.
|
||||
DDRB |= (1<<0);
|
||||
DDRE |= (1<<6);
|
||||
|
||||
if (usb_led & (1<<USB_LED_CAPS_LOCK))
|
||||
{
|
||||
// Output low.
|
||||
PORTB &= ~(1<<0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Output high.
|
||||
PORTB |= (1<<0);
|
||||
}
|
||||
|
||||
if (usb_led & (1<<USB_LED_SCROLL_LOCK))
|
||||
{
|
||||
// Output low.
|
||||
PORTE &= ~(1<<6);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Output high.
|
||||
PORTE |= (1<<6);
|
||||
}
|
||||
}
|
@ -1,283 +0,0 @@
|
||||
/*
|
||||
Copyright 2013 Mathias Andersson <wraul@dbox.se>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 0
|
||||
#endif
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
/* matrix state(1:on, 0:off) */
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
static uint8_t read_rows(void);
|
||||
static uint8_t read_caps(void);
|
||||
static void init_rows(void);
|
||||
static void unselect_cols(void);
|
||||
static void select_col(uint8_t col);
|
||||
|
||||
inline
|
||||
uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
unselect_cols();
|
||||
init_rows();
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++) { // 0-16
|
||||
select_col(col);
|
||||
_delay_us(3); // TODO: Determine the correct value needed here.
|
||||
uint8_t rows = read_rows();
|
||||
// Use the otherwise unused col: 0 row: 3 for caps lock.
|
||||
if(col == 0) {
|
||||
rows |= read_caps();
|
||||
}
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) { // 0-5
|
||||
bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
|
||||
bool curr_bit = rows & (1<<row);
|
||||
if (prev_bit != curr_bit) {
|
||||
matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
|
||||
if (debouncing) {
|
||||
dprint("bounce!: "); dprintf("%02X", debouncing); dprintln();
|
||||
}
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
}
|
||||
unselect_cols();
|
||||
}
|
||||
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
_delay_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
if (debouncing) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
return (matrix[row] & ((matrix_row_t)1<<col));
|
||||
}
|
||||
|
||||
inline
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
print("\nr/c 0123456789ABCDEF\n");
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_key_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
count += bitpop32(matrix[i]);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Row pin configuration
|
||||
* row: 0 1 2 3 4 5
|
||||
* pin: D0 D1 D2 D3 D5 B7
|
||||
*
|
||||
* Caps lock uses its own pin PE2
|
||||
*/
|
||||
static void init_rows(void)
|
||||
{
|
||||
// Input (DDR:0, PORT:0)
|
||||
DDRD &= ~0b00101111;
|
||||
PORTD &= ~0b00101111;
|
||||
DDRB &= ~(1<<7);
|
||||
PORTB &= ~(1<<7);
|
||||
|
||||
// Input with pull-up (DDR:0, PORT:1)
|
||||
DDRE &= ~(1<<2);
|
||||
PORTE |= (1<<2);
|
||||
}
|
||||
|
||||
static uint8_t read_rows(void)
|
||||
{
|
||||
return (PIND&(1<<0) ? (1<<0) : 0) |
|
||||
(PIND&(1<<1) ? (1<<1) : 0) |
|
||||
(PIND&(1<<2) ? (1<<2) : 0) |
|
||||
(PIND&(1<<3) ? (1<<3) : 0) |
|
||||
(PIND&(1<<5) ? (1<<4) : 0) |
|
||||
(PINB&(1<<7) ? (1<<5) : 0);
|
||||
}
|
||||
|
||||
static uint8_t read_caps(void)
|
||||
{
|
||||
return PINE&(1<<2) ? 0 : (1<<3);
|
||||
}
|
||||
|
||||
/* Columns 0 - 15
|
||||
* These columns uses two 74HC237D 3 to 8 bit demultiplexers.
|
||||
* col / pin: PC6 PB6 PF0 PF1 PC7
|
||||
* 0: 1 0 0 0 0
|
||||
* 1: 1 0 1 0 0
|
||||
* 2: 1 0 0 1 0
|
||||
* 3: 1 0 1 1 0
|
||||
* 4: 1 0 0 0 1
|
||||
* 5: 1 0 1 0 1
|
||||
* 6: 1 0 0 1 1
|
||||
* 7: 1 0 1 1 1
|
||||
* 8: 0 1 0 0 0
|
||||
* 9: 0 1 1 0 0
|
||||
* 10: 0 1 0 1 0
|
||||
* 11: 0 1 1 1 0
|
||||
* 12: 0 1 0 0 1
|
||||
* 13: 0 1 1 0 1
|
||||
* 14: 0 1 0 1 1
|
||||
* 15: 0 1 1 1 1
|
||||
*
|
||||
* col: 16
|
||||
* pin: PB5
|
||||
*/
|
||||
static void unselect_cols(void)
|
||||
{
|
||||
DDRB |= (1<<5) | (1<<6);
|
||||
PORTB &= ~((1<<5) | (1<<6));
|
||||
|
||||
DDRC |= (1<<6) | (1<<7);
|
||||
PORTC &= ~((1<<6) | (1<<7));
|
||||
|
||||
DDRF |= (1<<0) | (1<<1);
|
||||
PORTF &= ~((1<<0) | (1<<1));
|
||||
}
|
||||
|
||||
static void select_col(uint8_t col)
|
||||
{
|
||||
// Output high (DDR:1, PORT:1) to select
|
||||
switch (col) {
|
||||
case 0:
|
||||
PORTC |= (1<<6);
|
||||
break;
|
||||
case 1:
|
||||
PORTC |= (1<<6);
|
||||
PORTF |= (1<<0);
|
||||
break;
|
||||
case 2:
|
||||
PORTC |= (1<<6);
|
||||
PORTF |= (1<<1);
|
||||
break;
|
||||
case 3:
|
||||
PORTC |= (1<<6);
|
||||
PORTF |= (1<<0) | (1<<1);
|
||||
break;
|
||||
case 4:
|
||||
PORTC |= (1<<6);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 5:
|
||||
PORTC |= (1<<6);
|
||||
PORTF |= (1<<0);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 6:
|
||||
PORTC |= (1<<6);
|
||||
PORTF |= (1<<1);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 7:
|
||||
PORTC |= (1<<6);
|
||||
PORTF |= (1<<0) | (1<<1);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 8:
|
||||
PORTB |= (1<<6);
|
||||
break;
|
||||
case 9:
|
||||
PORTB |= (1<<6);
|
||||
PORTF |= (1<<0);
|
||||
break;
|
||||
case 10:
|
||||
PORTB |= (1<<6);
|
||||
PORTF |= (1<<1);
|
||||
break;
|
||||
case 11:
|
||||
PORTB |= (1<<6);
|
||||
PORTF |= (1<<0) | (1<<1);
|
||||
break;
|
||||
case 12:
|
||||
PORTB |= (1<<6);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 13:
|
||||
PORTB |= (1<<6);
|
||||
PORTF |= (1<<0);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 14:
|
||||
PORTB |= (1<<6);
|
||||
PORTF |= (1<<1);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 15:
|
||||
PORTB |= (1<<6);
|
||||
PORTF |= (1<<0) | (1<<1);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 16:
|
||||
PORTB |= (1<<5);
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = lightpad_lufa
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# List C source files here. (C dependencies are automatically generated.)
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
led.c \
|
||||
backlight.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
# MCU name
|
||||
MCU = atmega32u4
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 8000000
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
#CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
#COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
|
||||
# Boot Section Size in bytes
|
||||
# Teensy halfKay 512
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
@ -1,24 +0,0 @@
|
||||
Lightpad keypad firmware
|
||||
======================
|
||||
Korean custom keypad designed by Duck.
|
||||
|
||||
*Note that this is not the official firmware*
|
||||
|
||||
|
||||
Supported models
|
||||
----------------
|
||||
All pcb options are supported.
|
||||
|
||||
|
||||
Build
|
||||
-----
|
||||
Move to this directory then just run `make` like:
|
||||
|
||||
$ make -f Makefile.lufa
|
||||
|
||||
|
||||
Bootloader
|
||||
---------
|
||||
The PCB is hardwired to run the bootloader if the key at the `top left` position is held down when connecting the keyboard.
|
||||
|
||||
It is still possible to use Boot Magic and Command to access the bootloader though.
|
@ -1,129 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "backlight.h"
|
||||
|
||||
/* Backlight pin configuration
|
||||
*
|
||||
* FN1 PB0 (low)
|
||||
* FN2 PB5 (low)
|
||||
* FN3 PB4 (low)
|
||||
* FN4 PD7 (low)
|
||||
* REAR PD6 (high)
|
||||
* NUMPAD PB2 (high)
|
||||
* NUMLOCK PB1 (low)
|
||||
*/
|
||||
void backlight_init_ports() {
|
||||
DDRB |= (1<<0) | (1<<1) | (1<<2) | (1<<4) | (1<<5);
|
||||
DDRD |= (1<<6) | (1<<7);
|
||||
|
||||
backlight_disable_numlock();
|
||||
}
|
||||
|
||||
void backlight_set(uint8_t level) {
|
||||
(level & BACKLIGHT_FN1) ? backlight_enable_fn1() : backlight_disable_fn1();
|
||||
(level & BACKLIGHT_FN2) ? backlight_enable_fn2() : backlight_disable_fn2();
|
||||
(level & BACKLIGHT_FN3) ? backlight_enable_fn3() : backlight_disable_fn3();
|
||||
(level & BACKLIGHT_FN4) ? backlight_enable_fn4() : backlight_disable_fn4();
|
||||
(level & BACKLIGHT_NUMPAD) ? backlight_enable_numpad() : backlight_disable_numpad();
|
||||
(level & BACKLIGHT_REAR) ? backlight_enable_rear() : backlight_disable_rear();
|
||||
}
|
||||
|
||||
void backlight_enable_fn1() {
|
||||
PORTB &= ~(1<<0);
|
||||
}
|
||||
|
||||
void backlight_disable_fn1() {
|
||||
PORTB |= (1<<0);
|
||||
}
|
||||
|
||||
void backlight_invert_fn1() {
|
||||
PORTB ^= (1<<0);
|
||||
}
|
||||
|
||||
void backlight_enable_fn2() {
|
||||
PORTB &= ~(1<<5);
|
||||
}
|
||||
|
||||
void backlight_disable_fn2() {
|
||||
PORTB |= (1<<5);
|
||||
}
|
||||
|
||||
void backlight_invert_fn2() {
|
||||
PORTB ^= (1<<5);
|
||||
}
|
||||
|
||||
void backlight_enable_fn3() {
|
||||
PORTB &= ~(1<<4);
|
||||
}
|
||||
|
||||
void backlight_disable_fn3() {
|
||||
PORTB |= (1<<4);
|
||||
}
|
||||
|
||||
void backlight_invert_fn3() {
|
||||
PORTB ^= (1<<4);
|
||||
}
|
||||
|
||||
void backlight_enable_fn4() {
|
||||
PORTD &= ~(1<<7);
|
||||
}
|
||||
|
||||
void backlight_disable_fn4() {
|
||||
PORTD |= (1<<7);
|
||||
}
|
||||
|
||||
void backlight_invert_fn4() {
|
||||
PORTD ^= (1<<7);
|
||||
}
|
||||
|
||||
void backlight_enable_numpad() {
|
||||
PORTB |= (1<<2);
|
||||
}
|
||||
|
||||
void backlight_disable_numpad() {
|
||||
PORTB &= ~(1<<2);
|
||||
}
|
||||
|
||||
void backlight_invert_numpad() {
|
||||
PORTB ^= (1<<2);
|
||||
}
|
||||
|
||||
void backlight_enable_numlock() {
|
||||
PORTB &= ~(1<<1);
|
||||
}
|
||||
|
||||
void backlight_disable_numlock() {
|
||||
PORTB |= (1<<1);
|
||||
}
|
||||
|
||||
void backlight_invert_numlock() {
|
||||
PORTB ^= (1<<1);
|
||||
}
|
||||
|
||||
void backlight_enable_rear() {
|
||||
PORTD |= (1<<6);
|
||||
}
|
||||
|
||||
void backlight_disable_rear() {
|
||||
PORTD &= ~(1<<6);
|
||||
}
|
||||
|
||||
void backlight_invert_rear() {
|
||||
PORTD ^= (1<<6);
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
|
||||
enum backlight_level {
|
||||
BACKLIGHT_FN1 = 0b0000001,
|
||||
BACKLIGHT_FN2 = 0b0000010,
|
||||
BACKLIGHT_FN3 = 0b0000100,
|
||||
BACKLIGHT_FN4 = 0b0001000,
|
||||
BACKLIGHT_NUMPAD = 0b0010000,
|
||||
BACKLIGHT_REAR = 0b0100000,
|
||||
};
|
||||
|
||||
void backlight_init_ports(void);
|
||||
|
||||
void backlight_invert_fn1(void);
|
||||
void backlight_enable_fn1(void);
|
||||
void backlight_disable_fn1(void);
|
||||
|
||||
void backlight_invert_fn2(void);
|
||||
void backlight_enable_fn2(void);
|
||||
void backlight_disable_fn2(void);
|
||||
|
||||
void backlight_invert_fn3(void);
|
||||
void backlight_enable_fn3(void);
|
||||
void backlight_disable_fn3(void);
|
||||
|
||||
void backlight_invert_fn4(void);
|
||||
void backlight_enable_fn4(void);
|
||||
void backlight_disable_fn4(void);
|
||||
|
||||
void backlight_invert_numlock(void);
|
||||
void backlight_enable_numlock(void);
|
||||
void backlight_disable_numlock(void);
|
||||
|
||||
void backlight_enable_numpad(void);
|
||||
void backlight_disable_numpad(void);
|
||||
void backlight_invert_numpad(void);
|
||||
|
||||
void backlight_enable_rear(void);
|
||||
void backlight_disable_rear(void);
|
||||
void backlight_invert_rear(void);
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x6050
|
||||
#define DEVICE_VER 0x0104
|
||||
#define MANUFACTURER Duck
|
||||
#define PRODUCT Lightpad
|
||||
|
||||
/* message strings */
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for Lightpad
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 6
|
||||
#define MATRIX_COLS 4
|
||||
|
||||
/* number of backlight levels */
|
||||
#define BACKLIGHT_LEVELS 1
|
||||
|
||||
/* Set 0 if need no debouncing */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
#endif
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
#include "action_macro.h"
|
||||
#include "report.h"
|
||||
#include "host.h"
|
||||
#include "debug.h"
|
||||
#include "keymap.h"
|
||||
|
||||
/* Map physical keyboard layout to matrix array */
|
||||
#define KEYMAP( \
|
||||
K5A, K5B, K5C, K5D, \
|
||||
K4A, K4B, K4C, K4D, \
|
||||
K3A, K3B, K3C, K3D, \
|
||||
K2A, K2B, K2C, \
|
||||
K1A, K1B, K1C, K1D, \
|
||||
K0A, K0B, K0C \
|
||||
) { \
|
||||
/* 0 1 2 3 */ \
|
||||
/* 5 */ { KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D}, \
|
||||
/* 4 */ { KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D}, \
|
||||
/* 3 */ { KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D}, \
|
||||
/* 2 */ { KC_##K2A, KC_##K2B, KC_##K2C, KC_NO}, \
|
||||
/* 1 */ { KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D}, \
|
||||
/* 0 */ { KC_##K0A, KC_##K0B, KC_##K0C, KC_NO, } \
|
||||
}
|
||||
|
||||
#include "keymap_lightpad.h"
|
||||
|
||||
#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
|
||||
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
|
||||
|
||||
/* translates key to keycode */
|
||||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
if (layer < KEYMAPS_SIZE) {
|
||||
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||
} else {
|
||||
// fall back to layer 0
|
||||
return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
|
||||
}
|
||||
}
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint8_t keycode)
|
||||
{
|
||||
action_t action;
|
||||
if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
|
||||
action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
|
||||
} else {
|
||||
action.code = ACTION_NO;
|
||||
}
|
||||
return action;
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
#include "backlight.h"
|
||||
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
KEYMAP(\
|
||||
FN0, F1, DEL, BSPC, \
|
||||
NLCK,PSLS,PAST,PMNS, \
|
||||
P7, P8, P9, PPLS, \
|
||||
P4, P5, P6, \
|
||||
P1, P2, P3, PENT, \
|
||||
P0, NO, PDOT), \
|
||||
KEYMAP(\
|
||||
TRNS,PGDN,PGUP,MUTE, \
|
||||
MSEL,MPRV,MNXT,VOLD, \
|
||||
P7, P8, P9, VOLU, \
|
||||
FN4, FN5, FN6, \
|
||||
FN1, FN2, FN3, MPLY, \
|
||||
FN7, NO, MSTP)
|
||||
};
|
||||
|
||||
static const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1),
|
||||
[1] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_FN1),
|
||||
[2] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_FN2),
|
||||
[3] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_FN3),
|
||||
[4] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_FN4),
|
||||
[5] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_NUMPAD),
|
||||
[6] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_REAR),
|
||||
[7] = ACTION_BACKLIGHT_TOGGLE()
|
||||
};
|
@ -1,24 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "stdint.h"
|
||||
#include "led.h"
|
||||
|
||||
void led_set(uint8_t usb_led) {
|
||||
(usb_led & (1<<USB_LED_NUM_LOCK)) ? backlight_enable_numlock() : backlight_disable_numlock();
|
||||
}
|
@ -1,205 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
#include "eeconfig.h"
|
||||
#include "action_layer.h"
|
||||
#include "backlight.h"
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 0
|
||||
#endif
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
static uint8_t read_rows(void);
|
||||
static uint8_t read_fwkey(void);
|
||||
static void init_rows(void);
|
||||
static void unselect_cols(void);
|
||||
static void select_col(uint8_t col);
|
||||
|
||||
inline
|
||||
uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void misc_init(void) {
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
backlight_init_ports();
|
||||
unselect_cols();
|
||||
init_rows();
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
|
||||
select_col(col);
|
||||
_delay_us(3);
|
||||
uint8_t rows = read_rows();
|
||||
// Use the otherwise unused col: 0 row: 0 for firmware key
|
||||
if(col == 0) {
|
||||
rows |= read_fwkey();
|
||||
}
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
|
||||
bool curr_bit = rows & (1<<row);
|
||||
if (prev_bit != curr_bit) {
|
||||
matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
|
||||
if (debouncing) {
|
||||
dprint("bounce!: "); dprintf("%02X", debouncing); dprintln();
|
||||
}
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
}
|
||||
unselect_cols();
|
||||
}
|
||||
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
_delay_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
if (debouncing) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
return (matrix[row] & ((matrix_row_t)1<<col));
|
||||
}
|
||||
|
||||
inline
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
print("\nr/c 0123456789ABCDEF\n");
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_key_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
count += bitpop32(matrix[i]);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Row configuration
|
||||
*
|
||||
* row: 0 1 2 3 4 5
|
||||
* pin: PD0 PD1 PD2 PD3 PD5 PB7
|
||||
*
|
||||
* Firmware uses pin PE2
|
||||
*/
|
||||
static void init_rows(void)
|
||||
{
|
||||
DDRD &= ~0b00101111;
|
||||
PORTD |= 0b00101111;
|
||||
|
||||
DDRB &= ~0b10000000;
|
||||
PORTB |= 0b10000000;
|
||||
|
||||
DDRE &= ~0b00000100;
|
||||
PORTE |= 0b00000100;
|
||||
}
|
||||
|
||||
static uint8_t read_rows(void)
|
||||
{
|
||||
return (PIND&(1<<0) ? (1<<0) : 0) |
|
||||
(PIND&(1<<1) ? (1<<1) : 0) |
|
||||
(PIND&(1<<2) ? (1<<2) : 0) |
|
||||
(PIND&(1<<3) ? (1<<3) : 0) |
|
||||
(PIND&(1<<5) ? (1<<4) : 0) |
|
||||
(PINB&(1<<7) ? (1<<5) : 0);
|
||||
}
|
||||
|
||||
static uint8_t read_fwkey(void)
|
||||
{
|
||||
return PINE&(1<<2) ? 0 : (1<<0);
|
||||
}
|
||||
|
||||
/* Column configuration
|
||||
*
|
||||
* col: 0 1 2 3
|
||||
* pin: PF0 PF1 PC7 PC6
|
||||
*/
|
||||
static void unselect_cols(void)
|
||||
{
|
||||
DDRF |= 0b00000011;
|
||||
PORTF &= ~0b00000011;
|
||||
DDRC |= 0b11000000;
|
||||
PORTC &= ~0b11000000;
|
||||
}
|
||||
|
||||
static void select_col(uint8_t col)
|
||||
{
|
||||
switch (col) {
|
||||
case 0:
|
||||
PORTF |= (1<<0);
|
||||
break;
|
||||
case 1:
|
||||
PORTF |= (1<<1);
|
||||
break;
|
||||
case 2:
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 3:
|
||||
PORTC |= (1<<6);
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = lightsaber_lufa
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
|
||||
# List C source files here. (C dependencies are automatically generated.)
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
led.c \
|
||||
backlight.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name
|
||||
MCU = atmega32u4
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 8000000
|
||||
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
|
||||
|
||||
# Boot Section Size in bytes
|
||||
# Teensy halfKay 512
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
||||
|
||||
winkey: OPT_DEFS += -DLAYOUT_WINKEY
|
||||
winkey: all
|
@ -1,94 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = lightsaber_pjrc
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# keyboard dependent files
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
led.c \
|
||||
backlight.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name
|
||||
MCU = atmega32u4
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# Normally the first thing your program should do is set the clock prescaler,
|
||||
# so your program will run at the correct speed. You should also set this
|
||||
# variable to same clock speed. The _delay_ms() macro uses this, and many
|
||||
# examples use this variable to calculate timings. Do not add a "UL" here.
|
||||
F_CPU = 8000000
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
#MOUSEKEY_ENABLE = yes # Mouse keys(+5000)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+600)
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover(+500)
|
||||
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/pjrc.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
||||
|
||||
winkey: OPT_DEFS += -DLAYOUT_WINKEY
|
||||
winkey: all
|
@ -1,26 +0,0 @@
|
||||
Lightsaber keyboard firmware
|
||||
======================
|
||||
Korean custom keyboard designed by Duck.
|
||||
|
||||
*Note that this is not the official firmware*
|
||||
|
||||
Supported models
|
||||
----------------
|
||||
All pcb options are supported.
|
||||
|
||||
|
||||
Build
|
||||
-----
|
||||
Move to this directory then just run `make` like:
|
||||
|
||||
$ make -f Makefile.[pjrc|lufa]
|
||||
|
||||
Use `Makefile.pjrc` if you want to use PJRC stack or use `Makefile.lufa` for LUFA stack.
|
||||
|
||||
|
||||
Bootloader
|
||||
---------
|
||||
The PCB is hardwired to run the bootloader if the key at the `one above backspace` position is held down when connecting the keyboard.
|
||||
|
||||
It is still possible to use Boot Magic and Command to access the bootloader though.
|
||||
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "backlight.h"
|
||||
|
||||
/* Backlight pin configuration
|
||||
*
|
||||
* Alphas PB1 (high)
|
||||
* Numeric PB2 (high)
|
||||
* Mod+Num PB3 (high)
|
||||
* Backside PD6 (high)
|
||||
* TopRight PD7 (low)
|
||||
* F-Row PE6 (high)
|
||||
*/
|
||||
|
||||
void backlight_set(uint8_t level)
|
||||
{
|
||||
// Set as output.
|
||||
DDRB |= (1<<1) | (1<<2) | (1<<3);
|
||||
DDRD |= (1<<6) | (1<<7);
|
||||
DDRE |= (1<<6);
|
||||
|
||||
if (level & BACKLIGHT_ALPHA)
|
||||
{
|
||||
PORTB |= (1<<1);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTB &= ~(1<<1);
|
||||
}
|
||||
if (level & BACKLIGHT_NUMERIC)
|
||||
{
|
||||
PORTB |= (1<<2);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTB &= ~(1<<2);
|
||||
}
|
||||
if (level & BACKLIGHT_MODNUM)
|
||||
{
|
||||
PORTB |= (1<<3);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTB &= ~(1<<3);
|
||||
}
|
||||
if (level & BACKLIGHT_BACKSIDE)
|
||||
{
|
||||
PORTD |= (1<<6);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTD &= ~(1<<6);
|
||||
}
|
||||
if (level & BACKLIGHT_TOPRIGHT)
|
||||
{
|
||||
PORTD &= ~(1<<7);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTD |= (1<<7);
|
||||
}
|
||||
if (level & BACKLIGHT_FROW)
|
||||
{
|
||||
PORTE |= (1<<6);
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTE &= ~(1<<6);
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
|
||||
enum backlight_level {
|
||||
BACKLIGHT_ALPHA = 0b0000001,
|
||||
BACKLIGHT_NUMERIC = 0b0000010,
|
||||
BACKLIGHT_MODNUM = 0b0000100,
|
||||
BACKLIGHT_BACKSIDE = 0b0001000,
|
||||
BACKLIGHT_TOPRIGHT = 0b0010000,
|
||||
BACKLIGHT_FROW = 0b0100000,
|
||||
};
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
Copyright 2013 Mathias Andersson <wraul@dbox.se>
|
||||
|
||||
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
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x6050
|
||||
#define DEVICE_VER 0x0104
|
||||
#define MANUFACTURER Duck
|
||||
#define PRODUCT Lightsaber
|
||||
|
||||
/* message strings */
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for Lightsaber
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 6
|
||||
#define MATRIX_COLS 18
|
||||
|
||||
/* number of backlight levels */
|
||||
#define BACKLIGHT_LEVELS 1
|
||||
|
||||
/* Set 0 if need no debouncing */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
#endif
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Keymap for Lightsaber controller
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
#include "action_macro.h"
|
||||
#include "report.h"
|
||||
#include "host.h"
|
||||
#include "debug.h"
|
||||
#include "keymap.h"
|
||||
|
||||
// Convert physical keyboard layout to matrix array.
|
||||
// This is a macro to define keymap easily in keyboard layout form.
|
||||
#define KEYMAP( \
|
||||
K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, K5R, \
|
||||
K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, K4O, K4P, K4Q, K4R, \
|
||||
K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3O, K3P, K3Q, K3R, \
|
||||
K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2N, K2O, K2P, K2Q, K2R, \
|
||||
K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1M, K1N, K1O, K1P, K1Q, K1R, \
|
||||
K0A, K0B, K0C, K0G, K0K, K0L, K0M, K0N, K0O, K0P, K0Q, K0R \
|
||||
) { \
|
||||
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 */ \
|
||||
/* 5 */ { KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F, KC_##K5G, KC_##K5H, KC_##K5I, KC_##K5J, KC_##K5K, KC_##K5L, KC_##K5M, KC_##K5N, KC_##K5O, KC_##K5P, KC_##K5Q, KC_##K5R}, \
|
||||
/* 4 */ { KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F, KC_##K4G, KC_##K4H, KC_##K4I, KC_##K4J, KC_##K4K, KC_##K4L, KC_##K4M, KC_##K4N, KC_##K4O, KC_##K4P, KC_##K4Q, KC_##K4R}, \
|
||||
/* 3 */ { KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F, KC_##K3G, KC_##K3H, KC_##K3I, KC_##K3J, KC_##K3K, KC_##K3L, KC_##K3M, KC_##K3N, KC_##K3O, KC_##K3P, KC_##K3Q, KC_##K3R}, \
|
||||
/* 2 */ { KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F, KC_##K2G, KC_##K2H, KC_##K2I, KC_##K2J, KC_##K2K, KC_##K2L, KC_##K2M, KC_##K2N, KC_##K2O, KC_##K2P, KC_##K2Q, KC_##K2R}, \
|
||||
/* 1 */ { KC_##K1A, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F, KC_##K1G, KC_##K1H, KC_##K1I, KC_##K1J, KC_##K1K, KC_##K1L, KC_NO, KC_##K1M, KC_##K1N, KC_##K1O, KC_##K1P, KC_##K1Q, KC_##K1R}, \
|
||||
/* 0 */ { KC_##K0A, KC_##K0B, KC_##K0C, KC_NO, KC_NO, KC_##K0G, KC_NO, KC_NO, KC_##K0K, KC_NO, KC_##K0L, KC_NO, KC_##K0M, KC_##K0N, KC_##K0O, KC_##K0P, KC_##K0Q, KC_##K0R} \
|
||||
}
|
||||
|
||||
#include "keymap_winkey.h"
|
||||
|
||||
#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
|
||||
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
|
||||
|
||||
/* translates key to keycode */
|
||||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
if (layer < KEYMAPS_SIZE) {
|
||||
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||
} else {
|
||||
// fall back to layer 0
|
||||
return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
|
||||
}
|
||||
}
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint8_t keycode)
|
||||
{
|
||||
action_t action;
|
||||
if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
|
||||
action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
|
||||
} else {
|
||||
action.code = ACTION_NO;
|
||||
}
|
||||
return action;
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
#include "backlight.h"
|
||||
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
KEYMAP(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, PSCR, SLCK, BRK, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, NUMLOCK,KP_SLASH,KP_ASTERISK,KP_MINUS, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, KP_7, KP_8, KP_9, KP_PLUS, \
|
||||
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,FN0, ENT, KP_4, KP_5, KP_6, NO, \
|
||||
LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH,NO, RSFT, KP_1, KP_2, KP_3, KP_ENTER, \
|
||||
LCTL,LGUI,LALT, SPC, NO, RALT,RGUI,RCTL, KP_0, NO, KP_DOT, NO), \
|
||||
KEYMAP(\
|
||||
CALC,MYCM,WSCH,WHOM,MAIL,MUTE,VOLD,VOLU,MSEL,MSTP,MPLY,MPRV,MNXT,TRNS, TRNS, WAKE, PWR, SLEP, \
|
||||
FN1, FN2, FN3, FN4, FN5, FN6, FN7, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,PGDN,TRNS,LEFT,DOWN,UP ,RGHT,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, \
|
||||
TRNS, TRNS,TRNS,TRNS,TRNS,PGUP,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, \
|
||||
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS, TRNS)
|
||||
};
|
||||
|
||||
static const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1),
|
||||
[1] = ACTION_BACKLIGHT_TOGGLE(),
|
||||
[2] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_ALPHA),
|
||||
[3] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_MODNUM),
|
||||
[4] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_NUMERIC),
|
||||
[5] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_FROW),
|
||||
[6] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_BACKSIDE),
|
||||
[7] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_TOPRIGHT)
|
||||
};
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "stdint.h"
|
||||
#include "led.h"
|
||||
|
||||
/* LED pin configuration
|
||||
*
|
||||
* Caps PB0 (low)
|
||||
* NumLock PB4 (low)
|
||||
*
|
||||
*/
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
// Set as output.
|
||||
DDRB |= (1<<0) | (1<<4);
|
||||
|
||||
if (usb_led & (1<<USB_LED_CAPS_LOCK))
|
||||
{
|
||||
// Output low.
|
||||
PORTB &= ~(1<<0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Output high.
|
||||
PORTB |= (1<<0);
|
||||
}
|
||||
|
||||
if (usb_led & (1<<USB_LED_NUM_LOCK))
|
||||
{
|
||||
// Output low.
|
||||
PORTB &= ~(1<<4);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Output high.
|
||||
PORTB |= (1<<4);
|
||||
}
|
||||
}
|
@ -1,292 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 0
|
||||
#endif
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
/* matrix state(1:on, 0:off) */
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
static uint8_t read_rows(void);
|
||||
static uint8_t read_fwkey(void);
|
||||
static void init_rows(void);
|
||||
static void unselect_cols(void);
|
||||
static void select_col(uint8_t col);
|
||||
|
||||
inline
|
||||
uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
unselect_cols();
|
||||
init_rows();
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++) { // 0-17
|
||||
select_col(col);
|
||||
_delay_us(3); // TODO: Determine the correct value needed here.
|
||||
uint8_t rows = read_rows();
|
||||
// Use the otherwise unused col: 12 row: 3 for firmware.
|
||||
if(col == 12) {
|
||||
rows |= read_fwkey();
|
||||
}
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) { // 0-5
|
||||
bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
|
||||
bool curr_bit = rows & (1<<row);
|
||||
if (prev_bit != curr_bit) {
|
||||
matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
|
||||
if (debouncing) {
|
||||
dprint("bounce!: "); dprintf("%02X", debouncing); dprintln();
|
||||
}
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
}
|
||||
unselect_cols();
|
||||
}
|
||||
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
_delay_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
if (debouncing) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
return (matrix[row] & ((matrix_row_t)1<<col));
|
||||
}
|
||||
|
||||
inline
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
print("\nr/c 0123456789ABCDEF\n");
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_key_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
count += bitpop32(matrix[i]);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Row pin configuration
|
||||
* row: 0 1 2 3 4 5
|
||||
* pin: PD0 PD1 PD2 PD3 PD5 PB7
|
||||
*
|
||||
* Firmware uses its own pin PE2
|
||||
*/
|
||||
static void init_rows(void)
|
||||
{
|
||||
// Input (DDR:0, PORT:0)
|
||||
DDRD &= ~0b00101111;
|
||||
PORTD &= ~0b00101111;
|
||||
DDRB &= ~(1<<7);
|
||||
PORTB &= ~(1<<7);
|
||||
|
||||
// Input with pull-up (DDR:0, PORT:1)
|
||||
DDRE &= ~(1<<2);
|
||||
PORTE |= (1<<2);
|
||||
}
|
||||
|
||||
static uint8_t read_rows(void)
|
||||
{
|
||||
return (PIND&(1<<0) ? (1<<0) : 0) |
|
||||
(PIND&(1<<1) ? (1<<1) : 0) |
|
||||
(PIND&(1<<2) ? (1<<2) : 0) |
|
||||
(PIND&(1<<3) ? (1<<3) : 0) |
|
||||
(PIND&(1<<5) ? (1<<4) : 0) |
|
||||
(PINB&(1<<7) ? (1<<5) : 0);
|
||||
}
|
||||
|
||||
static uint8_t read_fwkey(void)
|
||||
{
|
||||
return PINE&(1<<2) ? 0 : (1<<3);
|
||||
}
|
||||
|
||||
/* Columns 0 - 15
|
||||
* These columns uses two 74HC237D 3 to 8 bit demultiplexers.
|
||||
* col / pin: PC6 PB6 PF0 PF1 PC7
|
||||
* 0: 1 0 0 0 0
|
||||
* 1: 1 0 1 0 0
|
||||
* 2: 1 0 0 1 0
|
||||
* 3: 1 0 1 1 0
|
||||
* 4: 1 0 0 0 1
|
||||
* 5: 1 0 1 0 1
|
||||
* 6: 1 0 0 1 1
|
||||
* 7: 1 0 1 1 1
|
||||
* 8: 0 1 0 0 0
|
||||
* 9: 0 1 1 0 0
|
||||
* 10: 0 1 0 1 0
|
||||
* 11: 0 1 1 1 0
|
||||
* 12: 0 1 0 0 1
|
||||
* 13: 0 1 1 0 1
|
||||
* 14: 0 1 0 1 1
|
||||
* 15: 0 1 1 1 1
|
||||
*
|
||||
* col: 16
|
||||
* pin: PB5
|
||||
*
|
||||
* col: 17
|
||||
* pin: PD4
|
||||
*/
|
||||
static void unselect_cols(void)
|
||||
{
|
||||
DDRB |= (1<<5) | (1<<6);
|
||||
PORTB &= ~((1<<5) | (1<<6));
|
||||
|
||||
DDRC |= (1<<6) | (1<<7);
|
||||
PORTC &= ~((1<<6) | (1<<7));
|
||||
|
||||
DDRD |= (1<<4);
|
||||
PORTD &= ~(1<<4);
|
||||
|
||||
DDRF |= (1<<0) | (1<<1);
|
||||
PORTF &= ~((1<<0) | (1<<1));
|
||||
}
|
||||
|
||||
static void select_col(uint8_t col)
|
||||
{
|
||||
// Output high (DDR:1, PORT:1) to select
|
||||
switch (col) {
|
||||
case 0:
|
||||
PORTC |= (1<<6);
|
||||
break;
|
||||
case 1:
|
||||
PORTC |= (1<<6);
|
||||
PORTF |= (1<<0);
|
||||
break;
|
||||
case 2:
|
||||
PORTC |= (1<<6);
|
||||
PORTF |= (1<<1);
|
||||
break;
|
||||
case 3:
|
||||
PORTC |= (1<<6);
|
||||
PORTF |= (1<<0) | (1<<1);
|
||||
break;
|
||||
case 4:
|
||||
PORTC |= (1<<6);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 5:
|
||||
PORTC |= (1<<6);
|
||||
PORTF |= (1<<0);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 6:
|
||||
PORTC |= (1<<6);
|
||||
PORTF |= (1<<1);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 7:
|
||||
PORTC |= (1<<6);
|
||||
PORTF |= (1<<0) | (1<<1);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 8:
|
||||
PORTB |= (1<<6);
|
||||
break;
|
||||
case 9:
|
||||
PORTB |= (1<<6);
|
||||
PORTF |= (1<<0);
|
||||
break;
|
||||
case 10:
|
||||
PORTB |= (1<<6);
|
||||
PORTF |= (1<<1);
|
||||
break;
|
||||
case 11:
|
||||
PORTB |= (1<<6);
|
||||
PORTF |= (1<<0) | (1<<1);
|
||||
break;
|
||||
case 12:
|
||||
PORTB |= (1<<6);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 13:
|
||||
PORTB |= (1<<6);
|
||||
PORTF |= (1<<0);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 14:
|
||||
PORTB |= (1<<6);
|
||||
PORTF |= (1<<1);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 15:
|
||||
PORTB |= (1<<6);
|
||||
PORTF |= (1<<0) | (1<<1);
|
||||
PORTC |= (1<<7);
|
||||
break;
|
||||
case 16:
|
||||
PORTB |= (1<<5);
|
||||
break;
|
||||
case 17:
|
||||
PORTD |= (1<<4);
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = macway_lufa
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
|
||||
# List C source files here. (C dependencies are automatically generated.)
|
||||
SRC += keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name
|
||||
#MCU = at90usb1287
|
||||
MCU = atmega32u4
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover
|
||||
|
||||
|
||||
# Boot Section Size in bytes
|
||||
# Teensy halfKay 512
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
#OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
@ -1,97 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = macway_pjrc
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# keyboard dependent files
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name, you MUST set this to match the board you are using
|
||||
# type "make clean" after changing this, so all files will be rebuilt
|
||||
#MCU = at90usb162 # Teensy 1.0
|
||||
MCU = atmega32u4 # Teensy 2.0
|
||||
#MCU = at90usb646 # Teensy++ 1.0
|
||||
#MCU = at90usb1286 # Teensy++ 2.0
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# Normally the first thing your program should do is set the clock prescaler,
|
||||
# so your program will run at the correct speed. You should also set this
|
||||
# variable to same clock speed. The _delay_ms() macro uses this, and many
|
||||
# examples use this variable to calculate timings. Do not add a "UL" here.
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover
|
||||
|
||||
|
||||
|
||||
#---------------- Programming Options --------------------------
|
||||
PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
|
||||
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/pjrc.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
Copyright 2011 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
|
||||
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0xBEE0
|
||||
#define DEVICE_VER 0x0202
|
||||
#define MANUFACTURER t.m.k.
|
||||
#define PRODUCT Macway mod
|
||||
|
||||
/* message strings */
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for Macway mod
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 9
|
||||
#define MATRIX_COLS 8
|
||||
|
||||
/* define if matrix has ghost */
|
||||
#define MATRIX_HAS_GHOST
|
||||
|
||||
/* Set 0 if need no debouncing */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
/* legacy keymap support */
|
||||
#define USE_LEGACY_KEYMAP
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_LCTRL) | MOD_BIT(KC_LALT) | MOD_BIT(KC_LGUI)) || \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
/* PS/2 mouse */
|
||||
#ifdef PS2_MOUSE_ENABLE
|
||||
# define PS2_CLOCK_PORT PORTF
|
||||
# define PS2_CLOCK_PIN PINF
|
||||
# define PS2_CLOCK_DDR DDRF
|
||||
# define PS2_CLOCK_BIT 0
|
||||
# define PS2_DATA_PORT PORTF
|
||||
# define PS2_DATA_PIN PINF
|
||||
# define PS2_DATA_DDR DDRF
|
||||
# define PS2_DATA_BIT 1
|
||||
#endif
|
||||
|
||||
#endif
|
Before Width: | Height: | Size: 119 KiB |
Before Width: | Height: | Size: 143 KiB |
Before Width: | Height: | Size: 114 KiB |
Before Width: | Height: | Size: 107 KiB |
Before Width: | Height: | Size: 113 KiB |
Before Width: | Height: | Size: 162 KiB |
Before Width: | Height: | Size: 162 KiB |
Before Width: | Height: | Size: 149 KiB |
Before Width: | Height: | Size: 116 KiB |
@ -1,195 +0,0 @@
|
||||
/*
|
||||
Copyright 2011 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Keymap for Macway mod
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "keycode.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "keymap.h"
|
||||
|
||||
|
||||
// Convert physical keyboard layout to matrix array.
|
||||
// This is a macro to define keymap easily in keyboard layout form.
|
||||
#define KEYMAP( \
|
||||
K11, K10, K20, K30, K40, K41, K51, K50, K60, K70, K80, K81, K61, K02, \
|
||||
K12, K13, K23, K33, K43, K42, K52, K53, K63, K73, K83, K82, K62, K01, \
|
||||
K15, K14, K24, K34, K44, K45, K55, K54, K64, K74, K84, K85, K06, \
|
||||
K67, K16, K26, K36, K46, K47, K57, K56, K66, K76, K87, K32, K35, \
|
||||
K75, K22, K00, K07, K21, K04, K37, K27, K17 \
|
||||
) { \
|
||||
{ KC_##K00, KC_##K01, KC_##K02, KC_NO, KC_##K04, KC_NO, KC_##K06, KC_##K07 }, \
|
||||
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
|
||||
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_NO, KC_##K26, KC_##K27 }, \
|
||||
{ KC_##K30, KC_NO, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \
|
||||
{ KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \
|
||||
{ KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
|
||||
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_NO, KC_##K66, KC_##K67 }, \
|
||||
{ KC_##K70, KC_NO, KC_NO, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO }, \
|
||||
{ KC_##K80, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_NO, KC_##K87 } \
|
||||
}
|
||||
|
||||
#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
|
||||
|
||||
|
||||
// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
|
||||
static const uint8_t PROGMEM fn_layer[] = {
|
||||
0, // Fn0
|
||||
1, // Fn1
|
||||
2, // Fn2
|
||||
3, // Fn3
|
||||
4, // Fn4
|
||||
0, // Fn5
|
||||
3, // Fn6
|
||||
3 // Fn7
|
||||
};
|
||||
|
||||
// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
|
||||
// See layer.c for details.
|
||||
static const uint8_t PROGMEM fn_keycode[] = {
|
||||
KC_NO, // Fn0
|
||||
KC_NO, // Fn1
|
||||
KC_SLSH, // Fn2
|
||||
KC_SCLN, // Fn3
|
||||
KC_SPC, // Fn4
|
||||
KC_NO, // Fn5
|
||||
KC_NO, // Fn6
|
||||
KC_NO // Fn7
|
||||
};
|
||||
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Layer 0: Default Layer
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| |
|
||||
* |-----------------------------------------------------' |
|
||||
* |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn1|
|
||||
* |-----------------------------------------------------------|
|
||||
* |Fn7|Gui |Alt |Fn4 |Alt |Gui|Fn6|Fn6|Ctr|
|
||||
* `-----------------------------------------------------------'
|
||||
*/
|
||||
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \
|
||||
LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,ENT, \
|
||||
LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,FN1, \
|
||||
FN7, LGUI,LALT,FN4, RALT,GRV, FN6, FN6, RCTL),
|
||||
|
||||
|
||||
/* Layer 1: HHKB mode (HHKB Fn)
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Caps | | | | | | | |Psc|Slk|Pus|Up | | |
|
||||
* |-----------------------------------------------------' |
|
||||
* |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | | | | | | +| -|End|PgD|Dow|Shift |xxx|
|
||||
* |-----------------------------------------------------------|
|
||||
* | |Gui |Alt | |Alt |Gui| | |Ctr|
|
||||
* `-----------------------------------------------------------'
|
||||
*/
|
||||
KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \
|
||||
CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,BRK, UP, INS, NLCK,\
|
||||
LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \
|
||||
LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,FN1, \
|
||||
NO, LGUI,LALT,SPC, RALT,NO, NO, NO, RCTL),
|
||||
|
||||
|
||||
/* Layer 2: Vi mode (Quote/Rmeta)
|
||||
* ,-----------------------------------------------------------.
|
||||
* | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| ` |
|
||||
* |-----------------------------------------------------------|
|
||||
* | \ |Hom|PgD|Up |PgU|End|Hom|PgD|PgU|End| | | | |
|
||||
* |-----------------------------------------------------' |
|
||||
* |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | | \ |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | | | | | |Hom|PgD|PgU|End|xxx|Shift | |
|
||||
* |-----------------------------------------------------------|
|
||||
* | |Gui |Alt |Space |Alt |Gui|Fn6|Fn6|Ctr|
|
||||
* `-----------------------------------------------------------'
|
||||
*/
|
||||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \
|
||||
BSLS,HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, NO, \
|
||||
LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, BSLS, \
|
||||
LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT,NO, \
|
||||
NO, LGUI,LALT,SPC, RALT,RGUI,FN6, FN6, RCTL),
|
||||
|
||||
|
||||
/* Layer 3: Mouse mode (Semicolon)
|
||||
* ,-----------------------------------------------------------.
|
||||
* | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| ` |
|
||||
* |-----------------------------------------------------------|
|
||||
* | \ |MwL|MwD|McU|MwU|MwR|MwL|MwD|MwU|MwR| | | | |
|
||||
* |-----------------------------------------------------' |
|
||||
* |Contro| |McL|McD|McR| |McL|McD|McU|McR|xxx| | \ |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | | |Mb1|Mb2|Mb3|Mb2|Mb1| | | |Shift | |
|
||||
* |-----------------------------------------------------------|
|
||||
* |xxx|Gui |Alt |Mb1 |Alt | | | | |
|
||||
* `-----------------------------------------------------------'
|
||||
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
||||
*/
|
||||
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \
|
||||
BSLS,WH_L,WH_D,MS_U,WH_U,WH_R,WH_L,WH_D,WH_U,WH_R,NO, NO, NO, NO, \
|
||||
LCTL,NO, MS_L,MS_D,MS_R,NO, MS_L,MS_D,MS_U,MS_R,FN3, NO, BSLS, \
|
||||
LSFT,NO, NO, BTN1,BTN2,BTN3,BTN2,BTN1,NO, NO, NO, RSFT,NO, \
|
||||
FN7, LGUI,LALT,BTN1,RALT,NO, FN6, FN6, NO),
|
||||
|
||||
|
||||
/* Layer 4: Matias half keyboard style (Space)
|
||||
* ,-----------------------------------------------------------.
|
||||
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Backs| P| O| I| U| Y| T| R| E| W| Q|Tab|Tab| |
|
||||
* |-----------------------------------------------------' |
|
||||
* |Contro| ;| L| K| J| H| G| F| D| S| A|Con|Control |
|
||||
* |-----------------------------------------------------------|
|
||||
* |Shift | /| .| ,| M| N| B| V| C| X| Z|Shift | |
|
||||
* |-----------------------------------------------------------|
|
||||
* | |Gui |Alt |xxxxxxxxxxxxxxxxxxxxxx|Alt |Gui| | |Ctr|
|
||||
* `-----------------------------------------------------------'
|
||||
*/
|
||||
KEYMAP(MINS,0, 9, 8, 7, 6, 5, 4, 3, 2, 1, NO, NO, ESC, \
|
||||
BSPC,P, O, I, U, Y, T, R, E, W, Q, TAB, TAB, TAB, \
|
||||
LCTL,SCLN,L, K, J, H, G, F, D, S, A, RCTL,RCTL, \
|
||||
LSFT,SLSH,DOT, COMM,M, N, B, V, C, X, Z, RSFT,NO, \
|
||||
NO, LGUI,LALT,FN4, RALT,RGUI,NO, NO, RCTL),
|
||||
};
|
||||
|
||||
|
||||
uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
|
||||
{
|
||||
return KEYCODE(layer, row, col);
|
||||
}
|
||||
|
||||
uint8_t keymap_fn_layer(uint8_t index)
|
||||
{
|
||||
return pgm_read_byte(&fn_layer[index]);
|
||||
}
|
||||
|
||||
uint8_t keymap_fn_keycode(uint8_t index)
|
||||
{
|
||||
return pgm_read_byte(&fn_keycode[index]);
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
/*
|
||||
Copyright 2011 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/>.
|
||||
*/
|
||||
|
||||
#include "stdint.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
}
|
@ -1,217 +0,0 @@
|
||||
/*
|
||||
Copyright 2011 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* scan matrix
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 5
|
||||
#endif
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
/* matrix state(1:on, 0:off) */
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
#ifdef MATRIX_HAS_GHOST
|
||||
static bool matrix_has_ghost_in_row(uint8_t row);
|
||||
#endif
|
||||
static matrix_row_t read_cols(void);
|
||||
static void unselect_rows(void);
|
||||
static void select_row(uint8_t row);
|
||||
|
||||
|
||||
inline
|
||||
uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
// initialize row and col
|
||||
unselect_rows();
|
||||
// Input with pull-up(DDR:0, PORT:1)
|
||||
DDRB = 0x00;
|
||||
PORTB = 0xFF;
|
||||
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
select_row(i);
|
||||
_delay_us(30); // without this wait read unstable value.
|
||||
matrix_row_t cols = read_cols();
|
||||
if (matrix_debouncing[i] != cols) {
|
||||
matrix_debouncing[i] = cols;
|
||||
if (debouncing) {
|
||||
debug("bounce!: "); debug_hex(debouncing); debug("\n");
|
||||
}
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
unselect_rows();
|
||||
}
|
||||
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
_delay_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
if (debouncing) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
return (matrix[row] & ((matrix_row_t)1<<col));
|
||||
}
|
||||
|
||||
inline
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
print("\nr/c 01234567\n");
|
||||
for (uint8_t row = 0; row < matrix_rows(); row++) {
|
||||
phex(row); print(": ");
|
||||
pbin_reverse(matrix_get_row(row));
|
||||
#ifdef MATRIX_HAS_GHOST
|
||||
if (matrix_has_ghost_in_row(row)) {
|
||||
print(" <ghost");
|
||||
}
|
||||
#endif
|
||||
print("\n");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MATRIX_HAS_GHOST
|
||||
inline
|
||||
static bool matrix_has_ghost_in_row(uint8_t row)
|
||||
{
|
||||
// no ghost exists in case less than 2 keys on
|
||||
if (((matrix[row] - 1) & matrix[row]) == 0)
|
||||
return false;
|
||||
|
||||
// ghost exists in case same state as other row
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
if (i != row && (matrix[i] & matrix[row]))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline
|
||||
static matrix_row_t read_cols(void)
|
||||
{
|
||||
return ~PINB;
|
||||
}
|
||||
|
||||
inline
|
||||
static void unselect_rows(void)
|
||||
{
|
||||
// Hi-Z(DDR:0, PORT:0) to unselect
|
||||
DDRC &= ~0b01000000; // PC: 6
|
||||
PORTC &= ~0b01000000;
|
||||
DDRD &= ~0b11100111; // PD: 7,6,5,2,1,0
|
||||
PORTD &= ~0b11100111;
|
||||
DDRF &= ~0b11000000; // PF: 7,6
|
||||
PORTF &= ~0b11000000;
|
||||
}
|
||||
|
||||
inline
|
||||
static void select_row(uint8_t row)
|
||||
{
|
||||
// Output low(DDR:1, PORT:0) to select
|
||||
// row: 0 1 2 3 4 5 6 7 8
|
||||
// pin: PD0, PD5, PD7, PF6, PD6, PD1, PD2, PC6, PF7
|
||||
switch (row) {
|
||||
case 0:
|
||||
DDRD |= (1<<0);
|
||||
PORTD &= ~(1<<0);
|
||||
break;
|
||||
case 1:
|
||||
DDRD |= (1<<5);
|
||||
PORTD &= ~(1<<5);
|
||||
break;
|
||||
case 2:
|
||||
DDRD |= (1<<7);
|
||||
PORTD &= ~(1<<7);
|
||||
break;
|
||||
case 3:
|
||||
DDRF |= (1<<6);
|
||||
PORTF &= ~(1<<6);
|
||||
break;
|
||||
case 4:
|
||||
DDRD |= (1<<6);
|
||||
PORTD &= ~(1<<6);
|
||||
break;
|
||||
case 5:
|
||||
DDRD |= (1<<1);
|
||||
PORTD &= ~(1<<1);
|
||||
break;
|
||||
case 6:
|
||||
DDRD |= (1<<2);
|
||||
PORTD &= ~(1<<2);
|
||||
break;
|
||||
case 7:
|
||||
DDRC |= (1<<6);
|
||||
PORTC &= ~(1<<6);
|
||||
break;
|
||||
case 8:
|
||||
DDRF |= (1<<7);
|
||||
PORTF &= ~(1<<7);
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
PROJECT = mbed_onekey
|
||||
|
||||
TMK_DIR = ../../tmk_core
|
||||
MBED_DIR = $(TMK_DIR)/mbed-sdk
|
||||
|
||||
#VPATH += $(MBED_DIR):$(TMK_DIR)
|
||||
vpath %.s .:$(MBED_DIR):$(TMK_DIR)
|
||||
vpath %.c .:$(MBED_DIR):$(TMK_DIR)
|
||||
vpath %.cpp .:$(MBED_DIR):$(TMK_DIR)
|
||||
|
||||
OBJDIR = ./build
|
||||
|
||||
OBJECTS = \
|
||||
$(OBJDIR)/./main.o
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
SYS_OBJECTS =
|
||||
|
||||
INCLUDE_PATHS = -I.
|
||||
|
||||
LIBRARY_PATHS =
|
||||
LIBRARIES =
|
||||
|
||||
# Build Options
|
||||
# Comment out to disable
|
||||
#BOOTMAGIC_ENABLE = yes
|
||||
#MOUSEKEY_ENABLE = yes
|
||||
|
||||
|
||||
include $(TMK_DIR)/tool/mbed/mbed.mk
|
||||
include $(TMK_DIR)/tool/mbed/common.mk
|
||||
include $(TMK_DIR)/tool/mbed/gcc.mk
|
@ -1,7 +0,0 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#define MATRIX_ROWS 1
|
||||
#define MATRIX_COLS 1
|
||||
|
||||
#endif
|
@ -1,33 +0,0 @@
|
||||
#include "mbed.h"
|
||||
#include "action.h"
|
||||
#include "keycode.h"
|
||||
#include "host.h"
|
||||
#include "mbed_driver.h"
|
||||
|
||||
|
||||
// Button and LEDs of LPC11U35 board
|
||||
DigitalIn isp(P0_1); // ISP button
|
||||
DigitalOut led_red(P0_20);
|
||||
DigitalOut led_green(P0_21);
|
||||
|
||||
|
||||
int main(void) {
|
||||
isp.mode(PullUp);
|
||||
led_red = 1;
|
||||
led_green = 0;
|
||||
|
||||
host_set_driver(&mbed_driver);
|
||||
|
||||
bool last_isp = isp;
|
||||
while (1) {
|
||||
if (last_isp == isp) continue;
|
||||
last_isp = isp;
|
||||
if (last_isp == 0) {
|
||||
led_red = 0; // on
|
||||
register_code(KC_A);
|
||||
} else {
|
||||
led_red = 1; // off
|
||||
unregister_code(KC_A);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = nerd_lufa
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# project specific files
|
||||
SRC = keymap_common.c \
|
||||
matrix.c \
|
||||
backlight.c
|
||||
|
||||
ifdef LAYOUT
|
||||
OPT_DEFS += -DNERD_LAYOUT_$(LAYOUT)
|
||||
endif
|
||||
|
||||
ifdef KEYMAP
|
||||
SRC := keymap_$(LAYOUT)_$(KEYMAP).c $(SRC)
|
||||
endif
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
# MCU name
|
||||
MCU = atmega32u4
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 8000000
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
# Boot Section Size in *bytes*
|
||||
# Teensy halfKay 512
|
||||
# Teensy++ halfKay 1024
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
# USBaspLoader 2048
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
@ -1,52 +0,0 @@
|
||||
NerD keyboard firmware
|
||||
========================
|
||||
|
||||
Korean Keyboard designed by GON.
|
||||
|
||||
*Note that this is not the official firmware*
|
||||
|
||||
|
||||
Hardware revision
|
||||
-----------------
|
||||
|
||||
This firmware was developed and tested for NerD pcb version 1.61 and 2.0.
|
||||
|
||||
|
||||
Supported features
|
||||
------------------
|
||||
|
||||
* All layout options are supported
|
||||
* All leds are supported
|
||||
* 60% and 80% (TKL) pcbs are supported
|
||||
|
||||
|
||||
Changing Bootloader
|
||||
-------------------
|
||||
|
||||
You can't simply just upload this firmware to a new NerD board because the original
|
||||
bootloader won't accept DFU connections.
|
||||
|
||||
You can change the bootloader of the keyboard with an ISP programmer of your choice.
|
||||
The bootloader pins are easy to access on the NerD pcb.
|
||||
|
||||
*Be aware that after changing the bootloader the official configuration software
|
||||
won't work anymore and you'll lose your warrenty. GON won't provide any support for this firmware.*
|
||||
|
||||
|
||||
Build
|
||||
-----
|
||||
|
||||
For building you have to specify two build-options, LAYOUT and KEYMAP. The layout option defines
|
||||
pcb layout and can be either 60% or 80% at the momemnt. The keymap option selects your
|
||||
preferred keymapping.
|
||||
|
||||
Move to this directory then just run `make LAYOUT=60 KEYMAP=ansi150`
|
||||
|
||||
to compile a firmware for a 60% pcb with ANSI 150 key mapping.
|
||||
|
||||
|
||||
Jump to Bootloader
|
||||
------------------
|
||||
|
||||
You can jump to bootloader by software if you have a macro defined for this in your keymap. The
|
||||
default command is (LSFT+RSFT+PAUS) to access the bootloader by software jump.
|
@ -1,81 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "backlight.h"
|
||||
#include "led.h"
|
||||
|
||||
void backlight_init_ports()
|
||||
{
|
||||
DDRB |= 0b11100000; // PB7 (switch), PB6 (pcb), PB5 (caps)
|
||||
}
|
||||
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
(usb_led & (1<<USB_LED_CAPS_LOCK)) ? backlight_caps_enable() : backlight_caps_disable();
|
||||
}
|
||||
|
||||
void backlight_set(uint8_t level)
|
||||
{
|
||||
(level & BACKLIGHT_SWITCH) ? backlight_switch_enable() : backlight_switch_disable();
|
||||
(level & BACKLIGHT_PCB) ? backlight_pcb_enable() : backlight_pcb_disable();
|
||||
}
|
||||
|
||||
void backlight_switch_enable()
|
||||
{
|
||||
PORTB |= 0b10000000;
|
||||
}
|
||||
|
||||
void backlight_switch_disable()
|
||||
{
|
||||
PORTB &= ~0b10000000;
|
||||
}
|
||||
|
||||
void backlight_switch_invert()
|
||||
{
|
||||
PORTB ^= 0b10000000;
|
||||
}
|
||||
|
||||
void backlight_pcb_enable()
|
||||
{
|
||||
PORTB |= 0b01000000;
|
||||
}
|
||||
|
||||
void backlight_pcb_disable()
|
||||
{
|
||||
PORTB &= ~0b01000000;
|
||||
}
|
||||
|
||||
void backlight_pcb_invert()
|
||||
{
|
||||
PORTB ^= 0b01000000;
|
||||
}
|
||||
|
||||
void backlight_caps_enable()
|
||||
{
|
||||
PORTB |= 0b00100000;
|
||||
}
|
||||
|
||||
void backlight_caps_disable()
|
||||
{
|
||||
PORTB &= ~0b00100000;
|
||||
}
|
||||
|
||||
void backlight_caps_invert()
|
||||
{
|
||||
PORTB ^= 0b00100000;
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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 BACKLIGHT_H
|
||||
#define BACKLIGHT_H
|
||||
|
||||
enum backlight_level {
|
||||
BACKLIGHT_SWITCH = 0b0000001,
|
||||
BACKLIGHT_PCB = 0b0000010,
|
||||
};
|
||||
|
||||
void backlight_init_ports(void);
|
||||
|
||||
void backlight_switch_invert(void);
|
||||
void backlight_switch_enable(void);
|
||||
void backlight_switch_disable(void);
|
||||
|
||||
void backlight_pcb_invert(void);
|
||||
void backlight_pcb_enable(void);
|
||||
void backlight_pcb_disable(void);
|
||||
|
||||
void backlight_caps_invert(void);
|
||||
void backlight_caps_enable(void);
|
||||
void backlight_caps_disable(void);
|
||||
|
||||
#endif // BACKLIGHT_H
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x6060
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER GON
|
||||
#define PRODUCT NerD
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for NerD
|
||||
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 9
|
||||
#define MATRIX_COLS 10
|
||||
|
||||
/* Set 0 if debouncing isn't needed */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
/* number of backlight levels */
|
||||
#define BACKLIGHT_LEVELS 2
|
||||
|
||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||
#define LOCKING_SUPPORT_ENABLE
|
||||
|
||||
/* Locking resynchronize hack */
|
||||
#define LOCKING_RESYNC_ENABLE
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
#endif
|
@ -1,30 +0,0 @@
|
||||
#include "keymap_common.h"
|
||||
#include "backlight.h"
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Layer 0: Default */
|
||||
KEYMAP_ANSI150(GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \
|
||||
ESC, A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, \
|
||||
LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT, \
|
||||
LCTL,LGUI,LALT, SPC, RALT,FN0 ,RCTL),
|
||||
/* Layer 1: Space Fn */
|
||||
KEYMAP_ANSI150(TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
|
||||
TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS, FN1, TRNS,FN0, TRNS),
|
||||
/* Layer 2: Functions */
|
||||
KEYMAP_ANSI150(SLEP,F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, MUTE, \
|
||||
TRNS,BTN1,MS_U,BTN3,PSCR,SLCK,PAUS,HOME,INS, END, MPLY,VOLD,VOLU,FN3, \
|
||||
CAPS,MS_L,MS_D,MS_R,PGDN,TRNS,LEFT,DOWN,UP ,RGHT,MPRV,MNXT, FN2, \
|
||||
UP, TRNS,DEL, TRNS,TRNS,PGUP,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
|
||||
LEFT,DOWN,RGHT, TRNS, TRNS,TRNS,TRNS)
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(2),
|
||||
[1] = ACTION_LAYER_TAP_KEY(2, KC_SPACE),
|
||||
[2] = ACTION_LAYER_TOGGLE(1),
|
||||
[3] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_SWITCH)
|
||||
};
|
@ -1,33 +0,0 @@
|
||||
#include "keymap_common.h"
|
||||
#include "backlight.h"
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* Layer 0: Default */
|
||||
KEYMAP_ANSI150(ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, \
|
||||
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, \
|
||||
LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT, UP, \
|
||||
LCTL,LGUI,LALT, SPC, RALT,FN0, RCTL, LEFT,DOWN,RGHT),
|
||||
/* Layer 1: Space Fn */
|
||||
KEYMAP_ANSI150(TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, \
|
||||
ESC,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
|
||||
TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
|
||||
TRNS,TRNS,TRNS, FN1, TRNS,FN0, TRNS, TRNS,TRNS,TRNS),
|
||||
/* Layer 2: Functions */
|
||||
KEYMAP_ANSI150(SLEP, MYCM,WSCH,WHOM,MAIL,VOLD,VOLU,MUTE,MSEL,MPLY,MPRV,MNXT,MSTP, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,END, TRNS,TRNS,TRNS,TRNS,TRNS,HOME,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, \
|
||||
TRNS,BTN1,MS_U,BTN3,PSCR,SLCK,TRNS,TRNS,INS, TRNS,TRNS,TRNS,TRNS,FN3, TRNS,TRNS,TRNS, \
|
||||
CAPS,MS_L,MS_D,MS_R,PGDN,TRNS,LEFT,DOWN,UP ,RGHT,TRNS,TRNS, FN2, \
|
||||
TRNS, TRNS,DEL, TRNS,TRNS,PGUP,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
|
||||
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS),
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(2),
|
||||
[1] = ACTION_LAYER_TAP_KEY(2, KC_SPACE),
|
||||
[2] = ACTION_LAYER_TOGGLE(1),
|
||||
[3] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_SWITCH)
|
||||
};
|
@ -1,29 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
#include "keymap_common.h"
|
||||
|
||||
/* translates key to keycode */
|
||||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||
}
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint8_t keycode)
|
||||
{
|
||||
return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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 KEYMAP_COMMON_H
|
||||
#define KEYMAP_COMMON_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
#include "action_macro.h"
|
||||
#include "report.h"
|
||||
#include "host.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "keymap.h"
|
||||
|
||||
extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
|
||||
extern const uint16_t fn_actions[];
|
||||
|
||||
#define KEYMAP( \
|
||||
K08, K09, K18, K19, K28, K29, K38, K39, K48, K49, K58, K59, K68, K69, K88, K89, \
|
||||
K00, K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61, K80, K81, K84, \
|
||||
K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63, K82, K83, K85, \
|
||||
K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64, K71, K65, \
|
||||
K07, K79, K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66, K67, K86, \
|
||||
K06, K05, K78, K70, K72, K73, K74, K75, K76, K77, K87 \
|
||||
) { \
|
||||
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09 }, \
|
||||
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19 }, \
|
||||
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29 }, \
|
||||
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39 }, \
|
||||
{ KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47, KC_##K48, KC_##K49 }, \
|
||||
{ KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57, KC_##K58, KC_##K59 }, \
|
||||
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67, KC_##K68, KC_##K69 }, \
|
||||
{ KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77, KC_##K78, KC_##K79 }, \
|
||||
{ KC_##K80, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86, KC_##K87, KC_##K88, KC_##K89 } \
|
||||
}
|
||||
|
||||
#ifdef NERD_LAYOUT_60
|
||||
#define KEYMAP_ANSI150( \
|
||||
K08, K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61, \
|
||||
K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63, \
|
||||
K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64, K65, \
|
||||
K07, K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66, \
|
||||
K06, K05, K78, K70, K73, K74, K75 \
|
||||
) KEYMAP( \
|
||||
K08, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, \
|
||||
NO, K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61, NO, NO, NO, \
|
||||
K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63, NO, NO, NO, \
|
||||
K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64, NO, K65, \
|
||||
K07, NO, K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66, NO, NO, \
|
||||
K06, K05, K78, K70, NO, K73, K74, K75, NO, NO, NO \
|
||||
)
|
||||
#endif
|
||||
|
||||
#ifdef NERD_LAYOUT_80
|
||||
#define KEYMAP_ANSI150( \
|
||||
K08, K09, K18, K19, K28, K29, K38, K39, K48, K49, K58, K59, K68, K69, K88, K89, \
|
||||
K00, K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61, K80, K81, K84, \
|
||||
K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63, K82, K83, K85, \
|
||||
K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64, K65, \
|
||||
K07, K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66, K86, \
|
||||
K06, K05, K78, K70, K73, K74, K75, K76, K77, K87 \
|
||||
) KEYMAP( \
|
||||
K08, K09, K18, K19, K28, K29, K38, K39, K48, K49, K58, K59, K68, K69, K88, K89, \
|
||||
K00, K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61, K80, K81, K84, \
|
||||
K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63, K82, K83, K85, \
|
||||
K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64, NO, K65, \
|
||||
K07, NO, K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66, NO, K86, \
|
||||
K06, K05, K78, K70, NO, K73, K74, K75, K76, K77, K87 \
|
||||
)
|
||||
#endif
|
||||
|
||||
#endif // KEYMAP_COMMON_H
|
@ -1,221 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
#include "backlight.h"
|
||||
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 5
|
||||
#endif
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
/* matrix state(1:on, 0:off) */
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
static uint16_t read_inputs(void);
|
||||
static void init_inputs(void);
|
||||
static void init_outputs(void);
|
||||
static void reset_inputs(void);
|
||||
static void reset_outputs(void);
|
||||
static void select_output(uint8_t col);
|
||||
|
||||
inline
|
||||
uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
backlight_init_ports();
|
||||
init_inputs();
|
||||
init_outputs();
|
||||
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
|
||||
reset_inputs();
|
||||
reset_outputs();
|
||||
select_output(col);
|
||||
_delay_us(3);
|
||||
uint16_t rows = read_inputs();
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
|
||||
bool curr_bit = rows & (1<<row);
|
||||
if (prev_bit != curr_bit) {
|
||||
matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
|
||||
if (debouncing) {
|
||||
dprint("bounce!: "); dprintf("%02X", debouncing); dprintln();
|
||||
}
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
_delay_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
if (debouncing) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
return (matrix[row] & ((matrix_row_t)1<<col));
|
||||
}
|
||||
|
||||
inline
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
print("\nr/c 0123456789ABCDEF\n");
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
phex(row); print(": ");
|
||||
pbin_reverse16(matrix_get_row(row));
|
||||
print("\n");
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_key_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
count += bitpop16(matrix[i]);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static void init_inputs(void)
|
||||
{
|
||||
DDRE &= ~0b01000000; // PE6 (Col 0)
|
||||
DDRB &= ~0b00001111; // PB0 (Col 1), PB1 (Col 2), PB2 (Col 3), PB3 (Col 4)
|
||||
DDRF &= ~0b00000001; // PF0 (Col 5)
|
||||
DDRD &= ~0b00100011; // PD0 (Col 6), PD1 (Col 8 TKL), PD5 (Col 7)
|
||||
}
|
||||
|
||||
static uint16_t read_inputs(void)
|
||||
{
|
||||
return (PINE&(1<<6) ? 0 : (1<<0)) | // PE6 (Col 0)
|
||||
(PINB&(1<<0) ? 0 : (1<<1)) | // PB0 (Col 1)
|
||||
(PINB&(1<<1) ? 0 : (1<<2)) | // PB1 (Col 2)
|
||||
(PINB&(1<<2) ? 0 : (1<<3)) | // PB2 (Col 3)
|
||||
(PINB&(1<<3) ? 0 : (1<<4)) | // PB3 (Col 4)
|
||||
(PINF&(1<<0) ? 0 : (1<<5)) | // PF0 (Col 5)
|
||||
(PIND&(1<<0) ? 0 : (1<<6)) | // PD0 (Col 6)
|
||||
(PIND&(1<<5) ? 0 : (1<<7)) | // PD5 (Col 7)
|
||||
(PIND&(1<<1) ? 0 : (1<<8)); // PD1 (Col 8 TKL)
|
||||
}
|
||||
|
||||
static void reset_inputs(void)
|
||||
{
|
||||
PORTE |= 0b01000000; // PE6 (Col 0)
|
||||
PORTB |= 0b00001111; // PB0 (Col 1), PB1 (Col 2), PB2 (Col 3), PB3 (Col 4)
|
||||
PORTF |= 0b00000001; // PF0 (Col 5)
|
||||
PORTD |= 0b00100011; // PD0 (Col 6), PD1 (Col 8 TKL), PD5 (Col 7)
|
||||
}
|
||||
|
||||
static void init_outputs(void)
|
||||
{
|
||||
DDRB |= 0b00010000; // PB4 (Row 0)
|
||||
DDRE |= 0b00000100; // PE2 (Row 1)
|
||||
DDRF |= 0b11110010; // PF4 (Row 2), PF7 (Row 3), PF1 (Row 4), PF6 (Row 5), PF5 (Row 7)
|
||||
DDRC |= 0b11000000; // PC6 (Row 6), PC7 (Row 9)
|
||||
DDRD |= 0b10000000; // PD7 (Row 8)
|
||||
}
|
||||
|
||||
static void reset_outputs(void)
|
||||
{
|
||||
PORTB |= 0b00010000; // PB4 (Row 0)
|
||||
PORTE |= 0b00000100; // PE2 (Row 1)
|
||||
PORTF |= 0b11110010; // PF4 (Row 2), PF7 (Row 3), PF1 (Row 4), PF6 (Row 5), PF5 (Row 7)
|
||||
PORTC |= 0b11000000; // PC6 (Row 6), PC7 (Row 9)
|
||||
PORTD |= 0b10000000; // PD7 (Row 8)
|
||||
}
|
||||
|
||||
static void select_output(uint8_t col)
|
||||
{
|
||||
switch (col) {
|
||||
case 0:
|
||||
PORTB &= ~(1<<4);
|
||||
break;
|
||||
case 1:
|
||||
PORTE &= ~(1<<2);
|
||||
break;
|
||||
case 2:
|
||||
PORTF &= ~(1<<4);
|
||||
break;
|
||||
case 3:
|
||||
PORTF &= ~(1<<7);
|
||||
break;
|
||||
case 4:
|
||||
PORTF &= ~(1<<1);
|
||||
break;
|
||||
case 5:
|
||||
PORTF &= ~(1<<6);
|
||||
break;
|
||||
case 6:
|
||||
PORTC &= ~(1<<6);
|
||||
break;
|
||||
case 7:
|
||||
PORTF &= ~(1<<5);
|
||||
break;
|
||||
case 8:
|
||||
PORTD &= ~(1<<7);
|
||||
break;
|
||||
case 9:
|
||||
PORTC &= ~(1<<7);
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = onekey_lufa
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# project specific files
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name
|
||||
#MCU = at90usb1287
|
||||
MCU = atmega32u4
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
# Interrupt driven control endpoint task(+60)
|
||||
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||
|
||||
|
||||
# Boot Section Size in *bytes*
|
||||
# Teensy halfKay 512
|
||||
# Teensy++ halfKay 1024
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
# USBaspLoader 2048
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
#EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
#COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||
|
||||
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
||||
#PS2_USE_BUSYWAIT = yes # uses primitive reference code
|
||||
#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
|
||||
#PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/protocol.mk
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/rules.mk
|
@ -1,103 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = onekey_pjrc
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# project specific files
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name, you MUST set this to match the board you are using
|
||||
# type "make clean" after changing this, so all files will be rebuilt
|
||||
MCU = atmega32u4
|
||||
#MCU = at90usb1286
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# Normally the first thing your program should do is set the clock prescaler,
|
||||
# so your program will run at the correct speed. You should also set this
|
||||
# variable to same clock speed. The _delay_ms() macro uses this, and many
|
||||
# examples use this variable to calculate timings. Do not add a "UL" here.
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
# Boot Section Size in *bytes*
|
||||
# Teensy halfKay 512
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
#MOUSEKEY_ENABLE = yes # Mouse keys(+5000)
|
||||
#EXTRAKEY_ENABLE = yes # Audio control and System control(+600)
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
#COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover(+500)
|
||||
|
||||
PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
||||
PS2_USE_BUSYWAIT = yes # uses primitive reference code
|
||||
#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
|
||||
#PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/protocol.mk
|
||||
include $(TMK_DIR)/protocol/pjrc.mk
|
||||
include $(TMK_DIR)/rules.mk
|
@ -1,88 +0,0 @@
|
||||
# Target file name (without extension).
|
||||
TARGET = onekey_vusb
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# keyboard dependent files
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name, you MUST set this to match the board you are using
|
||||
# type "make clean" after changing this, so all files will be rebuilt
|
||||
#MCU = atmega168p
|
||||
MCU = atmega328p
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# Normally the first thing your program should do is set the clock prescaler,
|
||||
# so your program will run at the correct speed. You should also set this
|
||||
# variable to same clock speed. The _delay_ms() macro uses this, and many
|
||||
# examples use this variable to calculate timings. Do not add a "UL" here.
|
||||
F_CPU = 12000000
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
#MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
#EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover
|
||||
|
||||
|
||||
|
||||
#---------------- Programming Options --------------------------
|
||||
AVRDUDE = avrdude
|
||||
# Type: avrdude -c ? to get a full listing.
|
||||
AVRDUDE_PROGRAMMER = usbasp
|
||||
AVRDUDE_PORT =
|
||||
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
|
||||
|
||||
# Uncomment the following if you want avrdude's erase cycle counter.
|
||||
# Note that this counter needs to be initialized first using -Yn,
|
||||
# see avrdude manual.
|
||||
#AVRDUDE_ERASE_COUNTER = -y
|
||||
|
||||
# Uncomment the following if you do /not/ wish a verification to be
|
||||
# performed after programming the device.
|
||||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
#AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
|
||||
AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
|
||||
|
||||
PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
||||
# Boot Section Size in bytes
|
||||
# Teensy halfKay 512
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
# USBasp 2048
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=2048
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
|
||||
include $(TMK_DIR)/protocol.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/protocol/vusb.mk
|
||||
include $(TMK_DIR)/rules.mk
|
@ -1,5 +0,0 @@
|
||||
Onekey
|
||||
======
|
||||
Just one key keyboard for example. It sends 'a' key if pins PB0 and PB1 are short-circuited.
|
||||
|
||||
https://github.com/tmk/tmk_keyboard/issues/56
|
@ -1,156 +0,0 @@
|
||||
/*
|
||||
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
|
||||
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x1111
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER geekhack
|
||||
#define PRODUCT Onekey
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for Onekey
|
||||
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 1
|
||||
#define MATRIX_COLS 1
|
||||
|
||||
/* define if matrix has ghost */
|
||||
//#define MATRIX_HAS_GHOST
|
||||
|
||||
/* Set 0 if debouncing isn't needed */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||
#define LOCKING_SUPPORT_ENABLE
|
||||
/* Locking resynchronize hack */
|
||||
#define LOCKING_RESYNC_ENABLE
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Feature disable options
|
||||
* These options are also useful to firmware size reduction.
|
||||
*/
|
||||
|
||||
/* disable debug print */
|
||||
//#define NO_DEBUG
|
||||
|
||||
/* disable print */
|
||||
//#define NO_PRINT
|
||||
|
||||
/* disable action features */
|
||||
//#define NO_ACTION_LAYER
|
||||
//#define NO_ACTION_TAPPING
|
||||
//#define NO_ACTION_ONESHOT
|
||||
//#define NO_ACTION_MACRO
|
||||
//#define NO_ACTION_FUNCTION
|
||||
|
||||
|
||||
/* PS/2 mouse */
|
||||
#ifdef PS2_USE_BUSYWAIT
|
||||
# define PS2_CLOCK_PORT PORTD
|
||||
# define PS2_CLOCK_PIN PIND
|
||||
# define PS2_CLOCK_DDR DDRD
|
||||
# define PS2_CLOCK_BIT 1
|
||||
# define PS2_DATA_PORT PORTD
|
||||
# define PS2_DATA_PIN PIND
|
||||
# define PS2_DATA_DDR DDRD
|
||||
# define PS2_DATA_BIT 2
|
||||
#endif
|
||||
|
||||
|
||||
/* PS/2 mouse interrupt version */
|
||||
#ifdef PS2_USE_INT
|
||||
/* uses INT1 for clock line(ATMega32U4) */
|
||||
#define PS2_CLOCK_PORT PORTD
|
||||
#define PS2_CLOCK_PIN PIND
|
||||
#define PS2_CLOCK_DDR DDRD
|
||||
#define PS2_CLOCK_BIT 1
|
||||
#define PS2_DATA_PORT PORTD
|
||||
#define PS2_DATA_PIN PIND
|
||||
#define PS2_DATA_DDR DDRD
|
||||
#define PS2_DATA_BIT 2
|
||||
|
||||
#define PS2_INT_INIT() do { \
|
||||
EICRA |= ((1<<ISC11) | \
|
||||
(0<<ISC10)); \
|
||||
} while (0)
|
||||
#define PS2_INT_ON() do { \
|
||||
EIMSK |= (1<<INT1); \
|
||||
} while (0)
|
||||
#define PS2_INT_OFF() do { \
|
||||
EIMSK &= ~(1<<INT1); \
|
||||
} while (0)
|
||||
#define PS2_INT_VECT INT1_vect
|
||||
#endif
|
||||
|
||||
|
||||
/* PS/2 mouse USART version */
|
||||
#ifdef PS2_USE_USART
|
||||
#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
|
||||
/* XCK for clock line and RXD for data line */
|
||||
#define PS2_CLOCK_PORT PORTD
|
||||
#define PS2_CLOCK_PIN PIND
|
||||
#define PS2_CLOCK_DDR DDRD
|
||||
#define PS2_CLOCK_BIT 5
|
||||
#define PS2_DATA_PORT PORTD
|
||||
#define PS2_DATA_PIN PIND
|
||||
#define PS2_DATA_DDR DDRD
|
||||
#define PS2_DATA_BIT 2
|
||||
|
||||
/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
|
||||
/* set DDR of CLOCK as input to be slave */
|
||||
#define PS2_USART_INIT() do { \
|
||||
PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
|
||||
PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
|
||||
UCSR1C = ((1 << UMSEL10) | \
|
||||
(3 << UPM10) | \
|
||||
(0 << USBS1) | \
|
||||
(3 << UCSZ10) | \
|
||||
(0 << UCPOL1)); \
|
||||
UCSR1A = 0; \
|
||||
UBRR1H = 0; \
|
||||
UBRR1L = 0; \
|
||||
} while (0)
|
||||
#define PS2_USART_RX_INT_ON() do { \
|
||||
UCSR1B = ((1 << RXCIE1) | \
|
||||
(1 << RXEN1)); \
|
||||
} while (0)
|
||||
#define PS2_USART_RX_POLL_ON() do { \
|
||||
UCSR1B = (1 << RXEN1); \
|
||||
} while (0)
|
||||
#define PS2_USART_OFF() do { \
|
||||
UCSR1C = 0; \
|
||||
UCSR1B &= ~((1 << RXEN1) | \
|
||||
(1 << TXEN1)); \
|
||||
} while (0)
|
||||
#define PS2_USART_RX_READY (UCSR1A & (1<<RXC1))
|
||||
#define PS2_USART_RX_DATA UDR1
|
||||
#define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1)))
|
||||
#define PS2_USART_RX_VECT USART1_RX_vect
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
Copyright 2012,2013 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/>.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
#include "action_macro.h"
|
||||
#include "report.h"
|
||||
#include "host.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "keymap.h"
|
||||
|
||||
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
{{KC_A}},
|
||||
};
|
||||
|
||||
/*
|
||||
* Fn action definition
|
||||
*/
|
||||
static const uint16_t PROGMEM fn_actions[] = {
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
|
||||
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
|
||||
|
||||
/* translates key to keycode */
|
||||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
if (layer < KEYMAPS_SIZE) {
|
||||
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||
} else {
|
||||
// fall back to layer 0
|
||||
return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
|
||||
}
|
||||
}
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint8_t keycode)
|
||||
{
|
||||
action_t action;
|
||||
if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
|
||||
action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
|
||||
} else {
|
||||
action.code = ACTION_NO;
|
||||
}
|
||||
return action;
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "stdint.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
}
|
@ -1,176 +0,0 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* scan matrix
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 5
|
||||
#endif
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
/* matrix state(1:on, 0:off) */
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
static matrix_row_t read_cols(void);
|
||||
static void init_cols(void);
|
||||
static void unselect_rows(void);
|
||||
static void select_row(uint8_t row);
|
||||
|
||||
|
||||
inline
|
||||
uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
debug_enable = true;
|
||||
debug_matrix = true;
|
||||
debug_mouse = true;
|
||||
// initialize row and col
|
||||
unselect_rows();
|
||||
init_cols();
|
||||
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
select_row(i);
|
||||
_delay_us(30); // without this wait read unstable value.
|
||||
matrix_row_t cols = read_cols();
|
||||
if (matrix_debouncing[i] != cols) {
|
||||
matrix_debouncing[i] = cols;
|
||||
if (debouncing) {
|
||||
debug("bounce!: "); debug_hex(debouncing); debug("\n");
|
||||
}
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
unselect_rows();
|
||||
}
|
||||
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
_delay_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
if (debouncing) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
return (matrix[row] & ((matrix_row_t)1<<col));
|
||||
}
|
||||
|
||||
inline
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
print("\nr/c 0123456789ABCDEF\n");
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
phex(row); print(": ");
|
||||
pbin_reverse16(matrix_get_row(row));
|
||||
print("\n");
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_key_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
count += bitpop16(matrix[i]);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Column pin configuration
|
||||
* col: 0
|
||||
* pin: B0
|
||||
*/
|
||||
static void init_cols(void)
|
||||
{
|
||||
// Input with pull-up(DDR:0, PORT:1)
|
||||
DDRB &= ~(1<<0);
|
||||
PORTB |= (1<<0);
|
||||
}
|
||||
|
||||
static matrix_row_t read_cols(void)
|
||||
{
|
||||
return (PINB&(1<<0) ? 0 : (1<<0));
|
||||
}
|
||||
|
||||
/* Row pin configuration
|
||||
* row: 0
|
||||
* pin: B1
|
||||
*/
|
||||
static void unselect_rows(void)
|
||||
{
|
||||
// Hi-Z(DDR:0, PORT:0) to unselect
|
||||
DDRB &= ~0b00000010;
|
||||
PORTB &= ~0b00000010;
|
||||
}
|
||||
|
||||
static void select_row(uint8_t row)
|
||||
{
|
||||
// Output low(DDR:1, PORT:0) to select
|
||||
switch (row) {
|
||||
case 0:
|
||||
DDRB |= (1<<1);
|
||||
PORTB &= ~(1<<1);
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,377 +0,0 @@
|
||||
/* Name: usbconfig.h
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2005-04-01
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||
* This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $
|
||||
*/
|
||||
|
||||
#ifndef __usbconfig_h_included__
|
||||
#define __usbconfig_h_included__
|
||||
|
||||
|
||||
/*
|
||||
General Description:
|
||||
This file is an example configuration (with inline documentation) for the USB
|
||||
driver. It configures V-USB for USB D+ connected to Port D bit 2 (which is
|
||||
also hardware interrupt 0 on many devices) and USB D- to Port D bit 4. You may
|
||||
wire the lines to any other port, as long as D+ is also wired to INT0 (or any
|
||||
other hardware interrupt, as long as it is the highest level interrupt, see
|
||||
section at the end of this file).
|
||||
*/
|
||||
|
||||
/* ---------------------------- Hardware Config ---------------------------- */
|
||||
|
||||
#define USB_CFG_IOPORTNAME D
|
||||
/* This is the port where the USB bus is connected. When you configure it to
|
||||
* "B", the registers PORTB, PINB and DDRB will be used.
|
||||
*/
|
||||
#define USB_CFG_DMINUS_BIT 3
|
||||
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
|
||||
* This may be any bit in the port.
|
||||
*/
|
||||
#define USB_CFG_DPLUS_BIT 2
|
||||
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
|
||||
* This may be any bit in the port. Please note that D+ must also be connected
|
||||
* to interrupt pin INT0! [You can also use other interrupts, see section
|
||||
* "Optional MCU Description" below, or you can connect D- to the interrupt, as
|
||||
* it is required if you use the USB_COUNT_SOF feature. If you use D- for the
|
||||
* interrupt, the USB interrupt will also be triggered at Start-Of-Frame
|
||||
* markers every millisecond.]
|
||||
*/
|
||||
#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
|
||||
/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000,
|
||||
* 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code
|
||||
* require no crystal, they tolerate +/- 1% deviation from the nominal
|
||||
* frequency. All other rates require a precision of 2000 ppm and thus a
|
||||
* crystal!
|
||||
* Since F_CPU should be defined to your actual clock rate anyway, you should
|
||||
* not need to modify this setting.
|
||||
*/
|
||||
#define USB_CFG_CHECK_CRC 0
|
||||
/* Define this to 1 if you want that the driver checks integrity of incoming
|
||||
* data packets (CRC checks). CRC checks cost quite a bit of code size and are
|
||||
* currently only available for 18 MHz crystal clock. You must choose
|
||||
* USB_CFG_CLOCK_KHZ = 18000 if you enable this option.
|
||||
*/
|
||||
|
||||
/* ----------------------- Optional Hardware Config ------------------------ */
|
||||
|
||||
/* #define USB_CFG_PULLUP_IOPORTNAME D */
|
||||
/* If you connect the 1.5k pullup resistor from D- to a port pin instead of
|
||||
* V+, you can connect and disconnect the device from firmware by calling
|
||||
* the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
|
||||
* This constant defines the port on which the pullup resistor is connected.
|
||||
*/
|
||||
/* #define USB_CFG_PULLUP_BIT 4 */
|
||||
/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
|
||||
* above) where the 1.5k pullup resistor is connected. See description
|
||||
* above for details.
|
||||
*/
|
||||
|
||||
/* --------------------------- Functional Range ---------------------------- */
|
||||
|
||||
#define USB_CFG_HAVE_INTRIN_ENDPOINT 1
|
||||
/* Define this to 1 if you want to compile a version with two endpoints: The
|
||||
* default control endpoint 0 and an interrupt-in endpoint (any other endpoint
|
||||
* number).
|
||||
*/
|
||||
#define USB_CFG_HAVE_INTRIN_ENDPOINT3 1
|
||||
/* Define this to 1 if you want to compile a version with three endpoints: The
|
||||
* default control endpoint 0, an interrupt-in endpoint 3 (or the number
|
||||
* configured below) and a catch-all default interrupt-in endpoint as above.
|
||||
* You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature.
|
||||
*/
|
||||
#define USB_CFG_EP3_NUMBER 3
|
||||
/* If the so-called endpoint 3 is used, it can now be configured to any other
|
||||
* endpoint number (except 0) with this macro. Default if undefined is 3.
|
||||
*/
|
||||
/* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */
|
||||
/* The above macro defines the startup condition for data toggling on the
|
||||
* interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1.
|
||||
* Since the token is toggled BEFORE sending any data, the first packet is
|
||||
* sent with the oposite value of this configuration!
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_HALT 0
|
||||
/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature
|
||||
* for endpoint 1 (interrupt endpoint). Although you may not need this feature,
|
||||
* it is required by the standard. We have made it a config option because it
|
||||
* bloats the code considerably.
|
||||
*/
|
||||
#define USB_CFG_SUPPRESS_INTR_CODE 0
|
||||
/* Define this to 1 if you want to declare interrupt-in endpoints, but don't
|
||||
* want to send any data over them. If this macro is defined to 1, functions
|
||||
* usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if
|
||||
* you need the interrupt-in endpoints in order to comply to an interface
|
||||
* (e.g. HID), but never want to send any data. This option saves a couple
|
||||
* of bytes in flash memory and the transmit buffers in RAM.
|
||||
*/
|
||||
#define USB_CFG_INTR_POLL_INTERVAL 10
|
||||
/* If you compile a version with endpoint 1 (interrupt-in), this is the poll
|
||||
* interval. The value is in milliseconds and must not be less than 10 ms for
|
||||
* low speed devices.
|
||||
*/
|
||||
#define USB_CFG_IS_SELF_POWERED 0
|
||||
/* Define this to 1 if the device has its own power supply. Set it to 0 if the
|
||||
* device is powered from the USB bus.
|
||||
*/
|
||||
#define USB_CFG_MAX_BUS_POWER 100
|
||||
/* Set this variable to the maximum USB bus power consumption of your device.
|
||||
* The value is in milliamperes. [It will be divided by two since USB
|
||||
* communicates power requirements in units of 2 mA.]
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_FN_WRITE 1
|
||||
/* Set this to 1 if you want usbFunctionWrite() to be called for control-out
|
||||
* transfers. Set it to 0 if you don't need it and want to save a couple of
|
||||
* bytes.
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_FN_READ 0
|
||||
/* Set this to 1 if you need to send control replies which are generated
|
||||
* "on the fly" when usbFunctionRead() is called. If you only want to send
|
||||
* data from a static buffer, set it to 0 and return the data from
|
||||
* usbFunctionSetup(). This saves a couple of bytes.
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_FN_WRITEOUT 0
|
||||
/* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints.
|
||||
* You must implement the function usbFunctionWriteOut() which receives all
|
||||
* interrupt/bulk data sent to any endpoint other than 0. The endpoint number
|
||||
* can be found in 'usbRxToken'.
|
||||
*/
|
||||
#define USB_CFG_HAVE_FLOWCONTROL 0
|
||||
/* Define this to 1 if you want flowcontrol over USB data. See the definition
|
||||
* of the macros usbDisableAllRequests() and usbEnableAllRequests() in
|
||||
* usbdrv.h.
|
||||
*/
|
||||
#define USB_CFG_DRIVER_FLASH_PAGE 0
|
||||
/* If the device has more than 64 kBytes of flash, define this to the 64 k page
|
||||
* where the driver's constants (descriptors) are located. Or in other words:
|
||||
* Define this to 1 for boot loaders on the ATMega128.
|
||||
*/
|
||||
#define USB_CFG_LONG_TRANSFERS 0
|
||||
/* Define this to 1 if you want to send/receive blocks of more than 254 bytes
|
||||
* in a single control-in or control-out transfer. Note that the capability
|
||||
* for long transfers increases the driver size.
|
||||
*/
|
||||
/* #define USB_RX_USER_HOOK(data, len) if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(); */
|
||||
/* This macro is a hook if you want to do unconventional things. If it is
|
||||
* defined, it's inserted at the beginning of received message processing.
|
||||
* If you eat the received message and don't want default processing to
|
||||
* proceed, do a return after doing your things. One possible application
|
||||
* (besides debugging) is to flash a status LED on each packet.
|
||||
*/
|
||||
/* #define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();} */
|
||||
/* This macro is a hook if you need to know when an USB RESET occurs. It has
|
||||
* one parameter which distinguishes between the start of RESET state and its
|
||||
* end.
|
||||
*/
|
||||
/* #define USB_SET_ADDRESS_HOOK() hadAddressAssigned(); */
|
||||
/* This macro (if defined) is executed when a USB SET_ADDRESS request was
|
||||
* received.
|
||||
*/
|
||||
#define USB_COUNT_SOF 0
|
||||
/* define this macro to 1 if you need the global variable "usbSofCount" which
|
||||
* counts SOF packets. This feature requires that the hardware interrupt is
|
||||
* connected to D- instead of D+.
|
||||
*/
|
||||
/* #ifdef __ASSEMBLER__
|
||||
* macro myAssemblerMacro
|
||||
* in YL, TCNT0
|
||||
* sts timer0Snapshot, YL
|
||||
* endm
|
||||
* #endif
|
||||
* #define USB_SOF_HOOK myAssemblerMacro
|
||||
* This macro (if defined) is executed in the assembler module when a
|
||||
* Start Of Frame condition is detected. It is recommended to define it to
|
||||
* the name of an assembler macro which is defined here as well so that more
|
||||
* than one assembler instruction can be used. The macro may use the register
|
||||
* YL and modify SREG. If it lasts longer than a couple of cycles, USB messages
|
||||
* immediately after an SOF pulse may be lost and must be retried by the host.
|
||||
* What can you do with this hook? Since the SOF signal occurs exactly every
|
||||
* 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in
|
||||
* designs running on the internal RC oscillator.
|
||||
* Please note that Start Of Frame detection works only if D- is wired to the
|
||||
* interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES!
|
||||
*/
|
||||
#define USB_CFG_CHECK_DATA_TOGGLING 0
|
||||
/* define this macro to 1 if you want to filter out duplicate data packets
|
||||
* sent by the host. Duplicates occur only as a consequence of communication
|
||||
* errors, when the host does not receive an ACK. Please note that you need to
|
||||
* implement the filtering yourself in usbFunctionWriteOut() and
|
||||
* usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable
|
||||
* for each control- and out-endpoint to check for duplicate packets.
|
||||
*/
|
||||
#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0
|
||||
/* define this macro to 1 if you want the function usbMeasureFrameLength()
|
||||
* compiled in. This function can be used to calibrate the AVR's RC oscillator.
|
||||
*/
|
||||
#define USB_USE_FAST_CRC 0
|
||||
/* The assembler module has two implementations for the CRC algorithm. One is
|
||||
* faster, the other is smaller. This CRC routine is only used for transmitted
|
||||
* messages where timing is not critical. The faster routine needs 31 cycles
|
||||
* per byte while the smaller one needs 61 to 69 cycles. The faster routine
|
||||
* may be worth the 32 bytes bigger code size if you transmit lots of data and
|
||||
* run the AVR close to its limit.
|
||||
*/
|
||||
|
||||
/* -------------------------- Device Description --------------------------- */
|
||||
|
||||
#define USB_CFG_VENDOR_ID (VENDOR_ID & 0xFF), ((VENDOR_ID >> 8) & 0xFF)
|
||||
/* USB vendor ID for the device, low byte first. If you have registered your
|
||||
* own Vendor ID, define it here. Otherwise you may use one of obdev's free
|
||||
* shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules!
|
||||
* *** IMPORTANT NOTE ***
|
||||
* This template uses obdev's shared VID/PID pair for Vendor Class devices
|
||||
* with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand
|
||||
* the implications!
|
||||
*/
|
||||
#define USB_CFG_DEVICE_ID (PRODUCT_ID & 0xFF), ((PRODUCT_ID >> 8) & 0xFF)
|
||||
/* This is the ID of the product, low byte first. It is interpreted in the
|
||||
* scope of the vendor ID. If you have registered your own VID with usb.org
|
||||
* or if you have licensed a PID from somebody else, define it here. Otherwise
|
||||
* you may use one of obdev's free shared VID/PID pairs. See the file
|
||||
* USB-IDs-for-free.txt for details!
|
||||
* *** IMPORTANT NOTE ***
|
||||
* This template uses obdev's shared VID/PID pair for Vendor Class devices
|
||||
* with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand
|
||||
* the implications!
|
||||
*/
|
||||
#define USB_CFG_DEVICE_VERSION 0x00, 0x01
|
||||
/* Version number of the device: Minor number first, then major number.
|
||||
*/
|
||||
#define USB_CFG_VENDOR_NAME 't', '.', 'm', '.', 'k', '.'
|
||||
#define USB_CFG_VENDOR_NAME_LEN 6
|
||||
/* These two values define the vendor name returned by the USB device. The name
|
||||
* must be given as a list of characters under single quotes. The characters
|
||||
* are interpreted as Unicode (UTF-16) entities.
|
||||
* If you don't want a vendor name string, undefine these macros.
|
||||
* ALWAYS define a vendor name containing your Internet domain name if you use
|
||||
* obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for
|
||||
* details.
|
||||
*/
|
||||
#define USB_CFG_DEVICE_NAME 'P', 'S', '/', '2', ' ', 'k', 'e', 'y', 'b', 'o', 'a', 'r', 'd', ' ', 'c', 'o', 'n', 'v', 'e', 'r', 't', 'e', 'r'
|
||||
#define USB_CFG_DEVICE_NAME_LEN 23
|
||||
/* Same as above for the device name. If you don't want a device name, undefine
|
||||
* the macros. See the file USB-IDs-for-free.txt before you assign a name if
|
||||
* you use a shared VID/PID.
|
||||
*/
|
||||
/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */
|
||||
/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */
|
||||
/* Same as above for the serial number. If you don't want a serial number,
|
||||
* undefine the macros.
|
||||
* It may be useful to provide the serial number through other means than at
|
||||
* compile time. See the section about descriptor properties below for how
|
||||
* to fine tune control over USB descriptors such as the string descriptor
|
||||
* for the serial number.
|
||||
*/
|
||||
#define USB_CFG_DEVICE_CLASS 0
|
||||
#define USB_CFG_DEVICE_SUBCLASS 0
|
||||
/* See USB specification if you want to conform to an existing device class.
|
||||
* Class 0xff is "vendor specific".
|
||||
*/
|
||||
#define USB_CFG_INTERFACE_CLASS 3 /* HID */
|
||||
#define USB_CFG_INTERFACE_SUBCLASS 1 /* Boot */
|
||||
#define USB_CFG_INTERFACE_PROTOCOL 1 /* Keyboard */
|
||||
/* See USB specification if you want to conform to an existing device class or
|
||||
* protocol. The following classes must be set at interface level:
|
||||
* HID class is 3, no subclass and protocol required (but may be useful!)
|
||||
* CDC class is 2, use subclass 2 and protocol 1 for ACM
|
||||
*/
|
||||
#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 0
|
||||
/* Define this to the length of the HID report descriptor, if you implement
|
||||
* an HID device. Otherwise don't define it or define it to 0.
|
||||
* If you use this define, you must add a PROGMEM character array named
|
||||
* "usbHidReportDescriptor" to your code which contains the report descriptor.
|
||||
* Don't forget to keep the array and this define in sync!
|
||||
*/
|
||||
|
||||
/* #define USB_PUBLIC static */
|
||||
/* Use the define above if you #include usbdrv.c instead of linking against it.
|
||||
* This technique saves a couple of bytes in flash memory.
|
||||
*/
|
||||
|
||||
/* ------------------- Fine Control over USB Descriptors ------------------- */
|
||||
/* If you don't want to use the driver's default USB descriptors, you can
|
||||
* provide our own. These can be provided as (1) fixed length static data in
|
||||
* flash memory, (2) fixed length static data in RAM or (3) dynamically at
|
||||
* runtime in the function usbFunctionDescriptor(). See usbdrv.h for more
|
||||
* information about this function.
|
||||
* Descriptor handling is configured through the descriptor's properties. If
|
||||
* no properties are defined or if they are 0, the default descriptor is used.
|
||||
* Possible properties are:
|
||||
* + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched
|
||||
* at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is
|
||||
* used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if
|
||||
* you want RAM pointers.
|
||||
* + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found
|
||||
* in static memory is in RAM, not in flash memory.
|
||||
* + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash),
|
||||
* the driver must know the descriptor's length. The descriptor itself is
|
||||
* found at the address of a well known identifier (see below).
|
||||
* List of static descriptor names (must be declared PROGMEM if in flash):
|
||||
* char usbDescriptorDevice[];
|
||||
* char usbDescriptorConfiguration[];
|
||||
* char usbDescriptorHidReport[];
|
||||
* char usbDescriptorString0[];
|
||||
* int usbDescriptorStringVendor[];
|
||||
* int usbDescriptorStringDevice[];
|
||||
* int usbDescriptorStringSerialNumber[];
|
||||
* Other descriptors can't be provided statically, they must be provided
|
||||
* dynamically at runtime.
|
||||
*
|
||||
* Descriptor properties are or-ed or added together, e.g.:
|
||||
* #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18))
|
||||
*
|
||||
* The following descriptors are defined:
|
||||
* USB_CFG_DESCR_PROPS_DEVICE
|
||||
* USB_CFG_DESCR_PROPS_CONFIGURATION
|
||||
* USB_CFG_DESCR_PROPS_STRINGS
|
||||
* USB_CFG_DESCR_PROPS_STRING_0
|
||||
* USB_CFG_DESCR_PROPS_STRING_VENDOR
|
||||
* USB_CFG_DESCR_PROPS_STRING_PRODUCT
|
||||
* USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER
|
||||
* USB_CFG_DESCR_PROPS_HID
|
||||
* USB_CFG_DESCR_PROPS_HID_REPORT
|
||||
* USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver)
|
||||
*
|
||||
* Note about string descriptors: String descriptors are not just strings, they
|
||||
* are Unicode strings prefixed with a 2 byte header. Example:
|
||||
* int serialNumberDescriptor[] = {
|
||||
* USB_STRING_DESCRIPTOR_HEADER(6),
|
||||
* 'S', 'e', 'r', 'i', 'a', 'l'
|
||||
* };
|
||||
*/
|
||||
|
||||
#define USB_CFG_DESCR_PROPS_DEVICE 0
|
||||
#define USB_CFG_DESCR_PROPS_CONFIGURATION USB_PROP_IS_DYNAMIC
|
||||
//#define USB_CFG_DESCR_PROPS_CONFIGURATION 0
|
||||
#define USB_CFG_DESCR_PROPS_STRINGS 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_0 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0
|
||||
//#define USB_CFG_DESCR_PROPS_HID USB_PROP_IS_DYNAMIC
|
||||
#define USB_CFG_DESCR_PROPS_HID 0
|
||||
#define USB_CFG_DESCR_PROPS_HID_REPORT USB_PROP_IS_DYNAMIC
|
||||
//#define USB_CFG_DESCR_PROPS_HID_REPORT 0
|
||||
#define USB_CFG_DESCR_PROPS_UNKNOWN 0
|
||||
|
||||
/* ----------------------- Optional MCU Description ------------------------ */
|
||||
|
||||
/* The following configurations have working defaults in usbdrv.h. You
|
||||
* usually don't need to set them explicitly. Only if you want to run
|
||||
* the driver on a device which is not yet supported or with a compiler
|
||||
* which is not fully supported (such as IAR C) or if you use a differnt
|
||||
* interrupt than INT0, you may have to define some of these.
|
||||
*/
|
||||
/* #define USB_INTR_CFG MCUCR */
|
||||
/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */
|
||||
/* #define USB_INTR_CFG_CLR 0 */
|
||||
/* #define USB_INTR_ENABLE GIMSK */
|
||||
/* #define USB_INTR_ENABLE_BIT INT0 */
|
||||
/* #define USB_INTR_PENDING GIFR */
|
||||
/* #define USB_INTR_PENDING_BIT INTF0 */
|
||||
/* #define USB_INTR_VECTOR INT0_vect */
|
||||
|
||||
#endif /* __usbconfig_h_included__ */
|
@ -1,137 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = phantom_lufa
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
|
||||
# List C source files here. (C dependencies are automatically generated.)
|
||||
SRC += keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name
|
||||
#MCU = at90usb1287
|
||||
MCU = atmega32u4
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||
|
||||
|
||||
# Boot Section Size in bytes
|
||||
# Teensy halfKay 512
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=512
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
||||
|
||||
ansi: OPT_DEFS += -DLAYOUT_ANSI
|
||||
ansi: all
|
||||
|
||||
ansi_150: OPT_DEFS += -DLAYOUT_ANSI_150
|
||||
ansi_150: all
|
||||
|
||||
iso: OPT_DEFS += -DLAYOUT_ISO
|
||||
iso: all
|
||||
|
||||
iso_150: OPT_DEFS += -DLAYOUT_ISO_150
|
||||
iso_150: all
|
||||
|
||||
7bit: OPT_DEFS += -DLAYOUT_7BIT
|
||||
7bit: all
|
@ -1,108 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = phantom_pjrc
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# keyboard dependent files
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name, you MUST set this to match the board you are using
|
||||
# type "make clean" after changing this, so all files will be rebuilt
|
||||
#MCU = at90usb162 # Teensy 1.0
|
||||
MCU = atmega32u4 # Teensy 2.0
|
||||
#MCU = at90usb646 # Teensy++ 1.0
|
||||
#MCU = at90usb1286 # Teensy++ 2.0
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# Normally the first thing your program should do is set the clock prescaler,
|
||||
# so your program will run at the correct speed. You should also set this
|
||||
# variable to same clock speed. The _delay_ms() macro uses this, and many
|
||||
# examples use this variable to calculate timings. Do not add a "UL" here.
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
#MOUSEKEY_ENABLE = yes # Mouse keys(+5000)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+600)
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover(+500)
|
||||
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/pjrc.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
||||
|
||||
ansi: OPT_DEFS += -DLAYOUT_ANSI
|
||||
ansi: all
|
||||
|
||||
ansi_150: OPT_DEFS += -DLAYOUT_ANSI_150
|
||||
ansi_150: all
|
||||
|
||||
iso: OPT_DEFS += -DLAYOUT_ISO
|
||||
iso: all
|
||||
|
||||
iso_150: OPT_DEFS += -DLAYOUT_ISO_150
|
||||
iso_150: all
|
||||
|
||||
7bit: OPT_DEFS += -DLAYOUT_7BIT
|
||||
7bit: all
|
@ -1,248 +0,0 @@
|
||||
Phantom keyboard firmware
|
||||
======================
|
||||
DIY keyboard developed by Geekhack and Deskthority communities.
|
||||
The PCB was engineered by bpiphany from the original idea of HaveANiceDay.
|
||||
|
||||
## Wiki on Deskthority.net
|
||||
- [Info](http://deskthority.net/wiki/Phantom)
|
||||
- [Assembly Instructions](http://deskthority.net/wiki/Phantom)
|
||||
|
||||
|
||||
Build
|
||||
-----
|
||||
Move to this directory then just run `make` like:
|
||||
|
||||
$ make -f Makefile.[pjrc|lufa] [ansi|ansi_150|iso|iso_150|7bit]
|
||||
|
||||
Use `Makefile.pjrc` if you want to use PJRC stack or use `Makefile.lufa` for LUFA stack.
|
||||
|
||||
|
||||
LEDs
|
||||
----
|
||||
It is possible to configure the LEDs in 2 different ways.
|
||||
|
||||
### 1. LED Brightness
|
||||
The brightness of the LEDs can be controlled by software.
|
||||
|
||||
To select brightness edit [config.h](config.h) and set `LED_BRIGHTNESS` to a value
|
||||
between 0 and 255:
|
||||
|
||||
#define LED_BRIGHTNESS 250
|
||||
|
||||
|
||||
### 2. Sleep LED
|
||||
It is possible to have the LEDs fade in and out when the computer is suspended.
|
||||
|
||||
To enable this feature, uncomment the `SLEEP_LED_ENABLE` line in the makefile you are using:
|
||||
|
||||
SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
|
||||
*Note that this will set the LEDs to full brightness as this feature can't be combined with the brightness control.*
|
||||
|
||||
|
||||
Keymap
|
||||
------
|
||||
The PCB supports multiple physical layouts.
|
||||
Each layout have their own keymap file.
|
||||
|
||||
*Note that only the ANSI keymap is tested on actual hardware.*
|
||||
|
||||
To customize a keymap:
|
||||
|
||||
1. Edit the file that corresponds to your layout.
|
||||
2. Specify your layout when building.
|
||||
|
||||
See [keymap.c](keymap.c) to define your own custom layout.
|
||||
|
||||
|
||||
### 1. ANSI
|
||||
This is the default keymap.
|
||||
|
||||
See [keymap_ansi.h](keymap_ansi.h) for detail.
|
||||
|
||||
#### 1.0. ANSI Default Layer
|
||||
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
|Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
|
||||
`---' `---------------' `---------------' `---------------' `-----------'
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
|~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
|
||||
|-----------------------------------------------------------| '-----------'
|
||||
|Fn0 | A| S| D| F| G| H| J| K| L| ;| '|Return |
|
||||
|-----------------------------------------------------------| ,---.
|
||||
|Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
|
||||
|-----------------------------------------------------------| ,-----------.
|
||||
|Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig|
|
||||
`-----------------------------------------------------------' `-----------'
|
||||
|
||||
#### 1.1. ANSI Media Layer
|
||||
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
| | | | | | | | | | | | | | | | | | | |Slp|
|
||||
`---' `---------------' `---------------' `---------------' `-----------'
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
| | | | | | | | | | |Mut|V- |V+ | | | | | |
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
| | | | | | | | | |Stp|Ply|Prv|Nxt|Media| | | | |
|
||||
|-----------------------------------------------------------| '-----------'
|
||||
| | | | | | | | | | | | | |
|
||||
|-----------------------------------------------------------| ,---.
|
||||
| | | |Clc| | | | | | | |Caps | | |
|
||||
|-----------------------------------------------------------| ,-----------.
|
||||
| | | | | | | | | | | | |
|
||||
`-----------------------------------------------------------' `-----------'
|
||||
|
||||
|
||||
### 2. ANSI 150
|
||||
Layout with 1.5 unit modifiers.
|
||||
|
||||
See [keymap_ansi_150.h](keymap_ansi_150.h) for detail.
|
||||
|
||||
#### 2.0. ANSI 150 Default Layer
|
||||
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
|Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
|
||||
`---' `---------------' `---------------' `---------------' `-----------'
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
|~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
|
||||
|-----------------------------------------------------------| '-----------'
|
||||
|Fn0 | A| S| D| F| G| H| J| K| L| ;| '|Return |
|
||||
|-----------------------------------------------------------| ,---.
|
||||
|Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
|
||||
|-----------------------------------------------------------| ,-----------.
|
||||
|Ctl |Gui|Alt | Space |Alt |Gui|Ctl | |Lef|Dow|Rig|
|
||||
`-----------------------------------------------------------' `-----------'
|
||||
|
||||
#### 2.1. ANSI 150 Media Layer
|
||||
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
| | | | | | | | | | | | | | | | | | | |Slp|
|
||||
`---' `---------------' `---------------' `---------------' `-----------'
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
| | | | | | | | | | |Mut|V- |V+ | | | | | |
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
| | | | | | | | | |Stp|Ply|Prv|Nxt|Media| | | | |
|
||||
|-----------------------------------------------------------| '-----------'
|
||||
| | | | | | | | | | | | | |
|
||||
|-----------------------------------------------------------| ,---.
|
||||
| | | |Clc| | | | | | | |Caps | | |
|
||||
|-----------------------------------------------------------| ,-----------.
|
||||
| | | | | | | | | | | |
|
||||
`-----------------------------------------------------------' `-----------'
|
||||
|
||||
|
||||
### 3. ISO
|
||||
ISO layout.
|
||||
|
||||
See [keymap_iso.h](keymap_iso.h) for detail.
|
||||
|
||||
#### 3.0. ISO Default Layer
|
||||
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
|Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
|
||||
`---' `---------------' `---------------' `---------------' `-----------'
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
|~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | |Del|End|PgD|
|
||||
|------------------------------------------------------` Ret| '-----------'
|
||||
|Fn0 | A| S| D| F| G| H| J| K| L| ;| '| #| |
|
||||
|-----------------------------------------------------------| ,---.
|
||||
|Shif| \| Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
|
||||
|-----------------------------------------------------------| ,-----------.
|
||||
|Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig|
|
||||
`-----------------------------------------------------------' `-----------'
|
||||
|
||||
#### 3.1. ISO Media Layer
|
||||
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
| | | | | | | | | | | | | | | | | | | |Slp|
|
||||
`---' `---------------' `---------------' `---------------' `-----------'
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
| | | | | | | | | | |Mut|V- |V+ | | | | | |
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
| | | | | | | | | |Stp|Ply|Prv|Nxt| | | | | |
|
||||
|------------------------------------------------------` Med| '-----------'
|
||||
| | | | | | | | | | | | | | |
|
||||
|-----------------------------------------------------------| ,---.
|
||||
| | | | |Clc| | | | | | | |Caps | | |
|
||||
|-----------------------------------------------------------| ,-----------.
|
||||
| | | | | | | | | | | | |
|
||||
`-----------------------------------------------------------' `-----------'
|
||||
|
||||
|
||||
### 4. ISO 150
|
||||
ISO layout with 1.5 unit modifiers.
|
||||
|
||||
See [keymap_iso_150.h](keymap_iso_150.h) for detail.
|
||||
|
||||
#### 4.0. ISO 150 Default Layer
|
||||
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
|Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
|
||||
`---' `---------------' `---------------' `---------------' `-----------'
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
|~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | |Del|End|PgD|
|
||||
|------------------------------------------------------` Ret| '-----------'
|
||||
|Fn0 | A| S| D| F| G| H| J| K| L| ;| '| #| |
|
||||
|-----------------------------------------------------------| ,---.
|
||||
|Shif| \| Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
|
||||
|-----------------------------------------------------------| ,-----------.
|
||||
|Ctl |Gui|Alt | Space |Alt |Gui|Ctl | |Lef|Dow|Rig|
|
||||
`-----------------------------------------------------------' `-----------'
|
||||
|
||||
#### 4.1. ISO 150 Media Layer
|
||||
,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
| | | | | | | | | | | | | | | | | | | |Slp|
|
||||
`---' `---------------' `---------------' `---------------' `-----------'
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
| | | | | | | | | | |Mut|V- |V+ | | | | | |
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
| | | | | | | | | |Stp|Ply|Prv|Nxt| | | | | |
|
||||
|------------------------------------------------------` Med| '-----------'
|
||||
| | | | | | | | | | | | | | |
|
||||
|-----------------------------------------------------------| ,---.
|
||||
| | | | |Clc| | | | | | | |Caps | | |
|
||||
|-----------------------------------------------------------| ,-----------.
|
||||
| | | | | | | | | | | |
|
||||
`-----------------------------------------------------------' `-----------'
|
||||
|
||||
|
||||
### 5. 7bit
|
||||
Layout using all the available keys on the PCB.
|
||||
|
||||
This keymap is only provided as an example of what can be done using this layout.
|
||||
No real thought has been put into this keymap.
|
||||
|
||||
See [keymap_7bit.h](keymap_7bit.h) for detail.
|
||||
|
||||
#### 5.0. 7bit Default Layer
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
|Esc|F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|V- |V+ | |PrS|ScL|Pau|
|
||||
`-----------------------------------------------------------' `-----------'
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
|~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| (| )| |Ins|Hom|PgU|
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs| |Del|End|PgD|
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
|Fn0 | A| S| D| F| G| H| J| K| L| ;| '| \| Ret| |Stp|Ply|Med|
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
|Cap|Shif| Z| X| C| V| B| N| M| ,| .| /|Shift |Cap| |Prv|Up |Nxt|
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
|Ctrl |Gui|Alt |Spc |Bspc |Del|Ret |Alt |Gui |App|Ctrl | |Lef|Dow|Rig|
|
||||
`-----------------------------------------------------------' `-----------'
|
||||
|
||||
#### 5.1. 7bit Media Layer
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
| | | | | | | | | | | | | | | | | | |Slp|
|
||||
`-----------------------------------------------------------' `-----------'
|
||||
,-----------------------------------------------------------. ,-----------.
|
||||
| | | | | | | | | | |Mut|V- |V+ | | | | | | |
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
| | | | | | | | | |Stp|Ply|Prv|Nxt|Media| | | | |
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
| | | | | | | | | | | | | | | | | | |
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
| | | | | | | | | | | | | | | | | | |
|
||||
|-----------------------------------------------------------| |-----------|
|
||||
| | | | | | | | | | | | | | | |
|
||||
`-----------------------------------------------------------' `-----------'
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
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
|
||||
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x6057
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER t.m.k.
|
||||
#define PRODUCT Phantom
|
||||
|
||||
/* message strings */
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for Phantom
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 6
|
||||
#define MATRIX_COLS 17
|
||||
|
||||
/* define if matrix has ghost */
|
||||
//#define MATRIX_HAS_GHOST
|
||||
|
||||
/* Set 0 if need no debouncing */
|
||||
#define DEBOUNCE 7
|
||||
|
||||
/* Set LED brightness 0-255.
|
||||
* This have no effect if sleep LED is enabled. */
|
||||
#define LED_BRIGHTNESS 250
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
#endif
|
@ -1,151 +0,0 @@
|
||||
/*
|
||||
Copyright 2011 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Keymap for Phantom controller
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
#include "action_macro.h"
|
||||
#include "report.h"
|
||||
#include "host.h"
|
||||
#include "debug.h"
|
||||
#include "keymap.h"
|
||||
|
||||
// Convert physical keyboard layout to matrix array.
|
||||
// This is a macro to define keymap easily in keyboard layout form.
|
||||
#define KEYMAP( \
|
||||
K5A, K5B, K5C, K5D, K5E, K5F, K5G, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, K5R, \
|
||||
K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4N, K4O, K4P, K4Q, K4R, \
|
||||
K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3P, K3Q, K3R, \
|
||||
K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2N, K2P, K2Q, K2R, \
|
||||
K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1M, K1N, K1P, K1Q, K1R, \
|
||||
K0A, K0B, K0C, K0D, K0F, K0G, K0H, K0K, K0L, K0M, K0N, K0P, K0Q, K0R \
|
||||
) { \
|
||||
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */ \
|
||||
/* 5 */ { KC_##K5A, KC_##K4A, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F, KC_##K5H, KC_##K5I, KC_##K5J, KC_##K5K, KC_##K5L, KC_##K5M, KC_##K5N, KC_##K5O, KC_##K5P, KC_##K5Q, KC_##K5R}, \
|
||||
/* 4 */ { KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F, KC_##K4G, KC_##K4H, KC_##K4I, KC_##K4J, KC_##K4K, KC_##K4L, KC_##K4M, KC_##K4N, KC_##K4O, KC_##K4P, KC_##K4Q, KC_##K4R}, \
|
||||
/* 3 */ { KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F, KC_##K3G, KC_##K3H, KC_##K3I, KC_##K3J, KC_##K3K, KC_##K3L, KC_##K3M, KC_##K3N, KC_##K3P, KC_##K3Q, KC_##K3R}, \
|
||||
/* 2 */ { KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F, KC_##K2G, KC_##K2H, KC_##K2I, KC_##K2J, KC_##K2K, KC_##K2L, KC_##K2M, KC_##K2N, KC_##K2P, KC_##K2Q, KC_##K2R}, \
|
||||
/* 1 */ { KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F, KC_##K1G, KC_##K1H, KC_##K1I, KC_##K1J, KC_##K1K, KC_##K1L, KC_##K1M, KC_##K1N, KC_##K1P, KC_##K1Q, KC_##K1R}, \
|
||||
/* 0 */ { KC_##K0A, KC_##K0B, KC_##K0C, KC_##K5B, KC_##K0D, KC_##K0F, KC_##K5G, KC_##K0G, KC_##K0H, KC_NO, KC_##K0K, KC_##K0L, KC_##K0M, KC_##K0N, KC_##K0P, KC_##K0Q, KC_##K0R} \
|
||||
}
|
||||
|
||||
#define KEYMAP_ANSI( \
|
||||
K5A, K5C, K5D, K5E, K5F, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, K5R, \
|
||||
K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4O, K4P, K4Q, K4R, \
|
||||
K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3P, K3Q, K3R, \
|
||||
K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2N, \
|
||||
K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1N, K1Q, \
|
||||
K0A, K0B, K0C, K0G, K0K, K0L, K0M, K0N, K0P, K0Q, K0R \
|
||||
) KEYMAP( \
|
||||
K5A, NO, K5C, K5D, K5E, K5F, NO, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, K5R, \
|
||||
K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, NO, K4O, K4P, K4Q, K4R, \
|
||||
K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3P, K3Q, K3R, \
|
||||
K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, NO, K2N, NO, NO, NO, \
|
||||
K1A, NO, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, NO, K1N, NO, K1Q, NO, \
|
||||
K0A, K0B, K0C, NO, NO, K0G, NO, K0K, K0L, K0M, K0N, K0P, K0Q, K0R \
|
||||
)
|
||||
|
||||
#define KEYMAP_ANSI_150( \
|
||||
K5A, K5C, K5D, K5E, K5F, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, K5R, \
|
||||
K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4O, K4P, K4Q, K4R, \
|
||||
K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3P, K3Q, K3R, \
|
||||
K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2N, \
|
||||
K1A, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1N, K1Q, \
|
||||
K0A, K0B, K0C, K0G, K0L, K0M, K0N, K0P, K0Q, K0R \
|
||||
) KEYMAP( \
|
||||
K5A, NO, K5C, K5D, K5E, K5F, NO, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, K5R, \
|
||||
K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, NO, K4O, K4P, K4Q, K4R, \
|
||||
K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3P, K3Q, K3R, \
|
||||
K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, NO, K2N, NO, NO, NO, \
|
||||
K1A, NO, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, NO, K1N, NO, K1Q, NO, \
|
||||
K0A, K0B, K0C, NO, NO, K0G, NO, NO, K0L, K0M, K0N, K0P, K0Q, K0R \
|
||||
)
|
||||
|
||||
#define KEYMAP_ISO( \
|
||||
K5A, K5C, K5D, K5E, K5F, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, K5R, \
|
||||
K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4O, K4P, K4Q, K4R, \
|
||||
K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3P, K3Q, K3R, \
|
||||
K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2N, \
|
||||
K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1N, K1Q, \
|
||||
K0A, K0B, K0C, K0G, K0K, K0L, K0M, K0N, K0P, K0Q, K0R \
|
||||
) KEYMAP( \
|
||||
K5A, NO, K5C, K5D, K5E, K5F, NO, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, K5R, \
|
||||
K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, NO, K4O, K4P, K4Q, K4R, \
|
||||
K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, NO, K3P, K3Q, K3R, \
|
||||
K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2N, NO, NO, NO, \
|
||||
K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, NO, K1N, NO, K1Q, NO, \
|
||||
K0A, K0B, K0C, NO, NO, K0G, NO, K0K, K0L, K0M, K0N, K0P, K0Q, K0R \
|
||||
)
|
||||
|
||||
#define KEYMAP_ISO_150( \
|
||||
K5A, K5C, K5D, K5E, K5F, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, K5R, \
|
||||
K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, K4O, K4P, K4Q, K4R, \
|
||||
K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3P, K3Q, K3R, \
|
||||
K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2N, \
|
||||
K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1N, K1Q, \
|
||||
K0A, K0B, K0C, K0G, K0L, K0M, K0N, K0P, K0Q, K0R \
|
||||
) KEYMAP( \
|
||||
K5A, NO, K5C, K5D, K5E, K5F, NO, K5H, K5I, K5J, K5K, K5L, K5M, K5N, K5O, K5P, K5Q, K5R, \
|
||||
K4A, K4B, K4C, K4D, K4E, K4F, K4G, K4H, K4I, K4J, K4K, K4L, K4M, NO, K4O, K4P, K4Q, K4R, \
|
||||
K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, NO, K3P, K3Q, K3R, \
|
||||
K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2N, NO, NO, NO, \
|
||||
K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, NO, K1N, NO, K1Q, NO, \
|
||||
K0A, K0B, K0C, NO, NO, K0G, NO, NO, K0L, K0M, K0N, K0P, K0Q, K0R \
|
||||
)
|
||||
|
||||
#if defined(LAYOUT_7BIT)
|
||||
#include "keymap_7bit.h"
|
||||
#elif defined(LAYOUT_ISO_150)
|
||||
#include "keymap_iso_150.h"
|
||||
#elif defined(LAYOUT_ISO)
|
||||
#include "keymap_iso.h"
|
||||
#elif defined(LAYOUT_ANSI_150)
|
||||
#include "keymap_ansi_150.h"
|
||||
#else
|
||||
#include "keymap_ansi.h"
|
||||
#endif
|
||||
|
||||
#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
|
||||
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
|
||||
|
||||
/* translates key to keycode */
|
||||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
if (layer < KEYMAPS_SIZE) {
|
||||
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||
} else {
|
||||
// fall back to layer 0
|
||||
return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
|
||||
}
|
||||
}
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint8_t keycode)
|
||||
{
|
||||
action_t action;
|
||||
if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
|
||||
action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
|
||||
} else {
|
||||
action.code = ACTION_NO;
|
||||
}
|
||||
return action;
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
// Phantom 7bit
|
||||
/*
|
||||
* 7bit:
|
||||
*
|
||||
* ,-----------------------------------------------------------. ,-----------.
|
||||
* |Esc|F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|V- |V+ | |PrS|ScL|Pau|
|
||||
* `-----------------------------------------------------------' `-----------'
|
||||
* ,-----------------------------------------------------------. ,-----------.
|
||||
* |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| (| )| |Ins|Hom|PgU|
|
||||
* |-----------------------------------------------------------| |-----------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs| |Del|End|PgD|
|
||||
* |-----------------------------------------------------------| |-----------|
|
||||
* |Fn0 | A| S| D| F| G| H| J| K| L| ;| '| \| Ret| |MSt|Ply|Med|
|
||||
* |-----------------------------------------------------------| |-----------|
|
||||
* |Cap|Shif| Z| X| C| V| B| N| M| ,| .| /|Shift |Cap| |Prv|Up |Nxt|
|
||||
* |-----------------------------------------------------------| |-----------|
|
||||
* |Ctrl |Gui|Alt |Spc |Bspc |Del|Ret |Alt |Gui |App|Ctrl | |Lef|Dow|Rig|
|
||||
* `-----------------------------------------------------------' `-----------'
|
||||
*/
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* 0: qwerty + a few media keys */
|
||||
KEYMAP(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, VOLD,VOLU, PSCR,SLCK,BRK, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, FN1, FN2, INS, HOME,PGUP, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, DEL, END, PGDN, \
|
||||
FN0, A, S, D, F, G, H, J, K, L, SCLN,QUOT,BSLS,ENT, MSTP,MPLY,MSEL, \
|
||||
CAPS,LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,CAPS, MPRV,UP, MNXT, \
|
||||
LCTL,LGUI,LALT,SPC, BSPC,DEL, ENT, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT),
|
||||
/* 1: media keys */
|
||||
KEYMAP(\
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,SLEP, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MUTE,VOLD,VOLU,TRNS,TRNS, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MSTP,MPLY,MPRV,MNXT,MSEL, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,CALC,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS)
|
||||
};
|
||||
static const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1),
|
||||
[1] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
|
||||
[2] = ACTION_MODS_KEY(MOD_LSFT, KC_0)
|
||||
};
|
@ -1,22 +0,0 @@
|
||||
// Phantom ANSI
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* 0: qwerty */
|
||||
KEYMAP_ANSI(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, \
|
||||
FN0, A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, \
|
||||
LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, \
|
||||
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT),
|
||||
/* 1: media keys */
|
||||
KEYMAP_ANSI(\
|
||||
TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,SLEP, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MUTE,VOLD,VOLU,TRNS, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MSTP,MPLY,MPRV,MNXT,MSEL, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
|
||||
TRNS, TRNS,TRNS,CALC,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, CAPS, TRNS, \
|
||||
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS)
|
||||
};
|
||||
static const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1)
|
||||
};
|
@ -1,22 +0,0 @@
|
||||
// Phantom ANSI 150
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* 0: qwerty */
|
||||
KEYMAP_ANSI_150(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, \
|
||||
FN0, A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, \
|
||||
LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, \
|
||||
LCTL,LGUI,LALT, SPC, RALT,RGUI,RCTL, LEFT,DOWN,RGHT),
|
||||
/* 1: media keys */
|
||||
KEYMAP_ANSI_150(\
|
||||
TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,SLEP, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MUTE,VOLD,VOLU,TRNS, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MSTP,MPLY,MPRV,MNXT,MSEL, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \
|
||||
TRNS, TRNS,TRNS,CALC,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, CAPS, TRNS, \
|
||||
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS)
|
||||
};
|
||||
static const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1)
|
||||
};
|
@ -1,22 +0,0 @@
|
||||
// Phantom ISO
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* 0: qwerty */
|
||||
KEYMAP_ISO(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, DEL, END, PGDN, \
|
||||
FN0, A, S, D, F, G, H, J, K, L, SCLN,QUOT,NUHS,ENT, \
|
||||
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, \
|
||||
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT),
|
||||
/* 1: media keys */
|
||||
KEYMAP_ISO(\
|
||||
TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,SLEP, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MUTE,VOLD,VOLU, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MSTP,MPLY,MPRV,MNXT,MSEL, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,CALC,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, CAPS, TRNS, \
|
||||
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS)
|
||||
};
|
||||
static const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1)
|
||||
};
|
@ -1,22 +0,0 @@
|
||||
// Phantom ISO 150
|
||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* 0: qwerty */
|
||||
KEYMAP_ISO_150(\
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, \
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, \
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, DEL, END, PGDN, \
|
||||
FN0, A, S, D, F, G, H, J, K, L, SCLN,QUOT,NUHS,ENT, \
|
||||
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, \
|
||||
LCTL,LGUI,LALT, SPC, RALT,RGUI,RCTL, LEFT,DOWN,RGHT),
|
||||
/* 1: media keys */
|
||||
KEYMAP_ISO_150(\
|
||||
TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,SLEP, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MUTE,VOLD,VOLU, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MSTP,MPLY,MPRV,MNXT,MSEL, TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS,CALC,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, CAPS, TRNS, \
|
||||
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS)
|
||||
};
|
||||
static const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1)
|
||||
};
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "led.h"
|
||||
|
||||
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
if (usb_led & (1<<USB_LED_CAPS_LOCK))
|
||||
{
|
||||
// Output high.
|
||||
DDRB |= (1<<6);
|
||||
PORTB |= (1<<6);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Output low.
|
||||
DDRB &= ~(1<<6);
|
||||
PORTB &= ~(1<<6);
|
||||
}
|
||||
|
||||
if (usb_led & (1<<USB_LED_SCROLL_LOCK))
|
||||
{
|
||||
// Output high.
|
||||
DDRB |= (1<<7);
|
||||
PORTB |= (1<<7);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Output low.
|
||||
DDRB &= ~(1<<7);
|
||||
PORTB &= ~(1<<7);
|
||||
}
|
||||
}
|
@ -1,274 +0,0 @@
|
||||
/* Copyright 2012 Jun Wako <wakojun@gmail.com>
|
||||
*
|
||||
* This is heavily based on phantom/board.{c|h}.
|
||||
* https://github.com/BathroomEpiphanies/AVR-Keyboard
|
||||
*
|
||||
* Copyright (c) 2012 Fredrik Atmer, Bathroom Epiphanies Inc
|
||||
* http://bathroomepiphanies.com
|
||||
*
|
||||
* As for liscensing consult with the original files or its author.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 0
|
||||
#endif
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
// bit array of key state(1:on, 0:off)
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
static uint8_t read_rows(void);
|
||||
static void init_rows(void);
|
||||
static void unselect_cols(void);
|
||||
static void select_col(uint8_t col);
|
||||
|
||||
#ifndef SLEEP_LED_ENABLE
|
||||
/* LEDs are on output compare pins OC1B OC1C
|
||||
This activates fast PWM mode on them.
|
||||
Prescaler 256 and 8-bit counter results in
|
||||
16000000/256/256 = 244 Hz blink frequency.
|
||||
LED_A: Caps Lock
|
||||
LED_B: Scroll Lock */
|
||||
/* Output on PWM pins are turned off when the timer
|
||||
reaches the value in the output compare register,
|
||||
and are turned on when it reaches TOP (=256). */
|
||||
static
|
||||
void setup_leds(void)
|
||||
{
|
||||
TCCR1A |= // Timer control register 1A
|
||||
(1<<WGM10) | // Fast PWM 8-bit
|
||||
(1<<COM1B1)| // Clear OC1B on match, set at TOP
|
||||
(1<<COM1C1); // Clear OC1C on match, set at TOP
|
||||
TCCR1B |= // Timer control register 1B
|
||||
(1<<WGM12) | // Fast PWM 8-bit
|
||||
(1<<CS12); // Prescaler 256
|
||||
OCR1B = LED_BRIGHTNESS; // Output compare register 1B
|
||||
OCR1C = LED_BRIGHTNESS; // Output compare register 1C
|
||||
// LEDs: LED_A -> PORTB6, LED_B -> PORTB7
|
||||
DDRB |= (1<<6) | (1<<7);
|
||||
PORTB &= ~((1<<6) | (1<<7));
|
||||
}
|
||||
#endif
|
||||
|
||||
inline
|
||||
uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
// To use PORTF disable JTAG with writing JTD bit twice within four cycles.
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
|
||||
// initialize row and col
|
||||
unselect_cols();
|
||||
init_rows();
|
||||
#ifndef SLEEP_LED_ENABLE
|
||||
setup_leds();
|
||||
#endif
|
||||
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++) { // 0-16
|
||||
select_col(col);
|
||||
_delay_us(3); // without this wait it won't read stable value.
|
||||
uint8_t rows = read_rows();
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) { // 0-5
|
||||
bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
|
||||
bool curr_bit = rows & (1<<row);
|
||||
if (prev_bit != curr_bit) {
|
||||
matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
|
||||
if (debouncing) {
|
||||
dprint("bounce!: "); dprintf("%02X", debouncing); dprintln();
|
||||
}
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
}
|
||||
unselect_cols();
|
||||
}
|
||||
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
_delay_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
if (debouncing) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
return (matrix[row] & ((matrix_row_t)1<<col));
|
||||
}
|
||||
|
||||
inline
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
print("\nr/c 0123456789ABCDEF\n");
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_key_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
count += bitpop32(matrix[i]);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Row pin configuration
|
||||
* row: 0 1 2 3 4 5
|
||||
* pin: B5 B4 B3 B2 B1 B0
|
||||
*/
|
||||
static void init_rows(void)
|
||||
{
|
||||
// Input with pull-up(DDR:0, PORT:1)
|
||||
DDRB &= ~0b00111111;
|
||||
PORTB |= 0b00111111;
|
||||
}
|
||||
|
||||
static uint8_t read_rows(void)
|
||||
{
|
||||
return (PINB&(1<<5) ? 0 : (1<<0)) |
|
||||
(PINB&(1<<4) ? 0 : (1<<1)) |
|
||||
(PINB&(1<<3) ? 0 : (1<<2)) |
|
||||
(PINB&(1<<2) ? 0 : (1<<3)) |
|
||||
(PINB&(1<<1) ? 0 : (1<<4)) |
|
||||
(PINB&(1<<0) ? 0 : (1<<5));
|
||||
}
|
||||
|
||||
/* Column pin configuration
|
||||
* col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
||||
* pin: D5 C7 C6 D4 D0 E6 F0 F1 F4 F5 F6 F7 D7 D6 D1 D2 D3
|
||||
*/
|
||||
static void unselect_cols(void)
|
||||
{
|
||||
// Hi-Z(DDR:0, PORT:0) to unselect
|
||||
DDRC |= 0b11000000; // PC: 7 6
|
||||
PORTC |= 0b11000000;
|
||||
DDRD |= 0b11111111; // PD: 7 6 5 4 3 2 1 0
|
||||
PORTD |= 0b11111111;
|
||||
DDRE |= 0b01000000; // PE: 6
|
||||
PORTE |= 0b01000000;
|
||||
DDRF |= 0b11110011; // PF: 7 6 5 4 1 0
|
||||
PORTF |= 0b11110011;
|
||||
}
|
||||
|
||||
static void select_col(uint8_t col)
|
||||
{
|
||||
// Output low(DDR:1, PORT:0) to select
|
||||
switch (col) {
|
||||
case 0:
|
||||
DDRD |= (1<<5);
|
||||
PORTD &= ~(1<<5);
|
||||
break;
|
||||
case 1:
|
||||
DDRC |= (1<<7);
|
||||
PORTC &= ~(1<<7);
|
||||
break;
|
||||
case 2:
|
||||
DDRC |= (1<<6);
|
||||
PORTC &= ~(1<<6);
|
||||
break;
|
||||
case 3:
|
||||
DDRD |= (1<<4);
|
||||
PORTD &= ~(1<<4);
|
||||
break;
|
||||
case 4:
|
||||
DDRD |= (1<<0);
|
||||
PORTD &= ~(1<<0);
|
||||
break;
|
||||
case 5:
|
||||
DDRE |= (1<<6);
|
||||
PORTE &= ~(1<<6);
|
||||
break;
|
||||
case 6:
|
||||
DDRF |= (1<<0);
|
||||
PORTF &= ~(1<<0);
|
||||
break;
|
||||
case 7:
|
||||
DDRF |= (1<<1);
|
||||
PORTF &= ~(1<<1);
|
||||
break;
|
||||
case 8:
|
||||
DDRF |= (1<<4);
|
||||
PORTF &= ~(1<<4);
|
||||
break;
|
||||
case 9:
|
||||
DDRF |= (1<<5);
|
||||
PORTF &= ~(1<<5);
|
||||
break;
|
||||
case 10:
|
||||
DDRF |= (1<<6);
|
||||
PORTF &= ~(1<<6);
|
||||
break;
|
||||
case 11:
|
||||
DDRF |= (1<<7);
|
||||
PORTF &= ~(1<<7);
|
||||
break;
|
||||
case 12:
|
||||
DDRD |= (1<<7);
|
||||
PORTD &= ~(1<<7);
|
||||
break;
|
||||
case 13:
|
||||
DDRD |= (1<<6);
|
||||
PORTD &= ~(1<<6);
|
||||
break;
|
||||
case 14:
|
||||
DDRD |= (1<<1);
|
||||
PORTD &= ~(1<<1);
|
||||
break;
|
||||
case 15:
|
||||
DDRD |= (1<<2);
|
||||
PORTD &= ~(1<<2);
|
||||
break;
|
||||
case 16:
|
||||
DDRD |= (1<<3);
|
||||
PORTD &= ~(1<<3);
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,155 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = quark_lufa
|
||||
|
||||
# Directory common source filess exist
|
||||
TOP_DIR = ../..
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
|
||||
|
||||
# # project specific files
|
||||
ifdef COMMON
|
||||
|
||||
SRC = keymap_common.c \
|
||||
matrix.c \
|
||||
led.c \
|
||||
backlight.c
|
||||
|
||||
ifdef KEYMAP
|
||||
SRC := common_keymaps/keymap_$(KEYMAP).c $(SRC)
|
||||
else
|
||||
SRC := common_keymaps/keymap_jack.c $(SRC)
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
SRC = extended_keymap_common.c \
|
||||
matrix.c \
|
||||
led.c \
|
||||
backlight.c
|
||||
|
||||
ifdef KEYMAP
|
||||
SRC := extended_keymaps/extended_keymap_$(KEYMAP).c $(SRC)
|
||||
else
|
||||
SRC := extended_keymaps/extended_keymap_default.c $(SRC)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
# MCU name
|
||||
#MCU = at90usb1287
|
||||
MCU = atmega32u4
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
# This will be an integer division of F_USB below, as it is sourced by
|
||||
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
#
|
||||
# LUFA specific
|
||||
#
|
||||
# Target architecture (see library "Board Types" documentation).
|
||||
ARCH = AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||
# at the end, this will be done automatically to create a 32-bit value in your
|
||||
# source code.
|
||||
#
|
||||
# If no clock division is performed on the input clock inside the AVR (via the
|
||||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||
F_USB = $(F_CPU)
|
||||
|
||||
# Interrupt driven control endpoint task(+60)
|
||||
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||
|
||||
|
||||
# Boot Section Size in *bytes*
|
||||
# Teensy halfKay 512
|
||||
# Teensy++ halfKay 1024
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
# USBaspLoader 2048
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
|
||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
|
||||
# Optimize size but this may cause error "relocation truncated to fit"
|
||||
#EXTRALDFLAGS = -Wl,--relax
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TOP_DIR)
|
||||
|
||||
include $(TOP_DIR)/protocol/lufa.mk
|
||||
include $(TOP_DIR)/common.mk
|
||||
include $(TOP_DIR)/rules.mk
|
@ -1,116 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# On command line:
|
||||
#
|
||||
# make all = Make software.
|
||||
#
|
||||
# make clean = Clean out built project files.
|
||||
#
|
||||
# make coff = Convert ELF to AVR COFF.
|
||||
#
|
||||
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||
#
|
||||
# make program = Download the hex file to the device.
|
||||
# Please customize your programmer settings(PROGRAM_CMD)
|
||||
#
|
||||
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||
# (must have teensy_loader_cli installed).
|
||||
#
|
||||
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||
# have dfu-programmer installed).
|
||||
#
|
||||
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||
# have Atmel FLIP installed).
|
||||
#
|
||||
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||
# (must have dfu-programmer installed).
|
||||
#
|
||||
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||
# (must have Atmel FLIP installed).
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
#
|
||||
# make filename.i = Create a preprocessed source file for use in submitting
|
||||
# bug reports to the GCC project.
|
||||
#
|
||||
# To rebuild project do "make clean" then "make all".
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = gh60_pjrc
|
||||
|
||||
# Directory common source filess exist
|
||||
TOP_DIR = ../..
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# project specific files
|
||||
SRC = keymap_common.c \
|
||||
matrix.c \
|
||||
led.c
|
||||
|
||||
ifdef KEYMAP
|
||||
SRC := keymap_$(KEYMAP).c $(SRC)
|
||||
else
|
||||
SRC := keymap_jack.c $(SRC)
|
||||
endif
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
|
||||
# MCU name, you MUST set this to match the board you are using
|
||||
# type "make clean" after changing this, so all files will be rebuilt
|
||||
MCU = atmega32u4
|
||||
#MCU = at90usb1286
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# Normally the first thing your program should do is set the clock prescaler,
|
||||
# so your program will run at the correct speed. You should also set this
|
||||
# variable to same clock speed. The _delay_ms() macro uses this, and many
|
||||
# examples use this variable to calculate timings. Do not add a "UL" here.
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
# Boot Section Size in *bytes*
|
||||
# Teensy halfKay 512
|
||||
# Atmel DFU loader 4096
|
||||
# LUFA bootloader 4096
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys(+5000)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+600)
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
NKRO_ENABLE = yes # USB Nkey Rollover(+500)
|
||||
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TOP_DIR)
|
||||
|
||||
include $(TOP_DIR)/protocol/pjrc.mk
|
||||
include $(TOP_DIR)/common.mk
|
||||
include $(TOP_DIR)/rules.mk
|
||||
|
||||
plain: OPT_DEFS += -DKEYMAP_PLAIN
|
||||
plain: all
|
||||
|
||||
poker: OPT_DEFS += -DKEYMAP_POKER
|
||||
poker: all
|
||||
|
||||
poker_set: OPT_DEFS += -DKEYMAP_POKER_SET
|
||||
poker_set: all
|
||||
|
||||
poker_bit: OPT_DEFS += -DKEYMAP_POKER_BIT
|
||||
poker_bit: all
|
@ -1,53 +0,0 @@
|
||||
Quark keyboard firmware
|
||||
======================
|
||||
DIY/Assembled compact 40% keyboard by [Ortholinear Keyboards](http://ortholinearkeyboards.com).
|
||||
|
||||
## Extended Keymap
|
||||
If you include extended_keymap_common.h instead of keymap_common.h at the top of your file, you'll have access to a bunch of goodies:
|
||||
|
||||
- Use `LSFT()`, `LCTL()`, et. al. (listed in extended_keymap_common.h) as modifiers for keys (daisy-chain-able)
|
||||
- Use `FUNC(1)` instead of `FN1` (etc.) to access the function layers beyond the 32 function layer limit
|
||||
- Use `CM_F` instead of `KC_F` to get the ColeMak equivilent for shortcuts (maps backwards)
|
||||
- Use `MACRODOWN()` instead of `MACRO()` to easily make a keydown macro (`CM_*` works here too)
|
||||
|
||||
### Some notes on usage:
|
||||
|
||||
- The `KEYMAP()` macro is unable to be used due to the bitwise modifications that take place - refer to extended_keymap_jack.c to see how to set things up with the `KC_` prefix
|
||||
- Keep an eye on the Makefile - this needs to include the correct files to work
|
||||
- Don't forget to use `const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {` instead of the 8bit equivilent
|
||||
|
||||
## Build
|
||||
|
||||
Follow [this guide](http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html) to setup your development environment before anything else. Abbreviated instructions are provide at the [bottom of this document](https://github.com/rswiernik/tmk_keyboard/tree/rswiernik_dev/keyboard/quark#environment-setup)
|
||||
|
||||
Download the whole firmware [here](https://github.com/jackhumbert/tmk_keyboard/archive/master.zip) and navigate to the keyboard/quark folder. Once your dev env is setup, you'll be able to type `make` to generate your .hex that you can load with the Teensy app onto your Planck (once you've hit reset/shorted GND & RST).
|
||||
|
||||
Depending on which keymap you would like to use, you will have to compile slightly differently.
|
||||
|
||||
####Default
|
||||
To build with the default keymap, simply move to the tmk\_keyboard/keyboard/quark/ and run `make` as follows:
|
||||
```
|
||||
$ make
|
||||
```
|
||||
|
||||
## Keymap
|
||||
Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create file named `keymap_<name>.c` and see keymap document (you can find in top README.md) and existent keymap files.
|
||||
|
||||
####**Extended Keymaps**
|
||||
|
||||
To build the firmware binary hex file with an extended keymap just do `make` with `KEYMAP` option like:
|
||||
```
|
||||
$ make KEYMAP=[common|jack|<name>]
|
||||
```
|
||||
_The only applicable keymaps will work with this option._ Extended keymaps follow the format **__extended\_keymap\_\<name\>.c__**
|
||||
|
||||
####**Common Keymaps**
|
||||
|
||||
Building with a common keymap is as simple as adding the COMMON option. Note that only
|
||||
```
|
||||
$ make KEYMAP=[common|jack|<name>] COMMON=true
|
||||
```
|
||||
_The only applicable keymaps will work with this option._ Common keymaps follow the format **__keymap\_\<name\>.c__**
|
||||
|
||||
## Notable TMK forks (which some of the keymap files are from)
|
||||
- (add yours)
|
@ -1,46 +0,0 @@
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "backlight.h"
|
||||
|
||||
|
||||
void backlight_init_ports()
|
||||
{
|
||||
// Setup PB7 as output and output low.
|
||||
DDRB |= (1<<7);
|
||||
PORTB &= ~(1<<7);
|
||||
|
||||
// Use full 16-bit resolution.
|
||||
ICR1 = 0xFFFF;
|
||||
|
||||
// I could write a wall of text here to explain... but TL;DW
|
||||
// Go read the ATmega32u4 datasheet.
|
||||
// And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
|
||||
|
||||
// Pin PB7 = OCR1C (Timer 1, Channel C)
|
||||
// Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
|
||||
// (i.e. start high, go low when counter matches.)
|
||||
// WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
|
||||
// Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
|
||||
|
||||
TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
|
||||
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
|
||||
|
||||
// Default to zero duty cycle.
|
||||
OCR1C = 0x0000;
|
||||
}
|
||||
|
||||
void backlight_set(uint8_t level)
|
||||
{
|
||||
if ( level == 0 )
|
||||
{
|
||||
// Turn off PWM control on PB7, revert to output low.
|
||||
TCCR1A &= ~(_BV(COM1C1));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Turn on PWM control of PB7
|
||||
TCCR1A |= _BV(COM1C1);
|
||||
OCR1C = level << 12 | 0x0FFF;
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +0,0 @@
|
||||
|
||||
void backlight_init_ports(void);
|
@ -1,42 +0,0 @@
|
||||
#include "keymap_common.h"
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = KEYMAP(
|
||||
ESC, Q, W, E, R, T, Y, U, I, O, P, BSPC,
|
||||
LCTL, A, S, D, F, G, H, J, K, L, SCLN, ENT,
|
||||
LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT,
|
||||
TAB, LGUI, RSFT, LALT, FN2, SPC, FN1, LEFT, DOWN, UP, RGHT),
|
||||
[1] = KEYMAP( /* RAISE */
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, DEL,
|
||||
TRNS, F1, F2, F3, F4, F5, F6, 4, 5, 6, QUOT, TRNS,
|
||||
TRNS, F7, F8, F9, F10, F11, F12, 1, 2, 3, TRNS, PGUP,
|
||||
MPRV, MNXT, TRNS, MUTE, TRNS, TRNS, FN1, 0, 0, TRNS, PGDN),
|
||||
[2] = KEYMAP( /* LOWER */
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MINS,
|
||||
TRNS, TRNS, TRNS, PAUSE, TRNS, TRNS, TRNS, TRNS, LBRC, RBRC, BSLS, EQL,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
|
||||
MPLY, MSTP, VOLU, VOLD, FN2, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS),
|
||||
};
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_MOMENTARY(1), // to Fn overlay
|
||||
[2] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay
|
||||
|
||||
[10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
|
||||
[11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
|
||||
[12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
|
||||
[13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
|
||||
[14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
|
||||
[15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
|
||||
[16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
|
||||
[17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
|
||||
[18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
|
||||
[19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
|
||||
[20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
|
||||
[21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
|
||||
[22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
|
||||
[23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
|
||||
[24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
|
||||
[28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
|
||||
|
||||
[29] = ACTION_MODS_KEY(MOD_LSFT | MOD_RSFT, KC_PAUSE),
|
||||
};
|
@ -1,34 +0,0 @@
|
||||
#include "keymap_common.h"
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = KEYMAP(
|
||||
ESC, Q, W, E, R, T, Y, U, I, O, P, BSPC,
|
||||
FN1, A, S, D, F, G, H, J, K, L, SCLN, ENT,
|
||||
LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, LBRC,
|
||||
LCTL, BSLS, QUOT, LALT, FN22, SPC, LEFT, UP, DOWN, RGHT, RBRC),
|
||||
[1] = KEYMAP(
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, DEL,
|
||||
TRNS, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, TRNS, TRNS, TRNS,
|
||||
TRNS, FN18, FN19, FN22, EQL, MINS, FN20, TRNS, TRNS, TRNS, TRNS, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN1, TRNS, VOLD, VOLU, TRNS),
|
||||
};
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_MOMENTARY(1), // to Fn overlay
|
||||
|
||||
[10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
|
||||
[11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
|
||||
[12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
|
||||
[13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
|
||||
[14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
|
||||
[15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
|
||||
[16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
|
||||
[17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
|
||||
[18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
|
||||
[19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
|
||||
[20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
|
||||
[21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
|
||||
[22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
|
||||
[23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
|
||||
[24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
|
||||
[28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
|
||||
};
|
@ -1,50 +0,0 @@
|
||||
#include "keymap_common.h"
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = KEYMAP( /* Jack */
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, BSPC,
|
||||
ESC, A, S, D, F, G, H, J, K, L, SCLN, QUOT,
|
||||
LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, ENT,
|
||||
RSFT, LCTL, LALT, LGUI, FN2, SPC, FN1, LEFT, DOWN, UP, RGHT),
|
||||
[1] = KEYMAP( /* Jack colemak */
|
||||
TAB, Q, W, F, P, G, J, L, U, Y, SCLN, BSPC,
|
||||
ESC, A, R, S, T, D, H, N, E, I, O, QUOT,
|
||||
LSFT, Z, X, C, V, B, K, M, COMM, DOT, SLSH, ENT,
|
||||
FN3, LCTL, LALT, LGUI, FN2, SPC, FN1, LEFT, DOWN, UP, RGHT),
|
||||
[2] = KEYMAP( /* Jack RAISE */
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, BSPC,
|
||||
TRNS, FN3, FN4, PAUSE, TRNS, TRNS, TRNS, MINS, EQL, LBRC, RBRC, BSLS,
|
||||
TRNS, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN1, MNXT, VOLD, VOLU, MPLY),
|
||||
[3] = KEYMAP( /* Jack LOWER */
|
||||
FN22, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, BSPC,
|
||||
TRNS, FN3, FN4, PAUSE, TRNS, TRNS, TRNS, FN20, FN21, FN23, FN24, FN28,
|
||||
TRNS, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, FN2, TRNS, TRNS, MNXT, VOLD, VOLU, MPLY),
|
||||
};
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay
|
||||
[2] = ACTION_LAYER_MOMENTARY(3), // to Fn overlay
|
||||
|
||||
[3] = ACTION_DEFAULT_LAYER_SET(0),
|
||||
[4] = ACTION_DEFAULT_LAYER_SET(1),
|
||||
|
||||
[10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
|
||||
[11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
|
||||
[12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
|
||||
[13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
|
||||
[14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
|
||||
[15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
|
||||
[16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
|
||||
[17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
|
||||
[18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
|
||||
[19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
|
||||
[20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
|
||||
[21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
|
||||
[22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
|
||||
[23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
|
||||
[24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
|
||||
[28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
|
||||
|
||||
[29] = ACTION_MODS_KEY(MOD_LSFT | MOD_RSFT, KC_PAUSE),
|
||||
};
|
@ -1,107 +0,0 @@
|
||||
#include "keymap_common.h"
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = KEYMAP( /* Joe colemak */
|
||||
ESC, Q, W, F, P, G, J, L, U, Y, SCLN, MINS,
|
||||
BSPC, A, R, S, T, D, H, N, E, I, O, ENT,
|
||||
TAB, Z, X, C, V, B, K, M, COMM, DOT, SLSH, QUOT,
|
||||
LCTL, LGUI, LALT, LSFT, FN1, SPC, FN0, LEFT, DOWN, UP, RGHT),
|
||||
[1] = KEYMAP( /* Joe qwerty */
|
||||
ESC, Q, W, E, R, T, Y, U, I, O, P, MINS,
|
||||
BSPC, A, S, D, F, G, H, J, K, L, SCLN, ENT,
|
||||
TAB, Z, X, C, V, B, N, M, COMM, DOT, SLSH, QUOT,
|
||||
LCTL, LGUI, LALT, LSFT, FN1, SPC, FN0, LEFT, DOWN, UP, RGHT),
|
||||
[2] = KEYMAP( /* Joe RAISE */
|
||||
F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
|
||||
DEL, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, TRNS,
|
||||
BSLS, FN5, FN6, TRNS, TRNS, MENU, CAPS, INS, PSCR, LBRC, RBRC, FN21,
|
||||
TRNS, TRNS, TRNS, TRNS, FN2, TRNS, FN0, FN26, FN27, FN28, FN29),
|
||||
[3] = KEYMAP( /* Joe LOWER */
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN7, FN8, FN9, FN30, FN31,
|
||||
DEL, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, TRNS,
|
||||
FN25, FN3, FN4, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN23, FN24, EQL,
|
||||
TRNS, TRNS, TRNS, TRNS, FN1, TRNS, FN2, HOME, PGDN, PGUP, END),
|
||||
[4] = KEYMAP( /* Joe LOWER + RAISE */
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MNXT, VOLD, VOLU, MPLY),
|
||||
};
|
||||
|
||||
enum macro_id {
|
||||
M_Q0,
|
||||
M_Q1,
|
||||
M_Q2,
|
||||
M_Q3,
|
||||
M_Q4
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay
|
||||
[1] = ACTION_LAYER_MOMENTARY(3), // to Fn overlay
|
||||
[2] = ACTION_LAYER_MOMENTARY(4), // to Fn overlay
|
||||
|
||||
[3] = ACTION_DEFAULT_LAYER_SET(0),
|
||||
[4] = ACTION_DEFAULT_LAYER_SET(1),
|
||||
|
||||
[5] = ACTION_MODS_KEY(MOD_LCTL, KC_PGDN),
|
||||
[6] = ACTION_MODS_KEY(MOD_LCTL, KC_PGUP),
|
||||
|
||||
[10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
|
||||
[11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
|
||||
[12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
|
||||
[13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
|
||||
[14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
|
||||
[15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
|
||||
[16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
|
||||
[17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
|
||||
[18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
|
||||
[19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
|
||||
[20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
|
||||
[21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
|
||||
[22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
|
||||
[23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
|
||||
[24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
|
||||
[25] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
|
||||
|
||||
[7] = ACTION_MACRO(M_Q0),
|
||||
[8] = ACTION_MACRO(M_Q1),
|
||||
[9] = ACTION_MACRO(M_Q2),
|
||||
[30] = ACTION_MACRO(M_Q3),
|
||||
[31] = ACTION_MACRO(M_Q4),
|
||||
|
||||
[26] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT, KC_LEFT),
|
||||
[27] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT, KC_DOWN),
|
||||
[28] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT, KC_UP),
|
||||
[29] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT, KC_RGHT),
|
||||
|
||||
};
|
||||
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
keyevent_t event = record->event;
|
||||
switch (id) {
|
||||
case M_Q0:
|
||||
return event.pressed ?
|
||||
MACRO( D(LSFT), T(SCLN), U(LSFT), T(SLSH), END ) :
|
||||
MACRO_NONE;
|
||||
case M_Q1:
|
||||
return event.pressed ?
|
||||
MACRO( D(LSFT), T(SCLN), T(9), U(LSFT), END ) :
|
||||
MACRO_NONE;
|
||||
case M_Q2:
|
||||
return event.pressed ?
|
||||
MACRO( D(LSFT), T(0), T(SCLN), U(LSFT), END ) :
|
||||
MACRO_NONE;
|
||||
case M_Q3:
|
||||
return event.pressed ?
|
||||
MACRO( D(LSFT), T(9), T(SCLN), U(LSFT), END ) :
|
||||
MACRO_NONE;
|
||||
case M_Q4:
|
||||
return event.pressed ?
|
||||
MACRO( D(LSFT), T(SCLN), T(0), U(LSFT), END ) :
|
||||
MACRO_NONE;
|
||||
|
||||
}
|
||||
return MACRO_NONE;
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
// by Matthew Pepers - https://github.com/pepers
|
||||
|
||||
/* grid planck layout - modified programmer dvorak
|
||||
,-----------------------------------------------------------------------------------------------.
|
||||
| pause | @ | | | ^ | | | | | * | # | $ | del |
|
||||
| esc | ; : | , < | . > | P | Y | F | G | G | C | R | bkspc |
|
||||
| F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
|
||||
|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|
|
||||
| & | / | { | ( | [ | = | ! | ] | ) | } | \ | + |
|
||||
| ` ~ | A | O | E | U | I | D | H | T | N | S | - _ |
|
||||
| % | 7 | 5 | 3 | 1 | 9 | 0 | 2 | 4 | 6 | 8 | ? |
|
||||
|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|
|
||||
| | | | | | | | | | | | prtsc |
|
||||
| tab | ' " | Q | J | K | X | B | M | W | V | Z | retrn |
|
||||
| | | | | | | | | | | | insrt |
|
||||
|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|
|
||||
| | | | | | | | | | | | |
|
||||
| lctrl | lgui | lalt | ralt | lower | shift | space | raise | left | down | up | right |
|
||||
| | | | | | | | | home | pgdn | pgup | end |
|
||||
`-----------------------------------------------------------------------------------------------'
|
||||
*/
|
||||
|
||||
#include "keymap_common.h"
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* 0: dvorak */
|
||||
[0] = KEYMAP_GRID( ESC, SCLN, COMM, DOT, P, Y, F, G, C, R, L, BSPC, \
|
||||
GRV, A, O, E, U, I, D, H, T, N, S, MINS, \
|
||||
TAB, QUOT, Q, J, K, X, B, M, W, V, Z, ENT, \
|
||||
LCTL, LGUI, LALT, RALT, FN1, LSFT, SPC, FN2, LEFT, DOWN, UP, RGHT),
|
||||
|
||||
/* 1: lower (FN1) */
|
||||
[1] = KEYMAP_GRID( F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, \
|
||||
FN17, 7, 5, 3, 1, 9, 0, 2, 4, 6, 8, FN18, \
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, INS, \
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, HOME, PGDN, PGUP, END),
|
||||
|
||||
/* 2: raise (FN2) */
|
||||
[2] = KEYMAP_GRID(PAUS, FN19, FN20, FN21, TRNS, TRNS, TRNS, TRNS, FN22, FN23, FN24, DEL, \
|
||||
FN10, SLSH, FN11, FN12, LBRC, EQL, FN13, RBRC, FN14, FN15, BSLS, FN16, \
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, PSCR, \
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS),
|
||||
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_MOMENTARY(1), // lower Fn layer
|
||||
[2] = ACTION_LAYER_MOMENTARY(2), // raise Fn layer
|
||||
|
||||
// lower row1
|
||||
[17] = ACTION_MODS_KEY(MOD_LSFT, KC_5), // %
|
||||
[18] = ACTION_MODS_KEY(MOD_LSFT, KC_SLASH), // ?
|
||||
|
||||
// raise row0
|
||||
[19] = ACTION_MODS_KEY(MOD_LSFT, KC_2), // @
|
||||
[20] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLASH), // |
|
||||
[21] = ACTION_MODS_KEY(MOD_LSFT, KC_6), // ^
|
||||
[22] = ACTION_MODS_KEY(MOD_LSFT, KC_8), // *
|
||||
[23] = ACTION_MODS_KEY(MOD_LSFT, KC_3), // #
|
||||
[24] = ACTION_MODS_KEY(MOD_LSFT, KC_4), // $
|
||||
|
||||
// raise row1
|
||||
[10] = ACTION_MODS_KEY(MOD_LSFT, KC_7), // &
|
||||
[11] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRACKET), // {
|
||||
[12] = ACTION_MODS_KEY(MOD_LSFT, KC_9), // (
|
||||
[13] = ACTION_MODS_KEY(MOD_LSFT, KC_1), // !
|
||||
[14] = ACTION_MODS_KEY(MOD_LSFT, KC_0), // )
|
||||
[15] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRACKET), // }
|
||||
[16] = ACTION_MODS_KEY(MOD_LSFT, KC_EQUAL), // +
|
||||
};
|
@ -1,153 +0,0 @@
|
||||
// Author: Nathan Ross Powell <nathanrospowell@gmail.com>
|
||||
// https://github.com/nathanrosspowell/tmk_keyboard/blob/planck-jack/keyboard/planck/keymap_nathan.c
|
||||
|
||||
#include "keymap_common.h"
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* 0: main layer
|
||||
* ,-----------------------------------------------------------------------.
|
||||
* |Tab | q | w | e | r | t | y | u | i | o | p | BS |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* |Ctrl | a | s | d | f | g | h | j | k | l | ; | Ret |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* |Shift| z | x | c | v | b | n | m | [ | ( | { | < |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* |Meta | \ | / | Alt |Lower|Space|Space|Upper|Left |Down | Up |Right|
|
||||
* `-----------------------------------------------------------------------'
|
||||
*/
|
||||
[0] = KEYMAP_GRID(
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, BSPC,
|
||||
LCTL, A, S, D, F, G, H, J, K, L, SCLN, ENT,
|
||||
RSFT, Z, X, C, V, B, N, M, LBRC, FN10, FN11, FN12,
|
||||
LGUI, BSLS, SLSH, LALT, FN0, SPC, SPC, FN1, LEFT, DOWN, UP, RGHT),
|
||||
|
||||
/* 1: fn left/lower layer
|
||||
* The top row are Visual Studio combos:
|
||||
* 'Run', 'Breakpoint', 'Step over', 'Step into', 'Set cursor to line'
|
||||
* 2nd row are key combos:
|
||||
* 'ctrl-alt-delete', 'ctrl-shift-escape'
|
||||
* 3rd row are macros keys:
|
||||
* 'P0' - 'P5' execute a script on Windows machines
|
||||
* ,-----------------------------------------------------------------------.
|
||||
* | ESC | F5 | F9 | F10 | F11 |S+F11|CSF10|NLock|Num7 |Num8 |Num9 | Del |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* | |C/A/D|C/S/E| Ins |Print|Pause|SLock|Num0 |Num4 |Num5 |Num6 |Num= |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* | | P0 | P1 | P2 | P3 | P4 | P5 |Num. |Num1 |Num2 |Num3 |Num/ |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* | |User | | | | | | |Home |PgDn |PgUp | End |
|
||||
* `-----------------------------------------------------------------------'
|
||||
*/
|
||||
[1] = KEYMAP_GRID(
|
||||
ESC, F5, F9, F10, F11, FN30, FN31, NLCK, P7, P8, P9, DEL,
|
||||
TRNS, FN16, FN17, INS, PSCR, PAUS, SLCK, P0, P4, P5, P6, PEQL,
|
||||
TRNS, FN2, FN3, FN4, FN5, FN6, FN7, PDOT, P1, P2, P3, PSLS,
|
||||
TRNS, FN8, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, HOME, PGDN, PGUP, END ),
|
||||
|
||||
/* 2: fn right/raise layer
|
||||
* ,-----------------------------------------------------------------------.
|
||||
* | F1 | F2 | F3 | F4 |F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* | | ! | @ | # | $ | % | ^ | & | * | - | + | = |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* | | _ | ' | " | ` | ~ | , | . | ] | ) | } | > |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* | |NextT|PrevT| | | | Esc | |Mute |Vol- |Vol+ | P/P |
|
||||
* `-----------------------------------------------------------------------'
|
||||
*/
|
||||
[2] = KEYMAP_GRID(
|
||||
F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
|
||||
TRNS, FN18, FN19, FN20, FN21, FN22, FN23, FN24, FN25, MINS, FN26, PAST,
|
||||
TRNS, FN27, QUOT, FN28, GRV, FN29, COMM, DOT, RBRC, FN13, FN14, FN15,
|
||||
TRNS, MNXT, MPRV, TRNS, TRNS, TRNS, ESC, TRNS, MUTE, VOLD, VOLU, MPLY ),
|
||||
};
|
||||
|
||||
enum macro_id {
|
||||
M_P0,
|
||||
M_P1,
|
||||
M_P2,
|
||||
M_P3,
|
||||
M_P4,
|
||||
M_P5,
|
||||
M_USERNAME
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[0] = ACTION_LAYER_MOMENTARY(1), // left/lower layer
|
||||
[1] = ACTION_LAYER_MOMENTARY(2), // right/raise layer
|
||||
// Program macros
|
||||
[2] = ACTION_MACRO(M_P0),
|
||||
[3] = ACTION_MACRO(M_P1),
|
||||
[4] = ACTION_MACRO(M_P2),
|
||||
[5] = ACTION_MACRO(M_P3),
|
||||
[6] = ACTION_MACRO(M_P4),
|
||||
[7] = ACTION_MACRO(M_P5),
|
||||
[8] = ACTION_MACRO(M_USERNAME),
|
||||
// Braces
|
||||
[10] = ACTION_MODS_KEY(MOD_LSFT, KC_9), // (
|
||||
[11] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC), // {
|
||||
[12] = ACTION_MODS_KEY(MOD_LSFT, KC_COMMA), // <
|
||||
[13] = ACTION_MODS_KEY(MOD_LSFT, KC_0), // )
|
||||
[14] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC), // }
|
||||
[15] = ACTION_MODS_KEY(MOD_LSFT, KC_DOT), // >
|
||||
// Combo
|
||||
[16] = ACTION_MODS_KEY(MOD_LALT | MOD_LCTL, KC_DEL), // Ctrl+Alt+Delete
|
||||
[17] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_ESC), // Ctrl+Shft+Escape
|
||||
// Symbols
|
||||
[18] = ACTION_MODS_KEY(MOD_LSFT, KC_1), // !
|
||||
[19] = ACTION_MODS_KEY(MOD_LSFT, KC_2), // @
|
||||
[20] = ACTION_MODS_KEY(MOD_LSFT, KC_3), // #
|
||||
[21] = ACTION_MODS_KEY(MOD_LSFT, KC_4), // $
|
||||
[22] = ACTION_MODS_KEY(MOD_LSFT, KC_5), // %
|
||||
[23] = ACTION_MODS_KEY(MOD_LSFT, KC_6), // ^
|
||||
[24] = ACTION_MODS_KEY(MOD_LSFT, KC_7), // &
|
||||
[25] = ACTION_MODS_KEY(MOD_LSFT, KC_8), // *
|
||||
[26] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL), // +
|
||||
[27] = ACTION_MODS_KEY(MOD_LSFT, KC_MINUS), // _
|
||||
[28] = ACTION_MODS_KEY(MOD_LSFT, KC_QUOTE), // "
|
||||
[29] = ACTION_MODS_KEY(MOD_LSFT, KC_GRAVE), // ~
|
||||
// Debugging
|
||||
[30] = ACTION_MODS_KEY(MOD_LSFT, KC_F11), // Step into
|
||||
[31] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_F10), // Set cursor to line
|
||||
};
|
||||
|
||||
// Run a script and pass a key number to it. This is Windows specific and the script needs to be on your path.
|
||||
// *open run dialog* keypress.py [PRG_NUM]
|
||||
#define ADD_PYTHON_PROGRAM_ON_WIN( PRG_NUM ) MACRO( D(LGUI), T(R), U(LGUI), W(100), T(K), T(E), T(Y), T(P), T(R), T(E), T(S), T(S), T(DOT), T(P), T(Y), T(SPC), T(PRG_NUM), END )
|
||||
// *return*
|
||||
#define RUN_PYTHON_PROGRAM_ON_WIN MACRO( T(ENT), END )
|
||||
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
|
||||
keyevent_t event = record->event;
|
||||
switch (id) {
|
||||
case M_P0:
|
||||
return event.pressed ?
|
||||
ADD_PYTHON_PROGRAM_ON_WIN( 0 ) :
|
||||
RUN_PYTHON_PROGRAM_ON_WIN;
|
||||
case M_P1:
|
||||
return event.pressed ?
|
||||
ADD_PYTHON_PROGRAM_ON_WIN( 1 ) :
|
||||
RUN_PYTHON_PROGRAM_ON_WIN;
|
||||
case M_P2:
|
||||
return event.pressed ?
|
||||
ADD_PYTHON_PROGRAM_ON_WIN( 2 ) :
|
||||
RUN_PYTHON_PROGRAM_ON_WIN;
|
||||
case M_P3:
|
||||
return event.pressed ?
|
||||
ADD_PYTHON_PROGRAM_ON_WIN( 3 ) :
|
||||
RUN_PYTHON_PROGRAM_ON_WIN;
|
||||
case M_P4:
|
||||
return event.pressed ?
|
||||
ADD_PYTHON_PROGRAM_ON_WIN( 4 ) :
|
||||
RUN_PYTHON_PROGRAM_ON_WIN;
|
||||
case M_P5:
|
||||
return event.pressed ?
|
||||
ADD_PYTHON_PROGRAM_ON_WIN( 5 ) :
|
||||
RUN_PYTHON_PROGRAM_ON_WIN;
|
||||
case M_USERNAME:
|
||||
return event.pressed ?
|
||||
MACRO( T(N), T(A), T(T), T(H), T(A), T(N), T(R), T(O), T(S), T(S), T(P), T(O), T(W), T(E), T(L), T(L), END ) :
|
||||
MACRO_NONE;
|
||||
}
|
||||
return MACRO_NONE;
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
#include "keymap_common.h"
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = KEYMAP( /* Native */
|
||||
ESC, Q, W, E, R, T, Y, U, I, O, P, FN2,
|
||||
BSPC, A, S, D, F, G, H, J, K, L, SCLN, QUOT,
|
||||
TAB, Z, X, C, V, B, N, M, COMM, DOT, SLSH, ENT,
|
||||
DEL, LCTL, NO, LSFT, LALT, SPC, NO, LEFT, DOWN, UP, RGHT),
|
||||
[1] = KEYMAP( /* QWERTY->PHOTOSHOP */
|
||||
DELETE, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, FN1,
|
||||
O, G, S, U, T, FN27, F21, F10, F11, F7, F8, F9,
|
||||
TAB, FN4, FN5, FN6, F1, FN7, F18, F19, F23, F20, F22, FN9,
|
||||
COMM, DOT, FN10, FN11, FN3, SPC, FN12, F2, FN8, F3, F14),
|
||||
[2] = KEYMAP( /* 2: FN3 PHOTOSHOP */
|
||||
ESC, FN25, FN26, NO, NO, NO, NO, NO, NO, NO, NO, NO,
|
||||
NO, NO, NO, NO, NO, NO, NO, NO, NO, FN19, FN20, FN21,
|
||||
C, NO, FN22, FN5, NO, FN23, NO, NO, NO, NO, FN13, NO,
|
||||
FN14, FN15, FN16, FN17, FN3, SPC, FN18, NO, NO, F24, NO),
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_DEFAULT_LAYER_SET(0), // set Qwerty layout
|
||||
[2] = ACTION_DEFAULT_LAYER_SET(1), // set Photoshop presets
|
||||
[3] = ACTION_LAYER_ON_OFF(2), // Photoshop function layer
|
||||
|
||||
[4] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F9), // photo folder AHK
|
||||
[5] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_I), // select inverse
|
||||
[6] = ACTION_MODS_KEY(MOD_LSFT, KC_M), // marquee select
|
||||
[7] = ACTION_MODS_KEY(MOD_LALT, KC_BSPC), // fill
|
||||
[8] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_X), // warp
|
||||
[9] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT | MOD_LSFT, KC_F12), // merge all new layer
|
||||
[10] = ACTION_MODS_KEY(MOD_LCTL, KC_MINS), // zoom out
|
||||
[11] = ACTION_MODS_KEY(MOD_LCTL, KC_H), // RBG sliders
|
||||
[12] = ACTION_MODS_KEY(MOD_LCTL, KC_S), // save
|
||||
[13] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_F5), // layer mask from transparancy
|
||||
[14] = ACTION_MODS_KEY(MOD_LALT, KC_LBRC), // prev layer
|
||||
[15] = ACTION_MODS_KEY(MOD_LALT, KC_RBRC), // next layer
|
||||
[16] = ACTION_MODS_KEY(MOD_LCTL, KC_EQL), // zoom in
|
||||
[17] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_H), // HSV sliders
|
||||
[18] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F11), // save as PNG
|
||||
[19] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F7), // gaussian blur
|
||||
[20] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F8), // motion blur
|
||||
[21] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_X), // liquify filter
|
||||
[22] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS), // prev layer blending
|
||||
[23] = ACTION_MODS_KEY(MOD_LSFT | MOD_LALT, KC_N), // normal layer blending
|
||||
[24] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL), // next layer blending
|
||||
[25] = ACTION_MODS_KEY(MOD_LCTL, KC_Z), // step back
|
||||
[26] = ACTION_MODS_KEY(MOD_LCTL, KC_Y), // step forward
|
||||
[27] = ACTION_MODS_KEY(MOD_LCTL, KC_R), // rasterize
|
||||
|
||||
};
|
@ -1,74 +0,0 @@
|
||||
#include "keymap_common.h"
|
||||
|
||||
/*
|
||||
* BUILD:
|
||||
* Simply run the command below in the keyboard/planck directory
|
||||
* to build against this keymap
|
||||
*
|
||||
* make KEYMAP=reed COMMON_KEYMAP=true
|
||||
*
|
||||
*
|
||||
* DETAILS:
|
||||
*
|
||||
* This layout works off of Jack's layout, making some changes that I
|
||||
* feel significantly improve the function of the keyboard. Major changes
|
||||
* include adding a "gaming mode" that will allow users to still access
|
||||
* the number keys 1 through 4 easily for games that require it. Also
|
||||
* included is the ability to use the tap/hold function for easy use of
|
||||
* right shift and thumb shift with their tapped companions.
|
||||
*
|
||||
*/
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = KEYMAP_GRID( /* Reed */
|
||||
ESC, Q, W, E, R, T, Y, U, I, O, P, BSPC,
|
||||
TAB, A, S, D, F, G, H, J, K, L, SCLN, QUOT,
|
||||
LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, FN5,
|
||||
LCTL, CAPS, LALT, LGUI, FN2, FN7, SPC, FN1, LEFT, DOWN, UP, RGHT),
|
||||
|
||||
[1] = KEYMAP_GRID( /* Reed EXTREME GAMING */
|
||||
ESC, Q, W, E, R, T, Y, U, I, O, P, BSPC,
|
||||
TAB, A, S, D, F, G, H, J, K, L, SCLN, QUOT,
|
||||
LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, FN5,
|
||||
LCTL, 1, 2, 3, 4, SPC, FN2, FN1, LEFT, DOWN, UP, RGHT),
|
||||
|
||||
[2] = KEYMAP_GRID( /* Reed RAISE */
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, BSPC,
|
||||
TRNS, FN3, FN4, PAUSE, TRNS, TRNS, TRNS, MINS, EQL, LBRC, RBRC, BSLS,
|
||||
TRNS, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN1, MNXT, VOLD, VOLU, MPLY),
|
||||
|
||||
[3] = KEYMAP_GRID( /* Reed LOWER */
|
||||
TRNS, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, DEL,
|
||||
TRNS, TRNS, INS, HOME, PGUP, TRNS, TRNS, FN20, FN21, FN23, FN24, FN28,
|
||||
TRNS, TRNS, DEL, END, PGDN, F11, F12, F13, TRNS, VOLD, VOLU, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, FN2, TRNS, TRNS, TRNS, MPRV, MUTE, MPLY, MNXT),
|
||||
};
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay - RAISE
|
||||
[2] = ACTION_LAYER_MOMENTARY(3), // to Fn overlay - LOWER
|
||||
|
||||
[3] = ACTION_DEFAULT_LAYER_SET(0),
|
||||
[4] = ACTION_DEFAULT_LAYER_SET(1),
|
||||
// Actions for the tap/hold modifiers listed above
|
||||
[5] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_ENT),
|
||||
[7] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_BSPC),
|
||||
|
||||
[10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
|
||||
[11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
|
||||
[12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
|
||||
[13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
|
||||
[14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
|
||||
[15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
|
||||
[16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
|
||||
[17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
|
||||
[18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
|
||||
[19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
|
||||
[20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
|
||||
[21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
|
||||
[22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
|
||||
[23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
|
||||
[24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
|
||||
[28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
|
||||
|
||||
[29] = ACTION_MODS_KEY(MOD_LSFT | MOD_RSFT, KC_PAUSE),
|
||||
};
|
@ -1,57 +0,0 @@
|
||||
#include "keymap_common.h"
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = KEYMAP( /* Matrix Dvorak */
|
||||
QUOT, COMM, DOT, P, Y, SLSH, EQL, F, G, C, R, L,
|
||||
A, O, E, U, I, ESC, BSPC, D, H, T, N, S,
|
||||
SCLN, Q, J, K, X, TAB, ENT, B, M, W, V, Z,
|
||||
LSFT, LCTL, LALT, LGUI, FN1, SPC, FN2, LEFT, DOWN, UP, RGHT),
|
||||
|
||||
[1] = KEYMAP( /* Matrix Qwerty */
|
||||
Q, W, E, R, T, QUOT, EQL, Y, U, I, O, P,
|
||||
A, S, D, F, G, ESC, BSPC, H, J, K, L, SCLN,
|
||||
Z, X, C, V, B, TAB, ENT, N, M, COMM, DOT, SLSH,
|
||||
LSFT, LCTL, LALT, LGUI, FN1, SPC, FN2, LEFT, DOWN, UP, RGHT),
|
||||
|
||||
[2] = KEYMAP( /* fn1 lower */
|
||||
F1, F2, F3, F4, F5, TRNS, TRNS, F6, F7, F8, F9, F10,
|
||||
1, 2, 3, 4, 5, F18, DEL, 6, 7, 8, 9, 0,
|
||||
FN3, FN4, TRNS, GRV, MINS, TRNS, TRNS, BSLS, LBRC, RBRC, TRNS, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN5, HOME, PGDN, PGUP, END),
|
||||
|
||||
[3] = KEYMAP( /* fn2 raise */
|
||||
F1, F2, F3, F4, F5, TRNS, TRNS, F6, F7, F8, F9, F10,
|
||||
F11, F12, F13, F14, F15, F18, DEL, F16, F17, F18, F19, F20,
|
||||
FN3, FN4, TRNS, TRNS, TRNS, TRNS, TRNS, EJCT, PWR, LSFT,PAUSE, RSFT,
|
||||
LEFT, DOWN, UP, RGHT, FN5, TRNS, TRNS, MNXT, VOLD, VOLU, MUTE),
|
||||
|
||||
[4] = KEYMAP( /* lower + raise */
|
||||
LEFT, DOWN, UP, RGHT, TRNS, TRNS, TRNS, TRNS, LEFT, DOWN, UP, RGHT,
|
||||
HOME, PGDN, PGUP, END, TRNS, F18, DEL, TRNS, HOME, PGDN, PGUP, END,
|
||||
FN3, FN4, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, EJCT, PWR, MPLY, RSFT,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MNXT, VOLD, VOLU, MUTE),
|
||||
};
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay LOWER
|
||||
[2] = ACTION_LAYER_MOMENTARY(3), // to Fn overlay RAISE
|
||||
[3] = ACTION_DEFAULT_LAYER_SET(0),
|
||||
[4] = ACTION_DEFAULT_LAYER_SET(1),
|
||||
[5] = ACTION_LAYER_MOMENTARY(4), // to Fn overlay LOWER + RAISE
|
||||
|
||||
[10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
|
||||
[11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
|
||||
[12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
|
||||
[13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
|
||||
[14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
|
||||
[15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
|
||||
[16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
|
||||
[17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
|
||||
[18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
|
||||
[19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
|
||||
[20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
|
||||
[21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
|
||||
[22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
|
||||
[23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
|
||||
[24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
|
||||
[28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
|
||||
};
|
@ -1,100 +0,0 @@
|
||||
// https://github.com/shanecelis/tmk_keyboard/blob/master/keyboard/planck/keymap_shane.c
|
||||
|
||||
#include "keymap_common.h"
|
||||
#include "action_layer.h"
|
||||
#include "action.h"
|
||||
#include "action_util.h"
|
||||
|
||||
/*
|
||||
Shane's Planck Layout
|
||||
http://www.keyboard-layout-editor.com/#/layouts/015d9011102619d7695c86ffe57cf441
|
||||
*/
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = KEYMAP_AND_SWAP( /* Base */
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, MINS,
|
||||
LCTL, A, S, D, F, G, H, J, K, L, SCLN, BSPC,
|
||||
LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, FN5,
|
||||
/*ALPHA*/FN3, /*HYPER*/ /*SUPER*/LGUI, /*META*/LALT, LCTL, FN2, FN6, FN1, LEFT, DOWN, UP, RGHT),
|
||||
[2] = KEYMAP_AND_SWAP( /* More modifiers */
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, RCTL, RALT, RGUI, TRNS),
|
||||
[4] = KEYMAP_AND_SWAP( /* WASD */
|
||||
TRNS, TRNS, UP, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
|
||||
TRNS, LEFT, DOWN, RIGHT, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS),
|
||||
[6] = KEYMAP_AND_SWAP( /* Raise/FN1 */
|
||||
FN23, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, EQL,
|
||||
TRNS, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, ENT,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, BSLS, TRNS,
|
||||
PAUS, TRNS, TRNS, TRNS, TRNS, BSPC, TRNS, MUTE, PGUP, PGDN, MNXT),
|
||||
[8] = KEYMAP_AND_SWAP( /* Lower/FN2 */
|
||||
ESC, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN19, FN20, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, CAPS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, QUOT,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN24, FN25, LBRC, RBRC, TRNS, TRNS,
|
||||
FN4, TRNS, TRNS, TRNS, TRNS, ENT, TRNS, MPLY, VOLD, VOLU, MPRV),
|
||||
};
|
||||
|
||||
enum function_id {
|
||||
SPACE_FN,
|
||||
};
|
||||
|
||||
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
switch (id) {
|
||||
case SPACE_FN:
|
||||
if (record->event.pressed) {
|
||||
// Change the keyboard maps.
|
||||
// Whatever even layer's are on, turn on the odd one's too.
|
||||
for (uint8_t i = 0; i < 9; i += 2) {
|
||||
if (layer_state & (1UL << i))
|
||||
layer_on(i + 1);
|
||||
}
|
||||
layer_on(1);
|
||||
} else {
|
||||
// turn off all the even layers.
|
||||
for (uint8_t i = 0; i < 9; i += 2)
|
||||
layer_off(i + 1);
|
||||
|
||||
if (record->tap.count != 0) {
|
||||
// Space was tapped rather than used like a modifier.
|
||||
// So send a space up and down event.
|
||||
add_key(KC_SPC);
|
||||
send_keyboard_report();
|
||||
del_key(KC_SPC);
|
||||
send_keyboard_report();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_MOMENTARY(6), // to fist Fn overlay
|
||||
[2] = ACTION_LAYER_MOMENTARY(8), // to second Fn overlay
|
||||
[3] = ACTION_LAYER_TOGGLE(2), // toggle more modifiers
|
||||
[4] = ACTION_LAYER_TOGGLE(4), // toggle wasd
|
||||
[5] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_ENT),
|
||||
[6] = ACTION_FUNCTION_TAP(SPACE_FN),
|
||||
|
||||
[11] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
|
||||
[12] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
|
||||
[13] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
|
||||
[14] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
|
||||
[15] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
|
||||
[16] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
|
||||
[17] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
|
||||
[18] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
|
||||
[19] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
|
||||
[20] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
|
||||
[21] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
|
||||
[22] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
|
||||
[23] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
|
||||
[24] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
|
||||
[25] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
|
||||
[26] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
|
||||
};
|
@ -1,44 +0,0 @@
|
||||
#include "keymap_common.h"
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = KEYMAP( /* Jack */
|
||||
ESC, Q, W, E, R, T, Y, U, I, O, P, BSPC,
|
||||
TAB, A, S, D, F, G, H, J, K, L, DOT, ENT,
|
||||
LSFT, Z, X, C, V, B, N, M, COMM, DOT, SCLN, DEL,
|
||||
LCTL, ENT, LALT, CAPS, FN2, SPC, FN1, LEFT, DOWN, UP, RGHT),
|
||||
[1] = KEYMAP( /* Jack RAISE */
|
||||
TRNS, F1, F2, F3, F4, NO, FN11, FN9, FN12, NO, FN14, TRNS,
|
||||
TRNS, F5, F6, F7, F8, FN16, SLSH, MINS, EQL, LBRC, FN8, TRNS,
|
||||
TRNS, F9, F10, F11, F12, F15, F16, FN22, SCLN, MINS, QUOT, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS),
|
||||
[2] = KEYMAP( /* Jack LOWER */
|
||||
FN22, 1, 2, 3, FN13, FN14, FN15, FN16, FN17, FN18, FN19, BSPC,
|
||||
TRNS, 4, 5, 6, TRNS, TRNS, TRNS, FN20, FN21, FN23, FN24, FN28,
|
||||
TRNS, 7, 8, 9, 0, FN28, FN15, F7, F8, F9, F10, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS),
|
||||
};
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_MOMENTARY(1), // to Fn overlay
|
||||
[2] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay
|
||||
|
||||
[8] = ACTION_MODS_KEY(MOD_LSFT, KC_SLSH),
|
||||
[9] = ACTION_MODS_KEY(MOD_LSFT, KC_QUOT),
|
||||
[10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
|
||||
[11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
|
||||
[12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
|
||||
[13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
|
||||
[14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
|
||||
[15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
|
||||
[16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
|
||||
[17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
|
||||
[18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
|
||||
[19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
|
||||
[20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
|
||||
[21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
|
||||
[22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
|
||||
[23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
|
||||
[24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
|
||||
[28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
|
||||
|
||||
[29] = ACTION_MODS_KEY(MOD_LSFT | MOD_RSFT, KC_PAUSE),
|
||||
};
|
@ -1,44 +0,0 @@
|
||||
#include "keymap_common.h"
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = KEYMAP(
|
||||
ESC, Q, W, E, R, T, Y, U, I, O, P, BSPC,
|
||||
TAB, A, S, D, F, G, H, J, K, L, SCLN, ENT,
|
||||
LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT,
|
||||
LCTL, LALT, DEL, LGUI, FN2, SPC, FN1, F2, F5, F9, F12),
|
||||
[2] = KEYMAP( /* RAISE */
|
||||
TRNS, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, BSPC,
|
||||
GRV, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MINS, EQL, LBRC, RBRC, BSLS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, QUOT, FN29, TRNS, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN1, TRNS, TRNS, TRNS, TRNS),
|
||||
[3] = KEYMAP( /* LOWER */
|
||||
TRNS, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, BSPC,
|
||||
FN22, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN20, FN21, FN23, FN24, FN28,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, QUOT, FN29, TRNS, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, FN2, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS),
|
||||
};
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay
|
||||
[2] = ACTION_LAYER_MOMENTARY(3), // to Fn overlay
|
||||
|
||||
[3] = ACTION_DEFAULT_LAYER_SET(0),
|
||||
[4] = ACTION_DEFAULT_LAYER_SET(1),
|
||||
|
||||
[10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
|
||||
[11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
|
||||
[12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
|
||||
[13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
|
||||
[14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
|
||||
[15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
|
||||
[16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
|
||||
[17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
|
||||
[18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
|
||||
[19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
|
||||
[20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
|
||||
[21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
|
||||
[22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
|
||||
[23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
|
||||
[24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
|
||||
[28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
|
||||
[29] = ACTION_MODS_KEY(MOD_LSFT, KC_QUOT),
|
||||
};
|
@ -1,56 +0,0 @@
|
||||
#include "keymap_common.h"
|
||||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = KEYMAP( /* Wilba */
|
||||
FN27, FN28, FN29, E, R, T, Y, U, I, O, P, BSPC,
|
||||
TAB, A, S, D, F, G, H, J, K, L, SCLN, QUOT,
|
||||
LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, ENT,
|
||||
LCTL, LGUI, LALT, RSFT, FN1, SPC, FN2, LEFT, DOWN, UP, RGHT),
|
||||
[1] = KEYMAP( /* Wilba Alternate */
|
||||
ESC, Q, W, E, R, T, Y, U, I, O, P, BSPC,
|
||||
TAB, A, S, D, F, G, H, J, K, L, SCLN, QUOT,
|
||||
LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, ENT,
|
||||
LCTL, LGUI, LALT, RSFT, FN1, SPC, FN2, LEFT, DOWN, UP, RGHT),
|
||||
[2] = KEYMAP( /* Wilba LOWER */
|
||||
TRNS, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, TRNS,
|
||||
TRNS, F11, F12, LBRC, RBRC, FN20, EQL, FN23, FN24, MINS, FN21, TRNS,
|
||||
TRNS, BSLS, GRV, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, FN1, TRNS, TRNS, MNXT, VOLD, VOLU, MPLY),
|
||||
[3] = KEYMAP( /* Wilba RAISE */
|
||||
TRNS, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, TRNS,
|
||||
TRNS, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, TRNS,
|
||||
TRNS, FN25, FN22, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
|
||||
TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN2, TRNS, TRNS, TRNS, TRNS),
|
||||
};
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_MOMENTARY(2), // LOWER
|
||||
[2] = ACTION_LAYER_MOMENTARY(3), // RAISE
|
||||
|
||||
[3] = ACTION_DEFAULT_LAYER_SET(0),
|
||||
[4] = ACTION_DEFAULT_LAYER_SET(1),
|
||||
|
||||
[10] = ACTION_MODS_KEY(MOD_LSFT, KC_1), // !
|
||||
[11] = ACTION_MODS_KEY(MOD_LSFT, KC_2), // @
|
||||
[12] = ACTION_MODS_KEY(MOD_LSFT, KC_3), // #
|
||||
[13] = ACTION_MODS_KEY(MOD_LSFT, KC_4), // $
|
||||
[14] = ACTION_MODS_KEY(MOD_LSFT, KC_5), // %
|
||||
[15] = ACTION_MODS_KEY(MOD_LSFT, KC_6), // ^
|
||||
[16] = ACTION_MODS_KEY(MOD_LSFT, KC_7), // &
|
||||
[17] = ACTION_MODS_KEY(MOD_LSFT, KC_8), // *
|
||||
[18] = ACTION_MODS_KEY(MOD_LSFT, KC_9), // (
|
||||
[19] = ACTION_MODS_KEY(MOD_LSFT, KC_0), // )
|
||||
|
||||
[20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS), // _
|
||||
[21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL), // +
|
||||
[22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV), // ~
|
||||
[23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC), // {
|
||||
[24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC), // }
|
||||
[25] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS), // |
|
||||
|
||||
[26] = ACTION_MODS_KEY(MOD_LSFT | MOD_RSFT, KC_PAUSE),
|
||||
|
||||
[27] = ACTION_BACKLIGHT_TOGGLE(),
|
||||
[28] = ACTION_BACKLIGHT_INCREASE(),
|
||||
[29] = ACTION_BACKLIGHT_DECREASE()
|
||||
|
||||
};
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
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
|
||||
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x6060
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER jackhumbert
|
||||
#define PRODUCT Quark
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for the Quark
|
||||
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 4
|
||||
#define MATRIX_COLS 12
|
||||
|
||||
/* define if matrix has ghost */
|
||||
//#define MATRIX_HAS_GHOST
|
||||
|
||||
/* number of backlight levels */
|
||||
/* NOTE: this is the max value of 0..BACKLIGHT_LEVELS so really 16 levels. */
|
||||
#define BACKLIGHT_LEVELS 15
|
||||
|
||||
/* Set 0 if debouncing isn't needed */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||
#define LOCKING_SUPPORT_ENABLE
|
||||
/* Locking resynchronize hack */
|
||||
#define LOCKING_RESYNC_ENABLE
|
||||
|
||||
/* key combination for command */
|
||||
#define IS_COMMAND() ( \
|
||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||
)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Feature disable options
|
||||
* These options are also useful to firmware size reduction.
|
||||
*/
|
||||
|
||||
/* disable debug print */
|
||||
//#define NO_DEBUG
|
||||
|
||||
/* disable print */
|
||||
//#define NO_PRINT
|
||||
|
||||
/* disable action features */
|
||||
//#define NO_ACTION_LAYER
|
||||
//#define NO_ACTION_TAPPING
|
||||
//#define NO_ACTION_ONESHOT
|
||||
//#define NO_ACTION_MACRO
|
||||
//#define NO_ACTION_FUNCTION
|
||||
|
||||
#endif
|
@ -1,184 +0,0 @@
|
||||
/*
|
||||
Copyright 2012,2013 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/>.
|
||||
*/
|
||||
|
||||
#include "extended_keymap_common.h"
|
||||
#include "report.h"
|
||||
#include "keycode.h"
|
||||
#include "action_layer.h"
|
||||
#include "action.h"
|
||||
#include "action_macro.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
static action_t keycode_to_action(uint16_t keycode);
|
||||
|
||||
|
||||
/* converts key to action */
|
||||
action_t action_for_key(uint8_t layer, keypos_t key)
|
||||
{
|
||||
// 16bit keycodes - important
|
||||
uint16_t keycode = keymap_key_to_keycode(layer, key);
|
||||
|
||||
if (keycode >= 0x0100 && keycode < 0x2000) {
|
||||
// Has a modifier
|
||||
action_t action;
|
||||
// Split it up
|
||||
action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF);
|
||||
return action;
|
||||
} else if (keycode >= 0x2000 && keycode < 0x3000) {
|
||||
// Is a shortcut for function layer, pull last 12bits
|
||||
return keymap_func_to_action(keycode & 0xFFF);
|
||||
} else if (keycode >= 0x3000 && keycode < 0x4000) {
|
||||
action_t action;
|
||||
action.code = ACTION_MACRO(keycode & 0xFF);
|
||||
return action;
|
||||
}
|
||||
|
||||
switch (keycode) {
|
||||
case KC_FN0 ... KC_FN31:
|
||||
return keymap_fn_to_action(keycode);
|
||||
#ifdef BOOTMAGIC_ENABLE
|
||||
case KC_CAPSLOCK:
|
||||
case KC_LOCKING_CAPS:
|
||||
if (keymap_config.swap_control_capslock || keymap_config.capslock_to_control) {
|
||||
return keycode_to_action(KC_LCTL);
|
||||
}
|
||||
return keycode_to_action(keycode);
|
||||
case KC_LCTL:
|
||||
if (keymap_config.swap_control_capslock) {
|
||||
return keycode_to_action(KC_CAPSLOCK);
|
||||
}
|
||||
return keycode_to_action(KC_LCTL);
|
||||
case KC_LALT:
|
||||
if (keymap_config.swap_lalt_lgui) {
|
||||
if (keymap_config.no_gui) {
|
||||
return keycode_to_action(ACTION_NO);
|
||||
}
|
||||
return keycode_to_action(KC_LGUI);
|
||||
}
|
||||
return keycode_to_action(KC_LALT);
|
||||
case KC_LGUI:
|
||||
if (keymap_config.swap_lalt_lgui) {
|
||||
return keycode_to_action(KC_LALT);
|
||||
}
|
||||
if (keymap_config.no_gui) {
|
||||
return keycode_to_action(ACTION_NO);
|
||||
}
|
||||
return keycode_to_action(KC_LGUI);
|
||||
case KC_RALT:
|
||||
if (keymap_config.swap_ralt_rgui) {
|
||||
if (keymap_config.no_gui) {
|
||||
return keycode_to_action(ACTION_NO);
|
||||
}
|
||||
return keycode_to_action(KC_RGUI);
|
||||
}
|
||||
return keycode_to_action(KC_RALT);
|
||||
case KC_RGUI:
|
||||
if (keymap_config.swap_ralt_rgui) {
|
||||
return keycode_to_action(KC_RALT);
|
||||
}
|
||||
if (keymap_config.no_gui) {
|
||||
return keycode_to_action(ACTION_NO);
|
||||
}
|
||||
return keycode_to_action(KC_RGUI);
|
||||
case KC_GRAVE:
|
||||
if (keymap_config.swap_grave_esc) {
|
||||
return keycode_to_action(KC_ESC);
|
||||
}
|
||||
return keycode_to_action(KC_GRAVE);
|
||||
case KC_ESC:
|
||||
if (keymap_config.swap_grave_esc) {
|
||||
return keycode_to_action(KC_GRAVE);
|
||||
}
|
||||
return keycode_to_action(KC_ESC);
|
||||
case KC_BSLASH:
|
||||
if (keymap_config.swap_backslash_backspace) {
|
||||
return keycode_to_action(KC_BSPACE);
|
||||
}
|
||||
return keycode_to_action(KC_BSLASH);
|
||||
case KC_BSPACE:
|
||||
if (keymap_config.swap_backslash_backspace) {
|
||||
return keycode_to_action(KC_BSLASH);
|
||||
}
|
||||
return keycode_to_action(KC_BSPACE);
|
||||
#endif
|
||||
default:
|
||||
return keycode_to_action(keycode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Macro */
|
||||
__attribute__ ((weak))
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
return MACRO_NONE;
|
||||
}
|
||||
|
||||
/* Function */
|
||||
__attribute__ ((weak))
|
||||
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
}
|
||||
|
||||
/* translates keycode to action */
|
||||
static action_t keycode_to_action(uint16_t keycode)
|
||||
{
|
||||
action_t action;
|
||||
switch (keycode) {
|
||||
case KC_A ... KC_EXSEL:
|
||||
case KC_LCTRL ... KC_RGUI:
|
||||
action.code = ACTION_KEY(keycode);
|
||||
break;
|
||||
case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
|
||||
action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode));
|
||||
break;
|
||||
case KC_AUDIO_MUTE ... KC_WWW_FAVORITES:
|
||||
action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
|
||||
break;
|
||||
case KC_MS_UP ... KC_MS_ACCEL2:
|
||||
action.code = ACTION_MOUSEKEY(keycode);
|
||||
break;
|
||||
case KC_TRNS:
|
||||
action.code = ACTION_TRANSPARENT;
|
||||
break;
|
||||
default:
|
||||
action.code = ACTION_NO;
|
||||
break;
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
|
||||
/* translates key to keycode */
|
||||
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
// Read entire word (16bits)
|
||||
return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||
}
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint16_t keycode)
|
||||
{
|
||||
return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
|
||||
}
|
||||
|
||||
action_t keymap_func_to_action(uint16_t keycode)
|
||||
{
|
||||
// For FUNC without 8bit limit
|
||||
return (action_t){ .code = pgm_read_word(&fn_actions[(int)keycode]) };
|
||||
}
|
@ -1,152 +0,0 @@
|
||||
/*
|
||||
Copyright 2012,2013 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 KEYMAP_H
|
||||
#define KEYMAP_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "action.h"
|
||||
#include <avr/pgmspace.h>
|
||||
#include "keycode.h"
|
||||
#include "keymap.h"
|
||||
#include "action_macro.h"
|
||||
#include "report.h"
|
||||
#include "host.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
|
||||
#ifdef BOOTMAGIC_ENABLE
|
||||
/* NOTE: Not portable. Bit field order depends on implementation */
|
||||
typedef union {
|
||||
uint16_t raw;
|
||||
struct {
|
||||
bool swap_control_capslock:1;
|
||||
bool capslock_to_control:1;
|
||||
bool swap_lalt_lgui:1;
|
||||
bool swap_ralt_rgui:1;
|
||||
bool no_gui:1;
|
||||
bool swap_grave_esc:1;
|
||||
bool swap_backslash_backspace:1;
|
||||
bool nkro:1;
|
||||
};
|
||||
} keymap_config_t;
|
||||
keymap_config_t keymap_config;
|
||||
#endif
|
||||
|
||||
/* translates key to keycode */
|
||||
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint16_t keycode);
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_func_to_action(uint16_t keycode);
|
||||
|
||||
extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
|
||||
extern const uint16_t fn_actions[];
|
||||
|
||||
// Ability to use mods in layouts
|
||||
#define LCTL(kc) kc | 0x0100
|
||||
#define LSFT(kc) kc | 0x0200
|
||||
#define LALT(kc) kc | 0x0400
|
||||
#define LGUI(kc) kc | 0x0800
|
||||
#define RCTL(kc) kc | 0x1100
|
||||
#define RSFT(kc) kc | 0x1200
|
||||
#define RALT(kc) kc | 0x1400
|
||||
#define RGUI(kc) kc | 0x1800
|
||||
|
||||
// Alias for function layers than expand past FN31
|
||||
#define FUNC(kc) kc | 0x2000
|
||||
|
||||
// Aliases
|
||||
#define S(kc) LSFT(kc)
|
||||
#define F(kc) FUNC(kc)
|
||||
|
||||
// For software implementation of colemak
|
||||
#define CM_Q KC_Q
|
||||
#define CM_W KC_W
|
||||
#define CM_F KC_E
|
||||
#define CM_P KC_R
|
||||
#define CM_G KC_T
|
||||
#define CM_J KC_Y
|
||||
#define CM_L KC_U
|
||||
#define CM_U KC_I
|
||||
#define CM_Y KC_O
|
||||
#define CM_SCLN KC_P
|
||||
|
||||
#define CM_A KC_A
|
||||
#define CM_R KC_S
|
||||
#define CM_S KC_D
|
||||
#define CM_T KC_F
|
||||
#define CM_D KC_G
|
||||
#define CM_H KC_H
|
||||
#define CM_N KC_J
|
||||
#define CM_E KC_K
|
||||
#define CM_I KC_L
|
||||
#define CM_O KC_SCLN
|
||||
|
||||
#define CM_Z KC_Z
|
||||
#define CM_X KC_X
|
||||
#define CM_C KC_C
|
||||
#define CM_V KC_V
|
||||
#define CM_B KC_B
|
||||
#define CM_K KC_N
|
||||
#define CM_M KC_M
|
||||
#define CM_COMM KC_COMM
|
||||
#define CM_DOT KC_DOT
|
||||
#define CM_SLSH KC_SLSH
|
||||
|
||||
// Make it easy to support these in macros
|
||||
#define KC_CM_Q CM_Q
|
||||
#define KC_CM_W CM_W
|
||||
#define KC_CM_F CM_F
|
||||
#define KC_CM_P CM_P
|
||||
#define KC_CM_G CM_G
|
||||
#define KC_CM_J CM_J
|
||||
#define KC_CM_L CM_L
|
||||
#define KC_CM_U CM_U
|
||||
#define KC_CM_Y CM_Y
|
||||
#define KC_CM_SCLN CM_SCLN
|
||||
|
||||
#define KC_CM_A CM_A
|
||||
#define KC_CM_R CM_R
|
||||
#define KC_CM_S CM_S
|
||||
#define KC_CM_T CM_T
|
||||
#define KC_CM_D CM_D
|
||||
#define KC_CM_H CM_H
|
||||
#define KC_CM_N CM_N
|
||||
#define KC_CM_E CM_E
|
||||
#define KC_CM_I CM_I
|
||||
#define KC_CM_O CM_O
|
||||
|
||||
#define KC_CM_Z CM_Z
|
||||
#define KC_CM_X CM_X
|
||||
#define KC_CM_C CM_C
|
||||
#define KC_CM_V CM_V
|
||||
#define KC_CM_B CM_B
|
||||
#define KC_CM_K CM_K
|
||||
#define KC_CM_M CM_M
|
||||
#define KC_CM_COMM CM_COMM
|
||||
#define KC_CM_DOT CM_DOT
|
||||
#define KC_CM_SLSH CM_SLSH
|
||||
|
||||
#define M(kc) kc | 0x3000
|
||||
|
||||
#define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
|
||||
|
||||
#endif
|
@ -1,40 +0,0 @@
|
||||
#include "extended_keymap_common.h"
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = {
|
||||
{KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
|
||||
{ KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_NO, KC_ENT},
|
||||
{KC_CAPS, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_RSFT},
|
||||
{ KC_LCTL, KC_LALT, KC_LGUI, KC_NO, FUNC(2), KC_SPC, KC_NO, KC_NO, FUNC(1), KC_LEFT, KC_DOWN, KC_RGHT}
|
||||
},
|
||||
[1] = {
|
||||
{KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL},
|
||||
{ KC_TAB, KC_A, KC_S,S(KC_BSLS), S(KC_COMM),S(KC_DOT),S(KC_MINS),S(KC_GRV),S(KC_LBRC), S(KC_RBRC), KC_NO, KC_ENT},
|
||||
{KC_CAPS, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_SCLN, S(KC_SCLN), KC_HOME, KC_PGUP, KC_RSFT},
|
||||
{ KC_LCTL, KC_LALT, KC_LGUI, KC_NO, FUNC(2), KC_SPC, KC_NO, KC_NO, FUNC(1), KC_SCLN, KC_QUOT, KC_SLSH}
|
||||
},
|
||||
[2] = {
|
||||
{KC_ESC, S(KC_1), S(KC_2), S(KC_3), S(KC_4), S(KC_5), S(KC_6), S(KC_7), S(KC_8), S(KC_9), S(KC_0), KC_BSPC},
|
||||
{ KC_TAB, KC_A, KC_S, KC_D, KC_BSLS, KC_SLSH, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_NO, KC_ENT},
|
||||
{KC_CAPS, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, S(KC_7), S(KC_EQL), KC_COMM, KC_UP, KC_RSFT},
|
||||
{ KC_LCTL, KC_LALT, KC_LGUI, KC_NO, FUNC(2), KC_SPC, KC_NO, KC_NO, FUNC(1), KC_LEFT, KC_DOWN, KC_RGHT}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const uint16_t PROGMEM fn_actions[] = {
|
||||
[1] = ACTION_LAYER_MOMENTARY(1), // to Fn overlay
|
||||
[2] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay
|
||||
|
||||
};
|
||||
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
{
|
||||
// MACRODOWN only works in this function
|
||||
switch(id) {
|
||||
case 0:
|
||||
return MACRO_NONE;
|
||||
break;
|
||||
}
|
||||
return MACRO_NONE;
|
||||
};
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
Copyright 2012,2013 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/>.
|
||||
*/
|
||||
#include "keymap_common.h"
|
||||
|
||||
|
||||
/* translates key to keycode */
|
||||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||
}
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint8_t keycode)
|
||||
{
|
||||
return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
Copyright 2012,2013 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 KEYMAP_COMMON_H
|
||||
#define KEYMAP_COMMON_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "keycode.h"
|
||||
#include "action.h"
|
||||
#include "action_macro.h"
|
||||
#include "report.h"
|
||||
#include "host.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "keymap.h"
|
||||
|
||||
|
||||
extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
|
||||
extern const uint16_t fn_actions[];
|
||||
|
||||
|
||||
// MIT Layout
|
||||
/*
|
||||
* ,-----------------------------------------------------------------------.
|
||||
* | | | | | | | | | | | | |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* | | | | | | | | | | | | |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* | | | | | | | | | | | | |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* | | | | | | | | | | | |
|
||||
* `-----------------------------------------------------------------------'
|
||||
*/
|
||||
#define KEYMAP( \
|
||||
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
|
||||
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
|
||||
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
|
||||
K30, K31, K32, K33, K34, K35, K37, K38, K39, K3A, K3B \
|
||||
) { \
|
||||
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B }, \
|
||||
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B }, \
|
||||
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B }, \
|
||||
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_NO, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B } \
|
||||
}
|
||||
|
||||
// Grid Layout
|
||||
/*
|
||||
* ,-----------------------------------------------------------------------.
|
||||
* | | | | | | | | | | | | |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* | | | | | | | | | | | | |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* | | | | | | | | | | | | |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* | | | | | | | | | | | | |
|
||||
* `-----------------------------------------------------------------------'
|
||||
*/
|
||||
#define KEYMAP_GRID( \
|
||||
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
|
||||
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
|
||||
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
|
||||
K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B \
|
||||
) { \
|
||||
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B }, \
|
||||
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B }, \
|
||||
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B }, \
|
||||
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B } \
|
||||
}
|
||||
|
||||
|
||||
#endif
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "stdint.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
// Using PE6 Caps Lock LED
|
||||
if (usb_led & (1<<USB_LED_CAPS_LOCK))
|
||||
{
|
||||
// Output high.
|
||||
DDRE |= (1<<6);
|
||||
PORTE |= (1<<6);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Output low.
|
||||
DDRE &= ~(1<<6);
|
||||
PORTE &= ~(1<<6);
|
||||
}
|
||||
}
|
@ -1,193 +0,0 @@
|
||||
/*
|
||||
Copyright 2012 Jun Wako
|
||||
Generated by planckkeyboard.com (2014 Jack Humbert)
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* scan matrix
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 10
|
||||
#endif
|
||||
static uint8_t debouncing = DEBOUNCE;
|
||||
|
||||
/* matrix state(1:on, 0:off) */
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||
|
||||
static matrix_row_t read_cols(void);
|
||||
static void init_cols(void);
|
||||
static void unselect_rows(void);
|
||||
static void select_row(uint8_t row);
|
||||
|
||||
inline
|
||||
uint8_t matrix_rows(void)
|
||||
{
|
||||
return MATRIX_ROWS;
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t matrix_cols(void)
|
||||
{
|
||||
return MATRIX_COLS;
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
// initialize row and col
|
||||
unselect_rows();
|
||||
init_cols();
|
||||
|
||||
// initialize matrix state: all keys off
|
||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = 0;
|
||||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
select_row(i);
|
||||
_delay_us(30); // without this wait read unstable value.
|
||||
matrix_row_t cols = read_cols();
|
||||
if (matrix_debouncing[i] != cols) {
|
||||
matrix_debouncing[i] = cols;
|
||||
if (debouncing) {
|
||||
debug("bounce!: "); debug_hex(debouncing); debug("\n");
|
||||
}
|
||||
debouncing = DEBOUNCE;
|
||||
}
|
||||
unselect_rows();
|
||||
}
|
||||
|
||||
if (debouncing) {
|
||||
if (--debouncing) {
|
||||
_delay_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_modified(void)
|
||||
{
|
||||
if (debouncing) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||
{
|
||||
return (matrix[row] & ((matrix_row_t)1<col));
|
||||
}
|
||||
|
||||
inline
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
print("\nr/c 0123456789ABCDEF\n");
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
phex(row); print(": ");
|
||||
pbin_reverse16(matrix_get_row(row));
|
||||
print("\n");
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_key_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
count += bitpop16(matrix[i]);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static void init_cols(void)
|
||||
{
|
||||
DDRB &= ~(1<<6 | 1<<5 | 1<<4);
|
||||
PORTB |= (1<<6 | 1<<5 | 1<<4);
|
||||
DDRD &= ~(1<<7 | 1<<6 | 1<<4);
|
||||
PORTD |= (1<<7 | 1<<6 | 1<<4);
|
||||
DDRF &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
|
||||
PORTF |= (1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
|
||||
|
||||
}
|
||||
|
||||
static matrix_row_t read_cols(void)
|
||||
{
|
||||
return (PIND&(1<<4) ? 0 : (1<<0)) |
|
||||
(PIND&(1<<6) ? 0 : (1<<1)) |
|
||||
(PIND&(1<<7) ? 0 : (1<<2)) |
|
||||
(PINB&(1<<4) ? 0 : (1<<3)) |
|
||||
(PINB&(1<<5) ? 0 : (1<<4)) |
|
||||
(PINB&(1<<6) ? 0 : (1<<5)) |
|
||||
(PINF&(1<<7) ? 0 : (1<<6)) |
|
||||
(PINF&(1<<6) ? 0 : (1<<7)) |
|
||||
(PINF&(1<<5) ? 0 : (1<<8)) |
|
||||
(PINF&(1<<4) ? 0 : (1<<9)) |
|
||||
(PINF&(1<<1) ? 0 : (1<<10)) |
|
||||
(PINF&(1<<0) ? 0 : (1<<11));
|
||||
|
||||
}
|
||||
|
||||
static void unselect_rows(void)
|
||||
{
|
||||
DDRB &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3);
|
||||
PORTB |= (1<<0 | 1<<1 | 1<<2 | 1<<3);
|
||||
|
||||
}
|
||||
|
||||
static void select_row(uint8_t row)
|
||||
{
|
||||
switch (row) {
|
||||
case 0:
|
||||
DDRB |= (1<<0);
|
||||
PORTB &= ~(1<<0);
|
||||
break;
|
||||
case 1:
|
||||
DDRB |= (1<<1);
|
||||
PORTB &= ~(1<<1);
|
||||
break;
|
||||
case 2:
|
||||
DDRB |= (1<<2);
|
||||
PORTB &= ~(1<<2);
|
||||
break;
|
||||
case 3:
|
||||
DDRB |= (1<<3);
|
||||
PORTB &= ~(1<<3);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|