Merge remote-tracking branch 'tmk/master'
This commit is contained in:
commit
fd38f04ead
96 changed files with 19601 additions and 13998 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -30,13 +30,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "report.h"
|
||||
#include "host.h"
|
||||
#include "led.h"
|
||||
#include "timer.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static bool has_media_keys = false;
|
||||
static bool is_iso_layout = false;
|
||||
static report_mouse_t mouse_report = {};
|
||||
|
||||
// matrix state buffer(1:on, 0:off)
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
|
|
@ -122,12 +122,21 @@ void matrix_init(void)
|
|||
#endif
|
||||
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
|
||||
|
||||
static report_mouse_t mouse_report = {};
|
||||
|
||||
void adb_mouse_task(void)
|
||||
{
|
||||
uint16_t codes;
|
||||
int16_t x, y;
|
||||
static int8_t mouseacc;
|
||||
_delay_ms(12); // delay for preventing overload of poor ADB keyboard controller
|
||||
|
||||
/* tick of last polling */
|
||||
static uint16_t tick_ms;
|
||||
|
||||
// polling with 12ms interval
|
||||
if (timer_elapsed(tick_ms) < 12) return;
|
||||
tick_ms = timer_read();
|
||||
|
||||
codes = adb_host_mouse_recv();
|
||||
// If nothing received reset mouse acceleration, and quit.
|
||||
if (!codes) {
|
||||
|
|
@ -185,12 +194,18 @@ uint8_t matrix_scan(void)
|
|||
uint16_t codes;
|
||||
uint8_t key0, key1;
|
||||
|
||||
/* tick of last polling */
|
||||
static uint16_t tick_ms;
|
||||
|
||||
codes = extra_key;
|
||||
extra_key = 0xFFFF;
|
||||
|
||||
if ( codes == 0xFFFF )
|
||||
{
|
||||
_delay_ms(12); // delay for preventing overload of poor ADB keyboard controller
|
||||
// polling with 12ms interval
|
||||
if (timer_elapsed(tick_ms) < 12) return 0;
|
||||
tick_ms = timer_read();
|
||||
|
||||
codes = adb_host_kbd_recv(ADB_ADDR_KEYBOARD);
|
||||
|
||||
// Adjustable keybaord media keys
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -80,7 +80,8 @@ void matrix_init(void)
|
|||
print("IBM 4704 converter\n");
|
||||
matrix_clear();
|
||||
_delay_ms(2000); // wait for keyboard starting up
|
||||
xprintf("Keyboard ID: %02X\n", ibm4704_recv());
|
||||
uint8_t keyboard_id = ibm4704_recv();
|
||||
xprintf("Keyboard ID: %02X\n", keyboard_id);
|
||||
enable_break();
|
||||
}
|
||||
|
||||
|
|
|
|||
20
converter/ibm4704_usb/update_bin.sh
Normal file
20
converter/ibm4704_usb/update_bin.sh
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
make -f Makefile.unimap.rev1 clean
|
||||
make -f Makefile.unimap.rev2 clean
|
||||
make -f Makefile.unimap.alps.rev1 clean
|
||||
make -f Makefile.unimap.alps.rev2 clean
|
||||
|
||||
make -f Makefile.unimap.rev1
|
||||
make -f Makefile.unimap.rev2
|
||||
make -f Makefile.unimap.alps.rev1
|
||||
make -f Makefile.unimap.alps.rev2
|
||||
|
||||
cp ibm4704_usb_rev1_unimap.hex binary
|
||||
cp ibm4704_usb_rev2_unimap.hex binary
|
||||
cp ibm4704_usb_rev1_alps_unimap.hex binary
|
||||
cp ibm4704_usb_rev2_alps_unimap.hex binary
|
||||
|
||||
make -f Makefile.unimap.rev1 clean
|
||||
make -f Makefile.unimap.rev2 clean
|
||||
make -f Makefile.unimap.alps.rev1 clean
|
||||
make -f Makefile.unimap.alps.rev2 clean
|
||||
120
converter/news_usb/README.md
Normal file
120
converter/news_usb/README.md
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
Sony NEWS keyboard converter
|
||||
============================
|
||||
Sony NEWS is a BSD workstation with 68K/MIPS released in 1987 in Japan.
|
||||
|
||||
- http://en.wikipedia.org/wiki/Sony_NEWS
|
||||
- https://www.sony.net/SonyInfo/CorporateInfo/History/SonyHistory/2-12.html#block3
|
||||
|
||||
This converter allows NEWS keyboard to be connected to modern PC via USB. It works with NWP-5461 and NWP-411A.
|
||||
|
||||
How DIP switches work is unknown and you may need to turn all switches off with this converter.
|
||||
|
||||
Limitations:
|
||||
- Speaker/Buzzer is not supported.
|
||||
- LEDs on NWP-5461 is not supported.
|
||||
|
||||
Pics:
|
||||
- http://imgur.com/a/JyMzw
|
||||
|
||||
Discussion:
|
||||
- https://geekhack.org/index.php?topic=25759
|
||||
|
||||
|
||||
|
||||
Protocol
|
||||
--------
|
||||
NEWS keyboard protocol is a usual asynchronous serial communication. You can receive data from the keyboard easily with UART of micro controller.
|
||||
|
||||
- TTL level
|
||||
- 9600bps
|
||||
- 1-start bit
|
||||
- 8-data bit
|
||||
- non-parity
|
||||
- 1-stop bit.
|
||||
|
||||
Its scan code is one byte consists of 1-bit release(break) flag at MSB and 7-bit code.
|
||||
For example 0x29 is sent when 'a' key is pressed and 0xA9 when released.
|
||||
|
||||
MSB LSB
|
||||
7 6 5 4 3 2 1 0 bit
|
||||
| | | | | | | |
|
||||
| +-+-+-+-+-+-+-- scan code(00-7F)
|
||||
+---------------- break flag: sets when released
|
||||
|
||||
|
||||
Scan Codes
|
||||
----------
|
||||
### NWP-5461
|
||||
|
||||
,---. ,------------------------, ,------------------------. ,---------.
|
||||
|Pow| | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10| | F11| F12| ,-----------.
|
||||
`---' `------------------------' `------------------------' `---------' | *| /| +|
|
||||
,-------------------------------------------------------------. ,---. ,---------------|
|
||||
|Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| BS | |Hlp| | 7| 8| 9| -|
|
||||
|-------------------------------------------------------------| |---| |---------------|
|
||||
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Del| | |Ins| | 4| 5| 6| ,|
|
||||
|---------------------------------------------------------' | |---| |---------------|
|
||||
|Ctrl | A| S| D| F| G| H| J| K| L| ;| '| `|Return| |Clr| | 1| 2| 3| |
|
||||
|-------------------------------------------------------------| |---| |-----------|Ent|
|
||||
|Shift | Z| X| C| V| B| N| M| ,| ,| /| |Shift | |PgU| | 0| .| Up| |
|
||||
|-------------------------------------------------------------| |---| |---------------|
|
||||
|Alt |Gui |Alt | Space | |Gui|App|Ctrl | |PgD| |Tab|Lef|Dow|Rig|
|
||||
`-------------------------------------------------------------' `---' `---------------'
|
||||
|
||||
,---. ,------------------------, ,------------------------. ,---------.
|
||||
| 7A| | 01 | 02 | 03 | 04 | 05 | | 06 | 07 | 08 | 09 | 0A | | 68 | 69 | ,-----------.
|
||||
`---' `------------------------' `------------------------' `---------' | 64| 65| 52|
|
||||
,-------------------------------------------------------------. ,---. ,---------------|
|
||||
| 0B| 0C| 0D| 0E| 0F| 10| 11| 12| 13| 14| 15| 16| 17| 18| 19 | | 6A| | 4B| 4C| 4D| 4E|
|
||||
|-------------------------------------------------------------| |---| |---------------|
|
||||
| 1A | 1B| 1C| 1D| 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| | | 6B| | 4F| 50| 51| 56|
|
||||
|---------------------------------------------------------' | |---| |---------------|
|
||||
| 28 | 29| 2A| 2B| 2C| 2D| 2E| 2F| 30| 31| 32| 33| 34| 35 | | 6C| | 53| 54| 55| |
|
||||
|-------------------------------------------------------------| |---| |-----------| 5A|
|
||||
| 36 | 37| 38| 39| 3A| 3B| 3C| 3D| 3E| 3F| 40| 41| 42 | | 6D| | 57| 59| 58| |
|
||||
|-------------------------------------------------------------| |---| |---------------|
|
||||
| 43 | 44 | 45 | 46 | 47 | 48| 49| 4A | | 6E| | 66| 5B| 5C| 5D|
|
||||
`-------------------------------------------------------------' `---' `---------------'
|
||||
|
||||
|
||||
|
||||
Pinouts
|
||||
-------
|
||||
### NWP-5461
|
||||
|
||||
-------------
|
||||
\ 1 2 3 x 5 /
|
||||
\ 6 7 8 9 /
|
||||
---------
|
||||
1 VCC
|
||||
2 BZ(Speaker)
|
||||
3 Keyboard Data(from keyboard MCU TxD)
|
||||
4 NC
|
||||
5 GND
|
||||
6 Keyboard Command?(to MCU RxD via two schmitt triggers of Z8 74LS14)
|
||||
7 Mouse Data(from Mouse Ext connector)
|
||||
8 Power switch(directly to the switch via diode)
|
||||
9 FG
|
||||
|
||||
I have three NWP-5461s and GND and FG is connected in one of them for some reason.
|
||||
- Serial No.14178(EH0100 5 04 04 0173) GND and FG is not tied.
|
||||
- Serial No.14580(EH0100 5 09 12 0211) GND and FG is not tied.
|
||||
- Serial No.17458(EH0100 7 09 08 0104) GND and FG is not tied.
|
||||
|
||||
|
||||
### NWP-411A
|
||||
|
||||
-------------
|
||||
\ 1 2 3 x 5 /
|
||||
\ x 7 x 9 /
|
||||
---------
|
||||
1 VCC
|
||||
2 BZ(Speaker)
|
||||
3 Keyboard Data(from keyboard MCU TxD)
|
||||
4 NC
|
||||
5 GND
|
||||
6 NC
|
||||
7 Mouse Data(from Mouse Ext connector)
|
||||
8 NC
|
||||
9 FG
|
||||
NOTE: These are just from my guess and not confirmed.
|
||||
|
|
@ -103,6 +103,6 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,DEL, INS, P4, P5, P6, PCMM,
|
||||
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,GRV, ENT, CLR, P1, P2, P3, PENT,
|
||||
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RO, RSFT, PGUP, P0, PDOT,UP,
|
||||
LALT,CAPS,LALT, SPC, ERAS, RALT,RGUI,RCTL, PGDN, TAB, LEFT,DOWN,RGHT
|
||||
LALT,CAPS,LALT, SPC, RALT, RGUI,APP, RCTL, PGDN, TAB, LEFT,DOWN,RGHT
|
||||
),
|
||||
};
|
||||
|
|
|
|||
57
converter/pana_m8/Makefile
Normal file
57
converter/pana_m8/Makefile
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
TARGET ?= pana_m8
|
||||
TARGET_DIR ?= .
|
||||
TMK_DIR ?= ../../tmk_core
|
||||
|
||||
MCU ?= atmega32u4
|
||||
F_CPU ?= 16000000
|
||||
# Boot Section Size in *bytes*
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
# LUFA specific
|
||||
ARCH ?= AVR8
|
||||
F_USB ?= $(F_CPU)
|
||||
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||
|
||||
|
||||
# Build 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
|
||||
#ACTIONMAP_ENABLE ?= yes # Use 16bit actionmap instead of 8bit keymap
|
||||
UNIMAP_ENABLE ?= yes # Universal keymap
|
||||
KEYMAP_SECTION_ENABLE ?= yes # fixed address keymap for keymap editor
|
||||
|
||||
|
||||
# List C source files
|
||||
SRC ?= pana_m8.c
|
||||
|
||||
CONFIG_H ?= config.h
|
||||
|
||||
|
||||
# Keymap file
|
||||
ifeq (yes,$(strip $(UNIMAP_ENABLE)))
|
||||
KEYMAP_FILE = unimap
|
||||
else
|
||||
ifeq (yes,$(strip $(ACTIONMAP_ENABLE)))
|
||||
KEYMAP_FILE = actionmap
|
||||
else
|
||||
KEYMAP_FILE = keymap
|
||||
endif
|
||||
endif
|
||||
ifdef KEYMAP
|
||||
SRC := $(KEYMAP_FILE)_$(KEYMAP).c $(SRC)
|
||||
else
|
||||
SRC := $(KEYMAP_FILE).c $(SRC)
|
||||
endif
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
||||
94
converter/pana_m8/README
Normal file
94
converter/pana_m8/README
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
Panasonic VP-0187A
|
||||
==================
|
||||
2017/08/06
|
||||
|
||||
It is unknown keyboard from Panasonic with Hirose Cherry M8 and 6P6C connector.
|
||||
|
||||
Pictures:
|
||||
http://imgur.com/a/GAZE7
|
||||
|
||||
Hirose Cheery M8 switches:
|
||||
https://deskthority.net/wiki/Cherry_M8
|
||||
|
||||
|
||||
|
||||
Scan
|
||||
----
|
||||
The keyboard is comprised of some of 4000 series IC without microcontroller.
|
||||
|
||||
|
||||
RST>-----------+---------------+
|
||||
| |
|
||||
TC4520 | TC4520 |
|
||||
--------- carry ---------
|
||||
CLK>--->|row |------>|col |
|
||||
|counter|Q3 |counter|
|
||||
--------- ---------
|
||||
Q012 Q012
|
||||
||| |||
|
||||
||| ABC TC4028
|
||||
||| ---------
|
||||
||| |decoder|
|
||||
||| ---------
|
||||
||| |||||| col[0..7]
|
||||
ABC TC4512 vvvvvvv pull down
|
||||
---------- <----|+++++++|--100K--+
|
||||
|data | <----|+++++++|--100K--+
|
||||
STATE<--|selector| <----|+++++++|--100K--+
|
||||
| 7 to 1 | <----|+++++++|--100K--+
|
||||
---------- <----|+++++++|--100K--+
|
||||
row[0..7] | 8x8 matrix |
|
||||
| -
|
||||
TC4078 | GND
|
||||
------ |
|
||||
SENSE<----| OR |========+ OR'd row[0..7]
|
||||
------
|
||||
|
||||
- TC4520BP - Dual Binary Up Counter
|
||||
- TC4028B - BCD-to-Decimal Decoder
|
||||
- TC4512BP - 8-Channel Data Selector
|
||||
- TC4081BP - Quad 2-Input AND Gate
|
||||
- TC4071BP - Quad 2-Input OR Gate
|
||||
- TC4078BP - 8-Input NOR/OR Gate
|
||||
|
||||
|
||||
Matrix
|
||||
------
|
||||
0 1 2 3 4 5 6 7
|
||||
--------------------------------------------------------------------
|
||||
0 ESC 1 2 3 4 5 6 7
|
||||
1 8 9 0 - ^ BS INS DEL
|
||||
2 TAB Q W E R T Y U
|
||||
3 I O P @ [ ] F2 F1
|
||||
4 CTRL A S D F G H J
|
||||
5 K L ; : RETURN UP F3 F4
|
||||
6 SHIFT Z X C V B N M
|
||||
7 SPACE , . / LEFT RIGHT DOWN HOME
|
||||
|
||||
|
||||
|
||||
6P6C connector pinout
|
||||
---------------------
|
||||
1. VCC
|
||||
2. Clock - sends clock to binary counter TC4520
|
||||
3. Key State - indicates hi if key selected by counter is active
|
||||
4. Sense - indicates lo if any key is active while Reset is hi.
|
||||
5. Reset - resets counter and drives all column
|
||||
6. GND
|
||||
|
||||
123456
|
||||
,--------.
|
||||
| |||||| |
|
||||
| |
|
||||
`--____--'
|
||||
plug
|
||||
|
||||
|
||||
Ping configuration
|
||||
------------------
|
||||
AVR ATmega32u4 is used as protocol converter.
|
||||
|
||||
PD0: Clock. Counter couts up at falling edge.
|
||||
PD1: Key State. Hi if selected key is activated.
|
||||
PD2: Sense. Lo if any key is activated while Reset is Hi.
|
||||
PD3: Reset. Resets counters at riging edge.
|
||||
35
converter/pana_m8/config.h
Normal file
35
converter/pana_m8/config.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0xFFFF
|
||||
#define DEVICE_VER 0x0100
|
||||
#define MANUFACTURER TMK.
|
||||
#define PRODUCT Panasonic Cherry M8
|
||||
#define DESCRIPTION TMK. keyboard firmware
|
||||
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 8
|
||||
#define MATRIX_COLS 8
|
||||
|
||||
/* matrix debounce time in ms */
|
||||
#define DEBOUNCE 10
|
||||
|
||||
|
||||
/* 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_SPACE
|
||||
|
||||
#endif
|
||||
83
converter/pana_m8/pana_m8.c
Normal file
83
converter/pana_m8/pana_m8.c
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "matrix.h"
|
||||
#include "led.h"
|
||||
#include "wait.h"
|
||||
#include "timer.h"
|
||||
#include "debug.h"
|
||||
|
||||
#define CLK_HI() (PORTD |= (1<<0))
|
||||
#define CLK_LO() (PORTD &= ~(1<<0))
|
||||
#define STATE() (!!(PIND & (1<<1)))
|
||||
#define RST_HI() (PORTD |= (1<<3))
|
||||
#define RST_LO() (PORTD &= ~(1<<3))
|
||||
#define SENSE() (PIND & (1<<2))
|
||||
|
||||
static matrix_row_t matrix[8] = {};
|
||||
static matrix_row_t matrix_debouncing[8] = {};
|
||||
static uint16_t debouncing_time = 0;
|
||||
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
debug_enable = true;
|
||||
debug_keyboard = true;
|
||||
debug_matrix = true;
|
||||
|
||||
// PD0: Clock. Counter couts up at falling edge.
|
||||
// PD1: Key State. Hi if selected key is activated.
|
||||
// PD2: Sense. Lo if any key is activated while Reset is Hi.
|
||||
// PD3: Reset. Resets counters at riging edge.
|
||||
DDRD |= (1<<3) | (1<<0); // output
|
||||
DDRD &= ~((1<<2) | (1<<1)); // input
|
||||
PORTD &= ~((1<<3) | (1<<0)); // low
|
||||
PORTD |= (1<<2) | (1<<1); // pull-up
|
||||
|
||||
dprintf("init\n");
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
// TODO: debouce & unplug detect
|
||||
// Reset counters
|
||||
RST_HI();
|
||||
wait_us(10);
|
||||
RST_LO();
|
||||
wait_us(10);
|
||||
|
||||
// 8x8 matrix: row:sense, col:drive, key_on:hi
|
||||
for (uint8_t col = 0; col < 8; col++) {
|
||||
for (uint8_t row = 0; row < 8; row++) {
|
||||
CLK_HI();
|
||||
wait_us(10);
|
||||
|
||||
// detect state change and start debounce
|
||||
if ((matrix_debouncing[row] & (1<<col)) ^ (STATE()<<col)) {
|
||||
matrix_debouncing[row] ^= (1<<col);
|
||||
debouncing_time = timer_read() || 1;
|
||||
}
|
||||
|
||||
// proceed counter - next row
|
||||
CLK_LO();
|
||||
wait_us(10);
|
||||
}
|
||||
}
|
||||
|
||||
// debounced
|
||||
if (debouncing_time && timer_elapsed(debouncing_time) > DEBOUNCE) {
|
||||
for (int row = 0; row < MATRIX_ROWS; row++) {
|
||||
matrix[row] = matrix_debouncing[row];
|
||||
}
|
||||
debouncing_time = 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
}
|
||||
68
converter/pana_m8/unimap.c
Normal file
68
converter/pana_m8/unimap.c
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#include "unimap.h"
|
||||
#include "action.h"
|
||||
#include "actionmap.h"
|
||||
#include "hook.h"
|
||||
|
||||
|
||||
#define UMAP( \
|
||||
K29,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K2A, K49,K4C, K3A, \
|
||||
K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K35,K2F,K30, K3B, \
|
||||
K78,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, K28, K52, K3C, \
|
||||
K79,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, K50,K4F, K3D, \
|
||||
K2C, K51, K4A \
|
||||
) UNIMAP ( \
|
||||
NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, \
|
||||
K29, K3A,K3B,K3C,K3D,NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, \
|
||||
K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,NO, K2A, K49,K4A,NO, NO, NO, NO, NO, \
|
||||
K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, NO, K4C,NO, NO, NO, NO, NO, NO, \
|
||||
NO, K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, NO, K28, NO, NO, NO, NO, \
|
||||
K79,NO, K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, NO, NO, K52, NO, NO, NO, NO, \
|
||||
K78,NO, NO, NO, K2C, NO, NO, NO, NO, NO, NO, K50,K51,K4F, NO, NO, NO \
|
||||
)
|
||||
|
||||
#define AC_L1 ACTION_LAYER_MOMENTARY(1)
|
||||
#define AC_SPC1 ACTION_LAYER_TAP_KEY(1, KC_SPC)
|
||||
#define AC_AENT ACTION_MODS_TAP_KEY(MOD_LALT, KC_ENT)
|
||||
|
||||
#ifdef KEYMAP_SECTION_ENABLE
|
||||
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
|
||||
#else
|
||||
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
|
||||
#endif
|
||||
[0] = UMAP(
|
||||
ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, DEL, F1,
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,GRV, F2,
|
||||
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, AENT, UP, F3,
|
||||
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, LEFT,RGHT, F4,
|
||||
SPC1, DOWN, HOME
|
||||
),
|
||||
[1] = UMAP(
|
||||
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, BSLS, PSCR,PAUS, F5,
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGDN,UP, PGUP,TRNS,BSLS,TRNS,TRNS, F6,
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,HOME,LEFT,DOWN,RGHT,END, TRNS, LGUI, PGUP, F7,
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, HOME,END, F8,
|
||||
TRNS, PGDN, END
|
||||
),
|
||||
/*
|
||||
[2] = UMAP(
|
||||
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
|
||||
),
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = {
|
||||
{ UNIMAP_ESC, UNIMAP_1, UNIMAP_2, UNIMAP_3, UNIMAP_4, UNIMAP_5, UNIMAP_6, UNIMAP_7 },
|
||||
{ UNIMAP_8, UNIMAP_9, UNIMAP_0, UNIMAP_MINS, UNIMAP_EQL, UNIMAP_BSPC, UNIMAP_INS, UNIMAP_DEL },
|
||||
{ UNIMAP_TAB, UNIMAP_Q, UNIMAP_W, UNIMAP_E, UNIMAP_R, UNIMAP_T, UNIMAP_Y, UNIMAP_U },
|
||||
{ UNIMAP_I, UNIMAP_O, UNIMAP_P, UNIMAP_GRV, UNIMAP_LBRC, UNIMAP_RBRC, UNIMAP_F2, UNIMAP_F1 },
|
||||
{ UNIMAP_LCTL, UNIMAP_A, UNIMAP_S, UNIMAP_D, UNIMAP_F, UNIMAP_G, UNIMAP_H, UNIMAP_J },
|
||||
{ UNIMAP_K, UNIMAP_L, UNIMAP_SCLN, UNIMAP_QUOT, UNIMAP_ENT, UNIMAP_UP, UNIMAP_F3, UNIMAP_F4 },
|
||||
{ UNIMAP_LSFT, UNIMAP_Z, UNIMAP_X, UNIMAP_C, UNIMAP_V, UNIMAP_B, UNIMAP_N, UNIMAP_M },
|
||||
{ UNIMAP_SPC, UNIMAP_COMM, UNIMAP_DOT, UNIMAP_SLSH, UNIMAP_LEFT, UNIMAP_RIGHT, UNIMAP_DOWN, UNIMAP_HOME }
|
||||
};
|
||||
|
||||
|
|
@ -78,8 +78,8 @@ COMMAND_ENABLE = yes # Commands for debug and configuration
|
|||
# USART is recommended if it is available, others are for reference purpose.
|
||||
# INT implementation will drop simultaneous key strokes.
|
||||
#
|
||||
PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
|
||||
#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)
|
||||
PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
|
||||
#PS2_USE_BUSYWAIT = yes # uses primitive reference code
|
||||
|
||||
|
||||
|
|
@ -91,7 +91,6 @@ PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
|
|||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/protocol.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
|
|
|
|||
|
|
@ -128,20 +128,24 @@ const uint8_t PROGMEM fn_keycode[] = {
|
|||
|
||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
/* 0: default
|
||||
* ,---. ,---------------. ,---------------. ,---------------. ,-----------.
|
||||
* |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| -| =| \|BS | |Ins|Hom|PgU| |NmL| /| *| -|
|
||||
* |-----------------------------------------------------------| |-----------| |---------------|
|
||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| |
|
||||
* |-----------------------------------------------------------| `-----------' |-----------| +|
|
||||
* |CapsLo| A| S| D| F| G| H| J| K| L| ;| '| #|Retu| | 4| 5| 6| |
|
||||
* |-----------------------------------------------------------| ,---. |---------------|
|
||||
* |Shif| \| Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| |
|
||||
* |-----------------------------------------------------------| ,-----------. |-----------|Ent|
|
||||
* |Ctrl| |Alt | Space |Alt | |Ctrl| |Lef|Dow|Rig| | 0| .| |
|
||||
* `----' `---------------------------------------' `----' `-----------' `---------------'
|
||||
*
|
||||
* ,-----------------------------------------------.
|
||||
* |F13|F14|F15|F16|F17|F18|F19|F20|F21|F22|F23|F24|
|
||||
* `-----------------------------------------------'
|
||||
* ,-----------------------------------------------.
|
||||
* |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|
|
||||
* `-----------------------------------------------'
|
||||
* ,-------. ,-----------------------------------------------------------. ,-----------. ,---------------.
|
||||
* |PrS|Esc| | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \|BS | |Ins|Hom|PgU| |NmL| /| *| -|
|
||||
* |-------| |-----------------------------------------------------------| |-----------| |---------------|
|
||||
* |ScL|In4| |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| |
|
||||
* |-------| |-----------------------------------------------------------| `-----------' |-----------| +|
|
||||
* |Pau|In5| |CapsLo| A| S| D| F| G| H| J| K| L| ;| '| #|Retu| |Up | | 4| 5| 6| |
|
||||
* |-------| |-----------------------------------------------------------| ,-----------. |---------------|
|
||||
* |App|In6| |Shif| \| Z| X| C| V| B| N| M| ,| ,| /|Shift | |Lef|In2|Rig| | 1| 2| 3| |
|
||||
* |-------| |-----------------------------------------------------------| `-----------' |-----------|Ent|
|
||||
* |Gui|Gui| |Ctrl| |Alt | Space |Alt | |Ctrl| |Dow| | 0| .| |
|
||||
* `-------' `----' `---------------------------------------' `----' `---' `---------------'
|
||||
*/
|
||||
/*
|
||||
KEYMAP(
|
||||
|
|
|
|||
5
converter/usb_usb/Makefile.8mhz
Normal file
5
converter/usb_usb/Makefile.8mhz
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
F_CPU = 8000000
|
||||
F_USB = 16000000
|
||||
UNIMAP_ENABLE = yes
|
||||
KEYMAP_SECTION_ENABLE = yes
|
||||
include Makefile
|
||||
6
converter/usb_usb/Makefile.debug
Normal file
6
converter/usb_usb/Makefile.debug
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
TARGET = usb_usb_debug
|
||||
UNIMAP_ENABLE = yes
|
||||
#KEYMAP_SECTION_ENABLE = yes
|
||||
#LUFA_DEBUG = yes
|
||||
OPT_DEFS += -DDEBUG_USB_HOST
|
||||
include Makefile
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -42,7 +42,11 @@ static void LUFA_setup(void)
|
|||
wdt_disable();
|
||||
|
||||
/* Disable clock division */
|
||||
#if (F_CPU == 8000000)
|
||||
clock_prescale_set(clock_div_2); // 16MHz crystal divided by 2
|
||||
#else
|
||||
clock_prescale_set(clock_div_1);
|
||||
#endif
|
||||
|
||||
// Leonardo needs. Without this USB device is not recognized.
|
||||
USB_Disable();
|
||||
|
|
@ -75,11 +79,13 @@ int main(void)
|
|||
*/
|
||||
sei();
|
||||
|
||||
/* Some keyboards bootup quickly and cannot be initialized with this startup wait.
|
||||
// wait for startup of sendchar routine
|
||||
while (USB_DeviceState != DEVICE_STATE_Configured) ;
|
||||
if (debug_enable) {
|
||||
_delay_ms(1000);
|
||||
}
|
||||
*/
|
||||
|
||||
debug("init: done\n");
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ 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 UNIMAP_COMMON_H
|
||||
#define UNIMAP_COMMON_H
|
||||
#ifndef UNIMAP_TRANS_H
|
||||
#define UNIMAP_TRANS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
|
@ -43,38 +43,38 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
* `-----------------------------------------------------------' `-----------' `---------------'
|
||||
*/
|
||||
const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = {
|
||||
{ UNIMAP_KANA, UNIMAP_VOLUME_DOWN, UNIMAP_VOLUME_UP, UNIMAP_VOLUME_MUTE, UNIMAP_A, UNIMAP_B, UNIMAP_C, UNIMAP_D,
|
||||
UNIMAP_E, UNIMAP_F, UNIMAP_G, UNIMAP_H, UNIMAP_I, UNIMAP_J, UNIMAP_K, UNIMAP_L },
|
||||
{ UNIMAP_M, UNIMAP_N, UNIMAP_O, UNIMAP_P, UNIMAP_Q, UNIMAP_R, UNIMAP_S, UNIMAP_T,
|
||||
UNIMAP_U, UNIMAP_V, UNIMAP_W, UNIMAP_X, UNIMAP_Y, UNIMAP_Z, UNIMAP_1, UNIMAP_2 },
|
||||
{ UNIMAP_3, UNIMAP_4, UNIMAP_5, UNIMAP_6, UNIMAP_7, UNIMAP_8, UNIMAP_9, UNIMAP_0,
|
||||
UNIMAP_ENTER, UNIMAP_ESCAPE,UNIMAP_BSPACE,UNIMAP_TAB, UNIMAP_SPACE, UNIMAP_MINUS, UNIMAP_EQUAL, UNIMAP_LBRACKET },
|
||||
{ UNIMAP_RBRACKET,UNIMAP_BSLASH,UNIMAP_NONUS_HASH, UNIMAP_SCOLON, UNIMAP_QUOTE, UNIMAP_GRAVE, UNIMAP_COMMA, UNIMAP_DOT,
|
||||
UNIMAP_SLASH, UNIMAP_CAPSLOCK,UNIMAP_F1, UNIMAP_F2, UNIMAP_F3, UNIMAP_F4, UNIMAP_F5, UNIMAP_F6 },
|
||||
{ UNIMAP_F7, UNIMAP_F8, UNIMAP_F9, UNIMAP_F10, UNIMAP_F11, UNIMAP_F12, UNIMAP_PSCREEN,UNIMAP_SCROLLLOCK,
|
||||
UNIMAP_PAUSE, UNIMAP_INSERT,UNIMAP_HOME, UNIMAP_PGUP, UNIMAP_DELETE,UNIMAP_END, UNIMAP_PGDOWN, UNIMAP_RIGHT },
|
||||
{ UNIMAP_LEFT, UNIMAP_DOWN, UNIMAP_UP, UNIMAP_NUMLOCK, UNIMAP_KP_SLASH, UNIMAP_KP_ASTERISK, UNIMAP_KP_MINUS, UNIMAP_KP_PLUS,
|
||||
UNIMAP_KP_ENTER,UNIMAP_KP_1,UNIMAP_KP_2, UNIMAP_KP_3, UNIMAP_KP_4, UNIMAP_KP_5, UNIMAP_KP_6, UNIMAP_KP_7 },
|
||||
{ UNIMAP_KP_8, UNIMAP_KP_9, UNIMAP_KP_0, UNIMAP_KP_DOT,UNIMAP_NONUS_BSLASH,UNIMAP_APPLICATION,UNIMAP_KP_COMMA,UNIMAP_KP_EQUAL,
|
||||
UNIMAP_F13, UNIMAP_F14, UNIMAP_F15, UNIMAP_F16, UNIMAP_F17, UNIMAP_F18, UNIMAP_F19, UNIMAP_F20 },
|
||||
{ UNIMAP_F21, UNIMAP_F22, UNIMAP_F23, UNIMAP_F24, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO,
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* 78-7F */ \
|
||||
{ UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_RO, /* 80-87 */ \
|
||||
UNIMAP_NO, UNIMAP_JYEN, UNIMAP_HENK, UNIMAP_MHEN, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* 88-8F */ \
|
||||
{ UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, /* 90-97 */ \
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* 98-9F */ \
|
||||
{ UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, /* A0-A7 */ \
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* A8-AF */ \
|
||||
{ UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, /* B0-B7 */ \
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* B8-BF */ \
|
||||
{ UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, /* C0-C7 */ \
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* C8-CF */ \
|
||||
{ UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, /* D0-D7 */ \
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* D8-DF */ \
|
||||
{ UNIMAP_LCTRL, UNIMAP_LSHIFT,UNIMAP_LALT, UNIMAP_LGUI, UNIMAP_RCTRL, UNIMAP_RSHIFT,UNIMAP_RALT, UNIMAP_RGUI, /* E0-E7 */ \
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* E8-EF */ \
|
||||
{ UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, /* F0-F7 */ \
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* F8-FF */ \
|
||||
{ UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_A, UNIMAP_B, UNIMAP_C, UNIMAP_D, /* 00-07 */
|
||||
UNIMAP_E, UNIMAP_F, UNIMAP_G, UNIMAP_H, UNIMAP_I, UNIMAP_J, UNIMAP_K, UNIMAP_L }, /* 08-0F */
|
||||
{ UNIMAP_M, UNIMAP_N, UNIMAP_O, UNIMAP_P, UNIMAP_Q, UNIMAP_R, UNIMAP_S, UNIMAP_T, /* 10-17 */
|
||||
UNIMAP_U, UNIMAP_V, UNIMAP_W, UNIMAP_X, UNIMAP_Y, UNIMAP_Z, UNIMAP_1, UNIMAP_2 }, /* 18-1F */
|
||||
{ UNIMAP_3, UNIMAP_4, UNIMAP_5, UNIMAP_6, UNIMAP_7, UNIMAP_8, UNIMAP_9, UNIMAP_0, /* 20-27 */
|
||||
UNIMAP_ENTER, UNIMAP_ESCAPE, UNIMAP_BSPACE, UNIMAP_TAB, UNIMAP_SPACE, UNIMAP_MINUS, UNIMAP_EQUAL, UNIMAP_LBRACKET }, /* 28-2F */
|
||||
{ UNIMAP_RBRACKET, UNIMAP_BSLASH, UNIMAP_NONUS_HASH, UNIMAP_SCOLON, UNIMAP_QUOTE, UNIMAP_GRAVE, UNIMAP_COMMA, UNIMAP_DOT, /* 30-37 */
|
||||
UNIMAP_SLASH, UNIMAP_CAPSLOCK, UNIMAP_F1, UNIMAP_F2, UNIMAP_F3, UNIMAP_F4, UNIMAP_F5, UNIMAP_F6 }, /* 38-3F */
|
||||
{ UNIMAP_F7, UNIMAP_F8, UNIMAP_F9, UNIMAP_F10, UNIMAP_F11, UNIMAP_F12, UNIMAP_PSCREEN, UNIMAP_SCROLLLOCK, /* 40-47 */
|
||||
UNIMAP_PAUSE, UNIMAP_INSERT, UNIMAP_HOME, UNIMAP_PGUP, UNIMAP_DELETE, UNIMAP_END, UNIMAP_PGDOWN, UNIMAP_RIGHT }, /* 48-4F */
|
||||
{ UNIMAP_LEFT, UNIMAP_DOWN, UNIMAP_UP, UNIMAP_NUMLOCK, UNIMAP_KP_SLASH, UNIMAP_KP_ASTERISK, UNIMAP_KP_MINUS,UNIMAP_KP_PLUS, /* 50-57 */
|
||||
UNIMAP_KP_ENTER, UNIMAP_KP_1, UNIMAP_KP_2, UNIMAP_KP_3, UNIMAP_KP_4, UNIMAP_KP_5, UNIMAP_KP_6, UNIMAP_KP_7 }, /* 58-5F */
|
||||
{ UNIMAP_KP_8, UNIMAP_KP_9, UNIMAP_KP_0, UNIMAP_KP_DOT, UNIMAP_NONUS_BSLASH,UNIMAP_APPLICATION, UNIMAP_KP_COMMA,UNIMAP_KP_EQUAL, /* 60-67 */
|
||||
UNIMAP_F13, UNIMAP_F14, UNIMAP_F15, UNIMAP_F16, UNIMAP_F17, UNIMAP_F18, UNIMAP_F19, UNIMAP_F20 }, /* 68-6F */
|
||||
{ UNIMAP_F21, UNIMAP_F22, UNIMAP_F23, UNIMAP_F24, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, /* 70-77 */
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_MUTE }, /* 78-7F */
|
||||
{ UNIMAP_VOLU, UNIMAP_VOLD, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_KP_COMMA, UNIMAP_NO, UNIMAP_RO, /* 80-87 */
|
||||
UNIMAP_KANA, UNIMAP_JYEN, UNIMAP_HENK, UNIMAP_MHEN, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* 88-8F */
|
||||
{ UNIMAP_HENK, UNIMAP_MHEN, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, /* 90-97 */
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* 98-9F */
|
||||
{ UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, /* A0-A7 */
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* A8-AF */
|
||||
{ UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, /* B0-B7 */
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* B8-BF */
|
||||
{ UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, /* C0-C7 */
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* C8-CF */
|
||||
{ UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, /* D0-D7 */
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* D8-DF */
|
||||
{ UNIMAP_LCTRL, UNIMAP_LSHIFT, UNIMAP_LALT, UNIMAP_LGUI, UNIMAP_RCTRL, UNIMAP_RSHIFT, UNIMAP_RALT, UNIMAP_RGUI, /* E0-E7 */
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* E8-EF */
|
||||
{ UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, /* F0-F7 */
|
||||
UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, /* F8-FF */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ uint8_t matrix_scan(void) {
|
|||
|
||||
// restore LED state when keyboard comes up
|
||||
if (usb_state == USB_STATE_RUNNING) {
|
||||
dprintf("speed: %s\n", usb_host.getVbusState()==FSHOST ? "full" : "low");
|
||||
keyboard_set_leds(host_keyboard_leds());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,48 +1,45 @@
|
|||
#
|
||||
# Makefile for PJRC Teensy
|
||||
#
|
||||
|
||||
|
||||
# Target file name (without extension).
|
||||
TARGET = x68k_usb
|
||||
TARGET ?= x68k_usb
|
||||
|
||||
# Directory common source filess exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
TMK_DIR ?= ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
TARGET_DIR ?= .
|
||||
|
||||
# keyboard dependent files
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
# project specific files
|
||||
SRC ?= matrix.c \
|
||||
led.c \
|
||||
protocol/serial_uart.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
|
||||
MCU = atmega32u2 # Teensy 2.0
|
||||
|
||||
# MCU name
|
||||
# atmega32u4 Teensy2.0
|
||||
# atemga32u4 TMK Converter rev.1
|
||||
# atemga32u2 TMK Converter rev.2
|
||||
MCU ?= atmega32u2
|
||||
|
||||
# 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
|
||||
# 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
|
||||
ARCH ?= AVR8
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_USB, in all source code files equal to the
|
||||
|
|
@ -55,69 +52,58 @@ ARCH = AVR8
|
|||
#
|
||||
# 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)
|
||||
F_USB ?= $(F_CPU)
|
||||
|
||||
# Interrupt driven control endpoint task(+60)
|
||||
#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||
|
||||
|
||||
# Boot Section Size in bytes
|
||||
# Boot Section Size in *bytes*
|
||||
# Teensy halfKay 512
|
||||
# Atmel DFU loader 4096
|
||||
# Teensy++ halfKay 1024
|
||||
# Atmel DFU loader 4096 for TMK Converter rev.1/rev.2
|
||||
# LUFA bootloader 4096
|
||||
# USBaspLoader 2048
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
|
||||
# Build Options
|
||||
# *Comment out* to disable the options.
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
#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
|
||||
#UNIMAP_ENABLE = yes
|
||||
#ACTIONMAP_ENABLE = yes # Use 16bit actionmap instead of 8bit keymap
|
||||
#KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
|
||||
|
||||
|
||||
|
||||
#---------------- Programming Options --------------------------
|
||||
AVRDUDE = avrdude
|
||||
# Type: avrdude -c ? to get a full listing.
|
||||
AVRDUDE_PROGRAMMER = avr109
|
||||
AVRDUDE_PORT = /dev/ttyACM0
|
||||
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)
|
||||
#
|
||||
# Keymap file
|
||||
#
|
||||
ifeq (yes,$(strip $(UNIMAP_ENABLE)))
|
||||
KEYMAP_FILE = unimap
|
||||
else
|
||||
ifeq (yes,$(strip $(ACTIONMAP_ENABLE)))
|
||||
KEYMAP_FILE = actionmap
|
||||
else
|
||||
KEYMAP_FILE = keymap
|
||||
endif
|
||||
endif
|
||||
ifdef KEYMAP
|
||||
SRC := $(KEYMAP_FILE)_$(KEYMAP).c $(SRC)
|
||||
else
|
||||
SRC := $(KEYMAP_FILE).c $(SRC)
|
||||
endif
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
|
||||
include $(TMK_DIR)/protocol.mk
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/protocol.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
||||
|
|
|
|||
5
converter/x68k_usb/Makefile.unimap
Normal file
5
converter/x68k_usb/Makefile.unimap
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
TARGET = x68k_usb_unimap
|
||||
UNIMAP_ENABLE = yes
|
||||
KEYMAP_SECTION_ENABLE = yes
|
||||
include Makefile
|
||||
|
||||
1166
converter/x68k_usb/binary/x68k_usb_unimap.hex
Normal file
1166
converter/x68k_usb/binary/x68k_usb_unimap.hex
Normal file
File diff suppressed because it is too large
Load diff
45
converter/x68k_usb/unimap.c
Normal file
45
converter/x68k_usb/unimap.c
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
Copyright 2017 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 "unimap_trans.h"
|
||||
|
||||
|
||||
#define AC_FN0 ACTION_LAYER_MOMENTARY(1)
|
||||
|
||||
#ifdef KEYMAP_SECTION_ENABLE
|
||||
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
|
||||
#else
|
||||
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
|
||||
#endif
|
||||
UNIMAP(
|
||||
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,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, NUHS,ENT, P4, P5, P6, COMM,
|
||||
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PENT,
|
||||
LCTL,LGUI,LALT,MHEN, SPC, HENK,KANA,RALT,RGUI,FN0, RCTL, LEFT,DOWN,RGHT, P0, DOT, PEQL
|
||||
),
|
||||
UNIMAP(
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
|
||||
GRV, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, INS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,
|
||||
TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,TRNS,TRNS,HOME,PGUP,LEFT,RGHT, TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,
|
||||
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,END, PGDN,DOWN, TRNS,TRNS, PGUP, TRNS,TRNS,TRNS,TRNS,
|
||||
TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, HOME,PGDN,END, TRNS, TRNS,TRNS
|
||||
),
|
||||
};
|
||||
75
converter/x68k_usb/unimap_trans.h
Normal file
75
converter/x68k_usb/unimap_trans.h
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
Copyright 2017 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 UNIMAP_TRANS_H
|
||||
#define UNIMAP_TRANS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "unimap.h"
|
||||
|
||||
|
||||
/* X68000 Keyboard Scan codes to Unimap
|
||||
,---. ,---. ,-------------------, ,-------------------. ,-----------. ,---------------.
|
||||
| 61| | 62| | 63| 64| 65| 66| 67| | 68| 69| 6A| 6B| 6C| | 5A| 5B| 5C| | 5D| 52| 53| 54|
|
||||
`---' `---' `-------------------' `-------------------' `-----------' `---------------'
|
||||
,-----------------------------------------------------------. ,-----------. ,---------------.
|
||||
| 01| 02| 03| 04| 05| 06| 07| 08| 09| 0A| 0B| 0C| 0D| 0E| 0F| | 36| 5E| 37| | 3F| 40| 41| 42|
|
||||
|-----------------------------------------------------------| |------------ |---------------|
|
||||
| 10 | 11| 12| 13| 14| 15| 16| 17| 18| 19| 1A| 1B| 1C| | | 38| 39| 3A| | 43| 44| 45| 46|
|
||||
|------------------------------------------------------. 1D | `---=====---' |---------------|
|
||||
| 71 | 1E| 1F| 20| 21| 2l| 23| 24| 25| 26| 27| 28| 29| | ___| 3C|___ | 47| 48| 49| 4A|
|
||||
|-----------------------------------------------------------| | 3B|---| 3D| |-----------|---|
|
||||
| 70 | 2A| 2B| 2C| 2D| 2E| 2F| 30| 31| 32| 33| 34| 70 | `---| 3E|---' | 4B| 4C| 4D| |
|
||||
`-----------------------------------------------------------' .---=====---. |-----------| 4E|
|
||||
| 5F| 55 | 56 | 35 | 57 | 58 | 59 | 60| | 72 | 73 | | 4F| 50| 51| |
|
||||
`---------------------------------------------' `-----------' `---------------'
|
||||
|
||||
,---. ,---. ,-------------------, ,-------------------. ,-----------. ,---------------.
|
||||
|F11| |F12| | F1| F2| F3| F4| F5| | F6| F7| F8| F9|F10| |PrS|ScL|Pau| |F15|F16|F17|F18|
|
||||
`---' `---' `-------------------' `-------------------' `-----------' `---------------'
|
||||
,-----------------------------------------------------------. ,-----------. ,---------------.
|
||||
|Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \|Bsp| |Ins|Hom|PgU| |NmL| /| *| -|
|
||||
|-----------------------------------------------------------| |------------ |---------------|
|
||||
| Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | |Del|End|PgD| | 7| 8| 9| +|
|
||||
|------------------------------------------------------. Ent| `---=====---' |---------------|
|
||||
| Ctrl | A| S| D| F| G| H| J| K| L| ;| '| `| | ___|Up |___ | 4| 5| 6| =|
|
||||
|-----------------------------------------------------------| |Lef|---|Rig| |-----------|---|
|
||||
| Shift | Z| X| C| V| B| N| M| ,| .| /| RO| Shift| `---|Dow|---' | 1| 2| 3| |
|
||||
`-----------------------------------------------------------' .---=====---. |-----------|Ent|
|
||||
|Cap| Gui| Alt| Space | Alt| Gui| App|Ctl| | F13 | F14 | | 0| ,| .| |
|
||||
`---------------------------------------------' `-----------' `---------------'
|
||||
*/
|
||||
const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = {
|
||||
{ UNIMAP_NO, UNIMAP_ESC, UNIMAP_1, UNIMAP_2, UNIMAP_3, UNIMAP_4, UNIMAP_5, UNIMAP_6 }, \
|
||||
{ UNIMAP_7, UNIMAP_8, UNIMAP_9, UNIMAP_0, UNIMAP_MINUS, UNIMAP_EQUAL, UNIMAP_BSLS, UNIMAP_BSPC }, \
|
||||
{ UNIMAP_TAB, UNIMAP_Q, UNIMAP_W, UNIMAP_E, UNIMAP_R, UNIMAP_T, UNIMAP_Y, UNIMAP_U }, \
|
||||
{ UNIMAP_I, UNIMAP_O, UNIMAP_P, UNIMAP_LBRC, UNIMAP_RBRC, UNIMAP_ENTER, UNIMAP_A, UNIMAP_S }, \
|
||||
{ UNIMAP_D, UNIMAP_F, UNIMAP_G, UNIMAP_H, UNIMAP_J, UNIMAP_K, UNIMAP_L, UNIMAP_SCLN }, \
|
||||
{ UNIMAP_QUOTE, UNIMAP_GRAVE, UNIMAP_Z, UNIMAP_X, UNIMAP_C, UNIMAP_V, UNIMAP_B, UNIMAP_N }, \
|
||||
{ UNIMAP_M, UNIMAP_COMMA, UNIMAP_DOT, UNIMAP_SLASH, UNIMAP_RO, UNIMAP_SPACE, UNIMAP_INSERT,UNIMAP_PGUP }, \
|
||||
{ UNIMAP_DELETE,UNIMAP_END, UNIMAP_PGDOWN,UNIMAP_LEFT, UNIMAP_UP, UNIMAP_RIGHT, UNIMAP_DOWN, UNIMAP_NLCK }, \
|
||||
{ UNIMAP_PSLS, UNIMAP_PAST, UNIMAP_PMNS, UNIMAP_P7, UNIMAP_P8, UNIMAP_P9, UNIMAP_PPLS, UNIMAP_P4 }, \
|
||||
{ UNIMAP_P5, UNIMAP_P6, UNIMAP_PEQL, UNIMAP_P1, UNIMAP_P2, UNIMAP_P3, UNIMAP_PENT, UNIMAP_P0 }, \
|
||||
{ UNIMAP_PCMM, UNIMAP_PDOT, UNIMAP_F16, UNIMAP_F17, UNIMAP_F18, UNIMAP_LGUI, UNIMAP_LALT, UNIMAP_RALT }, \
|
||||
{ UNIMAP_RGUI, UNIMAP_APP, UNIMAP_PSCR, UNIMAP_SLCK, UNIMAP_PAUSE, UNIMAP_F15, UNIMAP_HOME, UNIMAP_CAPS }, \
|
||||
{ UNIMAP_RCTRL, UNIMAP_F11, UNIMAP_F12, UNIMAP_F1, UNIMAP_F2, UNIMAP_F3, UNIMAP_F4, UNIMAP_F5, }, \
|
||||
{ UNIMAP_F6, UNIMAP_F7, UNIMAP_F8, UNIMAP_F9, UNIMAP_F10, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO }, \
|
||||
{ UNIMAP_LSHIFT,UNIMAP_LCTRL, UNIMAP_F13, UNIMAP_F14, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, }, \
|
||||
{ UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO, UNIMAP_NO } \
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -137,4 +137,28 @@ KEYMAP_ALL( \
|
|||
WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
|
||||
)
|
||||
|
||||
/* XT layout */
|
||||
#define KEYMAP_XT( \
|
||||
K05,K06, K76, K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45, K4E,K55,K66, K77,K7E, \
|
||||
K04,K0C, K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, K5A, K6C,K75,K7D,K7B, \
|
||||
K03,K0B, K14,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K0E, K6B,K73,K74,K79,\
|
||||
K83,K0A, K12,K5D,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A,K59, K7C, K69,K72,K7A, \
|
||||
K01,K09, K11, K29, K58, K70, K71\
|
||||
) \
|
||||
KEYMAP_ALL( \
|
||||
K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,F11,F12, PSCR,K7E,BRK, \
|
||||
K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, INS,HOME,PGUP, K77,PSLS,K7C,K7B, \
|
||||
K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, DEL,END,PGDN, K6C,K75,K7D, \
|
||||
K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
|
||||
K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, UP, K69,K72,K7A, \
|
||||
K14,LGUI,K11, K29, RALT,RGUI,APP,RCTL, LEFT,DOWN,RGHT, K70,K71,PENT, \
|
||||
\
|
||||
SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
|
||||
AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
|
||||
MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
|
||||
MAIL, CALCULATOR, MY_COMPUTER, \
|
||||
WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
|
||||
WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
|
||||
)
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -32,7 +32,7 @@ const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
|
|||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS, INS,
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, DEL,
|
||||
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,UP,
|
||||
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLS6, RSFT,UP,
|
||||
L4, LGUI,LALT, SPC5, RALT,RCTL,L4, LEFT,DOWN,RGHT
|
||||
),
|
||||
[2] = KMAP(
|
||||
|
|
|
|||
110
keyboard/fc980c/Makefile
Normal file
110
keyboard/fc980c/Makefile
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
# Target name
|
||||
TARGET ?= fc980c
|
||||
|
||||
# Location of tmk_core
|
||||
TMK_DIR ?= ../../tmk_core
|
||||
|
||||
# Location of target dependent files exist
|
||||
TARGET_DIR ?= .
|
||||
|
||||
|
||||
# List C source files
|
||||
SRC ?= fc980c.c
|
||||
|
||||
# Configure file
|
||||
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 ?= 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
|
||||
#ACTIONMAP_ENABLE ?= yes # Use 16bit actionmap instead of 8bit keymap
|
||||
UNIMAP_ENABLE ?= yes # Universal keymap
|
||||
KEYMAP_SECTION_ENABLE ?= yes # fixed address keymap for keymap editor
|
||||
|
||||
#OPT_DEFS += -DNO_ACTION_TAPPING
|
||||
#OPT_DEFS += -DNO_ACTION_LAYER
|
||||
#OPT_DEFS += -DNO_ACTION_MACRO
|
||||
|
||||
|
||||
#
|
||||
# Keymap file
|
||||
#
|
||||
ifeq (yes,$(strip $(UNIMAP_ENABLE)))
|
||||
KEYMAP_FILE = unimap
|
||||
else
|
||||
ifeq (yes,$(strip $(ACTIONMAP_ENABLE)))
|
||||
KEYMAP_FILE = actionmap
|
||||
else
|
||||
KEYMAP_FILE = keymap
|
||||
endif
|
||||
endif
|
||||
ifdef KEYMAP
|
||||
SRC := $(KEYMAP_FILE)_$(KEYMAP).c $(SRC)
|
||||
else
|
||||
SRC := $(KEYMAP_FILE).c $(SRC)
|
||||
endif
|
||||
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TARGET_DIR)
|
||||
VPATH += $(TMK_DIR)
|
||||
|
||||
include $(TMK_DIR)/protocol/lufa.mk
|
||||
include $(TMK_DIR)/common.mk
|
||||
include $(TMK_DIR)/rules.mk
|
||||
154
keyboard/fc980c/README.md
Normal file
154
keyboard/fc980c/README.md
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
FC980C Alt controller
|
||||
=====================
|
||||
2017/07/21
|
||||
|
||||
This controler replaces original controller of Leopold FC980C and makes the keyboard programmable.
|
||||
|
||||
Discuss this here: https://geekhack.org/index.php?topic=90681.0
|
||||
|
||||
The keyboard is very similar electronically to its sibling model FC660C you can also refer this.
|
||||
|
||||
FC660C Alt Controller: https://geekhack.org/index.php?topic=88439.0
|
||||
|
||||
|
||||
Hardware
|
||||
--------
|
||||
This project uses common and familiar ATmega32u4 but any microcontroller with 5V I/O will work.
|
||||
|
||||
- Schematic of Alt controller: schematic.pdf
|
||||
|
||||
|
||||
Pin configuration
|
||||
-----------------
|
||||
Connector bridging between switch board and controller is Hirose DF14A-20P-1.25H.
|
||||
|
||||
|Switch |Controller |
|
||||
| board | board |Description |Function |ATmega32u4
|
||||
|--------|-----------|--------------------------------------|-----------|------------
|
||||
| 1 |20 | FG |FG |GND
|
||||
| 2 |19 | GND |GND |GND
|
||||
| 3 |18 | GND |GND |GND
|
||||
| 4 |17 | 3.3V |V33 |3.3V/5V
|
||||
| 5 |16 | 5V |Vcc |5V
|
||||
| 6 |15 |*Z6-TP1684-4-HYS(o) |KEY_HYS |PC7
|
||||
| 7 |14 |*Z6-TP1684-2-KEY(i) |KEY_STATE |PC6
|
||||
| 8 |13 |*Z7-AD5258-5-SCL(I2C) |I2C_SCL |PD0(TWI)
|
||||
| 9 |12 |*Z7-AD5258-4-SDA(I2C) |I2C_SDA |PD1(TWI)
|
||||
|10 |11 |*Z5/4-LV4051A-6-~EN(Lo:Z5 Hi:Z4) |COL_bit3 |PB3
|
||||
|11 |10 |+Z3-LV07A-5 (LV4051A-9-C) |COL_bit2 |PB2
|
||||
|12 | 9 |+Z3-LV07A-1 (LV4051A-10-B) |COL_bit1 |PB1
|
||||
|13 | 8 |+Z3-LV07A-3 (LV4051A-11-A) |COL_bit0 |PB0
|
||||
|14 | 7 |+Z1-LVC138A-3-C |ROW_bit2 |PD6
|
||||
|15 | 6 |+Z1-LVC138A-2-B |ROW_bit1 |PD5
|
||||
|16 | 5 |+Z1-LVC138A-1-A |ROW_bit0 |PD4
|
||||
|17 | 4 |+Z1-LVC138A-4-~G2A Z6-TP1684-5-~EN |KEY_ENABLE |PD7
|
||||
|18 | 3 |+Q4-NPN-B-NumLock_LED(Hi:On) |LED_NUML |PB4
|
||||
|19 | 2 |+Q3-NPN-B-CapsLock_LED(Hi:On) |LED_CAPS |PB5
|
||||
|20 | 1 |+Q2-NPN-B-ScrollLock_LED(Hi:On) |LED_SCRL |PB6
|
||||
|
||||
```
|
||||
* 5V intferface
|
||||
+ 3.3V interface
|
||||
```
|
||||
|
||||
|
||||
Switch matrix
|
||||
-------------
|
||||
|
||||
| |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |A |B |C |D |E |F |
|
||||
|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|
|
||||
| 0|Left|RCtl|RAlt| |Down|P. |Righ|P0 |X |LGui|` |V | |Esc |M |Spc |
|
||||
| 1|Fn |. | | |P1 |PEnt|P2 |P3 |Z |LAlt|LCtl|C |K | |N |B |
|
||||
| 2|' |/ |, | |P4 |P+ |P5 |P6 |D |A |LSft|F |J |F1 |H |G |
|
||||
| 3|RSft|; |L |] |Up | | | |S |Q |Caps|R |I |F3 |U |T |
|
||||
| 4| | | | | | | | | | | | | | | | |
|
||||
| 5|= |- |0 |\ |NLck|BSpc|P/ |P* |3 |2 | |4 |9 |F2 |7 |6 |
|
||||
| 6|[ |P |O |Ent |P7 |P- |P8 |P9 |W |1 |Tab |E |8 |F4 |Y |5 |
|
||||
| 7|F11 |F10 |F9 |F12 |Del |PgDn|Ins |PgUp| | | | |F8 |F5 |F7 |F6 |
|
||||
|
||||
|
||||
Row designation
|
||||
---------------
|
||||
LV138A(Z1) selects one of 8 row lines and gives strobe by enabling with ~G2A(17).
|
||||
|
||||
|ROW |bit0|bit1|bit2|
|
||||
|----|----|----|----|
|
||||
|0 |0 |0 |0 |
|
||||
|1 |1 |0 |0 |
|
||||
|2 |0 |1 |0 |
|
||||
|3 |1 |1 |0 |
|
||||
|4 |0 |0 |1 |
|
||||
|5 |1 |0 |1 |
|
||||
|6 |0 |1 |1 |
|
||||
|7 |1 |1 |1 |
|
||||
|
||||
|
||||
Column designation
|
||||
------------------
|
||||
LV4051A(Z4, Z5) select one of 16 column lines to sense capacitance of switches.
|
||||
|
||||
|COL |bit0|bit1|bit2|bit3|
|
||||
|----|----|----|----|----|
|
||||
|0 |0 |0 |0 |0 |
|
||||
|1 |1 |0 |0 |0 |
|
||||
|2 |0 |1 |0 |0 |
|
||||
|3 |1 |1 |0 |0 |
|
||||
|4 |0 |0 |1 |0 |
|
||||
|5 |1 |0 |1 |0 |
|
||||
|6 |0 |1 |1 |0 |
|
||||
|7 |1 |1 |1 |0 |
|
||||
|8 |0 |0 |0 |1 |
|
||||
|9 |1 |0 |0 |1 |
|
||||
|A |0 |1 |0 |1 |
|
||||
|B |1 |1 |0 |1 |
|
||||
|C |0 |0 |1 |1 |
|
||||
|D |1 |0 |1 |1 |
|
||||
|E |0 |1 |1 |1 |
|
||||
|F |1 |1 |1 |1 |
|
||||
|
||||
|
||||
Firmware
|
||||
--------
|
||||
Just `make` to build firmware. And consult with wiki for further information.
|
||||
|
||||
- https://github.com/tmk/tmk_keyboard/tree/master/keyboard/fc660c
|
||||
- https://github.com/tmk/tmk_keyboard/wiki
|
||||
|
||||
|
||||
Datasheets
|
||||
----------
|
||||
- Hirose DF14A-20P-1.25H: http://www.mouser.com/ds/2/185/DF14_catalog-939195.pdf
|
||||
- LV07A: http://www.ti.com/lit/ds/symlink/sn74lv07a.pdf
|
||||
- LV138A: http://www.ti.com/lit/ds/symlink/sn74lvc138a.pdf
|
||||
- LV4051A: http://www.ti.com/lit/ds/symlink/sn74lv4051a.pdf
|
||||
- AD5258: http://www.analog.com/media/en/technical-documentation/data-sheets/AD5258.pdf
|
||||
- JST S5B-PH-SM4: http://www.jst-mfg.com/product/pdf/eng/ePH.pdf
|
||||
- Hirose UX60SC-MB-5S8: https://www.hirose.com/product/en/products/UX/UX60SC-MB-5S8%2880%29/
|
||||
- TYU TU1252WNR-05S: http://php2.twinner.com.tw/files/tyu/TU1252series.pdf
|
||||
- Tr(E42) for LED?: http://cj-elec.com/txUpfile/2013614923661845.pdf
|
||||
|
||||
|
||||
3.3V power supply
|
||||
-----------------
|
||||
LV07A and LVC138A are 5V-tolerant and can be powered with 5V, the keyboard will work only with 5V power supply. It may not be completely safe to operate LV138A with 5V Vcc, its datasheet says:
|
||||
|
||||
> Exposure to absolute-maximum-rated conditions for extended periods may affect device reliability.
|
||||
|
||||
|
||||
Digipot AD5258
|
||||
--------------
|
||||
Controller can operate AD5258 via I2C to change actuation point of keys. This may make keyboard unusable accidentally and it will be difficult to recovery in some situation. For safety firmware doesn't support it at this point, though.
|
||||
|
||||
Lower value of RDAC register causes shallower actuation point.
|
||||
|
||||
|
||||
USB connector board
|
||||
-------------------
|
||||
The keyboard has USB receptacle on small separate 1.0mm-thick PCB. USB receptacle is Hirose UX60SC-MB-5S8 while wire-to-PCB connector is TYU TU1252WNR-05S.
|
||||
|
||||
http://i.imgur.com/Nucn6h9.jpg
|
||||
|
||||
|
||||
Resources
|
||||
---------
|
||||
- Pics: http://imgur.com/a/HhyIq
|
||||
1236
keyboard/fc980c/binary/fc980c.hex
Normal file
1236
keyboard/fc980c/binary/fc980c.hex
Normal file
File diff suppressed because it is too large
Load diff
49
keyboard/fc980c/config.h
Normal file
49
keyboard/fc980c/config.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
Copyright 2017 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 0x980C
|
||||
#define DEVICE_VER 0x0100
|
||||
#define MANUFACTURER TMK.
|
||||
#define PRODUCT FC980C Alt Controller
|
||||
#define DESCRIPTION TMK. keyboard firmware for FC980C
|
||||
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 8
|
||||
#define MATRIX_COLS 16
|
||||
|
||||
|
||||
/* 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_SPACE
|
||||
|
||||
#endif
|
||||
174
keyboard/fc980c/fc980c.c
Normal file
174
keyboard/fc980c/fc980c.c
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
Copyright 2017 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 "led.h"
|
||||
#include "fc980c.h"
|
||||
|
||||
|
||||
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];
|
||||
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
#if 0
|
||||
debug_enable = true;
|
||||
debug_keyboard = true;
|
||||
debug_matrix = true;
|
||||
#endif
|
||||
debug_enable = true;
|
||||
debug_matrix = true;
|
||||
|
||||
KEY_INIT();
|
||||
|
||||
// LEDs on NumLock, CapsLock and ScrollLock(PB4, PB5, PB6)
|
||||
DDRB |= (1<<4) | (1<<5) | (1<<6);
|
||||
PORTB |= (1<<4) | (1<<5) | (1<<6);
|
||||
|
||||
// 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)
|
||||
{
|
||||
matrix_row_t *tmp;
|
||||
|
||||
tmp = matrix_prev;
|
||||
matrix_prev = matrix;
|
||||
matrix = tmp;
|
||||
|
||||
uint8_t row, col;
|
||||
for (col = 0; col < MATRIX_COLS; col++) {
|
||||
SET_COL(col);
|
||||
for (row = 0; row < MATRIX_ROWS; row++) {
|
||||
//KEY_SELECT(row, col);
|
||||
SET_ROW(row);
|
||||
_delay_us(2);
|
||||
|
||||
// Not sure this is needed. This just emulates HHKB controller's behaviour.
|
||||
if (matrix_prev[row] & (1<<col)) {
|
||||
KEY_HYS_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.
|
||||
_delay_us(2);
|
||||
|
||||
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_HYS_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.
|
||||
_delay_us(75);
|
||||
}
|
||||
if (matrix[row] ^ matrix_prev[row]) {
|
||||
matrix_last_modified = timer_read32();
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
|
||||
PORTB |= (1<<4);
|
||||
} else {
|
||||
PORTB &= ~(1<<4);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef UNIMAP_ENABLE
|
||||
#include <avr/pgmspace.h>
|
||||
#include "unimap.h"
|
||||
|
||||
const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = {
|
||||
{ UNIMAP_LEFT, UNIMAP_RCTL, UNIMAP_RALT, UNIMAP_NO , UNIMAP_DOWN, UNIMAP_PDOT, UNIMAP_RGHT, UNIMAP_P0 ,
|
||||
UNIMAP_X , UNIMAP_LGUI, UNIMAP_GRV , UNIMAP_V , UNIMAP_NO , UNIMAP_ESC , UNIMAP_M , UNIMAP_SPC },
|
||||
{ UNIMAP_RGUI, UNIMAP_DOT , UNIMAP_NO , UNIMAP_NO , UNIMAP_P1 , UNIMAP_PENT, UNIMAP_P2 , UNIMAP_P3 ,
|
||||
UNIMAP_Z , UNIMAP_LALT, UNIMAP_LCTL, UNIMAP_C , UNIMAP_K , UNIMAP_NO , UNIMAP_N , UNIMAP_B },
|
||||
{ UNIMAP_QUOT, UNIMAP_SLSH, UNIMAP_COMM, UNIMAP_NO , UNIMAP_P4 , UNIMAP_PPLS, UNIMAP_P5 , UNIMAP_P6 ,
|
||||
UNIMAP_D , UNIMAP_A , UNIMAP_LSFT, UNIMAP_F , UNIMAP_J , UNIMAP_F1 , UNIMAP_H , UNIMAP_G },
|
||||
{ UNIMAP_RSFT, UNIMAP_SCLN, UNIMAP_L , UNIMAP_RBRC, UNIMAP_UP , UNIMAP_NO , UNIMAP_NO , UNIMAP_NO ,
|
||||
UNIMAP_S , UNIMAP_Q , UNIMAP_CAPS, UNIMAP_R , UNIMAP_I , UNIMAP_F3 , UNIMAP_U , UNIMAP_T },
|
||||
{ UNIMAP_NO , UNIMAP_NO , UNIMAP_NO , UNIMAP_NO , UNIMAP_NO , UNIMAP_NO , UNIMAP_NO , UNIMAP_NO ,
|
||||
UNIMAP_NO , UNIMAP_NO , UNIMAP_NO , UNIMAP_NO , UNIMAP_NO , UNIMAP_NO , UNIMAP_NO , UNIMAP_NO },
|
||||
{ UNIMAP_EQL , UNIMAP_MINS, UNIMAP_0 , UNIMAP_BSLS, UNIMAP_NLCK, UNIMAP_BSPC, UNIMAP_PSLS, UNIMAP_PAST,
|
||||
UNIMAP_3 , UNIMAP_2 , UNIMAP_NO , UNIMAP_4 , UNIMAP_9 , UNIMAP_F2 , UNIMAP_7 , UNIMAP_6 },
|
||||
{ UNIMAP_LBRC, UNIMAP_P , UNIMAP_O , UNIMAP_ENT , UNIMAP_P7 , UNIMAP_PMNS, UNIMAP_P8 , UNIMAP_P9 ,
|
||||
UNIMAP_W , UNIMAP_1 , UNIMAP_TAB , UNIMAP_E , UNIMAP_8 , UNIMAP_F4 , UNIMAP_Y , UNIMAP_5 },
|
||||
{ UNIMAP_F11 , UNIMAP_F10 , UNIMAP_F9 , UNIMAP_F12 , UNIMAP_DEL , UNIMAP_PGDN, UNIMAP_INS , UNIMAP_PGUP,
|
||||
UNIMAP_NO , UNIMAP_NO , UNIMAP_NO , UNIMAP_NO , UNIMAP_F8 , UNIMAP_F5 , UNIMAP_F7 , UNIMAP_F6 }
|
||||
|
||||
};
|
||||
#endif
|
||||
133
keyboard/fc980c/fc980c.h
Normal file
133
keyboard/fc980c/fc980c.h
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
#ifndef FC980C_H
|
||||
#define FC980C_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <util/delay.h>
|
||||
#include "timer.h"
|
||||
#include "unimap.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
|
||||
|
||||
|
||||
/*
|
||||
* Pin configuration for ATMega32U4
|
||||
*
|
||||
* Row: PD4-6, PD7(~EN)
|
||||
* Col: PB0-3
|
||||
* Key: PC6(pull-uped)
|
||||
* Hys: PC7
|
||||
*/
|
||||
static inline void KEY_ENABLE(void) { (PORTD &= ~(1<<7)); }
|
||||
static inline void KEY_UNABLE(void) { (PORTD |= (1<<7)); }
|
||||
static inline bool KEY_STATE(void) { return (PINC & (1<<6)); }
|
||||
static inline void KEY_HYS_ON(void) { (PORTC |= (1<<7)); }
|
||||
static inline void KEY_HYS_OFF(void) { (PORTC &= ~(1<<7)); }
|
||||
static inline void KEY_INIT(void)
|
||||
{
|
||||
/* Col */
|
||||
DDRB |= 0x0F;
|
||||
/* Key: input with pull-up */
|
||||
DDRC &= ~(1<<6);
|
||||
PORTC |= (1<<6);
|
||||
/* Hys */
|
||||
DDRC |= (1<<7);
|
||||
/* Row */
|
||||
DDRD |= 0xF0;
|
||||
|
||||
KEY_UNABLE();
|
||||
KEY_HYS_OFF();
|
||||
}
|
||||
static inline void SET_ROW(uint8_t ROW)
|
||||
{
|
||||
// PD4-6
|
||||
PORTD = (PORTD & 0x8F) | ((ROW & 0x07) << 4);
|
||||
}
|
||||
static inline void SET_COL(uint8_t COL)
|
||||
{
|
||||
// PB0-3
|
||||
PORTB = (PORTB & 0xF0) | (COL & 0x0F);
|
||||
}
|
||||
|
||||
|
||||
#ifdef UNIMAP_ENABLE
|
||||
/* unimap */
|
||||
#define KMAP( \
|
||||
K29, K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45, K4C,K49,K4B,K4E, \
|
||||
K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K2A, K53,K54,K55,K56, \
|
||||
K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30,K31, K5F,K60,K61,K57, \
|
||||
K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, K28, K5C,K5D,K5E, \
|
||||
K79, K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, K7D, K52, K59,K5A,K5B,K58, \
|
||||
K78,K7B,K7A, K2C, K7E,K7C,K7F, K50,K51,K4F, K62,K63 \
|
||||
) UNIMAP( \
|
||||
NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, \
|
||||
K29, K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45, NO, NO, NO, NO, NO, NO, \
|
||||
K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,NO, K2A, K49,NO, K4B, K53,K54,K55,K56, \
|
||||
K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, K31, K4C,NO, K4E, K5F,K60,K61,K57, \
|
||||
K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, NO, K28, K5C,K5D,K5E,NO, \
|
||||
K79,NO, K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, NO, K7D, K52, K59,K5A,K5B,K58, \
|
||||
K78,K7B,K7A,NO, K2C, NO, NO, K7E,K7F,NO, K7C, K50,K51,K4F, K62,K63,NO \
|
||||
)
|
||||
#elif defined(ACTIONMAP_ENABLE)
|
||||
/* actionmap */
|
||||
#define KMAP( \
|
||||
K0D, K2D,K5D,K3D,K6D,K7D,K7F,K7E,K7C,K72,K71,K70,K73, K74,K76,K77,K75, \
|
||||
K0A,K69,K59,K58,K5B,K6F,K5F,K5E,K6C,K5C,K52,K51,K50,K55, K54,K56,K57,K65, \
|
||||
K6A,K39,K68,K6B,K3B,K3F,K6E,K3E,K3C,K62,K61,K60,K33,K53, K64,K66,K67,K25, \
|
||||
K3A,K29,K38,K28,K2B,K2F,K2E,K2C,K1C,K32,K31,K20, K63, K24,K26,K27, \
|
||||
K2A, K18,K08,K1B,K0B,K1F,K1E,K0E,K22,K11,K21, K30, K34, K14,K16,K17,K15, \
|
||||
K1A,K09,K19, K0F, K02,K01,K10, K00,K04,K06, K07,K05 \
|
||||
) { \
|
||||
{ AC_##K00, AC_##K01, AC_##K02, AC_NO, AC_##K04, AC_##K05, AC_##K06, AC_##K07, \
|
||||
AC_##K08, AC_##K09, AC_##K0A, AC_##K0B, AC_NO, AC_##K0D, AC_##K0E, AC_##K0F }, \
|
||||
{ AC_##K10, AC_##K11, AC_NO, AC_NO, AC_##K14, AC_##K15, AC_##K16, AC_##K17, \
|
||||
AC_##K18, AC_##K19, AC_##K1A, AC_##K1B, AC_##K1C, AC_NO, AC_##K1E, AC_##K1F }, \
|
||||
{ AC_##K20, AC_##K21, AC_##K22, AC_NO, AC_##K24, AC_##K25, AC_##K26, AC_##K27, \
|
||||
AC_##K28, AC_##K29, AC_##K2A, AC_##K2B, AC_##K2C, AC_##K2D, AC_##K2E, AC_##K2F }, \
|
||||
{ AC_##K30, AC_##K31, AC_##K32, AC_##K33, AC_##K34, AC_NO, AC_NO, AC_NO, \
|
||||
AC_##K38, AC_##K39, AC_##K3A, AC_##K3B, AC_##K3C, AC_##K3D, AC_##K3E, AC_##K3F }, \
|
||||
{ AC_NO, AC_NO, AC_NO, AC_NO, AC_NO, AC_NO, AC_NO, AC_NO, \
|
||||
AC_NO, AC_NO, AC_NO, AC_NO, AC_NO, AC_NO, AC_NO, AC_NO }, \
|
||||
{ AC_##K50, AC_##K51, AC_##K52, AC_##K53, AC_##K54, AC_##K55, AC_##K56, AC_##K57, \
|
||||
AC_##K58, AC_##K59, AC_NO, AC_##K5B, AC_##K5C, AC_##K5D, AC_##K5E, AC_##K5F }, \
|
||||
{ AC_##K60, AC_##K61, AC_##K62, AC_##K63, AC_##K64, AC_##K65, AC_##K66, AC_##K67, \
|
||||
AC_##K68, AC_##K69, AC_##K6A, AC_##K6B, AC_##K6C, AC_##K6D, AC_##K6E, AC_##K6F }, \
|
||||
{ AC_##K70, AC_##K71, AC_##K72, AC_##K73, AC_##K74, AC_##K75, AC_##K76, AC_##K77, \
|
||||
AC_NO, AC_NO, AC_NO, AC_NO, AC_##K7C, AC_##K7D, AC_##K7E, AC_##K7F } \
|
||||
}
|
||||
#else
|
||||
/* keymap */
|
||||
#define KMAP( \
|
||||
K0D, K2D,K5D,K3D,K6D,K7D,K7F,K7E,K7C,K72,K71,K70,K73, K74,K76,K77,K75, \
|
||||
K0A,K69,K59,K58,K5B,K6F,K5F,K5E,K6C,K5C,K52,K51,K50,K55, K54,K56,K57,K65, \
|
||||
K6A,K39,K68,K6B,K3B,K3F,K6E,K3E,K3C,K62,K61,K60,K33,K53, K64,K66,K67,K25, \
|
||||
K3A,K29,K38,K28,K2B,K2F,K2E,K2C,K1C,K32,K31,K20, K63, K24,K26,K27, \
|
||||
K2A, K18,K08,K1B,K0B,K1F,K1E,K0E,K22,K11,K21, K30, K34, K14,K16,K17,K15, \
|
||||
K1A,K09,K19, K0F, K02,K01,K10, K00,K04,K06, K07,K05 \
|
||||
) { \
|
||||
{ KC_##K00, KC_##K01, KC_##K02, KC_NO, KC_##K04, KC_##K05, KC_##K06, KC_##K07, \
|
||||
KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_NO, KC_##K0D, KC_##K0E, KC_##K0F }, \
|
||||
{ KC_##K10, KC_##K11, KC_NO, KC_NO, KC_##K14, KC_##K15, KC_##K16, KC_##K17, \
|
||||
KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_NO, KC_##K1E, KC_##K1F }, \
|
||||
{ KC_##K20, KC_##K21, KC_##K22, KC_NO, KC_##K24, KC_##K25, KC_##K26, KC_##K27, \
|
||||
KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \
|
||||
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_NO, KC_NO, KC_NO, \
|
||||
KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \
|
||||
{ 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_NO, KC_NO, KC_NO }, \
|
||||
{ KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57, \
|
||||
KC_##K58, KC_##K59, KC_NO, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F }, \
|
||||
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67, \
|
||||
KC_##K68, KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_##K6D, KC_##K6E, KC_##K6F }, \
|
||||
{ KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77, \
|
||||
KC_NO, KC_NO, KC_NO, KC_NO, KC_##K7C, KC_##K7D, KC_##K7E, KC_##K7F } \
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
BIN
keyboard/fc980c/schematic.pdf
Normal file
BIN
keyboard/fc980c/schematic.pdf
Normal file
Binary file not shown.
30
keyboard/fc980c/unimap.c
Normal file
30
keyboard/fc980c/unimap.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "action.h"
|
||||
#include "actionmap.h"
|
||||
#include "hook.h"
|
||||
#include "fc980c.h"
|
||||
|
||||
|
||||
#define AC_L1 ACTION_LAYER_MOMENTARY(1)
|
||||
|
||||
#ifdef KEYMAP_SECTION_ENABLE
|
||||
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
|
||||
#else
|
||||
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
|
||||
#endif
|
||||
[0] = KMAP(
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, PGUP,PGDN,
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, NLCK,PSLS,PAST,PMNS,
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, P7, P8, P9, PPLS,
|
||||
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6,
|
||||
LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, PENT,
|
||||
LCTL,LGUI,LALT, SPC, RALT,RCTL,L1, LEFT,DOWN,RGHT, P0, PDOT
|
||||
),
|
||||
[1] = KMAP(
|
||||
TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,HOME,END,
|
||||
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,PSCR,SLCK,PAUS,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, PGUP, TRNS,TRNS,TRNS,TRNS,
|
||||
TRNS,TRNS,TRNS, TRNS, TRNS,APP, TRNS, HOME,PGDN,END, TRNS,TRNS
|
||||
),
|
||||
};
|
||||
|
|
@ -46,7 +46,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
{ KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_NO, KC_##K45, KC_NO, KC_NO, KC_NO, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D } \
|
||||
}
|
||||
|
||||
/* ANSI valiant. No extra keys for ISO */
|
||||
/* ANSI variant. No extra keys for ISO */
|
||||
#define KEYMAP_ANSI( \
|
||||
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \
|
||||
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
# build firmware for keymap editor
|
||||
#
|
||||
TARGET = hhkb_editor
|
||||
KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
|
||||
include Makefile
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# build firmware for keymap editor
|
||||
#
|
||||
TARGET = hhkb_rn42_editor
|
||||
KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
|
||||
include Makefile.rn42
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
TARGET ?= hhkb_rn42
|
||||
CONFIG_H ?= config_rn42.h
|
||||
RN42_ENABLE ?= yes
|
||||
NKRO_ENABLE ?= no
|
||||
NKRO_ENABLE ?= yes
|
||||
include Makefile
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ 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.
|
||||
|
||||
This controller can work with HHKB **Professional**, **Professional** 2, **JP** and **Type-S**.
|
||||
This controller can work with HHKB **Professional**, **Professional 2**, **JP** and **Type-S**.
|
||||
|
||||
See [this thread][AltController] in geekhack.org.
|
||||
See [this thread][AltController] in geekhack.org for details.
|
||||
|
||||
[HHKB]: http://www.pfu.fujitsu.com/hhkeyboard/
|
||||
[AltController]: http://geekhack.org/index.php?topic=12047.0
|
||||
|
|
@ -12,10 +12,9 @@ See [this thread][AltController] in geekhack.org.
|
|||
|
||||
## 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)
|
||||
|
||||
|
||||
##Features
|
||||
## Features
|
||||
* Customizable keymap
|
||||
* More keymap layers(more Fn keys)
|
||||
* Mouse keys
|
||||
|
|
@ -26,39 +25,43 @@ See README of [tmk_keyboard] for more.
|
|||
|
||||
[tmk_keyboard]: http://github.com/tmk/tmk_keyboard
|
||||
|
||||
###Pros
|
||||
### 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
|
||||
|
||||
###Cons
|
||||
### Cons
|
||||
* Void your warranty
|
||||
* Lose USB hub function of Pro2
|
||||
|
||||
##DISCLAIMER
|
||||
## 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.
|
||||
|
||||
|
||||
##Documents
|
||||
## HHKB Internals
|
||||
See [doc/HHKB.txt](doc/HHKB.txt) and files under [doc/](doc/) for internal of HHKB and this controller.
|
||||
|
||||
|
||||
##Build Firmware & Program
|
||||
See [this document](../../tmk_core/doc/build.md) first.
|
||||
## Build Firmware & Program
|
||||
See [this document](../../tmk_core/doc/build.md) and [this](https://github.com/tmk/tmk_keyboard/wiki#build-firmware) first.
|
||||
|
||||
### Configuration
|
||||
If your target is **HHKB JP** you need to set `HHKB_JP` build option in `Makefile` or use `Makefile.jp` instead of `Makefile`.
|
||||
Build options and firmware settings are available in `Makefile` and `config.h` or `config_rn42.h`.
|
||||
|
||||
|
||||
### Keymap
|
||||
To define your own keymap create file named `keymap_<name>.c` and see [keymap document](../../tmk_core/doc/keymap.md) and existent keymap files.
|
||||
|
||||
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.
|
||||
|
||||
### 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:
|
||||
|
||||
$ make -f Makefile.<jp|pjrc|rn42> KEYMAP=(hasu|hhkb|spacefn|<name>)
|
||||
$ make -f Makefile.<variant> KEYMAP=<name> clean
|
||||
$ make -f Makefile.<variant> KEYMAP=<name>
|
||||
|
||||
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**.
|
||||
`Makefile` can be used for **Pro2 and Pro** USB controller, `Makefile.jp` for **JP**, `Makefile.rn42` for **Pro2** Bluetooth and `Makefile.rn42.jp` for **JP** Bluetooth.
|
||||
|
||||
|
||||
### Program
|
||||
|
|
@ -72,31 +75,15 @@ Or you can also use [FLIP] command to program. Also the tool should be installed
|
|||
|
||||
$ make -f Makefile.<variant> KEYMAP=<name> flip
|
||||
|
||||
Use [Teensy Loader] if your controller is Teensy/Teensy++.
|
||||
|
||||
|
||||
##Keymap
|
||||
To define your own keymap create file named `keymap_<name>.c` and see [keymap document](../../tmk_core/doc/keymap.md) and existent keymap files.
|
||||
## Hardware
|
||||
|
||||
### TMK Alt Controller Board
|
||||
Preassmbled controller is available from [here](https://geekhack.org/index.php?topic=71517.0).
|
||||
|
||||
You can find design files of the controller at [Keyboard Controller Board for HHKB(KiCad project)](https://github.com/tmk/HHKB_controller).
|
||||
|
||||
|
||||
##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.
|
||||
|
||||
###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.
|
||||
|
||||
|
||||
###2. PJRC Teensy
|
||||
See [this thread](http://geekhack.org/index.php?topic=57008.0).
|
||||
|
||||
|
||||
###3. V-USB version
|
||||
See [V-USB controller for HHKB](doc/V-USB.md).
|
||||
|
||||
|
||||
[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
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -4,10 +4,11 @@ Not supported actively any more.
|
|||
|
||||
## Build
|
||||
Use `Makefile.vusb` for [V-USB] controller.
|
||||
|
||||
$ make -f Makefile.vusb
|
||||
|
||||
##Hardware
|
||||
###3. V-USB connection
|
||||
## Hardware
|
||||
|
||||
+---+ +---------------+
|
||||
USB GND | | ATmega328p |
|
||||
~~~ C3 | |
|
||||
|
|
|
|||
|
|
@ -72,12 +72,6 @@ int main(void)
|
|||
/* 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
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ static void status_led(bool on)
|
|||
void rn42_task_init(void)
|
||||
{
|
||||
battery_init();
|
||||
#ifdef NKRO_ENABLE
|
||||
rn42_nkro_last = keyboard_nkro;
|
||||
#endif
|
||||
}
|
||||
|
||||
void rn42_task(void)
|
||||
|
|
@ -69,14 +72,25 @@ void rn42_task(void)
|
|||
}
|
||||
}
|
||||
|
||||
/* 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);
|
||||
/* Switch between USB and Bluetooth */
|
||||
if (!config_mode) { // not switch while config mode
|
||||
if (!force_usb && !rn42_rts()) {
|
||||
if (host_get_driver() != &rn42_driver) {
|
||||
clear_keyboard();
|
||||
#ifdef NKRO_ENABLE
|
||||
rn42_nkro_last = keyboard_nkro;
|
||||
keyboard_nkro = false;
|
||||
#endif
|
||||
host_set_driver(&rn42_driver);
|
||||
}
|
||||
} else {
|
||||
if (host_get_driver() != &lufa_driver) {
|
||||
clear_keyboard();
|
||||
#ifdef NKRO_ENABLE
|
||||
keyboard_nkro = rn42_nkro_last;
|
||||
#endif
|
||||
host_set_driver(&lufa_driver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -339,8 +353,6 @@ bool command_extra(uint8_t code)
|
|||
} else {
|
||||
print("USB mode\n");
|
||||
force_usb = true;
|
||||
clear_keyboard();
|
||||
host_set_driver(&lufa_driver);
|
||||
}
|
||||
return true;
|
||||
case KC_DELETE:
|
||||
|
|
@ -360,6 +372,14 @@ bool command_extra(uint8_t code)
|
|||
case KC_SCROLLLOCK:
|
||||
init_rn42();
|
||||
return true;
|
||||
#ifdef NKRO_ENABLE
|
||||
case KC_N:
|
||||
if (host_get_driver() != &lufa_driver) {
|
||||
// ignored unless USB mode
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
default:
|
||||
if (config_mode)
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@
|
|||
#include <stdbool.h>
|
||||
#include "rn42.h"
|
||||
|
||||
#ifdef NKRO_ENABLE
|
||||
bool rn42_nkro_last;
|
||||
#endif
|
||||
|
||||
void rn42_task_init(void);
|
||||
void rn42_task(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@ const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section ("
|
|||
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
|
||||
#endif
|
||||
[0] = UNIMAP_HHKB(
|
||||
ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV,
|
||||
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_,
|
||||
LPRN, Z, X, C, V, B, N, M, COMM,DOT, SLS2, RSFT,L1,
|
||||
LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLS2, RSFT,L1,
|
||||
LGUI,LALT, SPC4, RALT,RGUI),
|
||||
|
||||
[1] = UNIMAP_HHKB(
|
||||
|
|
@ -71,14 +71,14 @@ const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
|
|||
|
||||
[3] = UNIMAP_HHKB(
|
||||
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL,
|
||||
APSW,NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BACK,FRWD, APSW,
|
||||
TAB, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BACK,FRWD, TAB,
|
||||
LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,TRNS,NO, ENT,
|
||||
LSFT, NO, NO, NO, NO, BTN3,BTN2,BTN1,BACK,FRWD,NO, RSFT,TRNS,
|
||||
LGUI,LALT, BTN1, TRNS,TRNS),
|
||||
|
||||
[4] = UNIMAP_HHKB(
|
||||
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL,
|
||||
APSW,NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BTN4,BTN5, APSW,
|
||||
TAB, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BTN4,BTN5, TAB,
|
||||
LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT,
|
||||
LSFT, NO, NO, NO, NO, BTN3,BTN2,BTN1,BACK,FRWD,NO, RSFT,TRNS,
|
||||
TRNS,TRNS, TRNS, TRNS,TRNS),
|
||||
|
|
@ -101,6 +101,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
|||
MACRO( D(VOLU), U(VOLU), END ) :
|
||||
MACRO_NONE );
|
||||
case ALT_TAB:
|
||||
// XXX: doesn't work after stuck key fix
|
||||
return (record->event.pressed ?
|
||||
MACRO( D(LALT), D(TAB), END ) :
|
||||
MACRO( U(TAB), END ));
|
||||
|
|
@ -122,6 +123,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
|
|||
|
||||
switch (id) {
|
||||
case LSHIFT_LPAREN:
|
||||
// XXX: doesn't work with other tap key. iffy at least
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -5,18 +5,7 @@ flabbergast's TMK/ChibiOS port
|
|||
|
||||
Build
|
||||
-----
|
||||
$ git clone -b chibios https://github.com/flabbergast/tmk_keyboard.git
|
||||
|
||||
$ cd tmk_keyboard
|
||||
$ git submodule add -f -b kinetis https://github.com/flabbergast/ChibiOS.git tmk_core/tool/chibios/chibios
|
||||
or
|
||||
$ cd tmk_keyboard/tmk_core/tool/chibios
|
||||
$ git clone -b kinetis https://github.com/flabbergast/ChibiOS.git tmk_core/tool/chibios/chibios
|
||||
|
||||
$ cd tmk_keyboard/keyboard/infinity_chibios
|
||||
$ make
|
||||
|
||||
|
||||
Set up ChibiOS according to tmk_core/protocol/chibios/README.md
|
||||
|
||||
|
||||
Chibios Configuration
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ TARGET_DIR = .
|
|||
|
||||
# project specific files
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
onekey.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ TARGET_DIR = .
|
|||
|
||||
# project specific files
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
onekey.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ TARGET_DIR = .
|
|||
|
||||
# keyboard dependent files
|
||||
SRC = keymap.c \
|
||||
matrix.c \
|
||||
onekey.c \
|
||||
vusb_osccal.c \
|
||||
led.c
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
|
@ -18,7 +19,8 @@ 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
|
||||
#MCU = atmega328p
|
||||
MCU = attiny85
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
|
|
@ -26,7 +28,9 @@ MCU = atmega328p
|
|||
# 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
|
||||
#F_CPU = 12000000
|
||||
# Xtal-less internal RC oscillator
|
||||
F_CPU = 16500000
|
||||
|
||||
|
||||
# Build Options
|
||||
|
|
@ -35,13 +39,19 @@ F_CPU = 12000000
|
|||
#MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
#EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
#NKRO_ENABLE = yes # USB Nkey Rollover
|
||||
NO_UART = yes # No UART debug(V-USB)
|
||||
|
||||
OPT_DEFS += -DNO_ACTION_TAPPING
|
||||
OPT_DEFS += -DNO_ACTION_LAYER
|
||||
OPT_DEFS += -DNO_ACTION_MACRO
|
||||
|
||||
|
||||
|
||||
#---------------- Programming Options --------------------------
|
||||
AVRDUDE = avrdude
|
||||
# Type: avrdude -c ? to get a full listing.
|
||||
AVRDUDE_PROGRAMMER = usbasp
|
||||
#AVRDUDE_PROGRAMMER = usbasp
|
||||
AVRDUDE_PROGRAMMER = avrispmkii
|
||||
AVRDUDE_PORT =
|
||||
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
Onekey
|
||||
======
|
||||
Just one key keyboard for example. It sends 'a' key if pins PB0 and PB1 are short-circuited.
|
||||
Just one key keyboard for example. It sends 'a' key if pins PB0 and GND are short-circuited.
|
||||
|
||||
https://github.com/tmk/tmk_keyboard/issues/56
|
||||
|
|
|
|||
68
keyboard/onekey/VUSB.md
Normal file
68
keyboard/onekey/VUSB.md
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
TMK with Xtal-less V-USB
|
||||
========================
|
||||
|
||||
TMK onekey works on ATtiny85.
|
||||
|
||||
$ make -f Makefile.vusb
|
||||
|
||||
...
|
||||
|
||||
Size after:
|
||||
text data bss dec hex filename
|
||||
5518 14 254 5786 169a onekey_vusb.elf
|
||||
|
||||
-------- end --------
|
||||
|
||||
|
||||
https://i.imgur.com/sNa302J.jpg
|
||||
|
||||
|
||||
Program with AVRISPmkII
|
||||
-----------------------
|
||||
D- and D+ lines are need to be disconnected when programed.
|
||||
|
||||
$ avrdude -p attiny85 -c avrispmkii -U flash:w:onekey_vusb.hex
|
||||
|
||||
|
||||
Xtal-less internal RC
|
||||
---------------------
|
||||
http://codeandlife.com/2012/02/22/v-usb-with-attiny45-attiny85-without-a-crystal/
|
||||
|
||||
Configure fuses for PLL, internal RC and BOD(Brown out detection).
|
||||
|
||||
$ avrdude -c avrispmkii -p attiny85 -U lfuse:w:0xe1:m -U hfuse:w:0xdd:m
|
||||
|
||||
Set 16.5MHz to F_CPU in Makefile
|
||||
|
||||
F_CPU = 16500000
|
||||
|
||||
Add settings for calibration in usbconfig.h
|
||||
|
||||
diff --git a/keyboard/onekey/usbconfig.h b/keyboard/onekey/usbconfig.h
|
||||
index e9b4f98..01e5aa6 100644
|
||||
--- a/keyboard/onekey/usbconfig.h
|
||||
+++ b/keyboard/onekey/usbconfig.h
|
||||
@@ -161,7 +161,11 @@ section at the end of this file).
|
||||
* 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();} */
|
||||
+#define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();}
|
||||
+/* http://codeandlife.com/2012/02/22/v-usb-with-attiny45-attiny85-without-a-crystal/ */
|
||||
+#ifndef __ASSEMBLER__
|
||||
+extern void hadUsbReset(void); // define the function for usbdrv.c
|
||||
+#endif
|
||||
/* 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.
|
||||
@@ -202,7 +206,7 @@ section at the end of this file).
|
||||
* 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 USB_CFG_HAVE_MEASURE_FRAME_LENGTH 1
|
||||
|
||||
|
||||
Another calibration code
|
||||
========================
|
||||
https://github.com/obdev/v-usb/tree/master/libs-device
|
||||
|
|
@ -1,133 +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);
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
inline
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return matrix[row];
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
70
keyboard/onekey/onekey.c
Normal file
70
keyboard/onekey/onekey.c
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
Copyright 2017 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 "debug.h"
|
||||
#include "timer.h"
|
||||
#include "matrix.h"
|
||||
|
||||
|
||||
#ifndef DEBOUNCE
|
||||
# define DEBOUNCE 5
|
||||
#endif
|
||||
/* matrix state(1:on, 0:off) */
|
||||
static matrix_row_t row_debounced = 0;
|
||||
static matrix_row_t row_debouncing = 0;
|
||||
static bool debouncing = false;
|
||||
static uint16_t debouncing_time = 0;
|
||||
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
debug_enable = true;
|
||||
debug_matrix = true;
|
||||
debug_mouse = true;
|
||||
|
||||
// PB0: Input with pull-up(DDR:0, PORT:1)
|
||||
DDRB &= ~(1<<0);
|
||||
PORTB |= (1<<0);
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
matrix_row_t r = (PINB&(1<<0) ? 0 : 1);
|
||||
if (row_debouncing != r) {
|
||||
row_debouncing = r;
|
||||
debouncing = true;
|
||||
debouncing_time = timer_read();
|
||||
}
|
||||
|
||||
if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) {
|
||||
row_debounced = row_debouncing;
|
||||
debouncing = false;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline
|
||||
matrix_row_t matrix_get_row(uint8_t row)
|
||||
{
|
||||
return row_debounced;
|
||||
}
|
||||
|
|
@ -24,11 +24,11 @@ section at the end of this file).
|
|||
|
||||
/* ---------------------------- Hardware Config ---------------------------- */
|
||||
|
||||
#define USB_CFG_IOPORTNAME D
|
||||
#define USB_CFG_IOPORTNAME B
|
||||
/* 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
|
||||
#define USB_CFG_DMINUS_BIT 1
|
||||
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
|
||||
* This may be any bit in the port.
|
||||
*/
|
||||
|
|
@ -161,7 +161,11 @@ section at the end of this file).
|
|||
* 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();} */
|
||||
#define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();}
|
||||
/* http://codeandlife.com/2012/02/22/v-usb-with-attiny45-attiny85-without-a-crystal/ */
|
||||
#ifndef __ASSEMBLER__
|
||||
extern void hadUsbReset(void); // define the function for usbdrv.c
|
||||
#endif
|
||||
/* 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.
|
||||
|
|
@ -202,7 +206,7 @@ section at the end of this file).
|
|||
* 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 USB_CFG_HAVE_MEASURE_FRAME_LENGTH 1
|
||||
/* 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.
|
||||
*/
|
||||
|
|
@ -250,8 +254,8 @@ section at the end of this file).
|
|||
* 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
|
||||
#define USB_CFG_DEVICE_NAME 'O', 'n', 'e', 'k', 'e', 'y'
|
||||
#define USB_CFG_DEVICE_NAME_LEN 6
|
||||
/* 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.
|
||||
|
|
|
|||
37
keyboard/onekey/vusb_osccal.c
Normal file
37
keyboard/onekey/vusb_osccal.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// V-USB with ATtiny45 / ATtiny85 without a crystal
|
||||
// http://codeandlife.com/2012/02/22/v-usb-with-attiny45-attiny85-without-a-crystal/
|
||||
#include <avr/io.h>
|
||||
#include <usbdrv.h>
|
||||
|
||||
|
||||
#define abs(x) ((x) > 0 ? (x) : (-x))
|
||||
|
||||
// Called by V-USB after device reset
|
||||
void hadUsbReset() {
|
||||
int frameLength, targetLength = (unsigned)(1499 * (double)F_CPU / 10.5e6 + 0.5);
|
||||
int bestDeviation = 9999;
|
||||
uint8_t trialCal, bestCal, step, region;
|
||||
|
||||
// do a binary search in regions 0-127 and 128-255 to get optimum OSCCAL
|
||||
for(region = 0; region <= 1; region++) {
|
||||
frameLength = 0;
|
||||
trialCal = (region == 0) ? 0 : 128;
|
||||
|
||||
for(step = 64; step > 0; step >>= 1) {
|
||||
if(frameLength < targetLength) // true for initial iteration
|
||||
trialCal += step; // frequency too low
|
||||
else
|
||||
trialCal -= step; // frequency too high
|
||||
|
||||
OSCCAL = trialCal;
|
||||
frameLength = usbMeasureFrameLength();
|
||||
|
||||
if(abs(frameLength-targetLength) < bestDeviation) {
|
||||
bestCal = trialCal; // new optimum found
|
||||
bestDeviation = abs(frameLength -targetLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OSCCAL = bestCal;
|
||||
}
|
||||
77
keyboard/teensy3.2_tkl/Makefile
Normal file
77
keyboard/teensy3.2_tkl/Makefile
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
# Target file name (without extension).
|
||||
PROJECT = ch
|
||||
|
||||
# Directory common source files exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# project specific files
|
||||
SRC = matrix.c \
|
||||
led.c
|
||||
|
||||
ifdef KEYMAP
|
||||
SRC := keymap_$(KEYMAP).c $(SRC)
|
||||
else
|
||||
SRC := keymap_plain.c $(SRC)
|
||||
endif
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
# - For Teensies, FAMILY = KINETIS and SERIES is either
|
||||
# KL2x (LC) or K20x (3.0,3.1,3.2).
|
||||
MCU_FAMILY = KINETIS
|
||||
MCU_SERIES = KL2x
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
|
||||
# or <this_dir>/ld/
|
||||
# - NOTE: a custom ld script is needed for EEPROM on Teensy LC
|
||||
# - LDSCRIPT =
|
||||
# - MKL26Z64 for Teensy LC
|
||||
# - MK20DX128 for Teensy 3.0
|
||||
# - MK20DX256 for Teensy 3.1 and 3.2
|
||||
MCU_LDSCRIPT = MKL26Z64
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/ports/ARMCMx/compilers/GCC/mk/
|
||||
# - STARTUP =
|
||||
# - kl2x for Teensy LC
|
||||
# - k20x5 for Teensy 3.0
|
||||
# - k20x7 for Teensy 3.1 and 3.2
|
||||
MCU_STARTUP = kl2x
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/
|
||||
# or <this_dir>/boards
|
||||
# - BOARD =
|
||||
# - PJRC_TEENSY_LC for Teensy LC
|
||||
# - PJRC_TEENSY_3 for Teensy 3.0
|
||||
# - PJRC_TEENSY_3_1 for Teensy 3.1 or 3.2
|
||||
BOARD = PJRC_TEENSY_LC
|
||||
|
||||
# Cortex version
|
||||
# Teensy LC is cortex-m0plus; Teensy 3.x are cortex-m4
|
||||
MCU = cortex-m0plus
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
# I.e. 6 for Teensy LC; 7 for Teensy 3.x
|
||||
ARMV = 6
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
|
||||
## (Note that for BOOTMAGIC on Teensy LC you have to use a custom .ld script.)
|
||||
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
|
||||
SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
NKRO_ENABLE = yes # USB Nkey Rollover
|
||||
|
||||
include $(TMK_DIR)/tool/chibios/common.mk
|
||||
include $(TMK_DIR)/tool/chibios/chibios.mk
|
||||
77
keyboard/teensy3.2_tkl/Makefile.3.0
Normal file
77
keyboard/teensy3.2_tkl/Makefile.3.0
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
# Target file name (without extension).
|
||||
PROJECT = ch
|
||||
|
||||
# Directory common source files exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# project specific files
|
||||
SRC = matrix.c \
|
||||
led.c
|
||||
|
||||
ifdef KEYMAP
|
||||
SRC := keymap_$(KEYMAP).c $(SRC)
|
||||
else
|
||||
SRC := keymap_plain.c $(SRC)
|
||||
endif
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
# - For Teensies, FAMILY = KINETIS and SERIES is either
|
||||
# KL2x (LC) or K20x (3.0,3.1,3.2).
|
||||
MCU_FAMILY = KINETIS
|
||||
MCU_SERIES = K20x
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
|
||||
# or <this_dir>/ld/
|
||||
# - NOTE: a custom ld script is needed for EEPROM on Teensy LC
|
||||
# - LDSCRIPT =
|
||||
# - MKL26Z64 for Teensy LC
|
||||
# - MK20DX128 for Teensy 3.0
|
||||
# - MK20DX256 for Teensy 3.1 and 3.2
|
||||
MCU_LDSCRIPT = MK20DX128
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/ports/ARMCMx/compilers/GCC/mk/
|
||||
# - STARTUP =
|
||||
# - kl2x for Teensy LC
|
||||
# - k20x5 for Teensy 3.0
|
||||
# - k20x7 for Teensy 3.1 and 3.2
|
||||
MCU_STARTUP = k20x5
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/
|
||||
# or <this_dir>/boards
|
||||
# - BOARD =
|
||||
# - PJRC_TEENSY_LC for Teensy LC
|
||||
# - PJRC_TEENSY_3 for Teensy 3.0
|
||||
# - PJRC_TEENSY_3_1 for Teensy 3.1 or 3.2
|
||||
BOARD = PJRC_TEENSY_3
|
||||
|
||||
# Cortex version
|
||||
# Teensy LC is cortex-m0; Teensy 3.x are cortex-m4
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
# I.e. 6 for Teensy LC; 7 for Teensy 3.x
|
||||
ARMV = 7
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
|
||||
## (Note that for BOOTMAGIC on Teensy LC you have to use a custom .ld script.)
|
||||
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
|
||||
SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
NKRO_ENABLE = yes # USB Nkey Rollover
|
||||
|
||||
include $(TMK_DIR)/tool/chibios/common.mk
|
||||
include $(TMK_DIR)/tool/chibios/chibios.mk
|
||||
77
keyboard/teensy3.2_tkl/Makefile.3.2
Normal file
77
keyboard/teensy3.2_tkl/Makefile.3.2
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
# Target file name (without extension).
|
||||
PROJECT = ch
|
||||
|
||||
# Directory common source files exist
|
||||
TMK_DIR = ../../tmk_core
|
||||
|
||||
# Directory keyboard dependent files exist
|
||||
TARGET_DIR = .
|
||||
|
||||
# project specific files
|
||||
SRC = matrix.c \
|
||||
led.c
|
||||
|
||||
ifdef KEYMAP
|
||||
SRC := keymap_$(KEYMAP).c $(SRC)
|
||||
else
|
||||
SRC := keymap_plain.c $(SRC)
|
||||
endif
|
||||
|
||||
CONFIG_H = config.h
|
||||
|
||||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
# - For Teensies, FAMILY = KINETIS and SERIES is either
|
||||
# KL2x (LC) or K20x (3.0,3.1,3.2).
|
||||
MCU_FAMILY = KINETIS
|
||||
MCU_SERIES = K20x
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
|
||||
# or <this_dir>/ld/
|
||||
# - NOTE: a custom ld script is needed for EEPROM on Teensy LC
|
||||
# - LDSCRIPT =
|
||||
# - MKL26Z64 for Teensy LC
|
||||
# - MK20DX128 for Teensy 3.0
|
||||
# - MK20DX256 for Teensy 3.1 and 3.2
|
||||
MCU_LDSCRIPT = MK20DX256
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/ports/ARMCMx/compilers/GCC/mk/
|
||||
# - STARTUP =
|
||||
# - kl2x for Teensy LC
|
||||
# - k20x5 for Teensy 3.0
|
||||
# - k20x7 for Teensy 3.1 and 3.2
|
||||
MCU_STARTUP = k20x7
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/
|
||||
# or <this_dir>/boards
|
||||
# - BOARD =
|
||||
# - PJRC_TEENSY_LC for Teensy LC
|
||||
# - PJRC_TEENSY_3 for Teensy 3.0
|
||||
# - PJRC_TEENSY_3_1 for Teensy 3.1 or 3.2
|
||||
BOARD = PJRC_TEENSY_3_1
|
||||
|
||||
# Cortex version
|
||||
# Teensy LC is cortex-m0; Teensy 3.x are cortex-m4
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
# I.e. 6 for Teensy LC; 7 for Teensy 3.x
|
||||
ARMV = 7
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
|
||||
## (Note that for BOOTMAGIC on Teensy LC you have to use a custom .ld script.)
|
||||
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
|
||||
SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||
NKRO_ENABLE = yes # USB Nkey Rollover
|
||||
|
||||
include $(TMK_DIR)/tool/chibios/common.mk
|
||||
include $(TMK_DIR)/tool/chibios/chibios.mk
|
||||
524
keyboard/teensy3.2_tkl/chconf.h
Normal file
524
keyboard/teensy3.2_tkl/chconf.h
Normal file
|
|
@ -0,0 +1,524 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file templates/chconf.h
|
||||
* @brief Configuration file template.
|
||||
* @details A copy of this file must be placed in each project directory, it
|
||||
* contains the application specific kernel settings.
|
||||
*
|
||||
* @addtogroup config
|
||||
* @details Kernel related settings and hooks.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef CHCONF_H
|
||||
#define CHCONF_H
|
||||
|
||||
#define _CHIBIOS_RT_CONF_
|
||||
|
||||
/*===========================================================================*/
|
||||
/**
|
||||
* @name System timers settings
|
||||
* @{
|
||||
*/
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief System time counter resolution.
|
||||
* @note Allowed values are 16 or 32 bits.
|
||||
*/
|
||||
#define CH_CFG_ST_RESOLUTION 32
|
||||
|
||||
/**
|
||||
* @brief System tick frequency.
|
||||
* @details Frequency of the system timer that drives the system ticks. This
|
||||
* setting also defines the system tick time unit.
|
||||
*/
|
||||
#define CH_CFG_ST_FREQUENCY 1000
|
||||
|
||||
/**
|
||||
* @brief Time delta constant for the tick-less mode.
|
||||
* @note If this value is zero then the system uses the classic
|
||||
* periodic tick. This value represents the minimum number
|
||||
* of ticks that is safe to specify in a timeout directive.
|
||||
* The value one is not valid, timeouts are rounded up to
|
||||
* this value.
|
||||
*/
|
||||
#define CH_CFG_ST_TIMEDELTA 0
|
||||
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/**
|
||||
* @name Kernel parameters and options
|
||||
* @{
|
||||
*/
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Round robin interval.
|
||||
* @details This constant is the number of system ticks allowed for the
|
||||
* threads before preemption occurs. Setting this value to zero
|
||||
* disables the preemption for threads with equal priority and the
|
||||
* round robin becomes cooperative. Note that higher priority
|
||||
* threads can still preempt, the kernel is always preemptive.
|
||||
* @note Disabling the round robin preemption makes the kernel more compact
|
||||
* and generally faster.
|
||||
* @note The round robin preemption is not supported in tickless mode and
|
||||
* must be set to zero in that case.
|
||||
*/
|
||||
#define CH_CFG_TIME_QUANTUM 20
|
||||
|
||||
/**
|
||||
* @brief Managed RAM size.
|
||||
* @details Size of the RAM area to be managed by the OS. If set to zero
|
||||
* then the whole available RAM is used. The core memory is made
|
||||
* available to the heap allocator and/or can be used directly through
|
||||
* the simplified core memory allocator.
|
||||
*
|
||||
* @note In order to let the OS manage the whole RAM the linker script must
|
||||
* provide the @p __heap_base__ and @p __heap_end__ symbols.
|
||||
* @note Requires @p CH_CFG_USE_MEMCORE.
|
||||
*/
|
||||
#define CH_CFG_MEMCORE_SIZE 0
|
||||
|
||||
/**
|
||||
* @brief Idle thread automatic spawn suppression.
|
||||
* @details When this option is activated the function @p chSysInit()
|
||||
* does not spawn the idle thread. The application @p main()
|
||||
* function becomes the idle thread and must implement an
|
||||
* infinite loop.
|
||||
*/
|
||||
#define CH_CFG_NO_IDLE_THREAD FALSE
|
||||
|
||||
/* Use __WFI in the idle thread for waiting. Does lower the power
|
||||
* consumption. */
|
||||
#define CORTEX_ENABLE_WFI_IDLE TRUE
|
||||
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/**
|
||||
* @name Performance options
|
||||
* @{
|
||||
*/
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief OS optimization.
|
||||
* @details If enabled then time efficient rather than space efficient code
|
||||
* is used when two possible implementations exist.
|
||||
*
|
||||
* @note This is not related to the compiler optimization options.
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#define CH_CFG_OPTIMIZE_SPEED TRUE
|
||||
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/**
|
||||
* @name Subsystem options
|
||||
* @{
|
||||
*/
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Time Measurement APIs.
|
||||
* @details If enabled then the time measurement APIs are included in
|
||||
* the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#define CH_CFG_USE_TM FALSE
|
||||
|
||||
/**
|
||||
* @brief Threads registry APIs.
|
||||
* @details If enabled then the registry APIs are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#define CH_CFG_USE_REGISTRY TRUE
|
||||
|
||||
/**
|
||||
* @brief Threads synchronization APIs.
|
||||
* @details If enabled then the @p chThdWait() function is included in
|
||||
* the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#define CH_CFG_USE_WAITEXIT TRUE
|
||||
|
||||
/**
|
||||
* @brief Semaphores APIs.
|
||||
* @details If enabled then the Semaphores APIs are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#define CH_CFG_USE_SEMAPHORES TRUE
|
||||
|
||||
/**
|
||||
* @brief Semaphores queuing mode.
|
||||
* @details If enabled then the threads are enqueued on semaphores by
|
||||
* priority rather than in FIFO order.
|
||||
*
|
||||
* @note The default is @p FALSE. Enable this if you have special
|
||||
* requirements.
|
||||
* @note Requires @p CH_CFG_USE_SEMAPHORES.
|
||||
*/
|
||||
#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
|
||||
|
||||
/**
|
||||
* @brief Mutexes APIs.
|
||||
* @details If enabled then the mutexes APIs are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#define CH_CFG_USE_MUTEXES TRUE
|
||||
|
||||
/**
|
||||
* @brief Enables recursive behavior on mutexes.
|
||||
* @note Recursive mutexes are heavier and have an increased
|
||||
* memory footprint.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
* @note Requires @p CH_CFG_USE_MUTEXES.
|
||||
*/
|
||||
#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
|
||||
|
||||
/**
|
||||
* @brief Conditional Variables APIs.
|
||||
* @details If enabled then the conditional variables APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_CFG_USE_MUTEXES.
|
||||
*/
|
||||
#define CH_CFG_USE_CONDVARS TRUE
|
||||
|
||||
/**
|
||||
* @brief Conditional Variables APIs with timeout.
|
||||
* @details If enabled then the conditional variables APIs with timeout
|
||||
* specification are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_CFG_USE_CONDVARS.
|
||||
*/
|
||||
#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
|
||||
|
||||
/**
|
||||
* @brief Events Flags APIs.
|
||||
* @details If enabled then the event flags APIs are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#define CH_CFG_USE_EVENTS TRUE
|
||||
|
||||
/**
|
||||
* @brief Events Flags APIs with timeout.
|
||||
* @details If enabled then the events APIs with timeout specification
|
||||
* are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_CFG_USE_EVENTS.
|
||||
*/
|
||||
#define CH_CFG_USE_EVENTS_TIMEOUT TRUE
|
||||
|
||||
/**
|
||||
* @brief Synchronous Messages APIs.
|
||||
* @details If enabled then the synchronous messages APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#define CH_CFG_USE_MESSAGES TRUE
|
||||
|
||||
/**
|
||||
* @brief Synchronous Messages queuing mode.
|
||||
* @details If enabled then messages are served by priority rather than in
|
||||
* FIFO order.
|
||||
*
|
||||
* @note The default is @p FALSE. Enable this if you have special
|
||||
* requirements.
|
||||
* @note Requires @p CH_CFG_USE_MESSAGES.
|
||||
*/
|
||||
#define CH_CFG_USE_MESSAGES_PRIORITY FALSE
|
||||
|
||||
/**
|
||||
* @brief Mailboxes APIs.
|
||||
* @details If enabled then the asynchronous messages (mailboxes) APIs are
|
||||
* included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_CFG_USE_SEMAPHORES.
|
||||
*/
|
||||
#define CH_CFG_USE_MAILBOXES TRUE
|
||||
|
||||
/**
|
||||
* @brief Core Memory Manager APIs.
|
||||
* @details If enabled then the core memory manager APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#define CH_CFG_USE_MEMCORE TRUE
|
||||
|
||||
/**
|
||||
* @brief Heap Allocator APIs.
|
||||
* @details If enabled then the memory heap allocator APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
|
||||
* @p CH_CFG_USE_SEMAPHORES.
|
||||
* @note Mutexes are recommended.
|
||||
*/
|
||||
#define CH_CFG_USE_HEAP TRUE
|
||||
|
||||
/**
|
||||
* @brief Memory Pools Allocator APIs.
|
||||
* @details If enabled then the memory pools allocator APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#define CH_CFG_USE_MEMPOOLS TRUE
|
||||
|
||||
/**
|
||||
* @brief Dynamic Threads APIs.
|
||||
* @details If enabled then the dynamic threads creation APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_CFG_USE_WAITEXIT.
|
||||
* @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
|
||||
*/
|
||||
#define CH_CFG_USE_DYNAMIC TRUE
|
||||
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/**
|
||||
* @name Debug options
|
||||
* @{
|
||||
*/
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Debug option, kernel statistics.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#define CH_DBG_STATISTICS FALSE
|
||||
|
||||
/**
|
||||
* @brief Debug option, system state check.
|
||||
* @details If enabled the correct call protocol for system APIs is checked
|
||||
* at runtime.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#define CH_DBG_SYSTEM_STATE_CHECK TRUE
|
||||
|
||||
/**
|
||||
* @brief Debug option, parameters checks.
|
||||
* @details If enabled then the checks on the API functions input
|
||||
* parameters are activated.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#define CH_DBG_ENABLE_CHECKS TRUE
|
||||
|
||||
/**
|
||||
* @brief Debug option, consistency checks.
|
||||
* @details If enabled then all the assertions in the kernel code are
|
||||
* activated. This includes consistency checks inside the kernel,
|
||||
* runtime anomalies and port-defined checks.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#define CH_DBG_ENABLE_ASSERTS TRUE
|
||||
|
||||
/**
|
||||
* @brief Debug option, trace buffer.
|
||||
* @details If enabled then the trace buffer is activated.
|
||||
*
|
||||
* @note The default is @p CH_DBG_TRACE_MASK_DISABLED.
|
||||
*/
|
||||
#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED
|
||||
|
||||
/**
|
||||
* @brief Trace buffer entries.
|
||||
* @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
|
||||
* different from @p CH_DBG_TRACE_MASK_DISABLED.
|
||||
*/
|
||||
#define CH_DBG_TRACE_BUFFER_SIZE 128
|
||||
|
||||
/**
|
||||
* @brief Debug option, stack checks.
|
||||
* @details If enabled then a runtime stack check is performed.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
* @note The stack check is performed in a architecture/port dependent way.
|
||||
* It may not be implemented or some ports.
|
||||
* @note The default failure mode is to halt the system with the global
|
||||
* @p panic_msg variable set to @p NULL.
|
||||
*/
|
||||
#define CH_DBG_ENABLE_STACK_CHECK TRUE
|
||||
|
||||
/**
|
||||
* @brief Debug option, stacks initialization.
|
||||
* @details If enabled then the threads working area is filled with a byte
|
||||
* value when a thread is created. This can be useful for the
|
||||
* runtime measurement of the used stack.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#define CH_DBG_FILL_THREADS TRUE
|
||||
|
||||
/**
|
||||
* @brief Debug option, threads profiling.
|
||||
* @details If enabled then a field is added to the @p thread_t structure that
|
||||
* counts the system ticks occurred while executing the thread.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
* @note This debug option is not currently compatible with the
|
||||
* tickless mode.
|
||||
*/
|
||||
#define CH_DBG_THREADS_PROFILING FALSE
|
||||
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/**
|
||||
* @name Kernel hooks
|
||||
* @{
|
||||
*/
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Threads descriptor structure extension.
|
||||
* @details User fields added to the end of the @p thread_t structure.
|
||||
*/
|
||||
#define CH_CFG_THREAD_EXTRA_FIELDS \
|
||||
/* Add threads custom fields here.*/
|
||||
|
||||
/**
|
||||
* @brief Threads initialization hook.
|
||||
* @details User initialization code added to the @p chThdInit() API.
|
||||
*
|
||||
* @note It is invoked from within @p chThdInit() and implicitly from all
|
||||
* the threads creation APIs.
|
||||
*/
|
||||
#define CH_CFG_THREAD_INIT_HOOK(tp) { \
|
||||
/* Add threads initialization code here.*/ \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Threads finalization hook.
|
||||
* @details User finalization code added to the @p chThdExit() API.
|
||||
*/
|
||||
#define CH_CFG_THREAD_EXIT_HOOK(tp) { \
|
||||
/* Add threads finalization code here.*/ \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Context switch hook.
|
||||
* @details This hook is invoked just before switching between threads.
|
||||
*/
|
||||
#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
|
||||
/* Context switch code here.*/ \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ISR enter hook.
|
||||
*/
|
||||
#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
|
||||
/* IRQ prologue code here.*/ \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ISR exit hook.
|
||||
*/
|
||||
#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
|
||||
/* IRQ epilogue code here.*/ \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Idle thread enter hook.
|
||||
* @note This hook is invoked within a critical zone, no OS functions
|
||||
* should be invoked from here.
|
||||
* @note This macro can be used to activate a power saving mode.
|
||||
*/
|
||||
#define CH_CFG_IDLE_ENTER_HOOK() { \
|
||||
/* Idle-enter code here.*/ \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Idle thread leave hook.
|
||||
* @note This hook is invoked within a critical zone, no OS functions
|
||||
* should be invoked from here.
|
||||
* @note This macro can be used to deactivate a power saving mode.
|
||||
*/
|
||||
#define CH_CFG_IDLE_LEAVE_HOOK() { \
|
||||
/* Idle-leave code here.*/ \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Idle Loop hook.
|
||||
* @details This hook is continuously invoked by the idle thread loop.
|
||||
*/
|
||||
#define CH_CFG_IDLE_LOOP_HOOK() { \
|
||||
/* Idle loop code here.*/ \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief System tick event hook.
|
||||
* @details This hook is invoked in the system tick handler immediately
|
||||
* after processing the virtual timers queue.
|
||||
*/
|
||||
#define CH_CFG_SYSTEM_TICK_HOOK() { \
|
||||
/* System tick event code here.*/ \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief System halt hook.
|
||||
* @details This hook is invoked in case to a system halting error before
|
||||
* the system is halted.
|
||||
*/
|
||||
#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
|
||||
/* System halt code here.*/ \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Trace hook.
|
||||
* @details This hook is invoked each time a new record is written in the
|
||||
* trace buffer.
|
||||
*/
|
||||
#define CH_CFG_TRACE_HOOK(tep) { \
|
||||
/* Trace code here.*/ \
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Port-specific settings (override port settings defaulted in chcore.h). */
|
||||
/*===========================================================================*/
|
||||
|
||||
#endif /* CHCONF_H */
|
||||
|
||||
/** @} */
|
||||
74
keyboard/teensy3.2_tkl/config.h
Normal file
74
keyboard/teensy3.2_tkl/config.h
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
Copyright 2015 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 0x6464
|
||||
#define DEVICE_VER 0x0001
|
||||
/* in python2: list(u"whatever".encode('utf-16-le')) */
|
||||
/* at most 32 characters or the ugly hack in usb_main.c borks */
|
||||
#define MANUFACTURER "TMK"
|
||||
#define USBSTR_MANUFACTURER 'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', '\xc6', '\x00'
|
||||
#define PRODUCT "ChibiOS TMK test"
|
||||
#define USBSTR_PRODUCT 'C', '\x00', 'h', '\x00', 'i', '\x00', 'b', '\x00', 'i', '\x00', 'O', '\x00', 'S', '\x00', ' ', '\x00', 'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', 't', '\x00', 'e', '\x00', 's', '\x00', 't', '\x00'
|
||||
#define DESCRIPTION "TMK keyboard firmware over ChibiOS"
|
||||
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 6
|
||||
#define MATRIX_COLS 17
|
||||
|
||||
/* 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
|
||||
|
||||
#endif
|
||||
187
keyboard/teensy3.2_tkl/halconf.h
Normal file
187
keyboard/teensy3.2_tkl/halconf.h
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file templates/halconf.h
|
||||
* @brief HAL configuration header.
|
||||
* @details HAL configuration file, this file allows to enable or disable the
|
||||
* various device drivers from your application. You may also use
|
||||
* this file in order to override the device drivers default settings.
|
||||
*
|
||||
* @addtogroup HAL_CONF
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _HALCONF_H_
|
||||
#define _HALCONF_H_
|
||||
|
||||
#include "mcuconf.h"
|
||||
|
||||
/**
|
||||
* @brief Enables the PAL subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_PAL TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the ADC subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_ADC FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the CAN subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_CAN FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the DAC subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_DAC FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the EXT subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_EXT FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the GPT subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_GPT FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the I2C subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_I2C FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the I2S subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_I2S FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the ICU subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_ICU FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the MAC subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_MAC FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the MMC_SPI subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_MMC_SPI FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the PWM subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_PWM FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the RTC subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_RTC FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the SDC subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_SDC FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the SERIAL subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_SERIAL FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the SERIAL over USB subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_SERIAL_USB FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the SPI subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_SPI FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the UART subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_UART FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the USB subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_USB TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the WDG subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_WDG FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* USB driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables synchronous APIs.
|
||||
* @note Disabling this option saves both code and data space.
|
||||
*/
|
||||
#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
|
||||
#define USB_USE_WAIT TRUE
|
||||
#endif
|
||||
|
||||
#endif /* _HALCONF_H_ */
|
||||
|
||||
/** @} */
|
||||
76
keyboard/teensy3.2_tkl/instructions.md
Normal file
76
keyboard/teensy3.2_tkl/instructions.md
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
# Teensy LC, 3.0, 3.1, 3.2 support
|
||||
|
||||
These ARM Teensies are now supported through [ChibiOS](http://chibios.org).
|
||||
|
||||
Follow the setup instructions in `tmk_core/protocol/chibios/README.md` to install ChibiOS and required toolchain.
|
||||
|
||||
Running `make` in `keyboard/teensy_lc_onekey` should create a working firmware in `build/`, called `ch.hex`.
|
||||
|
||||
For more notes about the ChibiOS backend in TMK, see `tmk_core/protocol/chibios/README.md`.
|
||||
|
||||
## About this onekey example
|
||||
|
||||
It's set up for Teensy LC. To use 3.x, you'll need to edit the `Makefile` (and comment out one line in `mcuconf.h`). A sample makefile for Teensy 3.0 is provided as `Makefile.3.0`, can be used without renaming with `make -f Makefile.3.0`. Similarly for Teensy 3.2, there's `Makefile.3.2`.
|
||||
|
||||
## Credits
|
||||
|
||||
TMK itself is written by hasu, original sources [here](https://github.com/tmk/tmk_keyboard).
|
||||
|
||||
The USB support for Kinetis MCUs is due to RedoX. His ChibiOS fork is also [on github](https://github.com/RedoXyde/ChibiOS); but it doesn't include Teensy LC definitions.
|
||||
|
||||
## Features that are not implemented yet
|
||||
|
||||
Currently only the more fancy suspend features are not there (power saving during suspend). The rest should work fine (reports either way are welcome).
|
||||
|
||||
# Matrix programming notes
|
||||
|
||||
The notes below explain what commands can be used to examine and set the status of Teensy pins.
|
||||
|
||||
## ChibiOS pin manipulation basics
|
||||
|
||||
### Pins
|
||||
|
||||
Each pin sits on a "port", each of which comprises at most 32 individual pins.
|
||||
So for instance "PTC5" from Kinetis manual/datasheet refers to port C (or GPIOA), pin 5. Most functions dealing with pins take 2 parameters which specify the pin -- the first being the port, the second being the pin number.
|
||||
|
||||
Within ChibiOS, there are definitions which simplify this a bit for the Teensies. `TEENSY_PINn_IOPORT` represents the port of the MCU's pin connected Teensy's PIN `n`, and `TEENSY_PINn` represents its MCU's pin number.
|
||||
|
||||
### Mode
|
||||
|
||||
A MCU pin can be in several modes. The basic command to set a pin mode is
|
||||
|
||||
palSetPadMode(TEENSY_PINn_IOPORT, TEENSY_PINn, PAL_MODE_INPUT_PULLUP);
|
||||
|
||||
The last parameter is the mode. For keyboards, the usual ones that are used are `PAL_MODE_INPUT_PULLUP` (input with a pullup), `PAL_MODE_INPUT_PULLDOWN` (input with a pulldown), `PAL_MODE_INPUT` (input floating, a.k.a. Hi-Z), `PAL_MODE_OUTPUT_PUSHPULL` (output in the Arduino sense -- can be then set HIGH or LOW).
|
||||
|
||||
### Setting
|
||||
|
||||
Pins are set HIGH (after they've been put into `OUTPUT_PUSHPULL` mode) by
|
||||
|
||||
palSetPad(TEENSY_PINn_IOPORT, TEENSY_PINn);
|
||||
|
||||
or set LOW by
|
||||
|
||||
palClearPad(TEENSY_PINn_IOPORT, TEENSY_PINn);
|
||||
|
||||
Toggling can be done with
|
||||
|
||||
palTogglePad(TEENSY_PINn_IOPORT, TEENSY_PINn);
|
||||
|
||||
Alternatively, you can use
|
||||
|
||||
palWritePad(TEENSY_PINn_IOPORT, TEENSY_PINn, bit);
|
||||
|
||||
where `bit` is either `PAL_LOW` or `PAL_HIGH` (i.e. `0` or `1`).
|
||||
|
||||
### Reading
|
||||
|
||||
Reading pin status is done with
|
||||
|
||||
palReadPad(TEENSY_PINn_IOPORT, TEENSY_PINn);
|
||||
|
||||
The function returns either `PAL_HIGH` (actually `1`) or `PAL_LOW` (actually `0`).
|
||||
|
||||
### Further docs
|
||||
|
||||
All the commands that are available for pin manipulation through ChibiOS HAL are documented in [ChibiOS PAL driver docs](http://chibios.sourceforge.net/docs3/hal/group___p_a_l.html).
|
||||
51
keyboard/teensy3.2_tkl/keymap_plain.c
Normal file
51
keyboard/teensy3.2_tkl/keymap_plain.c
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
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 "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 keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = {
|
||||
{KC_ESC, KC_CLR, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_CLR, KC_F9, KC_F10, KC_F11, KC_F12, KC_CLR, KC_CLR},
|
||||
{KC_GRV, 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_CLR, KC_CLR, KC_CLR},
|
||||
{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_BSLASH, KC_PSCR, KC_HOME, KC_PGUP},
|
||||
{KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_CLR, KC_ENTER, KC_DEL, KC_END, KC_PGDN},
|
||||
{KC_LSFT, KC_CLR, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLASH, KC_CLR, KC_RSFT, KC_CLR, KC_UP, KC_CLR},
|
||||
{KC_LCTL, KC_LGUI, KC_LALT, KC_CLR, KC_CLR, KC_CLR, KC_SPC, KC_CLR, KC_CLR, KC_CLR, KC_RALT, KC_RGUI, KC_RCTL, KC_CLR, KC_LEFT, KC_DOWN, KC_RIGHT}
|
||||
}
|
||||
};
|
||||
|
||||
static const action_t fn_actions[] = {
|
||||
};
|
||||
|
||||
/* translates key to keycode */
|
||||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
{
|
||||
return keymaps[(layer)][(key.row)][(key.col)];
|
||||
}
|
||||
|
||||
/* translates Fn keycode to action */
|
||||
action_t keymap_fn_to_action(uint8_t keycode)
|
||||
{
|
||||
return fn_actions[FN_INDEX(keycode)];
|
||||
}
|
||||
105
keyboard/teensy3.2_tkl/ld/MKL26Z64.ld
Normal file
105
keyboard/teensy3.2_tkl/ld/MKL26Z64.ld
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Copyright (C) 2013-2016 Fabio Utzig, http://fabioutzig.com
|
||||
* (C) 2016 flabbergast <s3+flabbergast@sdfeu.org>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* KL26Z64 memory setup.
|
||||
*/
|
||||
MEMORY
|
||||
{
|
||||
flash0 : org = 0x00000000, len = 0x100
|
||||
flash1 : org = 0x00000400, len = 0x10
|
||||
flash2 : org = 0x00000410, len = 62k - 0x410
|
||||
flash3 : org = 0x0000F800, len = 2k
|
||||
flash4 : org = 0x00000000, len = 0
|
||||
flash5 : org = 0x00000000, len = 0
|
||||
flash6 : org = 0x00000000, len = 0
|
||||
flash7 : org = 0x00000000, len = 0
|
||||
ram0 : org = 0x1FFFF800, len = 8k
|
||||
ram1 : org = 0x00000000, len = 0
|
||||
ram2 : org = 0x00000000, len = 0
|
||||
ram3 : org = 0x00000000, len = 0
|
||||
ram4 : org = 0x00000000, len = 0
|
||||
ram5 : org = 0x00000000, len = 0
|
||||
ram6 : org = 0x00000000, len = 0
|
||||
ram7 : org = 0x00000000, len = 0
|
||||
}
|
||||
|
||||
/* Flash region for the configuration bytes.*/
|
||||
SECTIONS
|
||||
{
|
||||
.cfmprotect : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.cfmconfig))
|
||||
} > flash1
|
||||
}
|
||||
|
||||
/* For each data/text section two region are defined, a virtual region
|
||||
and a load region (_LMA suffix).*/
|
||||
|
||||
/* Flash region to be used for exception vectors.*/
|
||||
REGION_ALIAS("VECTORS_FLASH", flash0);
|
||||
REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
|
||||
|
||||
/* Flash region to be used for constructors and destructors.*/
|
||||
REGION_ALIAS("XTORS_FLASH", flash2);
|
||||
REGION_ALIAS("XTORS_FLASH_LMA", flash2);
|
||||
|
||||
/* Flash region to be used for code text.*/
|
||||
REGION_ALIAS("TEXT_FLASH", flash2);
|
||||
REGION_ALIAS("TEXT_FLASH_LMA", flash2);
|
||||
|
||||
/* Flash region to be used for read only data.*/
|
||||
REGION_ALIAS("RODATA_FLASH", flash2);
|
||||
REGION_ALIAS("RODATA_FLASH_LMA", flash2);
|
||||
|
||||
/* Flash region to be used for various.*/
|
||||
REGION_ALIAS("VARIOUS_FLASH", flash2);
|
||||
REGION_ALIAS("VARIOUS_FLASH_LMA", flash2);
|
||||
|
||||
/* Flash region to be used for RAM(n) initialization data.*/
|
||||
REGION_ALIAS("RAM_INIT_FLASH_LMA", flash2);
|
||||
|
||||
/* RAM region to be used for Main stack. This stack accommodates the processing
|
||||
of all exceptions and interrupts.*/
|
||||
REGION_ALIAS("MAIN_STACK_RAM", ram0);
|
||||
|
||||
/* RAM region to be used for the process stack. This is the stack used by
|
||||
the main() function.*/
|
||||
REGION_ALIAS("PROCESS_STACK_RAM", ram0);
|
||||
|
||||
/* RAM region to be used for data segment.*/
|
||||
REGION_ALIAS("DATA_RAM", ram0);
|
||||
REGION_ALIAS("DATA_RAM_LMA", flash2);
|
||||
|
||||
/* RAM region to be used for BSS segment.*/
|
||||
REGION_ALIAS("BSS_RAM", ram0);
|
||||
|
||||
/* RAM region to be used for the default heap.*/
|
||||
REGION_ALIAS("HEAP_RAM", ram0);
|
||||
|
||||
__eeprom_workarea_start__ = ORIGIN(flash3);
|
||||
__eeprom_workarea_size__ = LENGTH(flash3);
|
||||
__eeprom_workarea_end__ = __eeprom_workarea_start__ + __eeprom_workarea_size__;
|
||||
|
||||
/* Generic rules inclusion.*/
|
||||
INCLUDE rules.ld
|
||||
32
keyboard/teensy3.2_tkl/led.c
Normal file
32
keyboard/teensy3.2_tkl/led.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
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 "hal.h"
|
||||
|
||||
#include "led.h"
|
||||
|
||||
|
||||
void led_set(uint8_t usb_led) {
|
||||
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
|
||||
// output high
|
||||
palSetPadMode(TEENSY_PIN13_IOPORT, TEENSY_PIN13, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPad(TEENSY_PIN13_IOPORT, TEENSY_PIN13);
|
||||
} else {
|
||||
// Hi-Z
|
||||
palSetPadMode(TEENSY_PIN13_IOPORT, TEENSY_PIN13, PAL_MODE_INPUT);
|
||||
}
|
||||
}
|
||||
221
keyboard/teensy3.2_tkl/matrix.c
Normal file
221
keyboard/teensy3.2_tkl/matrix.c
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
/*
|
||||
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 "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
/*
|
||||
* scan matrix
|
||||
*/
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
#include "matrix.h"
|
||||
#include "wait.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;
|
||||
}
|
||||
|
||||
#define LED_ON() do { palSetPad(TEENSY_PIN13_IOPORT, TEENSY_PIN13) ;} while (0)
|
||||
#define LED_OFF() do { palClearPad(TEENSY_PIN13_IOPORT, TEENSY_PIN13); } while (0)
|
||||
#define LED_TGL() do { palTogglePad(TEENSY_PIN13_IOPORT, TEENSY_PIN13); } while (0)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//debug
|
||||
debug_matrix = true;
|
||||
LED_ON();
|
||||
wait_ms(500);
|
||||
LED_OFF();
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
select_row(i);
|
||||
wait_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) {
|
||||
wait_ms(1);
|
||||
} else {
|
||||
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||
matrix[i] = matrix_debouncing[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
/* Column pin configuration
|
||||
*/
|
||||
static void init_cols(void)
|
||||
{
|
||||
// internal pull-up
|
||||
palSetPadMode(TEENSY_PIN6_IOPORT , TEENSY_PIN6, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN7_IOPORT , TEENSY_PIN7, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN8_IOPORT , TEENSY_PIN8, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN9_IOPORT , TEENSY_PIN9, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN10_IOPORT, TEENSY_PIN10, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN11_IOPORT, TEENSY_PIN11, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN12_IOPORT, TEENSY_PIN12, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN14_IOPORT, TEENSY_PIN14, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN15_IOPORT, TEENSY_PIN15, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN16_IOPORT, TEENSY_PIN16, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN17_IOPORT, TEENSY_PIN17, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN18_IOPORT, TEENSY_PIN18, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN19_IOPORT, TEENSY_PIN19, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN20_IOPORT, TEENSY_PIN20, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN21_IOPORT, TEENSY_PIN21, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN22_IOPORT, TEENSY_PIN22, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(TEENSY_PIN23_IOPORT, TEENSY_PIN23, PAL_MODE_INPUT_PULLUP);
|
||||
}
|
||||
|
||||
/* Returns status of switches(1:on, 0:off) */
|
||||
static matrix_row_t read_cols(void)
|
||||
{
|
||||
return (
|
||||
((palReadPad(TEENSY_PIN6_IOPORT , TEENSY_PIN6 )==PAL_HIGH) ? 0 : (1<<0))
|
||||
| ((palReadPad(TEENSY_PIN7_IOPORT , TEENSY_PIN7 )==PAL_HIGH) ? 0 : (1<<1))
|
||||
| ((palReadPad(TEENSY_PIN8_IOPORT , TEENSY_PIN8 )==PAL_HIGH) ? 0 : (1<<2))
|
||||
| ((palReadPad(TEENSY_PIN9_IOPORT , TEENSY_PIN9 )==PAL_HIGH) ? 0 : (1<<3))
|
||||
| ((palReadPad(TEENSY_PIN10_IOPORT, TEENSY_PIN10)==PAL_HIGH) ? 0 : (1<<4))
|
||||
| ((palReadPad(TEENSY_PIN11_IOPORT, TEENSY_PIN11)==PAL_HIGH) ? 0 : (1<<5))
|
||||
| ((palReadPad(TEENSY_PIN12_IOPORT, TEENSY_PIN12)==PAL_HIGH) ? 0 : (1<<6))
|
||||
| ((palReadPad(TEENSY_PIN14_IOPORT, TEENSY_PIN14)==PAL_HIGH) ? 0 : (1<<7))
|
||||
| ((palReadPad(TEENSY_PIN15_IOPORT, TEENSY_PIN15)==PAL_HIGH) ? 0 : (1<<8))
|
||||
| ((palReadPad(TEENSY_PIN16_IOPORT, TEENSY_PIN16)==PAL_HIGH) ? 0 : (1<<9))
|
||||
| ((palReadPad(TEENSY_PIN17_IOPORT, TEENSY_PIN17)==PAL_HIGH) ? 0 : (1<<10))
|
||||
| ((palReadPad(TEENSY_PIN18_IOPORT, TEENSY_PIN18)==PAL_HIGH) ? 0 : (1<<11))
|
||||
| ((palReadPad(TEENSY_PIN19_IOPORT, TEENSY_PIN19)==PAL_HIGH) ? 0 : (1<<12))
|
||||
| ((palReadPad(TEENSY_PIN20_IOPORT, TEENSY_PIN20)==PAL_HIGH) ? 0 : (1<<13))
|
||||
| ((palReadPad(TEENSY_PIN21_IOPORT, TEENSY_PIN21)==PAL_HIGH) ? 0 : (1<<14))
|
||||
| ((palReadPad(TEENSY_PIN22_IOPORT, TEENSY_PIN22)==PAL_HIGH) ? 0 : (1<<15))
|
||||
| ((palReadPad(TEENSY_PIN23_IOPORT, TEENSY_PIN23)==PAL_HIGH) ? 0 : (1<<16))
|
||||
);
|
||||
}
|
||||
|
||||
/* Row pin configuration
|
||||
*/
|
||||
static void unselect_rows(void)
|
||||
{
|
||||
palSetPadMode(TEENSY_PIN5_IOPORT, TEENSY_PIN5, PAL_MODE_INPUT);
|
||||
palSetPadMode(TEENSY_PIN4_IOPORT, TEENSY_PIN4, PAL_MODE_INPUT);
|
||||
palSetPadMode(TEENSY_PIN3_IOPORT, TEENSY_PIN3, PAL_MODE_INPUT);
|
||||
palSetPadMode(TEENSY_PIN2_IOPORT, TEENSY_PIN2, PAL_MODE_INPUT);
|
||||
palSetPadMode(TEENSY_PIN1_IOPORT, TEENSY_PIN1, PAL_MODE_INPUT);
|
||||
palSetPadMode(TEENSY_PIN0_IOPORT, TEENSY_PIN0, PAL_MODE_INPUT);
|
||||
}
|
||||
|
||||
static void select_row(uint8_t row)
|
||||
{
|
||||
(void)row;
|
||||
// Output low to select
|
||||
switch (row) {
|
||||
case 0:
|
||||
palSetPadMode(TEENSY_PIN5_IOPORT, TEENSY_PIN5, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palClearPad(TEENSY_PIN5_IOPORT, TEENSY_PIN5);
|
||||
break;
|
||||
case 1:
|
||||
palSetPadMode(TEENSY_PIN4_IOPORT, TEENSY_PIN4, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palClearPad(TEENSY_PIN4_IOPORT, TEENSY_PIN4);
|
||||
break;
|
||||
case 2:
|
||||
palSetPadMode(TEENSY_PIN3_IOPORT, TEENSY_PIN3, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palClearPad(TEENSY_PIN3_IOPORT, TEENSY_PIN3);
|
||||
break;
|
||||
case 3:
|
||||
palSetPadMode(TEENSY_PIN2_IOPORT, TEENSY_PIN2, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palClearPad(TEENSY_PIN2_IOPORT, TEENSY_PIN2);
|
||||
break;
|
||||
case 4:
|
||||
palSetPadMode(TEENSY_PIN1_IOPORT, TEENSY_PIN1, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palClearPad(TEENSY_PIN1_IOPORT, TEENSY_PIN1);
|
||||
break;
|
||||
case 5:
|
||||
palSetPadMode(TEENSY_PIN0_IOPORT, TEENSY_PIN0, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palClearPad(TEENSY_PIN0_IOPORT, TEENSY_PIN0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
55
keyboard/teensy3.2_tkl/mcuconf.h
Normal file
55
keyboard/teensy3.2_tkl/mcuconf.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _MCUCONF_H_
|
||||
#define _MCUCONF_H_
|
||||
|
||||
#define KL2x_MCUCONF
|
||||
|
||||
/*
|
||||
* HAL driver system settings.
|
||||
*/
|
||||
#if 1
|
||||
/* PEE mode - 48MHz system clock driven by (16 MHz) external crystal. */
|
||||
#define KINETIS_MCG_MODE KINETIS_MCG_MODE_PEE
|
||||
#define KINETIS_PLLCLK_FREQUENCY 96000000UL
|
||||
#define KINETIS_SYSCLK_FREQUENCY 48000000UL
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* crystal-less FEI mode - 48 MHz with internal 32.768 kHz crystal */
|
||||
#define KINETIS_MCG_MODE KINETIS_MCG_MODE_FEI
|
||||
#define KINETIS_MCG_FLL_DMX32 1 /* Fine-tune for 32.768 kHz */
|
||||
#define KINETIS_MCG_FLL_DRS 1 /* 1464x FLL factor */
|
||||
#define KINETIS_SYSCLK_FREQUENCY 47972352UL /* 32.768 kHz * 1464 (~48 MHz) */
|
||||
#define KINETIS_CLKDIV1_OUTDIV1 1 /* do not divide system clock */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* SERIAL driver system settings.
|
||||
*/
|
||||
#define KINETIS_SERIAL_USE_UART0 TRUE
|
||||
|
||||
/*
|
||||
* USB driver settings
|
||||
*/
|
||||
#define KINETIS_USB_USE_USB0 TRUE
|
||||
/* Need to redefine this, since the default is for K20x */
|
||||
/* This is for Teensy LC; you should comment it out (or change to 5)
|
||||
* for Teensy 3.x */
|
||||
#define KINETIS_USB_USB0_IRQ_PRIORITY 5
|
||||
|
||||
#endif /* _MCUCONF_H_ */
|
||||
|
|
@ -2,16 +2,7 @@
|
|||
|
||||
These ARM Teensies are now supported through [ChibiOS](http://chibios.org).
|
||||
|
||||
You'll need to install an ARM toolchain, for instance from [gcc ARM embedded](https://launchpad.net/gcc-arm-embedded) website, or using your favourite package manager. After installing, you should be able to run `arm-none-eabi-gcc -v` in the command prompt and get sensible output. This toolchain is used instead of `avr-gcc`, which is only for AVR chips. Naturally you'll also need the usual development tools (e.g. `make`), just as in the AVR setting.
|
||||
|
||||
Next, you'll need ChibiOS. For Teensies, you'll need code from two repositories: [chibios-main](https://github.com/ChibiOS/ChibiOS) and [chibios-contrib](https://github.com/ChibiOS/ChibiOS-Contrib).
|
||||
If you're not using git, you can just download a [zip of chibios from here](https://github.com/ChibiOS/ChibiOS/archive/a7df9a891067621e8e1a5c2a2c0ceada82403afe.zip), unpack the zip, and rename/move the unpacked directory (named `ChibiOS-<long_hash_here>`) to `tmk_core/tool/chibios/ChibiOS` (so that the file `tmk_core/tool/chibios/ChibiOS/license.txt` exists). Now the same procedure with a [zip of chibios-contrib from here](https://github.com/ChibiOS/ChibiOS-Contrib/archive/e1311c4db6cd366cf760673f769e925741ac0ad3.zip): unpack and move `ChibiOS-Contrib-<long_hash_here>` to `tmk_core/tool/chibios/ChibiOS-Contrib`.
|
||||
|
||||
If you're using git, you can just clone the two repos inside `tmk_core/tool/chibios`: [chibios](https://github.com/ChibiOS/ChibiOS) and [chibios-contrib](https://github.com/ChibiOS/ChibiOS-Contrib).
|
||||
|
||||
(Why do we need chibios-contrib? Well, the main repo focuses on STM32 chips, and Freescale/NXP Kinetis chips are supported via the Contrib repository.)
|
||||
|
||||
This should be it.
|
||||
Follow the setup instructions in `tmk_core/protocol/chibios/README.md` to install ChibiOS and required toolchain.
|
||||
|
||||
Running `make` in `keyboard/teensy_lc_onekey` should create a working firmware in `build/`, called `ch.hex`.
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,14 @@ Source code is available here: <https://github.com/tmk/tmk_keyboard/tree/core>
|
|||
|
||||
Updates
|
||||
-------
|
||||
#### 2017/05/30
|
||||
Fixed **Modifier/Layer key stuck** problem. See this wiki entry. <https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#modifierlayer-stuck> If you need old keymap behaviour for some reason define `NO_TRACK_KEY_PRESS` in your `config.h`.
|
||||
|
||||
This is virtually equivalent to QMK `PREVENT_STUCK_MODIFIERS`. <https://github.com/qmk/qmk_firmware/pull/182>
|
||||
|
||||
#### 2017/01/11
|
||||
Changed action code for `ACTION_LAYER_MODS` and this may cause incompatibility with existent shared URL and downloaded firmwware of keymap editor. If you are using the action you just have to redefine it on keymap editor. Existent keymap code should not suffer.
|
||||
|
||||
#### 2016/06/26
|
||||
Keymap framework was updated. `fn_actions[]` should be defined as `action_t` instead of `uint16_t`. And default code for keymap handling is now included in core you just need define `uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]` and `action_t fn_actions[]`.
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ void process_action(keyrecord_t *record)
|
|||
|
||||
if (IS_NOEVENT(event)) { return; }
|
||||
|
||||
action_t action = layer_switch_get_action(event.key);
|
||||
action_t action = layer_switch_get_action(event);
|
||||
dprint("ACTION: "); debug_action(action);
|
||||
#ifndef NO_ACTION_LAYER
|
||||
dprint(" layer_state: "); layer_debug();
|
||||
|
|
@ -492,6 +492,12 @@ void unregister_code(uint8_t code)
|
|||
}
|
||||
}
|
||||
|
||||
void type_code(uint8_t code)
|
||||
{
|
||||
register_code(code);
|
||||
unregister_code(code);
|
||||
}
|
||||
|
||||
void register_mods(uint8_t mods)
|
||||
{
|
||||
if (mods) {
|
||||
|
|
@ -529,9 +535,11 @@ void clear_keyboard_but_mods(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
bool is_tap_key(keypos_t key)
|
||||
bool is_tap_key(keyevent_t event)
|
||||
{
|
||||
action_t action = layer_switch_get_action(key);
|
||||
if (IS_NOEVENT(event)) { return false; }
|
||||
|
||||
action_t action = layer_switch_get_action(event);
|
||||
|
||||
switch (action.kind.id) {
|
||||
case ACT_LMODS_TAP:
|
||||
|
|
|
|||
|
|
@ -62,13 +62,14 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
|
|||
void process_action(keyrecord_t *record);
|
||||
void register_code(uint8_t code);
|
||||
void unregister_code(uint8_t code);
|
||||
void type_code(uint8_t code);
|
||||
void register_mods(uint8_t mods);
|
||||
void unregister_mods(uint8_t mods);
|
||||
//void set_mods(uint8_t mods);
|
||||
void clear_keyboard(void);
|
||||
void clear_keyboard_but_mods(void);
|
||||
void layer_switch(uint8_t new_layer);
|
||||
bool is_tap_key(keypos_t key);
|
||||
bool is_tap_key(keyevent_t event);
|
||||
|
||||
/* debug */
|
||||
void debug_event(keyevent_t event);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ static void default_layer_state_set(uint32_t state)
|
|||
default_layer_state = state;
|
||||
hook_default_layer_change(default_layer_state);
|
||||
default_layer_debug(); debug("\n");
|
||||
#ifdef NO_TRACK_KEY_PRESS
|
||||
clear_keyboard_but_mods(); // To avoid stuck keys
|
||||
#endif
|
||||
}
|
||||
|
||||
void default_layer_debug(void)
|
||||
|
|
@ -66,7 +68,9 @@ static void layer_state_set(uint32_t state)
|
|||
layer_state = state;
|
||||
hook_layer_change(layer_state);
|
||||
layer_debug(); dprintln();
|
||||
#ifdef NO_TRACK_KEY_PRESS
|
||||
clear_keyboard_but_mods(); // To avoid stuck keys
|
||||
#endif
|
||||
}
|
||||
|
||||
void layer_clear(void)
|
||||
|
|
@ -115,26 +119,47 @@ void layer_debug(void)
|
|||
|
||||
|
||||
|
||||
action_t layer_switch_get_action(keypos_t key)
|
||||
/* return layer effective for key at this time */
|
||||
static uint8_t current_layer_for_key(keypos_t key)
|
||||
{
|
||||
action_t action = ACTION_TRANSPARENT;
|
||||
|
||||
#ifndef NO_ACTION_LAYER
|
||||
action_t action = ACTION_TRANSPARENT;
|
||||
uint32_t layers = layer_state | default_layer_state;
|
||||
/* check top layer first */
|
||||
for (int8_t i = 31; i >= 0; i--) {
|
||||
if (layers & (1UL<<i)) {
|
||||
action = action_for_key(i, key);
|
||||
if (action.code != (action_t)ACTION_TRANSPARENT.code) {
|
||||
return action;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* fall back to layer 0 */
|
||||
action = action_for_key(0, key);
|
||||
return action;
|
||||
return 0;
|
||||
#else
|
||||
action = action_for_key(biton32(default_layer_state), key);
|
||||
return action;
|
||||
return biton32(default_layer_state);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef NO_TRACK_KEY_PRESS
|
||||
/* record layer on where key is pressed */
|
||||
static uint8_t layer_pressed[MATRIX_ROWS][MATRIX_COLS] = {};
|
||||
#endif
|
||||
action_t layer_switch_get_action(keyevent_t event)
|
||||
{
|
||||
if (IS_NOEVENT(event)) return (action_t)ACTION_NO;
|
||||
|
||||
uint8_t layer = 0;
|
||||
#ifndef NO_TRACK_KEY_PRESS
|
||||
if (event.pressed) {
|
||||
layer = current_layer_for_key(event.key);
|
||||
layer_pressed[event.key.row][event.key.col] = layer;
|
||||
} else {
|
||||
layer = layer_pressed[event.key.row][event.key.col];
|
||||
}
|
||||
#else
|
||||
layer = current_layer_for_key(event.key);
|
||||
#endif
|
||||
return action_for_key(layer, event.key);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,10 +34,6 @@ void default_layer_set(uint32_t state);
|
|||
void default_layer_or(uint32_t state);
|
||||
void default_layer_and(uint32_t state);
|
||||
void default_layer_xor(uint32_t state);
|
||||
#else
|
||||
#define default_layer_or(state)
|
||||
#define default_layer_and(state)
|
||||
#define default_layer_xor(state)
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -56,22 +52,10 @@ void layer_invert(uint8_t layer);
|
|||
void layer_or(uint32_t state);
|
||||
void layer_and(uint32_t state);
|
||||
void layer_xor(uint32_t state);
|
||||
#else
|
||||
#define layer_state 0
|
||||
#define layer_clear()
|
||||
#define layer_move(layer)
|
||||
#define layer_on(layer)
|
||||
#define layer_off(layer)
|
||||
#define layer_invert(layer)
|
||||
|
||||
#define layer_or(state)
|
||||
#define layer_and(state)
|
||||
#define layer_xor(state)
|
||||
#define layer_debug()
|
||||
#endif
|
||||
|
||||
|
||||
/* return action depending on current layer status */
|
||||
action_t layer_switch_get_action(keypos_t key);
|
||||
action_t layer_switch_get_action(keyevent_t key);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -105,6 +105,19 @@ enum macro_command_id{
|
|||
#define RM() RESTORE()
|
||||
/* clear modifier(s) */
|
||||
#define CM() CLEAR()
|
||||
/* key shift-type */
|
||||
#define ST(key) D(LSFT), T(key), U(LSFT)
|
||||
/* modifier utility macros */
|
||||
/* Example: Ctrl+Alt+[Shift+]<key1,key2> is CTL_( ALT_( [S]T(key1), [S]T(key2) )) . */
|
||||
#define SFT_(...) D(LSFT), __VA_ARGS__, U(LSFT)
|
||||
#define CTL_(...) D(LCTL), __VA_ARGS__, U(LCTL)
|
||||
#define ALT_(...) D(LALT), __VA_ARGS__, U(LALT)
|
||||
#define AGR_(...) D(RALT), __VA_ARGS__, U(RALT)
|
||||
/* Unicode macros for XOrg/MacOs/Win. */
|
||||
/* Example: UNIW_(0,1,4,9) enters a bullet glyph on Windows using Alt+KeyPad(####). */
|
||||
#define UNIX_(d1,d2,d3,d4) CTL_(ST(U)), T(d1), T(d2), T(d3), T(d4) , T(ENT)
|
||||
#define UNIM_(d1,d2,d3,d4) ALT_( T(d1), T(d2), T(d3), T(d4) )
|
||||
#define UNIW_(d1,d2,d3,d4) ALT_( T(P##d1), T(P##d2), T(P##d3), T(P##d4) )
|
||||
|
||||
/* for backward comaptibility */
|
||||
#define MD(key) DOWN(KC_##key)
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ bool process_tapping(keyrecord_t *keyp)
|
|||
*/
|
||||
else if (IS_RELEASED(event) && !waiting_buffer_typed(event)) {
|
||||
// Modifier should be retained till end of this tapping.
|
||||
action_t action = layer_switch_get_action(event.key);
|
||||
action_t action = layer_switch_get_action(event);
|
||||
switch (action.kind.id) {
|
||||
case ACT_LMODS:
|
||||
case ACT_RMODS:
|
||||
|
|
@ -152,7 +152,7 @@ bool process_tapping(keyrecord_t *keyp)
|
|||
debug_tapping_key();
|
||||
return true;
|
||||
}
|
||||
else if (is_tap_key(event.key) && event.pressed) {
|
||||
else if (is_tap_key(event) && event.pressed) {
|
||||
if (tapping_key.tap.count > 1) {
|
||||
debug("Tapping: Start new tap with releasing last tap(>1).\n");
|
||||
// unregister key
|
||||
|
|
@ -196,7 +196,7 @@ bool process_tapping(keyrecord_t *keyp)
|
|||
tapping_key = (keyrecord_t){};
|
||||
return true;
|
||||
}
|
||||
else if (is_tap_key(event.key) && event.pressed) {
|
||||
else if (is_tap_key(event) && event.pressed) {
|
||||
if (tapping_key.tap.count > 1) {
|
||||
debug("Tapping: Start new tap with releasing last timeout tap(>1).\n");
|
||||
// unregister key
|
||||
|
|
@ -241,7 +241,7 @@ bool process_tapping(keyrecord_t *keyp)
|
|||
tapping_key = *keyp;
|
||||
return true;
|
||||
}
|
||||
} else if (is_tap_key(event.key)) {
|
||||
} else if (is_tap_key(event)) {
|
||||
// Sequential tap can be interfered with other tap key.
|
||||
debug("Tapping: Start with interfering other tap.\n");
|
||||
tapping_key = *keyp;
|
||||
|
|
@ -272,7 +272,7 @@ bool process_tapping(keyrecord_t *keyp)
|
|||
}
|
||||
// not tapping state
|
||||
else {
|
||||
if (event.pressed && is_tap_key(event.key)) {
|
||||
if (event.pressed && is_tap_key(event)) {
|
||||
debug("Tapping: Start(Press tap key).\n");
|
||||
tapping_key = *keyp;
|
||||
waiting_buffer_scan_tap();
|
||||
|
|
|
|||
|
|
@ -70,14 +70,18 @@ static void power_down(uint8_t wdto)
|
|||
wdt_disable();
|
||||
}
|
||||
|
||||
#ifdef SUSPEND_MODE_STANDBY
|
||||
static void standby(void)
|
||||
{
|
||||
#ifdef SLEEP_MODE_STANDBY
|
||||
set_sleep_mode(SLEEP_MODE_STANDBY);
|
||||
sleep_enable();
|
||||
sei();
|
||||
sleep_cpu();
|
||||
sleep_disable();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
static void idle(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,7 +46,11 @@ void timer_init(void)
|
|||
#endif
|
||||
|
||||
OCR0A = TIMER_RAW_TOP;
|
||||
#ifdef TIMSK0
|
||||
TIMSK0 = (1<<OCIE0A);
|
||||
#else
|
||||
TIMSK = (1<<OCIE0A);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
|
|
|
|||
|
|
@ -57,9 +57,10 @@ static void command_console_help(void);
|
|||
#ifdef MOUSEKEY_ENABLE
|
||||
static bool mousekey_console(uint8_t code);
|
||||
static void mousekey_console_help(void);
|
||||
static uint8_t numkey2num(uint8_t code);
|
||||
#endif
|
||||
|
||||
static uint8_t numkey2num(uint8_t code);
|
||||
|
||||
static void switch_default_layer(uint8_t layer);
|
||||
|
||||
|
||||
|
|
@ -629,6 +630,7 @@ static bool mousekey_console(uint8_t code)
|
|||
/***********************************************************
|
||||
* Utilities
|
||||
***********************************************************/
|
||||
#if MOUSEKEY_ENABLE
|
||||
static uint8_t numkey2num(uint8_t code)
|
||||
{
|
||||
switch (code) {
|
||||
|
|
@ -645,6 +647,7 @@ static uint8_t numkey2num(uint8_t code)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void switch_default_layer(uint8_t layer)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ void keyboard_init(void)
|
|||
}
|
||||
|
||||
/*
|
||||
* Do keyboard routine jobs: scan mantrix, light LEDs, ...
|
||||
* Do keyboard routine jobs: scan matrix, light LEDs, ...
|
||||
* This is repeatedly called as fast as possible.
|
||||
*/
|
||||
void keyboard_task(void)
|
||||
|
|
@ -126,17 +126,18 @@ void keyboard_task(void)
|
|||
matrix_ghost[r] = matrix_row;
|
||||
#endif
|
||||
if (debug_matrix) matrix_print();
|
||||
for (uint8_t c = 0; c < MATRIX_COLS; c++) {
|
||||
if (matrix_change & ((matrix_row_t)1<<c)) {
|
||||
matrix_row_t col_mask = 1;
|
||||
for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) {
|
||||
if (matrix_change & col_mask) {
|
||||
keyevent_t e = (keyevent_t){
|
||||
.key = (keypos_t){ .row = r, .col = c },
|
||||
.pressed = (matrix_row & ((matrix_row_t)1<<c)),
|
||||
.pressed = (matrix_row & col_mask),
|
||||
.time = (timer_read() | 1) /* time should not be 0 */
|
||||
};
|
||||
action_exec(e);
|
||||
hook_matrix_change(e);
|
||||
// record a processed key
|
||||
matrix_prev[r] ^= ((matrix_row_t)1<<c);
|
||||
matrix_prev[r] ^= col_mask;
|
||||
|
||||
// This can miss stroke when scan matrix takes long like Topre
|
||||
// process a key per task call
|
||||
|
|
@ -148,7 +149,7 @@ void keyboard_task(void)
|
|||
// call with pseudo tick event when no real key event.
|
||||
action_exec(TICK);
|
||||
|
||||
MATRIX_LOOP_END:
|
||||
//MATRIX_LOOP_END:
|
||||
|
||||
hook_keyboard_loop();
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ The **default layer** is the base keymap layer (0-31) which is always active and
|
|||
|
||||
Note that the `default_layer_state` variable only determines the lowest value to which `layer_state` may be set, and that `default_layer_state` is used by the core firmware when determining the starting value of `layer_state` before applying changes. In other words, the default layer will *always* be set to *on* in `layer_state`.
|
||||
|
||||
The default layer is defined in the firmware by the `default_layer_state` variable, which is identical in format to the `layer_state` variable exlpained above. The value may be changed using the following functions:
|
||||
The default layer is defined in the firmware by the `default_layer_state` variable, which is identical in format to the `layer_state` variable explained above. The value may be changed using the following functions:
|
||||
|
||||
- `default_layer_state_set(state)` sets the state to the specified 32-bit integer value.
|
||||
- AND/OR/XOR functions set the state based on a boolean logic comparison between the current state and the specified 32-bit integer value:
|
||||
|
|
@ -86,7 +86,7 @@ default_layer_state_set(1UL<<3);
|
|||
|
||||
|
||||
### 0.2 Layer Precedence and Transparency
|
||||
Note that ***higher layers have priority in the layer stack***. The firmware starts at the topmost active layer, and works down to the bottom to find the an active keycode. Once the search encounters any keycode other than **`KC_TRNS`** (transparent) on an active layer, the search is halted and the remaining lower layers aren't examined, even if they are active.
|
||||
Note that ***higher layers have priority in the layer stack***. The firmware starts at the topmost active layer, and works down to the bottom to find an active keycode. Once the search encounters any keycode other than **`KC_TRNS`** (transparent) on an active layer, the search is halted and the remaining lower layers aren't examined, even if they are active.
|
||||
|
||||
**Note:** a layer must be activated before it may be included in the stack search.
|
||||
|
||||
|
|
@ -292,7 +292,7 @@ You can specify a **target layer** of action and **when the action is executed**
|
|||
|
||||
+ **layer**: `0`-`31`
|
||||
+ **on**: { `ON_PRESS` | `ON_RELEASE` | `ON_BOTH` }
|
||||
+ **bits**: 4-bit value and 1-bit mask bit
|
||||
+ **bits**: 5-bit: 1-bit for mask and 4-bit for operand
|
||||
|
||||
|
||||
#### 2.2.1 Default Layer
|
||||
|
|
@ -365,20 +365,44 @@ Turns on layer only and clear all layer on release..
|
|||
|
||||
|
||||
#### 2.2.10 Bitwise operation
|
||||
|
||||
**part** indicates which part of 32bit layer state(0-7). **bits** is 5-bit value. **on** indicates when the action is executed.
|
||||
Performs bitwise operation(AND, OR, XOR, SET) against layer state.
|
||||
|
||||
ACTION_LAYER_BIT_AND(part, bits, on)
|
||||
ACTION_LAYER_BIT_OR(part, bits, on)
|
||||
ACTION_LAYER_BIT_XOR(part, bits, on)
|
||||
ACTION_LAYER_BIT_SET(part, bits, on)
|
||||
|
||||
These actions works with parameters as following code.
|
||||
`part` parameter indicates 0-based index(0-7) of where breaking 32-bit `layer_state` into eight nibbles(4-bit unit).
|
||||
|
||||
bs
|
||||
|
||||
part 7 6 5 4 3 2 1 0
|
||||
layer_state 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
msb lsb
|
||||
|
||||
`bits` parameter is 5-bit value and consists of two portions, most significant bit(m) controls mask and other 4 bits(abcd) are operand of bit operation.
|
||||
|
||||
43210
|
||||
bits mdcba
|
||||
|
||||
These parameters works as following code.
|
||||
|
||||
uint32_t layer_state;
|
||||
uint8_t shift = part*4;
|
||||
uint32_t mask = (bits&0x10) ? ~(0xf<<shift) : 0;
|
||||
uint32_t layer_state = layer_state <bitop> ((bits<<shift)|mask);
|
||||
|
||||
uint32_t mask = (bits&0x10) ? ~((uint32_t)0xf<<shift) : 0;
|
||||
switch (<bitop>) {
|
||||
case BIT_AND:
|
||||
layer_state = layer_state & (((bits&0xf)<<shift)|mask);
|
||||
break;
|
||||
case BIT_OR:
|
||||
layer_state = layer_state | (((bits&0xf)<<shift)|mask);
|
||||
break;
|
||||
case BIT_XOR:
|
||||
layer_state = layer_state ^ (((bits&0xf)<<shift)|mask);
|
||||
break;
|
||||
case BIT_SET:
|
||||
layer_state = layer_state <bitop> (((bits&0xf)<<shift)|mask);
|
||||
break;
|
||||
|
||||
Default Layer also has bitwise operations, they are executed when key is released.
|
||||
|
||||
|
|
@ -578,7 +602,7 @@ This registers modifier key(s) simultaneously with layer switching.
|
|||
|
||||
ACTION_LAYER_MODS(2, MOD_LSFT | MOD_LALT)
|
||||
|
||||
You can combine four modifiers at most but cannot use both left and right modifiers at a time, either left or right modiiers only can be allowed.
|
||||
You can combine four modifiers at most but cannot use both left and right modifiers at a time, either left or right modifiers only can be allowed.
|
||||
|
||||
|
||||
## 4. Tapping
|
||||
|
|
|
|||
|
|
@ -4,9 +4,15 @@ This code can be used to run TMK keyboard logic on top of [ChibiOS], meaning tha
|
|||
|
||||
### Usage
|
||||
|
||||
- To use, get a [zip file](https://github.com/ChibiOS/ChibiOS/archive/a7df9a891067621e8e1a5c2a2c0ceada82403afe.zip) of ChibiOS and unpack/rename it to `tmk_core/tool/chibios/ChibiOS`; or you can just clone [ChibiOS repo](https://github.com/ChibiOS/ChibiOS) there. For Freescale/NXP Kinetis support (meaning Teensies 3.x/LC and the Infinity keyboard), you'll also need a [zip](https://github.com/ChibiOS/ChibiOS-Contrib/archive/e1311c4db6cd366cf760673f769e925741ac0ad3.zip) of ChibiOS-Contrib, unpacked/renamed to `tmk_core/tool/chibios/ChibiOS-Contrib`. Likewise, for git-savvy people, just clone [ChibiOS-Contrib repo](https://github.com/ChibiOS/ChibiOS-Contrib) there.
|
||||
- Note: the above mentioned directories are the defaults. You can have the two ChibiOS repositories wherever you want, just define their location in `CHIBIOS` and `CHIBIOS_CONTRIB` variables in your `Makefile`.
|
||||
- You will also need to install an ARM toolchain, for instance from [here](https://launchpad.net/gcc-arm-embedded). On linux, this is usually also present as a package for your distribution (as `gcc-arm` or something similar). On OS X, you can use [homebrew](http://brew.sh/) with an appropriate tap.
|
||||
- To use, get a [zip file](https://github.com/ChibiOS/ChibiOS/archive/stable_17.6.x.zip) of ChibiOS and unpack/rename it to `tmk_core/tool/chibios/ChibiOS`; or you can just clone [ChibiOS/ChibiOS](https://github.com/ChibiOS/ChibiOS) there.
|
||||
If you use git, make sure to check out the most recent stable branch such as `stable_17.6.x`
|
||||
For Freescale/NXP Kinetis support (meaning Teensies 3.x/LC and the Infinity keyboard), you'll also need a [zip](https://github.com/ChibiOS/ChibiOS-Contrib/archive/master.zip) of ChibiOS-Contrib, unpacked/renamed to `tmk_core/tool/chibios/ChibiOS-Contrib`.
|
||||
Likewise, for git-savvy people, just clone [ChibiOS/ChibiOS-Contrib](https://github.com/ChibiOS/ChibiOS-Contrib) there.
|
||||
- Note: the above mentioned directories are the defaults.
|
||||
You can have the two ChibiOS repositories wherever you want, just define their location in `CHIBIOS` and `CHIBIOS_CONTRIB` variables in your `Makefile`.
|
||||
- You will also need to install an ARM toolchain, for instance from [here](https://launchpad.net/gcc-arm-embedded).
|
||||
On linux, this is usually also present as a package for your distribution (as `gcc-arm` or something similar).
|
||||
On OS X, you can use [homebrew](http://brew.sh/) with an appropriate tap.
|
||||
|
||||
### Notes
|
||||
|
||||
|
|
|
|||
|
|
@ -138,16 +138,19 @@ typedef struct
|
|||
#ifdef CONSOLE_ENABLE
|
||||
# define CONSOLE_IN_EPNUM (EXTRAKEY_IN_EPNUM + 1)
|
||||
# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 1)
|
||||
//# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 2)
|
||||
#else
|
||||
# define CONSOLE_OUT_EPNUM EXTRAKEY_IN_EPNUM
|
||||
#endif
|
||||
|
||||
#ifdef NKRO_ENABLE
|
||||
# define NKRO_IN_EPNUM (CONSOLE_OUT_EPNUM + 1)
|
||||
# if defined(__AVR_ATmega32U2__) && NKRO_IN_EPNUM > 4
|
||||
# error "Endpoints are not available enough to support all functions. Remove some in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)"
|
||||
# endif
|
||||
#else
|
||||
# define NKRO_IN_EPNUM CONSOLE_OUT_EPNUM
|
||||
#endif
|
||||
|
||||
/* Check number of endpoints. ATmega32u2 has only four except for control endpoint. */
|
||||
#if defined(__AVR_ATmega32U2__) && NKRO_IN_EPNUM > 4
|
||||
# error "Endpoints are not available enough to support all functions. Disable some of build options in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ static void send_keyboard(report_keyboard_t *report)
|
|||
Endpoint_SelectEndpoint(NKRO_IN_EPNUM);
|
||||
|
||||
/* Check if write ready for a polling interval around 1ms */
|
||||
while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(4);
|
||||
while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(8);
|
||||
if (!Endpoint_IsReadWriteAllowed()) return;
|
||||
|
||||
/* Write Keyboard Report Data */
|
||||
|
|
@ -482,6 +482,7 @@ static void send_mouse(report_mouse_t *report)
|
|||
|
||||
static void send_system(uint16_t data)
|
||||
{
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
uint8_t timeout = 255;
|
||||
|
||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||
|
|
@ -499,10 +500,12 @@ static void send_system(uint16_t data)
|
|||
|
||||
Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL);
|
||||
Endpoint_ClearIN();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void send_consumer(uint16_t data)
|
||||
{
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
uint8_t timeout = 255;
|
||||
|
||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||
|
|
@ -520,6 +523,7 @@ static void send_consumer(uint16_t data)
|
|||
|
||||
Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL);
|
||||
Endpoint_ClearIN();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -647,6 +651,17 @@ int main(void)
|
|||
USB_USBTask();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* wait for Console startup */
|
||||
// TODO: long delay often works anyhoo but proper startup would be better
|
||||
uint16_t delay = 2000;
|
||||
while (delay--) {
|
||||
#ifndef INTERRUPT_CONTROL_ENDPOINT
|
||||
USB_USBTask();
|
||||
#endif
|
||||
_delay_ms(1);
|
||||
}
|
||||
|
||||
print("USB configured.\n");
|
||||
|
||||
/* init modules */
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include "oddebug.h"
|
||||
#include "sendchar.h"
|
||||
|
||||
|
||||
#if DEBUG_LEVEL > 0
|
||||
/* from oddebug.c */
|
||||
int8_t sendchar(uint8_t c)
|
||||
{
|
||||
while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */
|
||||
ODDBG_UDR = c;
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
int8_t sendchar(uint8_t c)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -56,20 +56,5 @@ static inline uint16_t wait_clock_lo(uint16_t us)
|
|||
while (clock_in() && us) { asm(""); wait_us(1); us--; }
|
||||
return us;
|
||||
}
|
||||
static inline uint16_t wait_clock_hi(uint16_t us)
|
||||
{
|
||||
while (!clock_in() && us) { asm(""); wait_us(1); us--; }
|
||||
return us;
|
||||
}
|
||||
static inline uint16_t wait_data_lo(uint16_t us)
|
||||
{
|
||||
while (data_in() && us) { asm(""); wait_us(1); us--; }
|
||||
return us;
|
||||
}
|
||||
static inline uint16_t wait_data_hi(uint16_t us)
|
||||
{
|
||||
while (!data_in() && us) { asm(""); wait_us(1); us--; }
|
||||
return us;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -427,7 +427,7 @@ dfu: $(TARGET).hex
|
|||
done
|
||||
@echo
|
||||
|
||||
ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1)))
|
||||
ifneq (, $(findstring 0.7, $(shell dfu-programmer 2>/dev/null && dfu-programmer --version 2>&1)))
|
||||
dfu-programmer $(MCU) erase --force
|
||||
else
|
||||
dfu-programmer $(MCU) erase
|
||||
|
|
@ -447,7 +447,7 @@ flip-ee: $(TARGET).hex $(TARGET).eep
|
|||
$(REMOVE) $(TARGET)eep.hex
|
||||
|
||||
dfu-ee: $(TARGET).hex $(TARGET).eep
|
||||
ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1)))
|
||||
ifneq (, $(findstring 0.7, $(shell dfu-programmer 2>/dev/null && dfu-programmer --version 2>&1)))
|
||||
dfu-programmer $(MCU) flash --eeprom $(TARGET).eep
|
||||
else
|
||||
dfu-programmer $(MCU) flash-eeprom $(TARGET).eep
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue