summaryrefslogtreecommitdiff
path: root/keyboard/gh60/matrix.c
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2015-01-14 22:43:01 -0500
committerJack Humbert <jack.humb@gmail.com>2015-01-14 22:43:01 -0500
commit4225f0353c2eb85fbd8ca0622eb89757975093e4 (patch)
treec9a21434e23181b41555b93a7488a65ccbcc3e83 /keyboard/gh60/matrix.c
parente4c4d6ad0aa5763504802ae22c6b4504b4084a45 (diff)
parent173dbe3b283ad4bb9bca2f2ac781eadd5c413bb3 (diff)
downloadqmk_firmware-4225f0353c2eb85fbd8ca0622eb89757975093e4.tar.gz
qmk_firmware-4225f0353c2eb85fbd8ca0622eb89757975093e4.zip
Merge branch 'planck-jack'
Diffstat (limited to 'keyboard/gh60/matrix.c')
-rw-r--r--keyboard/gh60/matrix.c82
1 files changed, 37 insertions, 45 deletions
diff --git a/keyboard/gh60/matrix.c b/keyboard/gh60/matrix.c
index 83016b77ae..720ac30043 100644
--- a/keyboard/gh60/matrix.c
+++ b/keyboard/gh60/matrix.c
@@ -30,7 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef DEBOUNCE
-# define DEBOUNCE 10
+# define DEBOUNCE 10
#endif
static uint8_t debouncing = DEBOUNCE;
@@ -56,21 +56,12 @@ uint8_t matrix_cols(void)
return MATRIX_COLS;
}
-static
-void setup_leds(void) {
- DDRF |= 0x00;
- PORTF |= 0x00;
-}
-
-
void matrix_init(void)
{
// initialize row and col
unselect_rows();
init_cols();
- setup_leds();
-
// initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
matrix[i] = 0;
@@ -104,15 +95,16 @@ uint8_t matrix_scan(void)
}
}
- // uint8_t layer = biton32(default_layer_state);
- switch (default_layer_state) {
+ uint8_t layer = biton32(layer_state);
+ switch (layer) {
case 1:
- DDRF &= ~(1<<0);
- PORTF &= ~(1<<0);
- break;
case 2:
- DDRF |= (1<<0);
- PORTF |= (1<<0);
+ DDRC |= (1<<7);
+ PORTC |= (1<<7);
+ break;
+ case 0:
+ DDRC &= ~(1<<7);
+ PORTC &= ~(1<<7);
break;
}
@@ -163,28 +155,28 @@ uint8_t matrix_key_count(void)
static void init_cols(void)
{
- DDRC &= ~(1<<6 | 1<<7);
- PORTC |= (1<<6 | 1<<7);
- DDRD &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<5);
- PORTD |= (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<5);
+ DDRF &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
+ PORTF |= (1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
+ DDRD &= ~(1<<0);
+ PORTD |= (1<<0);
DDRB &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
PORTB |= (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
}
static matrix_row_t read_cols(void)
{
- return (PIND&(1<<5) ? 0 : (1<< 0)) |
- (PINC&(1<<7) ? 0 : (1<< 1)) |
- (PINC&(1<<6) ? 0 : (1<< 2)) |
- (PIND&(1<<3) ? 0 : (1<< 3)) |
- (PIND&(1<<2) ? 0 : (1<< 4)) |
- (PIND&(1<<1) ? 0 : (1<< 5)) |
- (PIND&(1<<0) ? 0 : (1<< 6)) |
- (PINB&(1<<7) ? 0 : (1<< 7)) |
- (PINB&(1<<3) ? 0 : (1<< 8)) |
- (PINB&(1<<2) ? 0 : (1<< 9)) |
- (PINB&(1<<1) ? 0 : (1<<10)) |
- (PINB&(1<<0) ? 0 : (1<<11));
+ return (PINB&(1<<0) ? 0 : (1<< 0)) |
+ (PINB&(1<<1) ? 0 : (1<< 1)) |
+ (PINB&(1<<2) ? 0 : (1<< 2)) |
+ (PINB&(1<<3) ? 0 : (1<< 3)) |
+ (PINB&(1<<7) ? 0 : (1<< 4)) |
+ (PIND&(1<<0) ? 0 : (1<< 5)) |
+ (PINF&(1<<7) ? 0 : (1<< 6)) |
+ (PINF&(1<<6) ? 0 : (1<< 7)) |
+ (PINF&(1<<5) ? 0 : (1<< 8)) |
+ (PINF&(1<<4) ? 0 : (1<< 9)) |
+ (PINF&(1<<1) ? 0 : (1<<10)) |
+ (PINF&(1<<0) ? 0 : (1<<11));
}
/* Row pin configuration
@@ -194,30 +186,30 @@ static matrix_row_t read_cols(void)
static void unselect_rows(void)
{
// Hi-Z(DDR:0, PORT:0) to unselect
- DDRD &= ~(1<<4 | 1<<6 | 1<<7);
- PORTD |= (1<<4 | 1<<6 | 1<<7);
- DDRB &= ~(1<<4);
- PORTB |= (1<<4);
+ DDRB &= ~0b01110000;
+ PORTB &= ~0b01110000;
+ DDRD &= ~0b10000000;
+ PORTD &= ~0b10000000;
}
static void select_row(uint8_t row)
{
switch (row) {
case 0:
- DDRD |= (1<<4);
- PORTD &= ~(1<<4);
+ DDRB |= (1<<6);
+ PORTB &= ~(1<<6);
break;
case 1:
- DDRD |= (1<<6);
- PORTD &= ~(1<<6);
+ DDRB |= (1<<5);
+ PORTB &= ~(1<<5);
break;
case 2:
- DDRD |= (1<<7);
- PORTD &= ~(1<<7);
- break;
- case 3:
DDRB |= (1<<4);
PORTB &= ~(1<<4);
break;
+ case 3:
+ DDRD |= (1<<7);
+ PORTD &= ~(1<<7);
+ break;
}
}