]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
merging
authorJack Humbert <jack.humb@gmail.com>
Sun, 16 Aug 2015 21:56:15 +0000 (17:56 -0400)
committerJack Humbert <jack.humb@gmail.com>
Sun, 16 Aug 2015 21:56:15 +0000 (17:56 -0400)
1  2 
keyboard/atomic/Makefile
keyboard/atomic/keymap_common.h
keyboard/atomic/matrix.c
keyboard/planck/Makefile
keyboard/planck/matrix_handwired.c
keyboard/planck/matrix_pcb.c

index 12351b990b6a160c665182e6d2101cd7f16776fd,0d5baa9fa1967ae83f335c36fa2933c4a9fe15f9..ed1d331766eed977f6db4f16c78997c13355643e
@@@ -47,12 -47,9 +47,10 @@@ TOP_DIR = ../.
  # Directory keyboard dependent files exist
  TARGET_DIR = .
  
 -# project specific files
 -SRC = keymap_common.c \
 -      matrix.c \
 +# # project specific files
 +ifdef COMMON
 +
 +      SRC = keymap_common.c \
        led.c \
        backlight.c
  
index 4a0bcfbb0830e8da21b701069c11484bf0ca3923,cfb0cb3611ce7467d7bc2ff8b44eeb45190cbd3f..7c167eb51a28186b43fae15da3791b6bd4ef6ddc
@@@ -33,96 -33,67 +33,97 @@@ along with this program.  If not, see <
  extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
  extern const uint16_t fn_actions[];
  
 -// JCK: Semi-Standard layout
 -#define KEYMAP_JCK( \
 -    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C,   K0E,    \
 -    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \
 -    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,    K2D,   K2E, \
 -    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A,    K3C,   K3D, K3E, \
 -     K40,  K41,  K43,           K46,                  K4A, K4B, K4C, K4D, K4E  \
 -) { \
 -    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_NO,    KC_##K0E }, \
 -    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E }, \
 -    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_NO,    KC_##K2D, KC_##K2E }, \
 -    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_NO,    KC_##K3C, KC_##K3D, KC_##K3E }, \
 -    { KC_##K40, KC_##K41, KC_NO,    KC_##K43, KC_NO,    KC_NO,    KC_##K46, KC_NO,    KC_NO,    KC_NO,    KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
 -}
  
 -// ASK: Short Space layout
 -#define KEYMAP_ASK_MESSY( \
 -    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C,   K0E,    \
 -    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \
 -    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,    K2D,   K2E, \
 -    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A,    K3C,   K3D, K3E, \
 -     K40,  K41,  K43,  K44,        K46,     K48, K49, K4A, K4B, K4C, K4D, K4E  \
 +// MIT Layout
 +/*
 + * ,-----------------------------------------------------------------------.
 + * |     |     |     |     |     |     |     |     |     |     |     |     |
 + * |-----------------------------------------------------------------------|
 + * |     |     |     |     |     |     |     |     |     |     |     |     |
 + * |-----------------------------------------------------------------------|
 + * |     |     |     |     |     |     |     |     |     |     |     |     |
 + * |-----------------------------------------------------------------------|
 + * |     |     |     |     |     |           |     |     |     |     |     |
 + * `-----------------------------------------------------------------------'
 + */
 +#define KEYMAP( \
 +    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
 +    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
 +    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
 +    K30, K31, K32, K33, K34,    K35,   K37, K38, K39, K3A, K3B  \
  ) { \
 -    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_NO,    KC_##K0E }, \
 -    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E }, \
 -    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_NO,    KC_##K2D, KC_##K2E }, \
 -    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_NO,    KC_##K3C, KC_##K3D, KC_##K3E }, \
 -    { KC_##K40, KC_##K41, KC_NO,    KC_##K43, KC_##K44, KC_NO,    KC_##K46, KC_NO,    KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
 +    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B }, \
 +    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B }, \
 +    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B }, \
 +    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K35, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B }  \
  }
  
 -#define KEYMAP_ASK( \
 -    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C,   K0E,    \
 -    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \
 -    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,    K2C,   K2E, \
 -    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A,    K3B,   K3D, K3E, \
 -     K40,  K41,  K43,  K44,        K46,     K47, K48, K4A, K4B, K4C, K4D, K4E  \
 +// Grid Layout
 +/*
 + * ,-----------------------------------------------------------------------.
 + * |     |     |     |     |     |     |     |     |     |     |     |     |
 + * |-----------------------------------------------------------------------|
 + * |     |     |     |     |     |     |     |     |     |     |     |     |
 + * |-----------------------------------------------------------------------|
 + * |     |     |     |     |     |     |     |     |     |     |     |     |
 + * |-----------------------------------------------------------------------|
 + * |     |     |     |     |     |     |     |     |     |     |     |     |
 + * `-----------------------------------------------------------------------'
 + */
 +#define KEYMAP_GRID( \
 +    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
 +    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
 +    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
 +    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B  \
  ) { \
 -    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_NO,    KC_##K0E }, \
 -    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E }, \
 -    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_NO,    KC_##K2E }, \
 -    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_NO,    KC_##K3D, KC_##K3E }, \
 -    { KC_##K40, KC_##K41, KC_NO,    KC_##K43, KC_##K44, KC_NO,    KC_##K46, KC_##K47, KC_##K48, KC_NO,    KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
 +    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B }, \
 +    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B }, \
 +    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B }, \
 +    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B }  \
  }
  
 +#define KEYMAP_REVERSE(                                                 \
 +  K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B,           \
 +  K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B,           \
 +  K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,           \
 +  K30, K31, K32, K33, K34,    K35,   K37, K38, K39, K3A, K3B            \
 +  ) {                                                                   \
 +    { KC_##K0B, KC_##K0A, KC_##K09, KC_##K08, KC_##K07, KC_##K06, KC_##K05, KC_##K04, KC_##K03, KC_##K02, KC_##K01, KC_##K00 }, \
 +    { KC_##K1B, KC_##K1A, KC_##K19, KC_##K18, KC_##K17, KC_##K16, KC_##K15, KC_##K14, KC_##K13, KC_##K12, KC_##K11, KC_##K10 }, \
 +    { KC_##K2B, KC_##K2A, KC_##K29, KC_##K28, KC_##K27, KC_##K26, KC_##K25, KC_##K24, KC_##K23, KC_##K22, KC_##K21, KC_##K20 }, \
 +    { KC_##K3B, KC_##K3A, KC_##K39, KC_##K38, KC_##K37, KC_##K35, KC_##K35, KC_##K34, KC_##K33, KC_##K32, KC_##K31, KC_##K30 },   \
 +            }
 +
 +#define KEYMAP_AND_REVERSE(args...) KEYMAP(args), KEYMAP_REVERSE(args)
 +
 +#define KEYMAP_SWAP(                                                    \
 +  K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B,           \
 +  K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B,           \
 +  K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,           \
 +  K30, K31, K32, K33, K34,    K35,   K37, K38, K39, K3A, K3B            \
 +  ) {                                                                   \
 +    { KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05 }, \
 +    { KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15 }, \
 +    { KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25 }, \
 +    { KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K35, KC_##K35, KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34 },    \
 +}
  
 -// MLO: Semi-Grid layout
 +#define KEYMAP_AND_SWAP(args...) KEYMAP(args), KEYMAP_SWAP(args)
  
- /*
-    Keymap for the Planck 48 key variant.
-  */
#define KEYMAP_48( \
-     K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
-     K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
-     K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
-     K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B  \
+ // GRD: Grid layout
+ #define KEYMAP_GRD( \
    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, \
+     K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \
+     K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, \
+     K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E, \
+     K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B, K4C, K4D, K4E  \
  ) { \
-     { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B }, \
-     { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B }, \
-     { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B }, \
-     { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B }, \
+     { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E }, \
+     { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E }, \
+     { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E }, \
+     { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E }, \
+     { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47, KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
  }
  
  
index 2f2dbdb10893d8a1041a9b52559e7044ff1e7058,fd233ff53f4685600c132503e2b48d672d97d694..01f66e90fbd0c4d8a0a235a8a576084bec802e16
@@@ -55,8 -56,19 +55,18 @@@ uint8_t matrix_cols(void
      return MATRIX_COLS;
  }
  
 -
  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();
index 0da2a86c955689340d09d8a3389a3dbdb2b91b24,ad25854e6da3f1670b8e9ef64c736dc2fe829c12..81c9be1e4b9574a764595efe466d31b9cbd0c5bc
@@@ -53,9 -58,9 +58,10 @@@ $(warning MATRIX: $(MATRIX)
  ifdef COMMON
  
        SRC = keymap_common.c \
+       $(MATRIX) \
        led.c \
 -      backlight.c
 +      backlight.c \
 +      beeps.c 
  
  ifdef KEYMAP
      SRC := common_keymaps/keymap_$(KEYMAP).c $(SRC)
@@@ -72,10 -71,9 +78,10 @@@ endi
  else
  
  SRC = extended_keymap_common.c \
-       analog.c \
+       $(MATRIX) \
        led.c \
 -      backlight.c
 +      backlight.c \
 +      beeps.c 
  
  ifdef KEYMAP
      SRC := extended_keymaps/extended_keymap_$(KEYMAP).c $(SRC)
index 0000000000000000000000000000000000000000,2f2dbdb10893d8a1041a9b52559e7044ff1e7058..2ae69c3c8085bba3773b270483973fba6abd53fe
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,193 +1,193 @@@
 -#include "print.h"
+ /*
+ Copyright 2012 Jun Wako 
+ Generated by planckkeyboard.com (2014 Jack Humbert)
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+ /*
+  * scan matrix
+  */
+ #include <stdint.h>
+ #include <stdbool.h>
+ #include <avr/io.h>
+ #include <util/delay.h>
++// #include "print.h"
+ #include "debug.h"
+ #include "util.h"
+ #include "matrix.h"
+ #ifndef DEBOUNCE
+ #   define DEBOUNCE 10
+ #endif
+ static uint8_t debouncing = DEBOUNCE;
+ /* matrix state(1:on, 0:off) */
+ static matrix_row_t matrix[MATRIX_ROWS];
+ static matrix_row_t matrix_debouncing[MATRIX_ROWS];
+ static matrix_row_t read_cols(void);
+ static void init_cols(void);
+ static void unselect_rows(void);
+ static void select_row(uint8_t row);
+ inline
+ uint8_t matrix_rows(void)
+ {
+     return MATRIX_ROWS;
+ }
+ inline
+ uint8_t matrix_cols(void)
+ {
+     return MATRIX_COLS;
+ }
+ void matrix_init(void)
+ {
+     // initialize row and col
+     unselect_rows();
+     init_cols();
+     // initialize matrix state: all keys off
+     for (uint8_t i=0; i < MATRIX_ROWS; i++) {
+         matrix[i] = 0;
+         matrix_debouncing[i] = 0;
+     }
+ }
+ uint8_t matrix_scan(void)
+ {
+     for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+         select_row(i);
+         _delay_us(30);  // without this wait read unstable value.
+         matrix_row_t cols = read_cols();
+         if (matrix_debouncing[i] != cols) {
+             matrix_debouncing[i] = cols;
+             if (debouncing) {
+                 debug("bounce!: "); debug_hex(debouncing); debug("\n");
+             }
+             debouncing = DEBOUNCE;
+         }
+         unselect_rows();
+     }
+     if (debouncing) {
+         if (--debouncing) {
+             _delay_ms(1);
+         } else {
+             for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+                 matrix[i] = matrix_debouncing[i];
+             }
+         }
+     }
+     return 1;
+ }
+ bool matrix_is_modified(void)
+ {
+     if (debouncing) return false;
+     return true;
+ }
+ inline
+ bool matrix_is_on(uint8_t row, uint8_t col)
+ {
+     return (matrix[row] & ((matrix_row_t)1<col));
+ }
+ inline
+ matrix_row_t matrix_get_row(uint8_t row)
+ {
+     return matrix[row];
+ }
+ void matrix_print(void)
+ {
+     print("\nr/c 0123456789ABCDEF\n");
+     for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+         phex(row); print(": ");
+         pbin_reverse16(matrix_get_row(row));
+         print("\n");
+     }
+ }
+ uint8_t matrix_key_count(void)
+ {
+     uint8_t count = 0;
+     for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+         count += bitpop16(matrix[i]);
+     }
+     return count;
+ }
+ 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);
+     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));
+          
+ }
+ static void unselect_rows(void)
+ {
+     DDRB &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3);
+     PORTB |= (1<<0 | 1<<1 | 1<<2 | 1<<3);
+     
+ }
+ static void select_row(uint8_t row)
+ {
+     switch (row) {
+         case 0:
+             DDRB  |= (1<<0);
+             PORTB &= ~(1<<0);
+             break;
+         case 1:
+             DDRB  |= (1<<1);
+             PORTB &= ~(1<<1);
+             break;
+         case 2:
+             DDRB  |= (1<<2);
+             PORTB &= ~(1<<2);
+             break;
+         case 3:
+             DDRB  |= (1<<3);
+             PORTB &= ~(1<<3);
+             break;
+         
+     }
+ }
Simple merge