diff options
author | Jack Humbert <jack.humb@gmail.com> | 2015-08-16 17:56:15 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2015-08-16 17:56:15 -0400 |
commit | c9cbff446f58262ef9c26b7ce280f37e36b15b9a (patch) | |
tree | 1917ebd3b78dfbad7a6555b5ce425c551ca356ca /keyboard/atomic/matrix.c | |
parent | c5a8287dea6f5d9d798d0ea5b43b08d2c362c71d (diff) | |
parent | e12c0de608be5b3239222735bb6403e0fda3fb26 (diff) |
merging
Diffstat (limited to 'keyboard/atomic/matrix.c')
-rw-r--r-- | keyboard/atomic/matrix.c | 94 |
1 files changed, 64 insertions, 30 deletions
diff --git a/keyboard/atomic/matrix.c b/keyboard/atomic/matrix.c index 2f2dbdb108..01f66e90fb 100644 --- a/keyboard/atomic/matrix.c +++ b/keyboard/atomic/matrix.c @@ -57,6 +57,16 @@ uint8_t matrix_cols(void) void matrix_init(void) { + // To use PORTF disable JTAG with writing JTD bit twice within four cycles. + MCUCR |= (1<<JTD); + MCUCR |= (1<<JTD); + + backlight_init_ports(); + + // Turn status LED on + DDRE |= (1<<6); + PORTE |= (1<<6); + // initialize row and col unselect_rows(); init_cols(); @@ -134,60 +144,84 @@ uint8_t matrix_key_count(void) return count; } +// +// Atomic PCB Rev 0 Pin Assignments +// +// Column: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 +// Pin: F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7, D3, D2, D1 +// + static void init_cols(void) { - DDRB &= ~(1<<6 | 1<<5 | 1<<4); - PORTB |= (1<<6 | 1<<5 | 1<<4); - DDRD &= ~(1<<7 | 1<<6 | 1<<4); - PORTD |= (1<<7 | 1<<6 | 1<<4); + DDRB &= ~(1<<4 | 1<<0); + PORTB |= (1<<4 | 1<<0); + DDRC &= ~(1<<7); + PORTC |= (1<<7); + DDRD &= ~(1<<7 | 1<<6 | 1<<4 | 1<<3 | 1<<2 | 1<<1); + PORTD |= (1<<7 | 1<<6 | 1<<4 | 1<<3 | 1<<2 | 1<<1); 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); - } static matrix_row_t read_cols(void) { - return (PIND&(1<<4) ? 0 : (1<<0)) | - (PIND&(1<<6) ? 0 : (1<<1)) | - (PIND&(1<<7) ? 0 : (1<<2)) | - (PINB&(1<<4) ? 0 : (1<<3)) | - (PINB&(1<<5) ? 0 : (1<<4)) | - (PINB&(1<<6) ? 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)); - + return (PINF&(1<<1) ? 0 : (1<<0)) | + (PINF&(1<<0) ? 0 : (1<<1)) | + (PINB&(1<<0) ? 0 : (1<<2)) | + (PINC&(1<<7) ? 0 : (1<<3)) | + (PINF&(1<<4) ? 0 : (1<<4)) | + (PINF&(1<<5) ? 0 : (1<<5)) | + (PINF&(1<<6) ? 0 : (1<<6)) | + (PINF&(1<<7) ? 0 : (1<<7)) | + (PIND&(1<<4) ? 0 : (1<<8)) | + (PIND&(1<<6) ? 0 : (1<<9)) | + (PINB&(1<<4) ? 0 : (1<<10)) | + (PIND&(1<<7) ? 0 : (1<<11)) | + (PIND&(1<<3) ? 0 : (1<<12)) | + (PIND&(1<<2) ? 0 : (1<<13)) | + (PIND&(1<<1) ? 0 : (1<<14)); } + +// +// Atomic PCB Rev 0 Pin Assignments +// +// Row: 0, 1, 2, 3, 4 +// Pin: D0, D5, B5, B6, C6 +// + static void unselect_rows(void) { - DDRB &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3); - PORTB |= (1<<0 | 1<<1 | 1<<2 | 1<<3); - + DDRB &= ~(1<<5 | 1<<6); + PORTB |= (1<<5 | 1<<6); + DDRD &= ~(1<<0 | 1<<5); + PORTD |= (1<<0 | 1<<5); + DDRC &= ~(1<<6); + PORTC |= (1<<6); } static void select_row(uint8_t row) { switch (row) { case 0: - DDRB |= (1<<0); - PORTB &= ~(1<<0); + DDRD |= (1<<0); + PORTD &= ~(1<<0); break; case 1: - DDRB |= (1<<1); - PORTB &= ~(1<<1); + DDRD |= (1<<5); + PORTD &= ~(1<<5); break; case 2: - DDRB |= (1<<2); - PORTB &= ~(1<<2); + DDRB |= (1<<5); + PORTB &= ~(1<<5); break; case 3: - DDRB |= (1<<3); - PORTB &= ~(1<<3); + DDRB |= (1<<6); + PORTB &= ~(1<<6); break; - + case 4: + DDRC |= (1<<6); + PORTC &= ~(1<<6); + break; } } |