diff options
author | Joel Challis <git@zvecr.com> | 2021-09-07 16:34:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-07 16:34:59 +0100 |
commit | e7a5c006d9777a4009da934f408961aa2d2e6fb1 (patch) | |
tree | 98c6ca624c08dde5f5d288d405b8eb3a5356d6a6 /keyboards/sx60/sx60.c | |
parent | 2d6635214ab05858271f312619c5447bf317cf51 (diff) |
Refactor use of legacy i2c implementation (#14341)
Diffstat (limited to 'keyboards/sx60/sx60.c')
-rwxr-xr-x | keyboards/sx60/sx60.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/keyboards/sx60/sx60.c b/keyboards/sx60/sx60.c index ede8c07e97..cb7f2b88ff 100755 --- a/keyboards/sx60/sx60.c +++ b/keyboards/sx60/sx60.c @@ -1,5 +1,5 @@ #include "sx60.h" -#include "i2cmaster.h" +#include "i2c_master.h" bool i2c_initialized = 0; @@ -18,21 +18,18 @@ uint8_t init_mcp23018(void) { /* B Pins are Row, A pins are Columns Set them to output */ - mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(IODIRA); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(0b11111111); if (mcp23018_status) goto out; - /* Now write to IODIRB */ - mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out; - i2c_stop(); - - mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(GPPUA); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(0b11111111); if (mcp23018_status) goto out; - /* Now write to GPPUB */ - mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out; - -out: - i2c_stop(); - + static uint8_t direction[2] = { + 0b11111111, + 0b00000000, + }; + static uint8_t pullup[2] = { + 0b11111111, + 0b00000000, + }; + + mcp23018_status = i2c_writeReg(I2C_ADDR, IODIRA, direction, 2, I2C_TIMEOUT); + if (mcp23018_status) return mcp23018_status; + + mcp23018_status = i2c_writeReg(I2C_ADDR, GPPUA, pullup, 2, I2C_TIMEOUT); return mcp23018_status; } |