Move shifting of TWI slave address

As this may be obscure the shifting of the TWI slave address is moved
to where it is used instead of where it is set.
This commit is contained in:
finga 2021-09-24 12:25:47 +02:00
parent c0f8cac065
commit 2beecbe722

View file

@ -22,7 +22,7 @@
#define TWI_SDA PC4 #define TWI_SDA PC4
#define TWI_SCL PC5 #define TWI_SCL PC5
#define SI5351_ADDRESS (0x60 << 1) #define SI5351_ADDRESS 0x60
#define SYM_ENTRY(SYM) { SYM, sizeof(SYM) / 2 } #define SYM_ENTRY(SYM) { SYM, sizeof(SYM) / 2 }
@ -386,8 +386,8 @@ static uint8_t twi_read_register(const uint8_t address,
const uint8_t reg) { const uint8_t reg) {
twi_start(); twi_start();
if (twi_transmit(address) != TW_MT_SLA_ACK)
twi_error(); twi_error();
if (twi_transmit(address << 1) != TW_MT_SLA_ACK)
if (twi_transmit(reg) != TW_MT_DATA_ACK) if (twi_transmit(reg) != TW_MT_DATA_ACK)
twi_error(); twi_error();
@ -398,8 +398,8 @@ static uint8_t twi_read_register(const uint8_t address,
twi_start(); twi_start();
if (twi_transmit(address + 1) != TW_MR_SLA_ACK)
twi_error(); twi_error();
if (twi_transmit((address << 1) + 1) != TW_MR_SLA_ACK)
if (twi_receive() != TW_MR_DATA_NACK) if (twi_receive() != TW_MR_DATA_NACK)
twi_error(); twi_error();
@ -414,8 +414,8 @@ static void twi_write_register(const uint8_t address,
const uint8_t data) { const uint8_t data) {
twi_start(); twi_start();
if (twi_transmit(address) != TW_MT_SLA_ACK)
twi_error(); twi_error();
if (twi_transmit(address << 1) != TW_MT_SLA_ACK)
if (twi_transmit(reg) != TW_MT_DATA_ACK) if (twi_transmit(reg) != TW_MT_DATA_ACK)
twi_error(); twi_error();