From 931a52d1ae50aef36e55fde59874614f742554a3 Mon Sep 17 00:00:00 2001
From: nachie <me@nachie.com>
Date: Wed, 28 Mar 2018 20:20:15 -0700
Subject: Support for the Paladin64 PCB (#2639)

* Support for the Paladin64 PCB

* Paladin64: Added readme. Added the bootloader option to rules.mk

* Fixed the formatting

* fixed the flash command
---
 keyboards/paladin64/config.h                 | 124 +++++++++++++++++++++++++++
 keyboards/paladin64/keymaps/default/keymap.c | 100 +++++++++++++++++++++
 keyboards/paladin64/paladin64.c              |   2 +
 keyboards/paladin64/paladin64.h              |  23 +++++
 keyboards/paladin64/readme.md                |  19 ++++
 keyboards/paladin64/rules.mk                 |  60 +++++++++++++
 6 files changed, 328 insertions(+)
 create mode 100755 keyboards/paladin64/config.h
 create mode 100755 keyboards/paladin64/keymaps/default/keymap.c
 create mode 100755 keyboards/paladin64/paladin64.c
 create mode 100755 keyboards/paladin64/paladin64.h
 create mode 100644 keyboards/paladin64/readme.md
 create mode 100755 keyboards/paladin64/rules.mk

(limited to 'keyboards/paladin64')

diff --git a/keyboards/paladin64/config.h b/keyboards/paladin64/config.h
new file mode 100755
index 0000000000..27f54bf161
--- /dev/null
+++ b/keyboards/paladin64/config.h
@@ -0,0 +1,124 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#include "config_common.h"
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID       0xFEED
+#define PRODUCT_ID      0x6060
+#define DEVICE_VER      0x0001
+#define MANUFACTURER    inachie
+#define PRODUCT         paladin64
+#define DESCRIPTION     Paladin64 ALPS 64 keyboard with trackpoint and underglow
+
+/* key matrix size */
+#define MATRIX_ROWS 8
+#define MATRIX_COLS 8
+
+#ifdef PS2_USE_USART
+    #define PS2_CLOCK_PORT  PORTD
+    #define PS2_CLOCK_PIN   PIND
+    #define PS2_CLOCK_DDR   DDRD
+    #define PS2_CLOCK_BIT   5
+    #define PS2_DATA_PORT   PORTD
+    #define PS2_DATA_PIN    PIND
+    #define PS2_DATA_DDR    DDRD
+    #define PS2_DATA_BIT    2
+
+    /* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling
+     * edge */
+    /* set DDR of CLOCK as input to be slave */
+    #define PS2_USART_INIT() do {   \
+                    PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT);   \
+                    PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT);     \
+                    UCSR1C = ((1 << UMSEL10) |  \
+                                                  (3 << UPM10)   |  \
+                                                  (0 << USBS1)   |  \
+                                                  (3 << UCSZ10)  |  \
+                                                  (0 << UCPOL1));   \
+                    UCSR1A = 0;                 \
+                    UBRR1H = 0;                 \
+                    UBRR1L = 0;                 \
+                } while (0)
+    #define PS2_USART_RX_INT_ON() do {  \
+                    UCSR1B = ((1 << RXCIE1) |       \
+                                                  (1 << RXEN1));        \
+                } while (0)
+    #define PS2_USART_RX_POLL_ON() do { \
+                    UCSR1B = (1 << RXEN1);          \
+                } while (0)
+    #define PS2_USART_OFF() do {    \
+                    UCSR1C = 0;                 \
+                    UCSR1B &= ~((1 << RXEN1) |  \
+                                                    (1 << TXEN1));  \
+                } while (0)
+    #define PS2_USART_RX_READY      (UCSR1A & (1<<RXC1))
+    #define PS2_USART_RX_DATA       UDR1
+    #define PS2_USART_ERROR         (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1)))
+    #define PS2_USART_RX_VECT       USART1_RX_vect
+#endif
+
+#ifdef PS2_USE_INT
+#define PS2_CLOCK_PORT  PORTD
+#define PS2_CLOCK_PIN   PIND
+#define PS2_CLOCK_DDR   DDRD
+#define PS2_CLOCK_BIT   2
+#define PS2_DATA_PORT   PORTD
+#define PS2_DATA_PIN    PIND
+#define PS2_DATA_DDR    DDRD
+#define PS2_DATA_BIT    5
+
+    #define PS2_INT_INIT()  do {    \
+        EICRA |= ((1<<ISC21) |      \
+                  (0<<ISC20));      \
+    } while (0)
+    #define PS2_INT_ON()  do {      \
+        EIMSK |= (1<<INT2);         \
+    } while (0)
+    #define PS2_INT_OFF() do {      \
+        EIMSK &= ~(1<<INT2);        \
+    } while (0)
+    #define PS2_INT_VECT   INT2_vect
+
+#endif
+
+/* key matrix pins */
+#define MATRIX_ROW_PINS { C6, B6, B5, B4, D7, D6, B0, D3 }
+#define MATRIX_COL_PINS { C7, F7, F6, F5, F4, F1, F0, D1 }
+#define UNUSED_PINS
+
+/* COL2ROW or ROW2COL */
+#define DIODE_DIRECTION COL2ROW
+
+/* number of backlight levels */
+
+#ifdef BACKLIGHT_PIN
+#define BACKLIGHT_LEVELS 3
+#endif
+
+/* Set 0 if debouncing isn't needed */
+#define DEBOUNCING_DELAY 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)) \
+)
+
+/* prevent stuck modifiers */
+#define PREVENT_STUCK_MODIFIERS
+#define RGB_DI_PIN D0
+#ifdef RGB_DI_PIN
+#define RGBLIGHT_ANIMATIONS
+#define RGBLED_NUM 14
+#define RGBLIGHT_HUE_STEP 10
+#define RGBLIGHT_SAT_STEP 17
+#define RGBLIGHT_VAL_STEP 12
+#endif
+
+#endif
diff --git a/keyboards/paladin64/keymaps/default/keymap.c b/keyboards/paladin64/keymaps/default/keymap.c
new file mode 100755
index 0000000000..1ac670fa0f
--- /dev/null
+++ b/keyboards/paladin64/keymaps/default/keymap.c
@@ -0,0 +1,100 @@
+#include "paladin64.h"
+
+const uint16_t PROGMEM fn_actions[] = {};
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+
+    /* QWERTY */
+	KEYMAP(
+		KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_GRV, KC_BSLS,
+		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_BSPC,
+		MO(3), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
+		KC_LSFT, KC_NUBS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_LSFT, MO(3),
+		KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_APP, KC_RGUI, KC_RALT, KC_LCTL), 
+
+    /* DVORAK */
+	KEYMAP(
+		KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_LBRC, KC_RBRC, KC_GRV, KC_BSLS, 
+		KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_SLSH, KC_EQL, KC_BSPC,  
+		MO(3), KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_MINS, KC_ENT,
+		KC_LSFT, KC_NUBS, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_LSFT, MO(3),
+		KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_APP, KC_RGUI, KC_RALT, KC_RCTL), 
+
+    /* COLEMAK */
+	KEYMAP(
+		KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_GRV, KC_BSLS,
+		KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_LBRC, KC_RBRC, KC_BSPC,
+		MO(3), KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, KC_ENT, 
+		KC_LSFT, KC_NUBS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_LSFT, MO(3),
+		KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_APP, KC_RGUI, KC_RALT, KC_RCTL), 
+
+    /* FUNCTION */
+	KEYMAP(
+		KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, KC_TRNS,
+		KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, KC_TRNS, KC_TRNS, KC_PGUP, KC_UP, KC_PGDN, KC_PSCR, KC_SLCK, KC_PAUS, KC_BSPC,
+		KC_TRNS, KC_TRNS, KC_MPRV, KC_MPLY, KC_MNXT, KC_TRNS, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS,
+		KC_CAPS, KC_TRNS, KC_TRNS, KC_MUTE, KC_VOLD, KC_VOLU, KC_TRNS, KC_END, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+		KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_MOD, KC_TRNS, RGB_TOG),
+
+    /* AutoMouse */
+	KEYMAP(
+        KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+        KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+        KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+        KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+        KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN3, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
+
+};
+
+const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
+	// keyevent_t event = record->event;
+
+	switch (id) {
+
+	}
+	return MACRO_NONE;
+}
+
+void matrix_init_user(void) {
+}
+
+void matrix_scan_user(void) {
+}
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+	return true;
+}
+
+void led_set_user(uint8_t usb_led) {
+
+	if (usb_led & (1 << USB_LED_NUM_LOCK)) {
+		
+	} else {
+		
+	}
+
+	if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
+		
+	} else {
+		
+	}
+
+	if (usb_led & (1 << USB_LED_SCROLL_LOCK)) {
+		
+	} else {
+		
+	}
+
+	if (usb_led & (1 << USB_LED_COMPOSE)) {
+		
+	} else {
+		
+	}
+
+	if (usb_led & (1 << USB_LED_KANA)) {
+		
+	} else {
+		
+	}
+
+}
+
diff --git a/keyboards/paladin64/paladin64.c b/keyboards/paladin64/paladin64.c
new file mode 100755
index 0000000000..5ef78d5bf7
--- /dev/null
+++ b/keyboards/paladin64/paladin64.c
@@ -0,0 +1,2 @@
+#include "paladin64.h"
+
diff --git a/keyboards/paladin64/paladin64.h b/keyboards/paladin64/paladin64.h
new file mode 100755
index 0000000000..1bbf9ea530
--- /dev/null
+++ b/keyboards/paladin64/paladin64.h
@@ -0,0 +1,23 @@
+#ifndef PALADIN64_H
+#define PALADIN64_H
+
+#include "quantum.h"
+
+#define KEYMAP( \
+    K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K26, K27, \
+    K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \
+    K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \
+    K31, K41, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, K22, \
+    K30, K40, K50,           K60,                     K70, K00, K10, K20  \
+) { \
+    { K00, K01, K02, K03, K04, K05, K06, K07 }, \
+    { K10, K11, K12, K13, K14, K15, K16, K17 }, \
+    { K20, K21, K22, K23, K24, K25, K26, K27 }, \
+    { K30, K31, K32, K33, K34, K35, K36, K37 }, \
+    { K40, K41, K42, K43, K44, K45, K46, K47 }, \
+    { K50, K51, K52, K53, K54, K55, K56, K57 }, \
+    { K60, K61, K62, K63, K64, K65, K66, K67 }, \
+    { K70, K71, K72, K73, K74, K75, K76, K77 } \
+}
+
+#endif
diff --git a/keyboards/paladin64/readme.md b/keyboards/paladin64/readme.md
new file mode 100644
index 0000000000..41f66e2ac0
--- /dev/null
+++ b/keyboards/paladin64/readme.md
@@ -0,0 +1,19 @@
+# Paladin64 ALPS PCB by /u/iNachie
+
+Firmware for the Paladin64 ALPS64 PCB, with underglow and an optional
+trackpoint module.
+
+Keyboard Maintainer: [/u/iNachie](https://github.com/nachie)  
+Hardware Supported: Paladin64 ALPS PCB by iNachie  
+Hardware Availability: [/u/iNachie](https://www.reddit.com/user/inachie/)
+
+Make example for this keyboard (after setting up your build environment):
+
+    make paladin64:default
+
+Or to make and flash:
+
+    make paladin64:default:dfu
+
+
+See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information.
diff --git a/keyboards/paladin64/rules.mk b/keyboards/paladin64/rules.mk
new file mode 100755
index 0000000000..b24dc49d06
--- /dev/null
+++ b/keyboards/paladin64/rules.mk
@@ -0,0 +1,60 @@
+# 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(+60)
+OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+
+
+# Boot Section Size in *bytes*
+OPT_DEFS += -DBOOTLOADER_SIZE=4096
+
+BOOTLOADER = atmel-dfu
+
+# Build Options
+#   comment out to disable the options.
+#
+BOOTMAGIC_ENABLE ?= yes	# Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE ?= yes	# Mouse keys(+4700)
+EXTRAKEY_ENABLE ?= yes	# Audio control and System control(+450)
+CONSOLE_ENABLE ?= yes	# Console for debug(+400)
+COMMAND_ENABLE ?= no    # Commands for debug and configuration
+SLEEP_LED_ENABLE ?= no  # Breathing sleep LED during USB suspend
+NKRO_ENABLE ?= yes		# USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+BACKLIGHT_ENABLE ?= no  # Enable keyboard backlight functionality
+AUDIO_ENABLE ?= no
+RGBLIGHT_ENABLE ?= yes
+#PS2_MOUSE_ENABLE ?= yes
+#PS2_USE_USART ?= yes
+#PS2_USE_INT ?= yes
-- 
cgit v1.2.3