]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - keyboards/handwired/frenchdev/matrix.c
Update handwired/frenchdev keyboard (#5443)
[qmk_firmware.git] / keyboards / handwired / frenchdev / matrix.c
index df2b8e8b0727c0042ca5ca3224a2b0089c22f7ff..4263555e9516dd740394b0a338cbe9566488ed17 100644 (file)
@@ -1,15 +1,17 @@
 /*
 
+Note to self: adapted from ergodox EZ matrix
+The "column" and "row" in here actually refers to the opposite on the keyboard
+see definition of KEYMAP in v1.h, the grid is transposed so that a "row" in here is actually a "column" on the physical keyboard
+Nicolas
+
 Note for ErgoDox EZ customizers: Here be dragons!
 This is not a file you want to be messing with.
 All of the interesting stuff for you is under keymaps/ :)
 Love, Erez
 
-Note to self, the "column" and "row" in here actually refers to the opposite on the keyboard
-see definition of KEYMAP in v1.h, the grid is transposed so that a "row" in here is actually a "column" on the physical keyboard
-Nicolas
-
 Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
+Copyright 2013 Nicolas Poirey <nicolas.poirey@gmail.com>
 
 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
@@ -38,7 +40,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "util.h"
 #include "matrix.h"
 #include "frenchdev.h"
-#include "i2cmaster.h"
 #ifdef DEBUG_MATRIX_SCAN_RATE
 #include  "timer.h"
 #endif
@@ -164,7 +165,7 @@ uint8_t matrix_scan(void)
                 print("left side not responding\n");
             } else {
                 print("left side attached\n");
-                ergodox_blink_all_leds();
+                frenchdev_blink_all_leds();
             }
         }
     }
@@ -278,11 +279,12 @@ static matrix_row_t read_cols(uint8_t row)
             return 0;
         } else {
             uint8_t data = 0;
-            mcp23018_status = i2c_start(I2C_ADDR_WRITE);    if (mcp23018_status) goto out;
-            mcp23018_status = i2c_write(GPIOB);             if (mcp23018_status) goto out;
-            mcp23018_status = i2c_start(I2C_ADDR_READ);     if (mcp23018_status) goto out;
-            data = i2c_readNak();
-            data = ~data;
+            mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT);   if (mcp23018_status) goto out;
+            mcp23018_status = i2c_write(GPIOB, I2C_TIMEOUT);            if (mcp23018_status) goto out;
+            mcp23018_status = i2c_start(I2C_ADDR_READ, I2C_TIMEOUT);    if (mcp23018_status) goto out;
+            data = i2c_read_nack(I2C_TIMEOUT);                         if (mcp23018_status < 0) goto out;
+            data = ~((uint8_t)mcp23018_status);
+            mcp23018_status = I2C_STATUS_SUCCESS;
         out:
             i2c_stop();
             return data;
@@ -316,11 +318,9 @@ static void unselect_rows(void)
         // do nothing
     } else {
         // set all rows hi-Z : 1
-        mcp23018_status = i2c_start(I2C_ADDR_WRITE);    if (mcp23018_status) goto out;
-        mcp23018_status = i2c_write(GPIOA);             if (mcp23018_status) goto out;
-        mcp23018_status = i2c_write( 0xFF
-                              & ~(0<<8)
-                          );                            if (mcp23018_status) goto out;
+        mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT);    if (mcp23018_status) goto out;
+        mcp23018_status = i2c_write(GPIOA, I2C_TIMEOUT);             if (mcp23018_status) goto out;
+        mcp23018_status = i2c_write( 0xFF & ~(0<<8), I2C_TIMEOUT);   if (mcp23018_status) goto out;
     out:
         i2c_stop();
     }
@@ -344,11 +344,9 @@ static void select_row(uint8_t row)
         } else {
             // set active row low  : 0
             // set other rows hi-Z : 1
-            mcp23018_status = i2c_start(I2C_ADDR_WRITE);        if (mcp23018_status) goto out;
-            mcp23018_status = i2c_write(GPIOA);                 if (mcp23018_status) goto out;
-            mcp23018_status = i2c_write( 0xFF & ~(1<<row)
-                                  & ~(0<<8)
-                              );                                if (mcp23018_status) goto out;
+            mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT);                          if (mcp23018_status) goto out;
+            mcp23018_status = i2c_write(GPIOA, I2C_TIMEOUT);                                   if (mcp23018_status) goto out;
+            mcp23018_status = i2c_write( 0xFF & ~(1<<row) & ~(0<<8), I2C_TIMEOUT);             if (mcp23018_status) goto out;
         out:
             i2c_stop();
         }
@@ -391,4 +389,3 @@ static void select_row(uint8_t row)
         }
     }
 }
-