diff options
Diffstat (limited to 'keyboards')
-rw-r--r-- | keyboards/alps64/alps64.c | 29 | ||||
-rw-r--r-- | keyboards/alps64/alps64.h | 22 | ||||
-rw-r--r-- | keyboards/alps64/config.h | 7 | ||||
-rw-r--r-- | keyboards/alps64/led.c | 34 | ||||
-rw-r--r-- | keyboards/alps64/matrix.c | 199 | ||||
-rw-r--r-- | keyboards/alps64/rules.mk | 50 |
6 files changed, 24 insertions, 317 deletions
diff --git a/keyboards/alps64/alps64.c b/keyboards/alps64/alps64.c index 472d1d445c..0e4ef07bc0 100644 --- a/keyboards/alps64/alps64.c +++ b/keyboards/alps64/alps64.c @@ -14,17 +14,24 @@ 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 "quantum.h" +#include "alps64.h" -#define LED_ON() do { DDRC |= (1<<5); PORTC |= (1<<5); } while (0) -#define LED_OFF() do { DDRC &= ~(1<<5); PORTC &= ~(1<<5); } while (0) -#define LED_TGL() do { DDRC |= (1<<5); PINC |= (1<<5); } while (0) +void keyboard_pre_init_kb(void) { + // put your keyboard start-up code here + // runs once when the firmware starts up + setPinOutput(C5); + keyboard_pre_init_user(); +} +void led_set_kb(uint8_t usb_led) +{ + if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) { + // output high + writePinHigh(C5); + } else { + // Hi-Z + writePinLow(C5); + } -void matrix_init_kb(void) { - LED_ON(); - _delay_ms(500); - LED_OFF(); - - matrix_init_user(); -}
\ No newline at end of file + led_set_user(usb_led); +} diff --git a/keyboards/alps64/alps64.h b/keyboards/alps64/alps64.h index 14ff552185..d816be9da7 100644 --- a/keyboards/alps64/alps64.h +++ b/keyboards/alps64/alps64.h @@ -14,8 +14,7 @@ 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 ALPS64_H -#define ALPS64_H +#pragma once #include "quantum.h" @@ -105,22 +104,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. { K60, K61, K62, K63, K64, K65, K66, K67 }, \ { KC_NO, K71, K72, K73, K74, K75, K76, K77 } \ } - -#define LAYOUT_kc( \ - 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 \ -) { \ - { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ - { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ - { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ - { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ - { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \ - { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ - { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \ - { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 } \ -} - -#endif diff --git a/keyboards/alps64/config.h b/keyboards/alps64/config.h index 74f8017add..cc7eada11a 100644 --- a/keyboards/alps64/config.h +++ b/keyboards/alps64/config.h @@ -15,8 +15,7 @@ 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 +#pragma once #include "config_common.h" @@ -24,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define VENDOR_ID 0xFEED #define PRODUCT_ID 0x6464 #define DEVICE_VER 0x0001 -#define MANUFACTURER TMK +#define MANUFACTURER Hasu #define PRODUCT Alps64 #define DESCRIPTION TMK keyboard firmware for Alps64 @@ -64,5 +63,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. //#define NO_ACTION_ONESHOT //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION - -#endif diff --git a/keyboards/alps64/led.c b/keyboards/alps64/led.c deleted file mode 100644 index d20c51aabe..0000000000 --- a/keyboards/alps64/led.c +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright 2012 Jun Wako <wakojun@gmail.com> - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include <avr/io.h> -#include "stdint.h" -#include "led.h" - - -void led_set(uint8_t usb_led) -{ - if (usb_led & (1<<USB_LED_CAPS_LOCK)) { - // output high - DDRC |= (1<<5); - PORTC |= (1<<5); - } else { - // Hi-Z - DDRC &= ~(1<<5); - PORTC &= ~(1<<5); - } -} diff --git a/keyboards/alps64/matrix.c b/keyboards/alps64/matrix.c deleted file mode 100644 index b3508850de..0000000000 --- a/keyboards/alps64/matrix.c +++ /dev/null @@ -1,199 +0,0 @@ -/* -Copyright 2012 Jun Wako <wakojun@gmail.com> - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -/* - * scan matrix - */ -#include <stdint.h> -#include <stdbool.h> -#include <avr/io.h> -#include <util/delay.h> -#include "print.h" -#include "debug.h" -#include "util.h" -#include "matrix.h" - - -#ifndef DEBOUNCE -# define DEBOUNCE 5 -#endif -static uint8_t debouncing = DEBOUNCE; - -/* matrix state(1:on, 0:off) */ -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -static matrix_row_t read_cols(void); -static void init_cols(void); -static void unselect_rows(void); -static void select_row(uint8_t row); - - -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} - -void matrix_init(void) -{ - // 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(); - _delay_ms(500); - LED_OFF(); -} - -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]; - } - } - } - - matrix_scan_quantum(); - - 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 - * col: 0 1 2 3 4 5 6 7 - * pin: B0 B1 B2 B3 B4 B5 B6 B7 - */ -static void init_cols(void) -{ - // Input with pull-up(DDR:0, PORT:1) - DDRB &= ~0b11111111; - PORTB |= 0b11111111; -} - -/* Returns status of switches(1:on, 0:off) */ -static matrix_row_t read_cols(void) -{ - // Invert because PIN indicates 'switch on' with low(0) and 'off' with high(1) - return ~PINB; -} - -/* Row pin configuration - * row: 0 1 2 3 4 5 6 7 - * pin: D0 D1 D2 D3 D4 D5 D6 C2 - */ -static void unselect_rows(void) -{ - // Hi-Z(DDR:0, PORT:0) to unselect - DDRD &= ~0b01111111; - PORTD &= ~0b01111111; - DDRC &= ~0b00000100; - PORTC &= ~0b00000100; -} - - -static void select_row(uint8_t row) -{ - // Output low(DDR:1, PORT:0) to select - switch (row) { - case 0: - DDRD |= (1<<0); - PORTD &= ~(1<<0); - break; - case 1: - DDRD |= (1<<1); - PORTD &= ~(1<<1); - break; - case 2: - DDRD |= (1<<2); - PORTD &= ~(1<<2); - break; - case 3: - DDRD |= (1<<3); - PORTD &= ~(1<<3); - break; - case 4: - DDRD |= (1<<4); - PORTD &= ~(1<<4); - break; - case 5: - DDRD |= (1<<5); - PORTD &= ~(1<<5); - break; - case 6: - DDRD |= (1<<6); - PORTD &= ~(1<<6); - break; - case 7: - DDRC |= (1<<2); - PORTC &= ~(1<<2); - break; - } -} diff --git a/keyboards/alps64/rules.mk b/keyboards/alps64/rules.mk index 4f35faac29..d618e1c3ca 100644 --- a/keyboards/alps64/rules.mk +++ b/keyboards/alps64/rules.mk @@ -1,63 +1,19 @@ - - -# Target file name (without extension). - -# project specific files -SRC = led.c - # MCU name MCU = atmega32u2 -# Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to -# calculate timings. Do NOT tack on a 'UL' at the end, this will be done -# automatically to create a 32-bit value in your source code. -# -# This will be an integer division of F_USB below, as it is sourced by -# F_USB after it has run through any CPU prescalers. Note that this value -# does not *change* the processor frequency - it should merely be updated to -# reflect the processor speed set externally so that the code can use accurate -# software delays. -F_CPU = 16000000 - - -# -# LUFA specific -# -# Target architecture (see library "Board Types" documentation). -ARCH = AVR8 - -# Input clock frequency. -# This will define a symbol, F_USB, in all source code files equal to the -# input clock frequency (before any prescaling is performed) in Hz. This value may -# differ from F_CPU if prescaling is used on the latter, and is required as the -# raw input clock is fed directly to the PLL sections of the AVR for high speed -# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' -# at the end, this will be done automatically to create a 32-bit value in your -# source code. -# -# If no clock division is performed on the input clock inside the AVR (via the -# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. -F_USB = $(F_CPU) - -# Interrupt driven control endpoint task(+60) -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT - - # Boot Section Size in *bytes* # Teensy halfKay 512 # Teensy++ halfKay 1024 # Atmel DFU loader 4096 # LUFA bootloader 4096 # USBaspLoader 2048 -OPT_DEFS += -DBOOTLOADER_SIZE=4096 - +# OPT_DEFS += -DBOOTLOADER_SIZE=4096 +BOOTLOADER = atmel-dfu # Build Options # change to no to disable the options. # -BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +BOOTMAGIC_ENABLE = lite # 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) |