Add pin define to support AKB96 Rev3
This commit is contained in:
parent
7eec801424
commit
b84f264e57
@ -112,6 +112,11 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||
# USBaspLoader 2048
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
# PCB Revision
|
||||
ifdef REV
|
||||
OPT_DEFS += -DREV_$(REV)
|
||||
endif
|
||||
|
||||
# Additional definitions from command line
|
||||
ifdef DEFS
|
||||
OPT_DEFS += $(foreach DEF,$(DEFS),-D$(DEF))
|
||||
|
@ -82,6 +82,13 @@ F_CPU = 16000000
|
||||
# LUFA bootloader 4096
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
|
||||
# PCB Revision
|
||||
ifdef REV
|
||||
OPT_DEFS += -DREV_$(REV)
|
||||
else
|
||||
OPT_DEFS += -DREV_V3
|
||||
endif
|
||||
|
||||
# Additional definitions from command line
|
||||
ifdef DEFS
|
||||
OPT_DEFS += $(foreach DEF,$(DEFS),-D$(DEF))
|
||||
@ -101,6 +108,7 @@ COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
KEYMAP_EX_ENABLE = yes # External keymap in eeprom
|
||||
KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor
|
||||
BREATHING_LED_ENABLE = yes # Enable breathing backlight
|
||||
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0x9696
|
||||
#define DEVICE_VER 0x0001
|
||||
#define DEVICE_VER 0x0002
|
||||
#define MANUFACTURER Leon
|
||||
#define PRODUCT Leon AKB96
|
||||
#define DESCRIPTION t.m.k. keyboard firmware for AKB96
|
||||
|
@ -22,11 +22,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/* LED pin configration
|
||||
* REV_V2
|
||||
* CapsLock PB5 (D9)
|
||||
* NumLock PB2 (D16)
|
||||
* REV_V3
|
||||
* CapsLock PC7
|
||||
* NumLock PC6
|
||||
*/
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
#if defined(REV_V2)
|
||||
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
|
||||
// output high
|
||||
DDRB |= (1<<PB5);
|
||||
@ -36,11 +41,23 @@ void led_set(uint8_t usb_led)
|
||||
DDRB &= ~(1<<PB5);
|
||||
PORTB &= ~(1<<PB5);
|
||||
}
|
||||
#elif defined(REV_V3)
|
||||
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
|
||||
// output high
|
||||
DDRC |= (1<<PC7);
|
||||
PORTC |= (1<<PC7);
|
||||
} else {
|
||||
// Hi-Z
|
||||
DDRC &= ~(1<<PC7);
|
||||
PORTC &= ~(1<<PC7);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ON_LAYER_CHANGE
|
||||
void layer_change(uint32_t state)
|
||||
{
|
||||
#if defined(REV_V2)
|
||||
if (state & (1UL<<2)) {
|
||||
// output high
|
||||
DDRB |= (1<<PB2);
|
||||
@ -50,5 +67,16 @@ void layer_change(uint32_t state)
|
||||
DDRB &= ~(1<<PB2);
|
||||
PORTB &= ~(1<<PB2);
|
||||
}
|
||||
#elif defined(REV_V3)
|
||||
if (state & (1UL<<2)) {
|
||||
// output high
|
||||
DDRC |= (1<<PC6);
|
||||
PORTC |= (1<<PC6);
|
||||
} else {
|
||||
// Hi-Z
|
||||
DDRC &= ~(1<<PC6);
|
||||
PORTC &= ~(1<<PC6);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -138,30 +138,40 @@ uint8_t matrix_key_count(void)
|
||||
|
||||
/* Column pin configuration
|
||||
* col: 0 1 2 3 4 5
|
||||
* pin: D17 D15 A0 A1 A2 A3 (arduino)
|
||||
* pin: D17 D15 A0 A1 A2 A3 (arduino) REV_V2
|
||||
* PB3 PB1 PF7 PF6 PF5 PF4
|
||||
* PF0 PF1 PF4 PF5 PF6 PF7 REV_V3
|
||||
*/
|
||||
static void init_cols(void)
|
||||
{
|
||||
// Input with pull-up(DDR:0, PORT:1)
|
||||
#if defined(REV_V2)
|
||||
DDRF &= ~(1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4);
|
||||
PORTF |= (1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4);
|
||||
DDRB &= ~(1<<PB3 | 1<<PB1);
|
||||
PORTB |= (1<<PB3 | 1<<PB1);
|
||||
#elif defined(REV_V3)
|
||||
DDRF &= ~(1<<PF0 | 1<<PF1 | 1<<PF4 | 1<<PF5 | 1<<PF6 | 1<<PF7);
|
||||
#endif
|
||||
}
|
||||
|
||||
static matrix_row_t read_cols(void)
|
||||
{
|
||||
#if defined(REV_V2)
|
||||
return (PINB&(1<<PB3) ? 0 : (1<<0)) |
|
||||
(PINB&(1<<PB1) ? 0 : (1<<1)) |
|
||||
(PINF&(1<<PF7) ? 0 : (1<<2)) |
|
||||
(PINF&(1<<PF6) ? 0 : (1<<3)) |
|
||||
(PINF&(1<<PF5) ? 0 : (1<<4)) |
|
||||
(PINF&(1<<PF4) ? 0 : (1<<5));
|
||||
#elif defined(REV_V3)
|
||||
return (~(PINF) >> 4) | (~(PINF) & (1<<PF0 | 1<<PF1));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void unselect_rows(void)
|
||||
{
|
||||
#if defined(REV_V2)
|
||||
// Hi-Z(DDR:0, PORT:0) to unselect
|
||||
DDRB &= ~(1<<PB4);
|
||||
PORTB &= ~(1<<PB4);
|
||||
@ -174,20 +184,39 @@ static void unselect_rows(void)
|
||||
PORTD &= ~(1<<PD3 | 1<<PD2 | 1<<PD0);
|
||||
DDRC |= (1<<PC6);
|
||||
PORTC &= ~(1<<PC6);
|
||||
#elif defined(REV_V3)
|
||||
// Hi-Z(DDR:0, PORT:0) to unselect
|
||||
DDRB &= ~(1<<PB4 | 1<<PB5 | 1<<PB6);
|
||||
PORTB &= ~(1<<PB4 | 1<<PB5 | 1<<PB6);
|
||||
// Select 0
|
||||
DDRD |= (1<<PD4 | 1<<PD5 | 1<<PD6 | 1<<PD7);
|
||||
PORTD &= ~(1<<PD4 | 1<<PD5 | 1<<PD6 | 1<<PD7);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Row pin configuration
|
||||
* row: x 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
||||
* pin: D8 PB4 - 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
* / TX PD3 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0
|
||||
* | RX PD2 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0
|
||||
* | D3 PD0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0
|
||||
* \ D5 PC6 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0
|
||||
* D6 PD7 - 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1
|
||||
* D7 PE6 - 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
|
||||
*
|
||||
* pin: D8 PB4 - 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \
|
||||
* / TX PD3 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 |
|
||||
* | RX PD2 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 |
|
||||
* | D3 PD0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 |- REV_V2
|
||||
* \ D5 PC6 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 |
|
||||
* D6 PD7 - 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 |
|
||||
* D7 PE6 - 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 /
|
||||
*
|
||||
* PB4 - 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \
|
||||
* / PD4 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 |
|
||||
* | PD5 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 |
|
||||
* | PD6 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 |- REV_V3
|
||||
* \ PD7 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 |
|
||||
* 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 /
|
||||
*
|
||||
*/
|
||||
static void select_row(uint8_t row)
|
||||
{
|
||||
#if defined(REV_V2)
|
||||
// Output low(DDR:1, PORT:0) to select
|
||||
if (row == 0) {
|
||||
DDRB |= (1<<PB4);
|
||||
@ -202,9 +231,31 @@ static void select_row(uint8_t row)
|
||||
else if (row == 16) {
|
||||
DDRD |= (1<<PD7);
|
||||
PORTD &= ~(1<<PD7);
|
||||
DDRB |= (1<<PB5);
|
||||
PORTB &= ~(1<<PB5);
|
||||
}
|
||||
else if (row == 17) {
|
||||
DDRE |= (1<<PE6);
|
||||
PORTE &= ~(1<<PE6);
|
||||
DDRB |= (1<<PB6);
|
||||
PORTB &= ~(1<<PB6);
|
||||
}
|
||||
#elif defined(REV_V3)
|
||||
// Output low(DDR:1, PORT:0) to select
|
||||
if (row == 0) {
|
||||
DDRB |= (1<<PB4);
|
||||
PORTB &= ~(1<<PB4);
|
||||
}
|
||||
else if (row < 16) {
|
||||
PORTD = (PORTD & 0x0F) | ((row & 0x0F) << 4);
|
||||
}
|
||||
else if (row == 16) {
|
||||
DDRB |= (1<<PB5);
|
||||
PORTB &= ~(1<<PB5);
|
||||
}
|
||||
else if (row == 17) {
|
||||
DDRB |= (1<<PB6);
|
||||
PORTB &= ~(1<<PB6);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user