1
0
Fork 0

I2C driver cleanup (#21273)

* remove i2c_start and i2c_stop from i2c drivers

* remove static i2c_address variable from chibios i2c driver
This commit is contained in:
David Hoelscher 2024-01-17 07:05:38 -06:00 committed by GitHub
parent 2b0965944d
commit e9bd7d7ad3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 280 additions and 603 deletions

View file

@ -145,12 +145,7 @@ static matrix_row_t read_cols(uint8_t row) {
uint8_t data = 0;
// reading GPIOB (column port) since in mcp23018's sequential mode
// it is addressed directly after writing to GPIOA in select_row()
mcp23018_status = i2c_start(I2C_ADDR_READ, BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
mcp23018_status = i2c_read_nack(BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status < 0) goto out;
data = ~((uint8_t)mcp23018_status);
mcp23018_status = I2C_STATUS_SUCCESS;
out:
i2c_stop();
mcp23018_status = i2c_receive(I2C_ADDR, &data, 1, BAJJAK_EZ_I2C_TIMEOUT);
return data;
}
} else {
@ -195,11 +190,10 @@ static void select_row(uint8_t row) {
if (!mcp23018_status) {
// set active row low : 0
// set other rows hi-Z : 1
mcp23018_status = i2c_start(I2C_ADDR_WRITE, BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(GPIOA, BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
mcp23018_status = i2c_write(0xFF & ~(1 << row), BAJJAK_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
out:
i2c_stop();
uint8_t data;
data = 0xFF & ~(1 << row);
mcp23018_status = i2c_writeReg(I2C_ADDR, GPIOA, &data, 1, BAJJAK_EZ_I2C_TIMEOUT);
}
} else {
// select on teensy