fc980c: Fix for pin config of TMK controller
This commit is contained in:
parent
e3036006e8
commit
3d3bcd8ad6
2 changed files with 15 additions and 19 deletions
|
@ -51,11 +51,9 @@ void matrix_init(void)
|
||||||
|
|
||||||
KEY_INIT();
|
KEY_INIT();
|
||||||
|
|
||||||
// LEDs on NumLock, CapsLock and ScrollLock(PD7, PB5, PB6)
|
// LEDs on NumLock, CapsLock and ScrollLock(PB4, PB5, PB6)
|
||||||
DDRD |= (1<<7);
|
DDRB |= (1<<4) | (1<<5) | (1<<6);
|
||||||
PORTD |= (1<<7);
|
PORTB |= (1<<4) | (1<<5) | (1<<6);
|
||||||
DDRB |= (1<<5) | (1<<6);
|
|
||||||
PORTB |= (1<<5) | (1<<6);
|
|
||||||
|
|
||||||
// initialize matrix state: all keys off
|
// initialize matrix state: all keys off
|
||||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00;
|
for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00;
|
||||||
|
@ -133,9 +131,9 @@ matrix_row_t matrix_get_row(uint8_t row)
|
||||||
void led_set(uint8_t usb_led)
|
void led_set(uint8_t usb_led)
|
||||||
{
|
{
|
||||||
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
|
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
|
||||||
PORTD |= (1<<7);
|
PORTB |= (1<<4);
|
||||||
} else {
|
} else {
|
||||||
PORTD &= ~(1<<7);
|
PORTB &= ~(1<<4);
|
||||||
}
|
}
|
||||||
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
|
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
|
||||||
PORTB |= (1<<5);
|
PORTB |= (1<<5);
|
||||||
|
|
|
@ -19,42 +19,40 @@
|
||||||
/*
|
/*
|
||||||
* Pin configuration for ATMega32U4
|
* Pin configuration for ATMega32U4
|
||||||
*
|
*
|
||||||
* Row: PD5,6,PB0, PD4(~EN)
|
* Row: PD4-6, PD7(~EN)
|
||||||
* Col: PB1-3, 4
|
* Col: PB0-3
|
||||||
* Key: PC6(pull-uped)
|
* Key: PC6(pull-uped)
|
||||||
* Hys: PC7
|
* Hys: PC7
|
||||||
*/
|
*/
|
||||||
static inline void KEY_ENABLE(void) { (PORTD &= ~(1<<4)); }
|
static inline void KEY_ENABLE(void) { (PORTD &= ~(1<<7)); }
|
||||||
static inline void KEY_UNABLE(void) { (PORTD |= (1<<4)); }
|
static inline void KEY_UNABLE(void) { (PORTD |= (1<<7)); }
|
||||||
static inline bool KEY_STATE(void) { return (PINC & (1<<6)); }
|
static inline bool KEY_STATE(void) { return (PINC & (1<<6)); }
|
||||||
static inline void KEY_HYS_ON(void) { (PORTC |= (1<<7)); }
|
static inline void KEY_HYS_ON(void) { (PORTC |= (1<<7)); }
|
||||||
static inline void KEY_HYS_OFF(void) { (PORTC &= ~(1<<7)); }
|
static inline void KEY_HYS_OFF(void) { (PORTC &= ~(1<<7)); }
|
||||||
static inline void KEY_INIT(void)
|
static inline void KEY_INIT(void)
|
||||||
{
|
{
|
||||||
/* Col */
|
/* Col */
|
||||||
DDRB |= 0x1F;
|
DDRB |= 0x0F;
|
||||||
/* Key: input with pull-up */
|
/* Key: input with pull-up */
|
||||||
DDRC &= ~(1<<6);
|
DDRC &= ~(1<<6);
|
||||||
PORTC |= (1<<6);
|
PORTC |= (1<<6);
|
||||||
/* Hys */
|
/* Hys */
|
||||||
DDRC |= (1<<7);
|
DDRC |= (1<<7);
|
||||||
/* Row */
|
/* Row */
|
||||||
DDRD |= 0x70;
|
DDRD |= 0xF0;
|
||||||
|
|
||||||
KEY_UNABLE();
|
KEY_UNABLE();
|
||||||
KEY_HYS_OFF();
|
KEY_HYS_OFF();
|
||||||
}
|
}
|
||||||
static inline void SET_ROW(uint8_t ROW)
|
static inline void SET_ROW(uint8_t ROW)
|
||||||
{
|
{
|
||||||
// set row with unabling key
|
// PD4-6
|
||||||
PORTB = (PORTB & 0xFE) | ((ROW & 0x04) >> 2); // PB0
|
PORTD = (PORTD & 0x8F) | ((ROW & 0x07) << 4);
|
||||||
PORTD = (PORTD & 0x9F) | ((ROW & 0x03) << 5); // PD5,6
|
|
||||||
}
|
}
|
||||||
static inline void SET_COL(uint8_t COL)
|
static inline void SET_COL(uint8_t COL)
|
||||||
{
|
{
|
||||||
// PB4(Lo:Z5, Hi:Z4)
|
// PB0-3
|
||||||
// PB1-3
|
PORTB = (PORTB & 0xF0) | (COL & 0x0F);
|
||||||
PORTB = (PORTB & 0xE1) | ((COL & 0x0F) << 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue