]>
git.gir.st - tmk_keyboard.git/blob - converter/pana_m8/pana_m8.c
2 #include <avr/pgmspace.h>
8 #define CLK_HI() (PORTD |= (1<<0))
9 #define CLK_LO() (PORTD &= ~(1<<0))
10 #define STATE() (PIND & (1<<1))
11 #define RST_HI() (PORTD |= (1<<3))
12 #define RST_LO() (PORTD &= ~(1<<3))
13 #define SENSE() (PIND & (1<<2))
15 static matrix_row_t matrix
[8] = {};
18 void matrix_init(void)
21 debug_keyboard
= true;
24 // PD0: Clock. Counter couts up at falling edge.
25 // PD1: Key State. Hi if selected key is activated.
26 // PD2: Sense. Lo if any key is activated while Reset is Hi.
27 // PD3: Reset. Resets counters at riging edge.
28 DDRD
|= (1<<3) | (1<<0); // output
29 DDRD
&= ~((1<<2) | (1<<1)); // input
30 PORTD
&= ~((1<<3) | (1<<0)); // low
31 PORTD
|= (1<<2) | (1<<1); // pull-up
36 uint8_t matrix_scan(void)
38 // TODO: debouce & unplug detect
45 // 8x8 matrix: row:sense, col:drive, key_on:hi
46 for (uint8_t col
= 0; col
< 8; col
++) {
47 for (uint8_t row
= 0; row
< 8; row
++) {
52 matrix
[row
] |= (1<<col
);
54 matrix
[row
] &= ~(1<<col
);
57 // proceed counter - next row
65 matrix_row_t
matrix_get_row(uint8_t row
)
70 void led_set(uint8_t usb_led
)