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
|
|
@ -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`.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue