1
0

Add support for AKB96 Lite

This commit is contained in:
Kai Ryu 2014-10-14 11:33:07 +09:00
parent bb10a45a1f
commit ed3b4f868a
6 changed files with 264 additions and 8 deletions

View File

@ -0,0 +1,160 @@
#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF.
#
# make extcoff = Convert ELF to AVR Extended COFF.
#
# make program = Download the hex file to the device.
# Please customize your programmer settings(PROGRAM_CMD)
#
# make teensy = Download the hex file to the device, using teensy_loader_cli.
# (must have teensy_loader_cli installed).
#
# make dfu = Download the hex file to the device, using dfu-programmer (must
# have dfu-programmer installed).
#
# make flip = Download the hex file to the device, using Atmel FLIP (must
# have Atmel FLIP installed).
#
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
# (must have dfu-programmer installed).
#
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
# (must have Atmel FLIP installed).
#
# make debug = Start either simulavr or avarice as specified for debugging,
# with avr-gdb or avr-insight as the front end for debugging.
#
# make filename.s = Just compile filename.c into the assembler code only.
#
# make filename.i = Create a preprocessed source file for use in submitting
# bug reports to the GCC project.
#
# To rebuild project do "make clean" then "make all".
#----------------------------------------------------------------------------
# Target file name (without extension).
TARGET = akb96_lite_lufa
# Directory common source filess exist
TOP_DIR = ../..
# Directory keyboard dependent files exist
TARGET_DIR = .
# project specific files
SRC = keymap_common.c \
matrix.c \
led.c \
backlight.c \
ledmap.c
ifdef KEYMAP
SRC := keymap_$(KEYMAP).c $(SRC)
else
SRC := keymap_default.c $(SRC)
endif
CONFIG_H = config.h
# MCU name
#MCU = at90usb1287
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
# PCB Revision
ifdef REV
OPT_DEFS += -DREV_$(REV)_LITE
else
OPT_DEFS += -DREV_V3_LITE
endif
# Additional definitions from command line
ifdef DEFS
OPT_DEFS += $(foreach DEF,$(DEFS),-D$(DEF))
endif
# 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 = yes # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
USB_6KRO_ENABLE = yes # USB 6key Rollover
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
#PS2_USE_BUSYWAIT = yes
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
KEYMAP_IN_EEPROM_ENABLE = yes # Read keymap from eeprom
#KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor
SOFTPWM_LED_ENABLE = yes # Enable SoftPWM to drive backlight
FADING_LED_ENABLE = yes # Enable fading backlight
BREATHING_LED_ENABLE = yes # Enable breathing backlight
LEDMAP_ENABLE = yes # Enable LED mapping
LEDMAP_IN_EEPROM_ENABLE = yes # Read LED mapping from eeprom
# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax
# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TOP_DIR)
include $(TOP_DIR)/protocol/lufa.mk
include $(TOP_DIR)/protocol.mk
include $(TOP_DIR)/common.mk
include $(TOP_DIR)/rules.mk

View File

