aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHuangYang <Justin@HuangYangs-MacBook-Pro.local>2015-11-06 22:26:12 -0700
committerHuangYang <Justin@HuangYangs-MacBook-Pro.local>2015-11-06 22:26:12 -0700
commit765f8a2aef14caced83892b1ab16f5c0ce52aa83 (patch)
treef110644e263176a4e67eac90b6d179a827a39549
parent6485c7d7dae01c499a7e1f27e7956f12ce0f6901 (diff)
downloadqmk_firmware-765f8a2aef14caced83892b1ab16f5c0ce52aa83.tar.gz
qmk_firmware-765f8a2aef14caced83892b1ab16f5c0ce52aa83.zip
added support for jd45
-rw-r--r--keyboard/jd45/Makefile140
-rw-r--r--keyboard/jd45/backlight.c61
-rw-r--r--keyboard/jd45/config.h79
-rw-r--r--keyboard/jd45/jd45.c27
-rw-r--r--keyboard/jd45/jd45.h12
-rw-r--r--keyboard/jd45/keymaps/keymap_default.c31
-rw-r--r--keyboard/jd45/keymaps/keymap_justin.c101
7 files changed, 451 insertions, 0 deletions
diff --git a/keyboard/jd45/Makefile b/keyboard/jd45/Makefile
new file mode 100644
index 000000000..076dced82
--- /dev/null
+++ b/keyboard/jd45/Makefile
@@ -0,0 +1,140 @@
1#----------------------------------------------------------------------------
2# On command line:
3#
4# make all = Make software.
5#
6# make clean = Clean out built project files.
7#
8# make coff = Convert ELF to AVR COFF.
9#
10# make extcoff = Convert ELF to AVR Extended COFF.
11#
12# make program = Download the hex file to the device.
13# Please customize your programmer settings(PROGRAM_CMD)
14#
15# make teensy = Download the hex file to the device, using teensy_loader_cli.
16# (must have teensy_loader_cli installed).
17#
18# make dfu = Download the hex file to the device, using dfu-programmer (must
19# have dfu-programmer installed).
20#
21# make flip = Download the hex file to the device, using Atmel FLIP (must
22# have Atmel FLIP installed).
23#
24# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
25# (must have dfu-programmer installed).
26#
27# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
28# (must have Atmel FLIP installed).
29#
30# make debug = Start either simulavr or avarice as specified for debugging,
31# with avr-gdb or avr-insight as the front end for debugging.
32#
33# make filename.s = Just compile filename.c into the assembler code only.
34#
35# make filename.i = Create a preprocessed source file for use in submitting
36# bug reports to the GCC project.
37#
38# To rebuild project do "make clean" then "make all".
39#----------------------------------------------------------------------------
40
41# Target file name (without extension).
42TARGET = jd45
43
44
45# Directory common source filess exist
46TOP_DIR = ../..
47TMK_DIR = ../../tmk_core
48
49# Directory keyboard dependent files exist
50TARGET_DIR = .
51
52# # project specific files
53SRC = jd45.c \
54 backlight.c
55
56ifdef KEYMAP
57 SRC := keymaps/keymap_$(KEYMAP).c $(SRC)
58else
59 SRC := keymaps/keymap_default.c $(SRC)
60endif
61
62CONFIG_H = config.h
63
64# MCU name
65#MCU = at90usb1287
66MCU = atmega32u4
67
68# Processor frequency.
69# This will define a symbol, F_CPU, in all source code files equal to the
70# processor frequency in Hz. You can then use this symbol in your source code to
71# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
72# automatically to create a 32-bit value in your source code.
73#
74# This will be an integer division of F_USB below, as it is sourced by
75# F_USB after it has run through any CPU prescalers. Note that this value
76# does not *change* the processor frequency - it should merely be updated to
77# reflect the processor speed set externally so that the code can use accurate
78# software delays.
79F_CPU = 16000000
80
81
82#
83# LUFA specific
84#
85# Target architecture (see library "Board Types" documentation).
86ARCH = AVR8
87
88# Input clock frequency.
89# This will define a symbol, F_USB, in all source code files equal to the
90# input clock frequency (before any prescaling is performed) in Hz. This value may
91# differ from F_CPU if prescaling is used on the latter, and is required as the
92# raw input clock is fed directly to the PLL sections of the AVR for high speed
93# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
94# at the end, this will be done automatically to create a 32-bit value in your
95# source code.
96#
97# If no clock division is performed on the input clock inside the AVR (via the
98# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
99F_USB = $(F_CPU)
100
101# Interrupt driven control endpoint task(+60)
102OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
103
104
105# Boot Section Size in *bytes*
106# Teensy halfKay 512
107# Teensy++ halfKay 1024
108# Atmel DFU loader 4096
109# LUFA bootloader 4096
110# USBaspLoader 2048
111OPT_DEFS += -DBOOTLOADER_SIZE=4096
112
113
114# Build Options
115# comment out to disable the options.
116#
117BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
118MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
119EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
120CONSOLE_ENABLE = yes # Console for debug(+400)
121COMMAND_ENABLE = yes # Commands for debug and configuration
122# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
123# SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
124# NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
125BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
126MIDI_ENABLE = YES # MIDI controls
127# UNICODE_ENABLE = YES # Unicode
128BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
129
130
131# Optimize size but this may cause error "relocation truncated to fit"
132#EXTRALDFLAGS = -Wl,--relax
133
134# Search Path
135VPATH += $(TARGET_DIR)
136VPATH += $(TOP_DIR)
137VPATH += $(TMK_DIR)
138
139include $(TOP_DIR)/quantum/quantum.mk
140
diff --git a/keyboard/jd45/backlight.c b/keyboard/jd45/backlight.c
new file mode 100644
index 000000000..f69364b2a
--- /dev/null
+++ b/keyboard/jd45/backlight.c
@@ -0,0 +1,61 @@
1
2#include <avr/io.h>
3#include "backlight.h"
4
5#define CHANNEL OCR1C
6
7void backlight_init_ports()
8{
9
10 // Setup PB7 as output and output low.
11 DDRB |= (1<<7);
12 PORTB &= ~(1<<7);
13
14 // Use full 16-bit resolution.
15 ICR1 = 0xFFFF;
16
17 // I could write a wall of text here to explain... but TL;DW
18 // Go read the ATmega32u4 datasheet.
19 // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
20
21 // Pin PB7 = OCR1C (Timer 1, Channel C)
22 // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
23 // (i.e. start high, go low when counter matches.)
24 // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
25 // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
26
27 TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
28 TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
29
30 backlight_init();
31}
32
33void backlight_set(uint8_t level)
34{
35 if ( level == 0 )
36 {
37 // Turn off PWM control on PB7, revert to output low.
38 TCCR1A &= ~(_BV(COM1C1));
39 CHANNEL = 0x0;
40 // Prevent backlight blink on lowest level
41 PORTB &= ~(_BV(PORTB7));
42 }
43 else if ( level == BACKLIGHT_LEVELS )
44 {
45 // Prevent backlight blink on lowest level
46 PORTB &= ~(_BV(PORTB7));
47 // Turn on PWM control of PB7
48 TCCR1A |= _BV(COM1C1);
49 // Set the brightness
50 CHANNEL = 0xFFFF;
51 }
52 else
53 {
54 // Prevent backlight blink on lowest level
55 PORTB &= ~(_BV(PORTB7));
56 // Turn on PWM control of PB7
57 TCCR1A |= _BV(COM1C1);
58 // Set the brightness
59 CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2));
60 }
61} \ No newline at end of file
diff --git a/keyboard/jd45/config.h b/keyboard/jd45/config.h
new file mode 100644
index 000000000..24e162950
--- /dev/null
+++ b/keyboard/jd45/config.h
@@ -0,0 +1,79 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef CONFIG_H
19#define CONFIG_H
20
21#include "config_common.h"
22
23/* USB Device descriptor parameter */
24#define VENDOR_ID 0xFEED
25#define PRODUCT_ID 0x6060
26#define DEVICE_VER 0x0001
27#define MANUFACTURER Ortholinear Keyboards
28#define PRODUCT The Planck Keyboard
29#define DESCRIPTION A compact ortholinear keyboard
30
31/* key matrix size */
32#define MATRIX_ROWS 4
33#define MATRIX_COLS 13
34
35/* Planck PCB default pin-out */
36#define COLS (int []){F4, D7, B5, B6, C6, C7, D4, D6, D5, D0, D1, D2, B0}
37#define ROWS (int []){F0, F1, F5, B4}
38
39/* COL2ROW or ROW2COL */
40#define DIODE_DIRECTION COL2ROW
41
42/* define if matrix has ghost */
43//#define MATRIX_HAS_GHOST
44
45/* number of backlight levels */
46#define BACKLIGHT_LEVELS 3
47
48/* Set 0 if debouncing isn't needed */
49#define DEBOUNCE 5
50
51/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
52#define LOCKING_SUPPORT_ENABLE
53/* Locking resynchronize hack */
54#define LOCKING_RESYNC_ENABLE
55
56/* key combination for command */
57#define IS_COMMAND() ( \
58 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
59)
60
61/*
62 * Feature disable options
63 * These options are also useful to firmware size reduction.
64 */
65
66/* disable debug print */
67#define NO_DEBUG
68
69/* disable print */
70#define NO_PRINT
71
72/* disable action features */
73//#define NO_ACTION_LAYER
74//#define NO_ACTION_TAPPING
75//#define NO_ACTION_ONESHOT
76//#define NO_ACTION_MACRO
77//#define NO_ACTION_FUNCTION
78
79#endif
diff --git a/keyboard/jd45/jd45.c b/keyboard/jd45/jd45.c
new file mode 100644
index 000000000..d05714f07
--- /dev/null
+++ b/keyboard/jd45/jd45.c
@@ -0,0 +1,27 @@
1#include "jd45.h"
2
3__attribute__ ((weak))
4void * matrix_init_user(void) {
5
6};
7
8__attribute__ ((weak))
9void * matrix_scan_user(void) {
10
11};
12
13void * matrix_init_kb(void) {
14 #ifdef BACKLIGHT_ENABLE
15 backlight_init_ports();
16 #endif
17
18 if (matrix_init_user) {
19 (*matrix_init_user)();
20 }
21};
22
23void * matrix_scan_kb(void) {
24 if (matrix_scan_user) {
25 (*matrix_scan_user)();
26 }
27};
diff --git a/keyboard/jd45/jd45.h b/keyboard/jd45/jd45.h
new file mode 100644
index 000000000..f07bd5e13
--- /dev/null
+++ b/keyboard/jd45/jd45.h
@@ -0,0 +1,12 @@
1#ifndef JD45_H
2#define JD45_H
3
4#include "matrix.h"
5#include "keymap_common.h"
6#include "backlight.h"
7#include <stddef.h>
8
9void * matrix_init_user(void);
10void * matrix_scan_user(void);
11
12#endif
diff --git a/keyboard/jd45/keymaps/keymap_default.c b/keyboard/jd45/keymaps/keymap_default.c
new file mode 100644
index 000000000..05dd46e79
--- /dev/null
+++ b/keyboard/jd45/keymaps/keymap_default.c
@@ -0,0 +1,31 @@
1#include "jd45.h"
2#include "backlight.h"
3
4/* this keymap is to provide a basic keyboard layout for testing the matrix
5 * for more practical and complicated keymap refer to other keymaps in the same folder
6 */
7/* JD45 keymap definition macro
8 */
9#define KEYMAP( \
10 K01, K02, K03, K04, K05, K06, K07, K08, K09, K10, K11, K12, K13, \
11 K14, K15, K16, K17, K18, K19, K20, K21, K22, K23, K24, K25, \
12 K26, K27, K28, K29, K30, K31, K32, K33, K34, K35, K36, K37, \
13 K38, K39, K40, K41, K42, K43, K44, K45, K46, K47 \
14) { \
15 { KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K10, KC_##K11, KC_##K12, KC_##K13 }, \
16 { KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_NO }, \
17 { KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_NO }, \
18 { KC_##K38, KC_##K39, KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_##K43, KC_NO, KC_##K44, KC_##K45, KC_##K46, KC_##K47, KC_NO } \
19}
20
21const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
22[0] = KEYMAP(
23 ESC, Q, W, E, R, T, Y, U, I, O, P, QUOT, BSPC,
24 TAB, A, S, D, F, G, H, J, K, L, SCLN, ENT,
25 LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT,
26 PAUSE, LCTL, LALT, DEL, SPC, DEL, LEFT, UP, DOWN, RIGHT ),
27};
28
29const uint16_t PROGMEM fn_actions[] = {
30
31};
diff --git a/keyboard/jd45/keymaps/keymap_justin.c b/keyboard/jd45/keymaps/keymap_justin.c
new file mode 100644
index 000000000..f261b5463
--- /dev/null
+++ b/keyboard/jd45/keymaps/keymap_justin.c
@@ -0,0 +1,101 @@
1#include "jd45.h"
2#include "backlight.h"
3
4/* JD45 keymap definition macro
5 */
6#define KEYMAP( \
7 K01, K02, K03, K04, K05, K06, K07, K08, K09, K10, K11, K12, K13, \
8 K14, K15, K16, K17, K18, K19, K20, K21, K22, K23, K24, K25, \
9 K26, K27, K28, K29, K30, K31, K32, K33, K34, K35, K36, K37, \
10 K38, K39, K40, K41, K42, K43, K44, K45, K46, K47 \
11) { \
12 { KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K10, KC_##K11, KC_##K12, KC_##K13 }, \
13 { KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_NO }, \
14 { KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_NO }, \
15 { KC_##K38, KC_##K39, KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_##K43, KC_NO, KC_##K44, KC_##K45, KC_##K46, KC_##K47, KC_NO } \
16}
17
18const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
19[0] = KEYMAP(
20 ESC, Q, W, F, P, G, J, L, U, Y, SCLN, QUOT, BSPC,
21 FN8, A, R, S, T, D, H, N, E, I, O, ENT,
22 LSFT, Z, X, C, V, B, K, M, COMM, DOT, SLSH, FN6,
23 FN4, LGUI, FN7, FN2, FN1, SPC, FN5, RALT, FN3, FN0 ),
24[1] = KEYMAP(
25 TRNS, FN10, FN11, FN12, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, UP, DEL,
26 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, HOME, PGUP, LEFT, RGHT,
27 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, END, PGDN, DOWN, TRNS,
28 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS ),
29[2] = KEYMAP(
30 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, 7, 8, 9, 0, TRNS, TRNS,
31 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, LBRC, 4, 5, 6, DOT, TRNS,
32 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, RBRC, 1, 2, 3, BSLS, TRNS,
33 TRNS,FN29, TRNS, TRNS, TRNS, PAUSE, EQL, MINS, TRNS, TRNS ),
34[3] = KEYMAP(
35 TRNS, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
36 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
37 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
38 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS ),
39[4] = KEYMAP(
40 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, 7, 8, 9, 0, TRNS, TRNS,
41 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, LBRC, 4, 5, 6, DOT, TRNS,
42 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, RBRC, 1, 2, 3, BSLS, TRNS,
43 TRNS,FN29, TRNS, TRNS, TRNS, PAUSE, EQL, MINS, TRNS, TRNS ),
44};
45
46enum macro_id {
47 PSWD1,
48 PSWD2,
49 PSWD3,
50};
51
52const uint16_t PROGMEM fn_actions[] = {
53 [0] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_MINS),
54 [1] = ACTION_LAYER_MOMENTARY(1), // FN1
55 [2] = ACTION_LAYER_MOMENTARY(2), // FN2
56 [3] = ACTION_LAYER_MOMENTARY(3), // FN3
57 [4] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_GRV),
58 [5] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_RGUI),
59 [6] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_CAPS),
60 [7] = ACTION_LAYER_MODS(4, MOD_LSFT), // FN4
61 [8] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_TAB),
62
63 [10] = ACTION_MACRO(PSWD1),
64 [11] = ACTION_MACRO(PSWD2),
65 [12] = ACTION_MACRO(PSWD3),
66
67 [29] = ACTION_BACKLIGHT_TOGGLE(),
68 [30] = ACTION_BACKLIGHT_INCREASE(),
69 [31] = ACTION_BACKLIGHT_DECREASE()
70
71};
72
73/*
74 * Macro definition
75 */
76const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
77{
78 switch (id) {
79 case PSWD1:
80 return (record->event.pressed ?
81 MACRO( I(0), T(1), T(2), T(3), T(4), T(5), T(6), T(7), T(8), T(ENT), END ) :
82 MACRO_NONE );
83 case PSWD2:
84 return (record->event.pressed ?
85 MACRO( I(0), T(1), T(2), T(3), T(4), T(5), T(6), T(7), T(8), T(ENT), END ) :
86 MACRO_NONE );
87 case PSWD3:
88 return (record->event.pressed ?
89 MACRO( I(0), T(1), T(2), T(3), T(4), T(5), T(6), T(7), T(8), T(ENT), END ) :
90 MACRO_NONE );
91 //case VOLUP:
92 // return (record->event.pressed ?
93 // MACRO( D(VOLU), U(VOLU), END ) :
94 // MACRO_NONE );
95 //case ALT_TAB:
96 // return (record->event.pressed ?
97 // MACRO( D(LALT), D(TAB), END ) :
98 // MACRO( U(TAB), END ));
99 }
100 return MACRO_NONE;
101}