From 2beecbe7227241772360fa4913b63cfa2b437187 Mon Sep 17 00:00:00 2001 From: finga Date: Fri, 24 Sep 2021 12:25:47 +0200 Subject: [PATCH] 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. --- firmware/src/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/firmware/src/main.c b/firmware/src/main.c index 27add27..d51eb62 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -22,7 +22,7 @@ #define TWI_SDA PC4 #define TWI_SCL PC5 -#define SI5351_ADDRESS (0x60 << 1) +#define SI5351_ADDRESS 0x60 #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) { twi_start(); - if (twi_transmit(address) != TW_MT_SLA_ACK) twi_error(); + if (twi_transmit(address << 1) != TW_MT_SLA_ACK) if (twi_transmit(reg) != TW_MT_DATA_ACK) twi_error(); @@ -398,8 +398,8 @@ static uint8_t twi_read_register(const uint8_t address, twi_start(); - if (twi_transmit(address + 1) != TW_MR_SLA_ACK) twi_error(); + if (twi_transmit((address << 1) + 1) != TW_MR_SLA_ACK) if (twi_receive() != TW_MR_DATA_NACK) twi_error(); @@ -414,8 +414,8 @@ static void twi_write_register(const uint8_t address, const uint8_t data) { twi_start(); - if (twi_transmit(address) != TW_MT_SLA_ACK) twi_error(); + if (twi_transmit(address << 1) != TW_MT_SLA_ACK) if (twi_transmit(reg) != TW_MT_DATA_ACK) twi_error();