@ -39,7 +39,9 @@ static const uint8_t backlight_table[] PROGMEM = {
}; };
/* Backlight pin configuration /* Backlight pin configuration
* PWM: PB6 (D10) * PWM: PB6 (D10) REV_V2
* PB7 REV_V3
* PB7 REV_V3_LITE
*/ */
void backlight_enable(void) void backlight_enable(void)
{ {
@ -49,7 +51,7 @@ void backlight_enable(void)
// Turn on PWM // Turn on PWM
#if defined(REV_V2) #if defined(REV_V2)
DDRB |= (1<<PB6); DDRB |= (1<<PB6);
#elif defined(REV_V3) #elif defined(REV_V3) || defined(REV_V3_LITE)
DDRB |= (1<<PB7); DDRB |= (1<<PB7);
#endif #endif
cli(); cli();
@ -68,7 +70,7 @@ void backlight_disable(void)
cli(); cli();
#if defined(REV_V2) #if defined(REV_V2)
DDRB &= ~(1<<PB6); DDRB &= ~(1<<PB6);
#elif defined(REV_V3) #elif defined(REV_V3) || defined(REV_V3_LITE)
DDRB &= ~(1<<PB7); DDRB &= ~(1<<PB7);
#endif #endif
TCCR1A &= ~( (1<<WGM10) | (1<<COM1B1) ); TCCR1A &= ~( (1<<WGM10) | (1<<COM1B1) );
@ -177,7 +179,7 @@ void softpwm_led_init(void)
#if defined(REV_V2) #if defined(REV_V2)
DDRB |= (1<<PB6); DDRB |= (1<<PB6);
PORTB &= ~(1<<PB6); PORTB &= ~(1<<PB6);
#elif defined(REV_V3) #elif defined(REV_V3) || defined(REV_V3_LITE)
DDRB |= (1<<PB7); DDRB |= (1<<PB7);
PORTB &= ~(1<<PB7); PORTB &= ~(1<<PB7);
#endif #endif
@ -187,7 +189,7 @@ void softpwm_led_on(uint8_t index)
{ {
#if defined(REV_V2) #if defined(REV_V2)
PORTB |= (1<<PB6); PORTB |= (1<<PB6);
#elif defined(REV_V3) #elif defined(REV_V3) || defined(REV_V3_LITE)
PORTB |= (1<<PB7); PORTB |= (1<<PB7);
#endif #endif
} }
@ -196,7 +198,7 @@ void softpwm_led_off(uint8_t index)
{ {
#if defined(REV_V2) #if defined(REV_V2)
PORTB &= ~(1<<PB6); PORTB &= ~(1<<PB6);
#elif defined(REV_V3) #elif defined(REV_V3) || defined(REV_V3_LITE)
PORTB &= ~(1<<PB7); PORTB &= ~(1<<PB7);
#endif #endif
} }

View File

@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* USB Device descriptor parameter */ /* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED #define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x9696 #define PRODUCT_ID 0x9696
#define DEVICE_VER 0x0002 #define DEVICE_VER 0x0003
#define MANUFACTURER Leon #define MANUFACTURER Leon
#define PRODUCT Leon AKB96 #define PRODUCT Leon AKB96
#define DESCRIPTION t.m.k. keyboard firmware for AKB96 #define DESCRIPTION t.m.k. keyboard firmware for AKB96

View File

@ -30,6 +30,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* REV_V3 * REV_V3
* CapsLock PC7 * CapsLock PC7
* NumLock PC6 * NumLock PC6
* REV_V3_LITE
* CapsLock PC2
* NumLock PC4
*/ */
void led_set(uint8_t usb_led) void led_set(uint8_t usb_led)
{ {
@ -71,6 +74,25 @@ void led_set(uint8_t usb_led)
DDRC &= ~(1<<PC6); DDRC &= ~(1<<PC6);
PORTC &= ~(1<<PC6); PORTC &= ~(1<<PC6);
} }
#elif defined(REV_V3_LITE)
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
// output high
DDRC |= (1<<PC2);
PORTC |= (1<<PC2);
} else {
// Hi-Z
DDRC &= ~(1<<PC2);
PORTC &= ~(1<<PC2);
}
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
// output high
DDRC |= (1<<PC4);
PORTC |= (1<<PC4);
} else {
// Hi-Z
DDRC &= ~(1<<PC4);
PORTC &= ~(1<<PC4);
}
#endif #endif
} }

View File

@ -24,7 +24,11 @@ uint8_t ledmap_get_code(uint8_t index)
* REV_V3 * REV_V3
* CapsLock PC7 * CapsLock PC7
* NumLock PC6 * NumLock PC6
* Backlight PB6 * Backlight PB7
* REV_V3_LITE
* CapsLock PC2
* NumLock PC4
* Backlight PB7
*/ */
void ledmap_led_init(void) void ledmap_led_init(void)
{ {
@ -36,6 +40,11 @@ void ledmap_led_init(void)
PORTC &= ~(1<<PC7 | 1<<PC6); PORTC &= ~(1<<PC7 | 1<<PC6);
DDRB |= (1<<PB7); DDRB |= (1<<PB7);
PORTB &= ~(1<<PB7); PORTB &= ~(1<<PB7);
#elif defined(REV_V3_LITE)
DDRC |= (1<<PC2 | 1<<PC4);
PORTC &= ~(1<<PC2 | 1<<PC4);
DDRB |= (1<<PB7);
PORTB &= ~(1<<PB7);
#endif #endif
} }
@ -65,6 +74,18 @@ void ledmap_led_on(uint8_t index)
PORTB |= (1<<PB7); PORTB |= (1<<PB7);
break; break;
} }
#elif defined(REV_V3_LITE)
switch (index) {
case 0:
PORTC |= (1<<PC2);
break;
case 1:
PORTC |= (1<<PC4);
break;
case 2:
PORTB |= (1<<PB7);
break;
}
#endif #endif
} }
@ -94,6 +115,18 @@ void ledmap_led_off(uint8_t index)
PORTB &= ~(1<<PB7); PORTB &= ~(1<<PB7);
break; break;
} }
#elif defined(REV_V3_LITE)
switch (index) {
case 0:
PORTC &= ~(1<<PC2);
break;
case 1:
PORTC &= ~(1<<PC4);
break;
case 2:
PORTB &= ~(1<<PB7);
break;
}
#endif #endif
} }

View File

