aboutsummaryrefslogtreecommitdiff
path: root/keyboards/handwired/frenchdev/matrix.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/handwired/frenchdev/matrix.c')
-rw-r--r--keyboards/handwired/frenchdev/matrix.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/keyboards/handwired/frenchdev/matrix.c b/keyboards/handwired/frenchdev/matrix.c
index 7fe3d0bbf..4263555e9 100644
--- a/keyboards/handwired/frenchdev/matrix.c
+++ b/keyboards/handwired/frenchdev/matrix.c
@@ -40,7 +40,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
40#include "util.h" 40#include "util.h"
41#include "matrix.h" 41#include "matrix.h"
42#include "frenchdev.h" 42#include "frenchdev.h"
43#include "i2cmaster.h"
44#ifdef DEBUG_MATRIX_SCAN_RATE 43#ifdef DEBUG_MATRIX_SCAN_RATE
45#include "timer.h" 44#include "timer.h"
46#endif 45#endif
@@ -280,11 +279,12 @@ static matrix_row_t read_cols(uint8_t row)
280 return 0; 279 return 0;
281 } else { 280 } else {
282 uint8_t data = 0; 281 uint8_t data = 0;
283 mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; 282 mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT); if (mcp23018_status) goto out;
284 mcp23018_status = i2c_write(GPIOB); if (mcp23018_status) goto out; 283 mcp23018_status = i2c_write(GPIOB, I2C_TIMEOUT); if (mcp23018_status) goto out;
285 mcp23018_status = i2c_start(I2C_ADDR_READ); if (mcp23018_status) goto out; 284 mcp23018_status = i2c_start(I2C_ADDR_READ, I2C_TIMEOUT); if (mcp23018_status) goto out;
286 data = i2c_readNak(); 285 data = i2c_read_nack(I2C_TIMEOUT); if (mcp23018_status < 0) goto out;
287 data = ~data; 286 data = ~((uint8_t)mcp23018_status);
287 mcp23018_status = I2C_STATUS_SUCCESS;
288 out: 288 out:
289 i2c_stop(); 289 i2c_stop();
290 return data; 290 return data;
@@ -318,11 +318,9 @@ static void unselect_rows(void)
318 // do nothing 318 // do nothing
319 } else { 319 } else {
320 // set all rows hi-Z : 1 320 // set all rows hi-Z : 1
321 mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; 321 mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT); if (mcp23018_status) goto out;
322 mcp23018_status = i2c_write(GPIOA); if (mcp23018_status) goto out; 322 mcp23018_status = i2c_write(GPIOA, I2C_TIMEOUT); if (mcp23018_status) goto out;
323 mcp23018_status = i2c_write( 0xFF 323 mcp23018_status = i2c_write( 0xFF & ~(0<<8), I2C_TIMEOUT); if (mcp23018_status) goto out;
324 & ~(0<<8)
325 ); if (mcp23018_status) goto out;
326 out: 324 out:
327 i2c_stop(); 325 i2c_stop();
328 } 326 }
@@ -346,11 +344,9 @@ static void select_row(uint8_t row)
346 } else { 344 } else {
347 // set active row low : 0 345 // set active row low : 0
348 // set other rows hi-Z : 1 346 // set other rows hi-Z : 1
349 mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; 347 mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT); if (mcp23018_status) goto out;
350 mcp23018_status = i2c_write(GPIOA); if (mcp23018_status) goto out; 348 mcp23018_status = i2c_write(GPIOA, I2C_TIMEOUT); if (mcp23018_status) goto out;
351 mcp23018_status = i2c_write( 0xFF & ~(1<<row) 349 mcp23018_status = i2c_write( 0xFF & ~(1<<row) & ~(0<<8), I2C_TIMEOUT); if (mcp23018_status) goto out;
352 & ~(0<<8)
353 ); if (mcp23018_status) goto out;
354 out: 350 out:
355 i2c_stop(); 351 i2c_stop();
356 } 352 }
@@ -393,4 +389,3 @@ static void select_row(uint8_t row)
393 } 389 }
394 } 390 }
395} 391}
396