diff options
| author | Ryan <fauxpark@gmail.com> | 2024-03-27 23:41:53 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-27 12:41:53 +0000 |
| commit | 01be746fc41d7c0860df379849b5fa79ed6c5587 (patch) | |
| tree | 54d28e566092a9718e1d17e4b717303704ab951e | |
| parent | 148d66fc9f46b9186ec16e8b33f63bf267b7bb82 (diff) | |
Update I2C API usage in keyboard code (#23360)
| -rw-r--r-- | keyboards/bajjak/bajjak.c | 6 | ||||
| -rw-r--r-- | keyboards/bajjak/matrix.c | 2 | ||||
| -rw-r--r-- | keyboards/dc01/left/matrix.c | 2 | ||||
| -rw-r--r-- | keyboards/ergodox_ez/ergodox_ez.c | 6 | ||||
| -rw-r--r-- | keyboards/ergodox_ez/matrix.c | 2 | ||||
| -rw-r--r-- | keyboards/ferris/0_2/matrix.c | 8 | ||||
| -rw-r--r-- | keyboards/gboards/ergotaco/ergotaco.c | 4 | ||||
| -rw-r--r-- | keyboards/gboards/ergotaco/matrix.c | 4 | ||||
| -rw-r--r-- | keyboards/gboards/georgi/georgi.c | 4 | ||||
| -rw-r--r-- | keyboards/gboards/georgi/matrix.c | 4 | ||||
| -rw-r--r-- | keyboards/gboards/gergo/gergo.c | 4 | ||||
| -rw-r--r-- | keyboards/gboards/gergo/matrix.c | 4 | ||||
| -rw-r--r-- | keyboards/gboards/gergoplex/gergoplex.c | 4 | ||||
| -rw-r--r-- | keyboards/gboards/gergoplex/matrix.c | 2 | ||||
| -rw-r--r-- | keyboards/handwired/frenchdev/frenchdev.c | 4 | ||||
| -rw-r--r-- | keyboards/handwired/frenchdev/matrix.c | 6 | ||||
| -rw-r--r-- | keyboards/handwired/pterodactyl/matrix.c | 10 | ||||
| -rw-r--r-- | keyboards/hotdox/left.c | 4 | ||||
| -rw-r--r-- | keyboards/system76/launch_1/usb_mux.c | 2 | ||||
| -rw-r--r-- | platforms/chibios/drivers/i2c_master.c | 2 |
20 files changed, 42 insertions, 42 deletions
diff --git a/keyboards/bajjak/bajjak.c b/keyboards/bajjak/bajjak.c index e6102e817b..6689a6ba2c 100644 --- a/keyboards/bajjak/bajjak.c +++ b/keyboards/bajjak/bajjak.c | |||
| @@ -138,14 +138,14 @@ uint8_t init_mcp23018(void) { | |||
| 138 | // - input : input : 1 | 138 | // - input : input : 1 |
| 139 | // - driving : output : 0 | 139 | // - driving : output : 0 |
| 140 | uint8_t data[] = {0b00000000, 0b00111111}; | 140 | uint8_t data[] = {0b00000000, 0b00111111}; |
| 141 | mcp23018_status = i2c_writeReg(I2C_ADDR, IODIRA, data, 2, BAJJAK_EZ_I2C_TIMEOUT); | 141 | mcp23018_status = i2c_write_register(I2C_ADDR, IODIRA, data, 2, BAJJAK_EZ_I2C_TIMEOUT); |
| 142 | 142 | ||
| 143 | if (!mcp23018_status) { | 143 | if (!mcp23018_status) { |
| 144 | // set pull-up | 144 | // set pull-up |
| 145 | // - unused : on : 1 | 145 | // - unused : on : 1 |
| 146 | // - input : on : 1 | 146 | // - input : on : 1 |
| 147 | // - driving : off : 0 | 147 | // - driving : off : 0 |
| 148 | mcp23018_status = i2c_writeReg(I2C_ADDR, IODIRA, data, 2, BAJJAK_EZ_I2C_TIMEOUT); | 148 | mcp23018_status = i2c_write_register(I2C_ADDR, IODIRA, data, 2, BAJJAK_EZ_I2C_TIMEOUT); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | #ifdef LEFT_LEDS | 151 | #ifdef LEFT_LEDS |
| @@ -172,7 +172,7 @@ uint8_t bajjak_left_leds_update(void) { | |||
| 172 | uint8_t data[2]; | 172 | uint8_t data[2]; |
| 173 | data[0] = 0b11111111 & ~(bajjak_left_led_1<<LEFT_LED_1_SHIFT); | 173 | data[0] = 0b11111111 & ~(bajjak_left_led_1<<LEFT_LED_1_SHIFT); |
| 174 | data[1] = 0b11111111 & ~(bajjak_left_led_2<<LEFT_LED_2_SHIFT); | 174 | data[1] = 0b11111111 & ~(bajjak_left_led_2<<LEFT_LED_2_SHIFT); |
| 175 | mcp23018_status = i2c_writeReg(I2C_ADDR, OLATA, data, 2, BAJJAK_EZ_I2C_TIMEOUT); | 175 | mcp23018_status = i2c_write_register(I2C_ADDR, OLATA, data, 2, BAJJAK_EZ_I2C_TIMEOUT); |
| 176 | 176 | ||
| 177 | return mcp23018_status; | 177 | return mcp23018_status; |
| 178 | } | 178 | } |
diff --git a/keyboards/bajjak/matrix.c b/keyboards/bajjak/matrix.c index 424bc29e4e..b0d1ab531f 100644 --- a/keyboards/bajjak/matrix.c +++ b/keyboards/bajjak/matrix.c | |||
| @@ -192,7 +192,7 @@ static void select_row(uint8_t row) { | |||
| 192 | // set other rows hi-Z : 1 | 192 | // set other rows hi-Z : 1 |
| 193 | uint8_t data; | 193 | uint8_t data; |
| 194 | data = 0xFF & ~(1 << row); | 194 | data = 0xFF & ~(1 << row); |
| 195 | mcp23018_status = i2c_writeReg(I2C_ADDR, GPIOA, &data, 1, BAJJAK_EZ_I2C_TIMEOUT); | 195 | mcp23018_status = i2c_write_register(I2C_ADDR, GPIOA, &data, 1, BAJJAK_EZ_I2C_TIMEOUT); |
| 196 | 196 | ||
| 197 | } | 197 | } |
| 198 | } else { | 198 | } else { |
diff --git a/keyboards/dc01/left/matrix.c b/keyboards/dc01/left/matrix.c index fd21d4333b..39e5be5a1d 100644 --- a/keyboards/dc01/left/matrix.c +++ b/keyboards/dc01/left/matrix.c | |||
| @@ -388,7 +388,7 @@ static void unselect_cols(void) | |||
| 388 | // Complete rows from other modules over i2c | 388 | // Complete rows from other modules over i2c |
| 389 | i2c_status_t i2c_transaction(uint8_t address, uint32_t mask, uint8_t col_offset) { | 389 | i2c_status_t i2c_transaction(uint8_t address, uint32_t mask, uint8_t col_offset) { |
| 390 | uint8_t data[MATRIX_ROWS + 1]; | 390 | uint8_t data[MATRIX_ROWS + 1]; |
| 391 | i2c_status_t status = i2c_readReg(address, 0x01, data, (MATRIX_ROWS + 1), 5); | 391 | i2c_status_t status = i2c_read_register(address, 0x01, data, (MATRIX_ROWS + 1), 5); |
| 392 | 392 | ||
| 393 | for (uint8_t i = 0; i < (MATRIX_ROWS) && status >= 0; i++) { //assemble slave matrix in main matrix | 393 | for (uint8_t i = 0; i < (MATRIX_ROWS) && status >= 0; i++) { //assemble slave matrix in main matrix |
| 394 | matrix[i] &= mask; //mask bits to keep | 394 | matrix[i] &= mask; //mask bits to keep |
diff --git a/keyboards/ergodox_ez/ergodox_ez.c b/keyboards/ergodox_ez/ergodox_ez.c index 3d6272ae66..5270738f86 100644 --- a/keyboards/ergodox_ez/ergodox_ez.c +++ b/keyboards/ergodox_ez/ergodox_ez.c | |||
| @@ -156,14 +156,14 @@ uint8_t init_mcp23018(void) { | |||
| 156 | // - input : input : 1 | 156 | // - input : input : 1 |
| 157 | // - driving : output : 0 | 157 | // - driving : output : 0 |
| 158 | uint8_t data[] = {0b00000000, 0b00111111}; | 158 | uint8_t data[] = {0b00000000, 0b00111111}; |
| 159 | mcp23018_status = i2c_writeReg(I2C_ADDR, IODIRA, data, 2, ERGODOX_EZ_I2C_TIMEOUT); | 159 | mcp23018_status = i2c_write_register(I2C_ADDR, IODIRA, data, 2, ERGODOX_EZ_I2C_TIMEOUT); |
| 160 | 160 | ||
| 161 | if (!mcp23018_status) { | 161 | if (!mcp23018_status) { |
| 162 | // set pull-up | 162 | // set pull-up |
| 163 | // - unused : on : 1 | 163 | // - unused : on : 1 |
| 164 | // - input : on : 1 | 164 | // - input : on : 1 |
| 165 | // - driving : off : 0 | 165 | // - driving : off : 0 |
| 166 | mcp23018_status = i2c_writeReg(I2C_ADDR, GPPUA, data, 2, ERGODOX_EZ_I2C_TIMEOUT); | 166 | mcp23018_status = i2c_write_register(I2C_ADDR, GPPUA, data, 2, ERGODOX_EZ_I2C_TIMEOUT); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | #ifdef LEFT_LEDS | 169 | #ifdef LEFT_LEDS |
| @@ -191,7 +191,7 @@ uint8_t ergodox_left_leds_update(void) { | |||
| 191 | uint8_t data[2]; | 191 | uint8_t data[2]; |
| 192 | data[0] = 0b11111111 & ~(ergodox_left_led_3 << LEFT_LED_3_SHIFT); | 192 | data[0] = 0b11111111 & ~(ergodox_left_led_3 << LEFT_LED_3_SHIFT); |
| 193 | data[1] = 0b11111111 & ~(ergodox_left_led_2 << LEFT_LED_2_SHIFT) & ~(ergodox_left_led_1 << LEFT_LED_1_SHIFT); | 193 | data[1] = 0b11111111 & ~(ergodox_left_led_2 << LEFT_LED_2_SHIFT) & ~(ergodox_left_led_1 << LEFT_LED_1_SHIFT); |
| 194 | mcp23018_status = i2c_writeReg(I2C_ADDR, OLATA, data, 2, ERGODOX_EZ_I2C_TIMEOUT); | 194 | mcp23018_status = i2c_write_register(I2C_ADDR, OLATA, data, 2, ERGODOX_EZ_I2C_TIMEOUT); |
| 195 | 195 | ||
| 196 | return mcp23018_status; | 196 | return mcp23018_status; |
| 197 | } | 197 | } |
diff --git a/keyboards/ergodox_ez/matrix.c b/keyboards/ergodox_ez/matrix.c index 28bee05779..9013c0785f 100644 --- a/keyboards/ergodox_ez/matrix.c +++ b/keyboards/ergodox_ez/matrix.c | |||
| @@ -193,7 +193,7 @@ static void select_row(uint8_t row) { | |||
| 193 | // set other rows hi-Z : 1 | 193 | // set other rows hi-Z : 1 |
| 194 | uint8_t data; | 194 | uint8_t data; |
| 195 | data = 0xFF & ~(1 << row); | 195 | data = 0xFF & ~(1 << row); |
| 196 | mcp23018_status = i2c_writeReg(I2C_ADDR, GPIOA, &data, 1, ERGODOX_EZ_I2C_TIMEOUT); | 196 | mcp23018_status = i2c_write_register(I2C_ADDR, GPIOA, &data, 1, ERGODOX_EZ_I2C_TIMEOUT); |
| 197 | } | 197 | } |
| 198 | } else { | 198 | } else { |
| 199 | // select on teensy | 199 | // select on teensy |
diff --git a/keyboards/ferris/0_2/matrix.c b/keyboards/ferris/0_2/matrix.c index cf26385f4c..41b100b659 100644 --- a/keyboards/ferris/0_2/matrix.c +++ b/keyboards/ferris/0_2/matrix.c | |||
| @@ -77,7 +77,7 @@ uint8_t init_mcp23017(void) { | |||
| 77 | // This means: we will write to the pins 0-4 on GPIOB (in select_rows) | 77 | // This means: we will write to the pins 0-4 on GPIOB (in select_rows) |
| 78 | uint8_t buf[] = {0b11111111, 0b11110000}; | 78 | uint8_t buf[] = {0b11111111, 0b11110000}; |
| 79 | print("before transmit\n"); | 79 | print("before transmit\n"); |
| 80 | mcp23017_status = i2c_writeReg(I2C_ADDR, IODIRA, buf, sizeof(buf), MCP23017_I2C_TIMEOUT) | 80 | mcp23017_status = i2c_write_register(I2C_ADDR, IODIRA, buf, sizeof(buf), MCP23017_I2C_TIMEOUT); |
| 81 | uprintf("after transmit %i\n", mcp23017_status); | 81 | uprintf("after transmit %i\n", mcp23017_status); |
| 82 | if (!mcp23017_status) { | 82 | if (!mcp23017_status) { |
| 83 | // set pull-up | 83 | // set pull-up |
| @@ -86,7 +86,7 @@ uint8_t init_mcp23017(void) { | |||
| 86 | // - driving : off : 0 | 86 | // - driving : off : 0 |
| 87 | // This means: we will read all the bits on GPIOA | 87 | // This means: we will read all the bits on GPIOA |
| 88 | // This means: we will write to the pins 0-4 on GPIOB (in select_rows) | 88 | // This means: we will write to the pins 0-4 on GPIOB (in select_rows) |
| 89 | mcp23017_status = i2c_writeReg(I2C_ADDR, GPPUA, buf, sizeof(buf), MCP23017_I2C_TIMEOUT) | 89 | mcp23017_status = i2c_write_register(I2C_ADDR, GPPUA, buf, sizeof(buf), MCP23017_I2C_TIMEOUT); |
| 90 | uprintf("after transmit2 %i\n", mcp23017_status); | 90 | uprintf("after transmit2 %i\n", mcp23017_status); |
| 91 | } | 91 | } |
| 92 | return mcp23017_status; | 92 | return mcp23017_status; |
| @@ -191,7 +191,7 @@ static matrix_row_t read_cols(uint8_t row) { | |||
| 191 | // The return value is a row as represented in the generic matrix code were the rightmost bits represent the lower columns and zeroes represent non-depressed keys while ones represent depressed keys. | 191 | // The return value is a row as represented in the generic matrix code were the rightmost bits represent the lower columns and zeroes represent non-depressed keys while ones represent depressed keys. |
| 192 | // Since the pins connected to eact columns are sequential, and counting from zero up (col 5 -> GPIOA0, col 6 -> GPIOA1 and so on), the only transformation needed is a bitwise not to swap all zeroes and ones. | 192 | // Since the pins connected to eact columns are sequential, and counting from zero up (col 5 -> GPIOA0, col 6 -> GPIOA1 and so on), the only transformation needed is a bitwise not to swap all zeroes and ones. |
| 193 | uint8_t data[] = {0}; | 193 | uint8_t data[] = {0}; |
| 194 | mcp23017_status = i2c_readReg(I2C_ADDR, MCP23017_GPIOA, data, sizeof(data), MCP23017_I2C_TIMEOUT); | 194 | mcp23017_status = i2c_read_register(I2C_ADDR, MCP23017_GPIOA, data, sizeof(data), MCP23017_I2C_TIMEOUT); |
| 195 | return ~data[0]; | 195 | return ~data[0]; |
| 196 | } | 196 | } |
| 197 | } | 197 | } |
| @@ -237,7 +237,7 @@ static void select_row(uint8_t row) { | |||
| 237 | // Select the desired row by writing a byte for the entire GPIOB bus where only the bit representing the row we want to select is a zero (write instruction) and every other bit is a one. | 237 | // Select the desired row by writing a byte for the entire GPIOB bus where only the bit representing the row we want to select is a zero (write instruction) and every other bit is a one. |
| 238 | // Note that the row - MATRIX_ROWS_PER_SIDE reflects the fact that being on the right hand, the columns are numbered from MATRIX_ROWS_PER_SIDE to MATRIX_ROWS, but the pins we want to write to are indexed from zero up on the GPIOB bus. | 238 | // Note that the row - MATRIX_ROWS_PER_SIDE reflects the fact that being on the right hand, the columns are numbered from MATRIX_ROWS_PER_SIDE to MATRIX_ROWS, but the pins we want to write to are indexed from zero up on the GPIOB bus. |
| 239 | uint8_t buf[] = {0xFF & ~(1 << (row - MATRIX_ROWS_PER_SIDE))}; | 239 | uint8_t buf[] = {0xFF & ~(1 << (row - MATRIX_ROWS_PER_SIDE))}; |
| 240 | mcp23017_status = i2c_writeReg(I2C_ADDR, MCP23017_GPIOB, buf, sizeof(buf), MCP23017_I2C_TIMEOUT); | 240 | mcp23017_status = i2c_write_register(I2C_ADDR, MCP23017_GPIOB, buf, sizeof(buf), MCP23017_I2C_TIMEOUT); |
| 241 | } | 241 | } |
| 242 | } | 242 | } |
| 243 | } | 243 | } |
diff --git a/keyboards/gboards/ergotaco/ergotaco.c b/keyboards/gboards/ergotaco/ergotaco.c index 694e07f031..6795dfde4f 100644 --- a/keyboards/gboards/ergotaco/ergotaco.c +++ b/keyboards/gboards/ergotaco/ergotaco.c | |||
| @@ -50,14 +50,14 @@ uint8_t init_mcp23018(void) { | |||
| 50 | // - input : input : 1 | 50 | // - input : input : 1 |
| 51 | // - driving : output : 0 | 51 | // - driving : output : 0 |
| 52 | uint8_t data[] = {0b00000000, 0b00111111}; | 52 | uint8_t data[] = {0b00000000, 0b00111111}; |
| 53 | mcp23018_status = i2c_writeReg(I2C_ADDR, IODIRA, data, sizeof(data), ERGODOX_EZ_I2C_TIMEOUT); | 53 | mcp23018_status = i2c_write_register(I2C_ADDR, IODIRA, data, sizeof(data), ERGODOX_EZ_I2C_TIMEOUT); |
| 54 | 54 | ||
| 55 | if (!mcp23018_status) { | 55 | if (!mcp23018_status) { |
| 56 | // set pull-up | 56 | // set pull-up |
| 57 | // - unused : on : 1 | 57 | // - unused : on : 1 |
| 58 | // - input : on : 1 | 58 | // - input : on : 1 |
| 59 | // - driving : off : 0 | 59 | // - driving : off : 0 |
| 60 | mcp23018_status = i2c_writeReg(I2C_ADDR, GPPUA, data, sizeof(data), ERGODOX_EZ_I2C_TIMEOUT); | 60 | mcp23018_status = i2c_write_register(I2C_ADDR, GPPUA, data, sizeof(data), ERGODOX_EZ_I2C_TIMEOUT); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | // SREG=sreg_prev; | 63 | // SREG=sreg_prev; |
diff --git a/keyboards/gboards/ergotaco/matrix.c b/keyboards/gboards/ergotaco/matrix.c index 3c49f2802e..40299f958e 100644 --- a/keyboards/gboards/ergotaco/matrix.c +++ b/keyboards/gboards/ergotaco/matrix.c | |||
| @@ -234,7 +234,7 @@ static matrix_row_t read_cols(uint8_t row) | |||
| 234 | return 0; | 234 | return 0; |
| 235 | } else { | 235 | } else { |
| 236 | uint8_t data = 0; | 236 | uint8_t data = 0; |
| 237 | mcp23018_status = i2c_readReg(I2C_ADDR, GPIOB, &data, 1, ERGODOX_EZ_I2C_TIMEOUT); | 237 | mcp23018_status = i2c_read_register(I2C_ADDR, GPIOB, &data, 1, ERGODOX_EZ_I2C_TIMEOUT); |
| 238 | data = (~((uint8_t)data) >> 2) & 0x01 ; | 238 | data = (~((uint8_t)data) >> 2) & 0x01 ; |
| 239 | #ifdef DEBUG_MATRIX | 239 | #ifdef DEBUG_MATRIX |
| 240 | if (data != 0x00) xprintf("I2C: %d\n", data); | 240 | if (data != 0x00) xprintf("I2C: %d\n", data); |
| @@ -268,7 +268,7 @@ static void select_row(uint8_t row) | |||
| 268 | // Read using bitmask | 268 | // Read using bitmask |
| 269 | } else { // set active row low : 0 // set other rows hi-Z : 1 | 269 | } else { // set active row low : 0 // set other rows hi-Z : 1 |
| 270 | uint8_t data = ~(1<<row); | 270 | uint8_t data = ~(1<<row); |
| 271 | mcp23018_status = i2c_writeReg(I2C_ADDR, GPIOA, &data, 1, ERGODOX_EZ_I2C_TIMEOUT); | 271 | mcp23018_status = i2c_write_register(I2C_ADDR, GPIOA, &data, 1, ERGODOX_EZ_I2C_TIMEOUT); |
| 272 | } | 272 | } |
| 273 | } else { | 273 | } else { |
| 274 | // Output low(DDR:1, PORT:0) to select | 274 | // Output low(DDR:1, PORT:0) to select |
diff --git a/keyboards/gboards/georgi/georgi.c b/keyboards/gboards/georgi/georgi.c index 745e8ab35d..44b7067b47 100644 --- a/keyboards/gboards/georgi/georgi.c +++ b/keyboards/gboards/georgi/georgi.c | |||
| @@ -46,14 +46,14 @@ uint8_t init_mcp23018(void) { | |||
| 46 | // - input : input : 1 | 46 | // - input : input : 1 |
| 47 | // - driving : output : 0 | 47 | // - driving : output : 0 |
| 48 | uint8_t data[] = {0b10000000, 0b11111111}; | 48 | uint8_t data[] = {0b10000000, 0b11111111}; |
| 49 | mcp23018_status = i2c_writeReg(I2C_ADDR, IODIRA, data, 2, ERGODOX_EZ_I2C_TIMEOUT); | 49 | mcp23018_status = i2c_write_register(I2C_ADDR, IODIRA, data, 2, ERGODOX_EZ_I2C_TIMEOUT); |
| 50 | 50 | ||
| 51 | if (!mcp23018_status) { | 51 | if (!mcp23018_status) { |
| 52 | // set pull-up | 52 | // set pull-up |
| 53 | // - unused : on : 1 | 53 | // - unused : on : 1 |
| 54 | // - input : on : 1 | 54 | // - input : on : 1 |
| 55 | // - driving : off : 0 | 55 | // - driving : off : 0 |
| 56 | mcp23018_status = i2c_writeReg(I2C_ADDR, GPPUA, data, 2, ERGODOX_EZ_I2C_TIMEOUT); | 56 | mcp23018_status = i2c_write_register(I2C_ADDR, GPPUA, data, 2, ERGODOX_EZ_I2C_TIMEOUT); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | // SREG=sreg_prev; | 59 | // SREG=sreg_prev; |
diff --git a/keyboards/gboards/georgi/matrix.c b/keyboards/gboards/georgi/matrix.c index d1151ae80e..00c17a3e44 100644 --- a/keyboards/gboards/georgi/matrix.c +++ b/keyboards/gboards/georgi/matrix.c | |||
| @@ -254,7 +254,7 @@ static matrix_row_t read_cols(uint8_t row) | |||
| 254 | return 0; | 254 | return 0; |
| 255 | } else { | 255 | } else { |
| 256 | uint8_t data = 0; | 256 | uint8_t data = 0; |
| 257 | mcp23018_status = i2c_readReg(I2C_ADDR, GPIOB, &data, 1, ERGODOX_EZ_I2C_TIMEOUT); | 257 | mcp23018_status = i2c_read_register(I2C_ADDR, GPIOB, &data, 1, ERGODOX_EZ_I2C_TIMEOUT); |
| 258 | 258 | ||
| 259 | #ifdef DEBUG_MATRIX | 259 | #ifdef DEBUG_MATRIX |
| 260 | if (data != 0x00) xprintf("I2C: %d\n", data); | 260 | if (data != 0x00) xprintf("I2C: %d\n", data); |
| @@ -298,7 +298,7 @@ static void select_row(uint8_t row) | |||
| 298 | if (mcp23018_status) { // do nothing on error | 298 | if (mcp23018_status) { // do nothing on error |
| 299 | } else { // set active row low : 0 // set other rows hi-Z : 1 | 299 | } else { // set active row low : 0 // set other rows hi-Z : 1 |
| 300 | uint8_t data = 0xFF & ~(1<<row); | 300 | uint8_t data = 0xFF & ~(1<<row); |
| 301 | mcp23018_status = i2c_writeReg(I2C_ADDR, GPIOA, &data, 1, ERGODOX_EZ_I2C_TIMEOUT); | 301 | mcp23018_status = i2c_write_register(I2C_ADDR, GPIOA, &data, 1, ERGODOX_EZ_I2C_TIMEOUT); |
| 302 | 302 | ||
| 303 | } | 303 | } |
| 304 | } else { | 304 | } else { |
diff --git a/keyboards/gboards/gergo/gergo.c b/keyboards/gboards/gergo/gergo.c index 41d383d408..fa73c4b42f 100644 --- a/keyboards/gboards/gergo/gergo.c +++ b/keyboards/gboards/gergo/gergo.c | |||
| @@ -44,14 +44,14 @@ uint8_t init_mcp23018(void) { | |||
| 44 | // - input : input : 1 | 44 | // - input : input : 1 |
| 45 | // - driving : output : 0 | 45 | // - driving : output : 0 |
| 46 | uint8_t data[] = {0b10000000, 0b11111111}; | 46 | uint8_t data[] = {0b10000000, 0b11111111}; |
| 47 | mcp23018_status = i2c_writeReg(I2C_ADDR, IODIRA, data, sizeof(data), I2C_TIMEOUT); | 47 | mcp23018_status = i2c_write_register(I2C_ADDR, IODIRA, data, sizeof(data), I2C_TIMEOUT); |
| 48 | 48 | ||
| 49 | if (!mcp23018_status) { | 49 | if (!mcp23018_status) { |
| 50 | // set pull-up | 50 | // set pull-up |
| 51 | // - unused : on : 1 | 51 | // - unused : on : 1 |
| 52 | // - input : on : 1 | 52 | // - input : on : 1 |
| 53 | // - driving : off : 0 | 53 | // - driving : off : 0 |
| 54 | mcp23018_status = i2c_writeReg(I2C_ADDR, GPPUA, data, sizeof(data), I2C_TIMEOUT); | 54 | mcp23018_status = i2c_write_register(I2C_ADDR, GPPUA, data, sizeof(data), I2C_TIMEOUT); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | // SREG=sreg_prev; | 57 | // SREG=sreg_prev; |
diff --git a/keyboards/gboards/gergo/matrix.c b/keyboards/gboards/gergo/matrix.c index b4885361fb..1fa80a58a0 100644 --- a/keyboards/gboards/gergo/matrix.c +++ b/keyboards/gboards/gergo/matrix.c | |||
| @@ -297,7 +297,7 @@ static matrix_row_t read_cols(uint8_t row) { | |||
| 297 | return 0; | 297 | return 0; |
| 298 | } else { | 298 | } else { |
| 299 | uint8_t data = 0; | 299 | uint8_t data = 0; |
| 300 | mcp23018_status = i2c_readReg(I2C_ADDR, GPIOB, &data, 1, I2C_TIMEOUT); | 300 | mcp23018_status = i2c_read_register(I2C_ADDR, GPIOB, &data, 1, I2C_TIMEOUT); |
| 301 | 301 | ||
| 302 | #ifdef DEBUG_MATRIX | 302 | #ifdef DEBUG_MATRIX |
| 303 | if (~data != 0x00) xprintf("I2C: %d\n", ~data); | 303 | if (~data != 0x00) xprintf("I2C: %d\n", ~data); |
| @@ -344,7 +344,7 @@ static void select_row(uint8_t row) | |||
| 344 | if (mcp23018_status) { // do nothing on error | 344 | if (mcp23018_status) { // do nothing on error |
| 345 | } else { // set active row low : 0 // set other rows hi-Z : 1 | 345 | } else { // set active row low : 0 // set other rows hi-Z : 1 |
| 346 | uint8_t data = 0xFF & ~(1<<row); | 346 | uint8_t data = 0xFF & ~(1<<row); |
| 347 | mcp23018_status = i2c_writeReg(I2C_ADDR, GPIOA, &data, 1, I2C_TIMEOUT); | 347 | mcp23018_status = i2c_write_register(I2C_ADDR, GPIOA, &data, 1, I2C_TIMEOUT); |
| 348 | } | 348 | } |
| 349 | } else { | 349 | } else { |
| 350 | // Output low(DDR:1, PORT:0) to select | 350 | // Output low(DDR:1, PORT:0) to select |
diff --git a/keyboards/gboards/gergoplex/gergoplex.c b/keyboards/gboards/gergoplex/gergoplex.c index b621201c16..b5844125bb 100644 --- a/keyboards/gboards/gergoplex/gergoplex.c +++ b/keyboards/gboards/gergoplex/gergoplex.c | |||
| @@ -40,14 +40,14 @@ uint8_t init_mcp23018(void) { | |||
| 40 | // - input : input : 1 | 40 | // - input : input : 1 |
| 41 | // - driving : output : 0 | 41 | // - driving : output : 0 |
| 42 | uint8_t data[] = {0b11000001, 0b11111111}; | 42 | uint8_t data[] = {0b11000001, 0b11111111}; |
| 43 | mcp23018_status = i2c_writeReg(I2C_ADDR, IODIRA, data, sizeof(data), I2C_TIMEOUT); | 43 | mcp23018_status = i2c_write_register(I2C_ADDR, IODIRA, data, sizeof(data), I2C_TIMEOUT); |
| 44 | 44 | ||
| 45 | if (!mcp23018_status) { | 45 | if (!mcp23018_status) { |
| 46 | // set pull-up | 46 | // set pull-up |
| 47 | // - unused : on : 1 | 47 | // - unused : on : 1 |
| 48 | // - input : on : 1 | 48 | // - input : on : 1 |
| 49 | // - driving : off : 0 | 49 | // - driving : off : 0 |
| 50 | mcp23018_status = i2c_writeReg(I2C_ADDR, GPPUA, data, sizeof(data), I2C_TIMEOUT); | 50 | mcp23018_status = i2c_write_register(I2C_ADDR, GPPUA, data, sizeof(data), I2C_TIMEOUT); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | return mcp23018_status; | 53 | return mcp23018_status; |
diff --git a/keyboards/gboards/gergoplex/matrix.c b/keyboards/gboards/gergoplex/matrix.c index 9437b24377..9abe9a83b3 100644 --- a/keyboards/gboards/gergoplex/matrix.c +++ b/keyboards/gboards/gergoplex/matrix.c | |||
| @@ -207,7 +207,7 @@ static void select_row(uint8_t row) { | |||
| 207 | } else { // set active row low : 0 // set other rows hi-Z : 1 | 207 | } else { // set active row low : 0 // set other rows hi-Z : 1 |
| 208 | uint8_t data; | 208 | uint8_t data; |
| 209 | data = 0xFF & ~(1 << (row + 1)); | 209 | data = 0xFF & ~(1 << (row + 1)); |
| 210 | mcp23018_status = i2c_writeReg(I2C_ADDR, GPIOA, &data, 1, I2C_TIMEOUT); | 210 | mcp23018_status = i2c_write_register(I2C_ADDR, GPIOA, &data, 1, I2C_TIMEOUT); |
| 211 | 211 | ||
| 212 | } | 212 | } |
| 213 | } else { | 213 | } else { |
diff --git a/keyboards/handwired/frenchdev/frenchdev.c b/keyboards/handwired/frenchdev/frenchdev.c index 65f1ccce4b..818c395c8e 100644 --- a/keyboards/handwired/frenchdev/frenchdev.c +++ b/keyboards/handwired/frenchdev/frenchdev.c | |||
| @@ -84,14 +84,14 @@ uint8_t init_mcp23018(void) { | |||
| 84 | // - input : input : 1 | 84 | // - input : input : 1 |
| 85 | // - driving : output : 0 | 85 | // - driving : output : 0 |
| 86 | uint8_t data[] = {0b00000000, 0b00111111}; | 86 | uint8_t data[] = {0b00000000, 0b00111111}; |
| 87 | mcp23018_status = i2c_writeReg(I2C_ADDR, IODIRA, data, sizeof(data), I2C_TIMEOUT); | 87 | mcp23018_status = i2c_write_register(I2C_ADDR, IODIRA, data, sizeof(data), I2C_TIMEOUT); |
| 88 | 88 | ||
| 89 | if (!mcp23018_status) { | 89 | if (!mcp23018_status) { |
| 90 | // set pull-up | 90 | // set pull-up |
| 91 | // - unused : on : 1 | 91 | // - unused : on : 1 |
| 92 | // - input : on : 1 | 92 | // - input : on : 1 |
| 93 | // - driving : off : 0 | 93 | // - driving : off : 0 |
| 94 | mcp23018_status = i2c_writeReg(I2C_ADDR, GPPUA, data, sizeof(data), I2C_TIMEOUT); | 94 | mcp23018_status = i2c_write_register(I2C_ADDR, GPPUA, data, sizeof(data), I2C_TIMEOUT); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | // SREG=sreg_prev; | 97 | // SREG=sreg_prev; |
diff --git a/keyboards/handwired/frenchdev/matrix.c b/keyboards/handwired/frenchdev/matrix.c index af7c8b5444..68ec8e0801 100644 --- a/keyboards/handwired/frenchdev/matrix.c +++ b/keyboards/handwired/frenchdev/matrix.c | |||
| @@ -224,7 +224,7 @@ static matrix_row_t read_cols(uint8_t row) | |||
| 224 | return 0; | 224 | return 0; |
| 225 | } else { | 225 | } else { |
| 226 | uint8_t data = 0; | 226 | uint8_t data = 0; |
| 227 | mcp23018_status = i2c_readReg(I2C_ADDR, GPIOB, &data, 1, I2C_TIMEOUT); | 227 | mcp23018_status = i2c_read_register(I2C_ADDR, GPIOB, &data, 1, I2C_TIMEOUT); |
| 228 | 228 | ||
| 229 | return ~data; | 229 | return ~data; |
| 230 | } | 230 | } |
| @@ -259,7 +259,7 @@ static void unselect_rows(void) | |||
| 259 | // set all rows hi-Z : 1 | 259 | // set all rows hi-Z : 1 |
| 260 | uint8_t data; | 260 | uint8_t data; |
| 261 | data = 0xFF & ~(0<<8); | 261 | data = 0xFF & ~(0<<8); |
| 262 | mcp23018_status = i2c_writeReg(I2C_ADDR, GPIOA, &data, 1, I2C_TIMEOUT); | 262 | mcp23018_status = i2c_write_register(I2C_ADDR, GPIOA, &data, 1, I2C_TIMEOUT); |
| 263 | 263 | ||
| 264 | } | 264 | } |
| 265 | 265 | ||
| @@ -283,7 +283,7 @@ static void select_row(uint8_t row) | |||
| 283 | // set active row low : 0 | 283 | // set active row low : 0 |
| 284 | // set other rows hi-Z : 1 | 284 | // set other rows hi-Z : 1 |
| 285 | uint8_t data = 0xFF & ~(1<<row) & ~(0<<8); | 285 | uint8_t data = 0xFF & ~(1<<row) & ~(0<<8); |
| 286 | mcp23018_status = i2c_writeReg(I2C_ADDR, GPIOA, &data, 1, I2C_TIMEOUT); | 286 | mcp23018_status = i2c_write_register(I2C_ADDR, GPIOA, &data, 1, I2C_TIMEOUT); |
| 287 | } | 287 | } |
| 288 | } else { | 288 | } else { |
| 289 | // select on teensy | 289 | // select on teensy |
diff --git a/keyboards/handwired/pterodactyl/matrix.c b/keyboards/handwired/pterodactyl/matrix.c index 0dff65eda6..54da26a7d4 100644 --- a/keyboards/handwired/pterodactyl/matrix.c +++ b/keyboards/handwired/pterodactyl/matrix.c | |||
| @@ -182,14 +182,14 @@ void init_expander(void) { | |||
| 182 | uint8_t data[] = { expander_input_pin_mask, 0}; | 182 | uint8_t data[] = { expander_input_pin_mask, 0}; |
| 183 | # endif | 183 | # endif |
| 184 | #endif | 184 | #endif |
| 185 | expander_status = i2c_writeReg(I2C_ADDR, IODIRA, data, sizeof(data), I2C_TIMEOUT); | 185 | expander_status = i2c_write_register(I2C_ADDR, IODIRA, data, sizeof(data), I2C_TIMEOUT); |
| 186 | 186 | ||
| 187 | if (!expander_status) { | 187 | if (!expander_status) { |
| 188 | // set pull-up | 188 | // set pull-up |
| 189 | // - unused : off : 0 | 189 | // - unused : off : 0 |
| 190 | // - input : on : 1 | 190 | // - input : on : 1 |
| 191 | // - driving : off : 0 | 191 | // - driving : off : 0 |
| 192 | expander_status = i2c_writeReg(I2C_ADDR, GPPUA, data, sizeof(data), I2C_TIMEOUT); | 192 | expander_status = i2c_write_register(I2C_ADDR, GPPUA, data, sizeof(data), I2C_TIMEOUT); |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | } | 195 | } |
| @@ -305,7 +305,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | |||
| 305 | // Read columns from expander, unless it's in an error state | 305 | // Read columns from expander, unless it's in an error state |
| 306 | if (! expander_status) { | 306 | if (! expander_status) { |
| 307 | uint8_t data; | 307 | uint8_t data; |
| 308 | i2c_readReg(I2C_ADDR, EXPANDER_COL_REGISTER, &data, 1, I2C_TIMEOUT); | 308 | i2c_read_register(I2C_ADDR, EXPANDER_COL_REGISTER, &data, 1, I2C_TIMEOUT); |
| 309 | current_matrix[current_row] |= (~data) & expander_input_pin_mask; | 309 | current_matrix[current_row] |= (~data) & expander_input_pin_mask; |
| 310 | } | 310 | } |
| 311 | 311 | ||
| @@ -329,7 +329,7 @@ static void select_row(uint8_t row) { | |||
| 329 | // set active row low : 0 | 329 | // set active row low : 0 |
| 330 | // set other rows hi-Z : 1 | 330 | // set other rows hi-Z : 1 |
| 331 | uint8_t data = 0xFF & ~(1<<row); | 331 | uint8_t data = 0xFF & ~(1<<row); |
| 332 | i2c_writeReg(I2C_ADDR, EXPANDER_ROW_REGISTER, &data, 1, I2C_TIMEOUT); | 332 | i2c_write_register(I2C_ADDR, EXPANDER_ROW_REGISTER, &data, 1, I2C_TIMEOUT); |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | // select on teensy | 335 | // select on teensy |
| @@ -385,7 +385,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) | |||
| 385 | return false; | 385 | return false; |
| 386 | } | 386 | } |
| 387 | 387 | ||
| 388 | i2c_writeReg(I2C_ADDR, EXPANDER_ROW_REGISTER, &column_state, 1, I2C_TIMEOUT); | 388 | i2c_write_register(I2C_ADDR, EXPANDER_ROW_REGISTER, &column_state, 1, I2C_TIMEOUT); |
| 389 | column_state = ~column_state; | 389 | column_state = ~column_state; |
| 390 | } else { | 390 | } else { |
| 391 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { | 391 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { |
diff --git a/keyboards/hotdox/left.c b/keyboards/hotdox/left.c index f963ecdae7..5196fb3115 100644 --- a/keyboards/hotdox/left.c +++ b/keyboards/hotdox/left.c | |||
| @@ -99,7 +99,7 @@ i2c_status_t left_write(uint8_t reg, uint8_t data) | |||
| 99 | 99 | ||
| 100 | i2c_status_t ret; | 100 | i2c_status_t ret; |
| 101 | 101 | ||
| 102 | ret = i2c_writeReg(I2C_ADDR, reg, &data, sizeof(data), HOTDOX_I2C_TIMEOUT); | 102 | ret = i2c_write_register(I2C_ADDR, reg, &data, sizeof(data), HOTDOX_I2C_TIMEOUT); |
| 103 | 103 | ||
| 104 | return ret; | 104 | return ret; |
| 105 | } | 105 | } |
| @@ -112,7 +112,7 @@ i2c_status_t left_read(uint8_t reg, uint8_t *data) | |||
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | i2c_status_t ret = 0; | 114 | i2c_status_t ret = 0; |
| 115 | ret = i2c_readReg(I2C_ADDR, reg, data, 1, HOTDOX_I2C_TIMEOUT); | 115 | ret = i2c_read_register(I2C_ADDR, reg, data, 1, HOTDOX_I2C_TIMEOUT); |
| 116 | 116 | ||
| 117 | return ret; | 117 | return ret; |
| 118 | } | 118 | } |
diff --git a/keyboards/system76/launch_1/usb_mux.c b/keyboards/system76/launch_1/usb_mux.c index dd51b7c4b2..7ce1da07aa 100644 --- a/keyboards/system76/launch_1/usb_mux.c +++ b/keyboards/system76/launch_1/usb_mux.c | |||
| @@ -79,7 +79,7 @@ i2c_status_t usb7206_read_reg(struct USB7206* self, uint32_t addr, uint8_t* data | |||
| 79 | 79 | ||
| 80 | uint16_t read = 0x0006; // Buffer address 6 to skip header | 80 | uint16_t read = 0x0006; // Buffer address 6 to skip header |
| 81 | uint8_t data_with_buffer_length[length]; | 81 | uint8_t data_with_buffer_length[length]; |
| 82 | status = i2c_readReg16((self->addr << 1), read, data_with_buffer_length, length, I2C_TIMEOUT); | 82 | status = i2c_read_register16((self->addr << 1), read, data_with_buffer_length, length, I2C_TIMEOUT); |
| 83 | 83 | ||
| 84 | for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) { | 84 | for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) { |
| 85 | data[i] = data_with_buffer_length[i+1]; | 85 | data[i] = data_with_buffer_length[i+1]; |
diff --git a/platforms/chibios/drivers/i2c_master.c b/platforms/chibios/drivers/i2c_master.c index ad11d850dd..0d5fb1e985 100644 --- a/platforms/chibios/drivers/i2c_master.c +++ b/platforms/chibios/drivers/i2c_master.c | |||
| @@ -206,5 +206,5 @@ __attribute__((weak)) i2c_status_t i2c_ping_address(uint8_t address, uint16_t ti | |||
| 206 | // Best effort instead tries reading register 0 which will either succeed or timeout. | 206 | // Best effort instead tries reading register 0 which will either succeed or timeout. |
| 207 | // This approach may produce false negative results for I2C devices that do not respond to a register 0 read request. | 207 | // This approach may produce false negative results for I2C devices that do not respond to a register 0 read request. |
| 208 | uint8_t data = 0; | 208 | uint8_t data = 0; |
| 209 | return i2c_readReg(address, 0, &data, sizeof(data), timeout); | 209 | return i2c_read_register(address, 0, &data, sizeof(data), timeout); |
| 210 | } \ No newline at end of file | 210 | } \ No newline at end of file |