@ -55,9 +55,11 @@ uint8_t matrix_cols(void)
void matrix_init(void) void matrix_init(void)
{ {
#ifndef REV_V3_LITE
// disable JTAG // disable JTAG
MCUCR = (1<<JTD); MCUCR = (1<<JTD);
MCUCR = (1<<JTD); MCUCR = (1<<JTD);
#endif
// initialize row and col // initialize row and col
unselect_rows(); unselect_rows();
@ -141,6 +143,7 @@ uint8_t matrix_key_count(void)
* pin: D17 D15 A0 A1 A2 A3 (arduino) REV_V2 * pin: D17 D15 A0 A1 A2 A3 (arduino) REV_V2
* PB3 PB1 PF7 PF6 PF5 PF4 * PB3 PB1 PF7 PF6 PF5 PF4
* PF0 PF1 PF4 PF5 PF6 PF7 REV_V3 * PF0 PF1 PF4 PF5 PF6 PF7 REV_V3
* PD1 PD2 PD3 PD4 PD5 PD6
*/ */
static void init_cols(void) static void init_cols(void)
{ {
@ -153,6 +156,9 @@ static void init_cols(void)
#elif defined(REV_V3) #elif defined(REV_V3)
DDRF &= ~(1<<PF0 | 1<<PF1 | 1<<PF4 | 1<<PF5 | 1<<PF6 | 1<<PF7); DDRF &= ~(1<<PF0 | 1<<PF1 | 1<<PF4 | 1<<PF5 | 1<<PF6 | 1<<PF7);
PORTF |= (1<<PF0 | 1<<PF1 | 1<<PF4 | 1<<PF5 | 1<<PF6 | 1<<PF7); PORTF |= (1<<PF0 | 1<<PF1 | 1<<PF4 | 1<<PF5 | 1<<PF6 | 1<<PF7);
#elif defined(REV_V3_LITE)
DDRD &= ~(1<<PD1 | 1<<PD2 | 1<<PD3 | 1<<PD4 | 1<<PD5 | 1<<PD6);
PORTD |= (1<<PD1 | 1<<PD2 | 1<<PD3 | 1<<PD4 | 1<<PD5 | 1<<PD6);
#endif #endif
} }
@ -168,6 +174,8 @@ static matrix_row_t read_cols(void)
#elif defined(REV_V3) #elif defined(REV_V3)
//return ((~(PINF) >> 4) & 0x0F) | (~(PINF) & (1<<PF0 | 1<<PF1)); //return ((~(PINF) >> 4) & 0x0F) | (~(PINF) & (1<<PF0 | 1<<PF1));
return (~(PINF) & 0b00000011) | ((~(PINF) >> 2) & 0b00111100); return (~(PINF) & 0b00000011) | ((~(PINF) >> 2) & 0b00111100);
#elif defined(REV_V3_LITE)
return ~(PIND) >> 1;
#endif #endif
} }
@ -193,6 +201,13 @@ static void unselect_rows(void)
// Select 0 // Select 0
DDRD |= (1<<PD4 | 1<<PD5 | 1<<PD6 | 1<<PD7); DDRD |= (1<<PD4 | 1<<PD5 | 1<<PD6 | 1<<PD7);
PORTD &= ~(1<<PD4 | 1<<PD5 | 1<<PD6 | 1<<PD7); PORTD &= ~(1<<PD4 | 1<<PD5 | 1<<PD6 | 1<<PD7);
#elif defined(REV_V3_LITE)
// Hi-Z(DDR:0, PORT:0) to unselect
DDRB &= ~(1<<PB0 | 1<<PB1 | 1<<PB2);
PORTB &= ~(1<<PB0 | 1<<PB1 | 1<<PB2);
// Select 0
DDRB |= (1<<PB3 | 1<<PB4 | 1<<PB5 | 1<<PB6);
PORTB &= ~(1<<PB3 | 1<<PB4 | 1<<PB5 | 1<<PB6);
#endif #endif
} }
@ -215,6 +230,13 @@ static void unselect_rows(void)
* PB5 - 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 | * PB5 - 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 |
* PB6 - 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 / * PB6 - 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 /
* *
* PB0 - 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \
* / PB3 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 |
* | PB4 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 |
* | PB5 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 |- REV_V3_LITE
* \ PB6 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 |
* PB1 - 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 |
* PB2 - 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 /
*/ */
static void select_row(uint8_t row) static void select_row(uint8_t row)
{ {
@ -255,5 +277,22 @@ static void select_row(uint8_t row)
DDRB |= (1<<PB6); DDRB |= (1<<PB6);
PORTB &= ~(1<<PB6); PORTB &= ~(1<<PB6);
} }
#elif defined(REV_V3_LITE)
// Output low(DDR:1, PORT:0) to select
if (row == 0) {
DDRB |= (1<<PB0);
PORTB &= ~(1<<PB0);
}
else if (row < 16) {
PORTB = (PORTB & 0b10000111) | ((row & 0x0F) << 3);
}
else if (row == 16) {
DDRB |= (1<<PB1);
PORTB &= ~(1<<PB1);
}
else if (row == 17) {
DDRB |= (1<<PB2);
PORTB &= ~(1<<PB2);
}
#endif #endif
} }