diff options
author | Joel Challis <git@zvecr.com> | 2021-12-02 14:32:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-02 14:32:31 +0000 |
commit | 3bf2403244b035e982dec17680b836afbe5df603 (patch) | |
tree | 440023b7c3d4c69edcfb31969245abf4a173b9af /platforms/avr | |
parent | 44662618954ee72d3521becc2ffe517b47c10b2d (diff) | |
download | qmk_firmware-3bf2403244b035e982dec17680b836afbe5df603.tar.gz qmk_firmware-3bf2403244b035e982dec17680b836afbe5df603.zip |
Tidy up existing i2c_master implementations (#15376)
* Move chibios defines out of header
* Make some avr defines internal
Diffstat (limited to 'platforms/avr')
-rw-r--r-- | platforms/avr/drivers/i2c_master.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/platforms/avr/drivers/i2c_master.c b/platforms/avr/drivers/i2c_master.c index 111b55d6b0..d4024378ca 100644 --- a/platforms/avr/drivers/i2c_master.c +++ b/platforms/avr/drivers/i2c_master.c @@ -32,6 +32,9 @@ # define I2C_START_RETRY_COUNT 20 #endif // I2C_START_RETRY_COUNT +#define I2C_ACTION_READ 0x01 +#define I2C_ACTION_WRITE 0x00 + #define TWBR_val (((F_CPU / F_SCL) - 16) / 2) #define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) @@ -154,7 +157,7 @@ int16_t i2c_read_nack(uint16_t timeout) { } i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout) { - i2c_status_t status = i2c_start(address | I2C_WRITE, timeout); + i2c_status_t status = i2c_start(address | I2C_ACTION_WRITE, timeout); for (uint16_t i = 0; i < length && status >= 0; i++) { status = i2c_write(data[i], timeout); @@ -166,7 +169,7 @@ i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, } i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) { - i2c_status_t status = i2c_start(address | I2C_READ, timeout); + i2c_status_t status = i2c_start(address | I2C_ACTION_READ, timeout); for (uint16_t i = 0; i < (length - 1) && status >= 0; i++) { status = i2c_read_ack(timeout); |