# HG changeset patch # User Josef 'Jeff' Sipek # Date 1721045147 14400 # Mon Jul 15 08:05:47 2024 -0400 # Node ID 4d7c16586245e7021e83709d78ebe4e49c09df0c # Parent 4c0a39eba5ac267df3edd6cb2de67630c7033bd6 arch: extend i2c_rx_byte to return the status (ATmega48P) Signed-off-by: Josef 'Jeff' Sipek diff --git a/arch/atmega48p_i2c.h b/arch/atmega48p_i2c.h --- a/arch/atmega48p_i2c.h +++ b/arch/atmega48p_i2c.h @@ -93,12 +93,15 @@ } /* return received byte, sends ACK if !last and NACK if last */ -static inline uint8_t i2c_rx_byte(bool last) +static inline uint8_t i2c_rx_byte(bool last, bool *_sync) { + bool dummy; + bool *sync = _sync ? _sync : &dummy; + mmregs->twcr = REG_TWCR_TWINT | REG_TWCR_TWEN | (last ? 0 : REG_TWCR_TWEA); - i2c_sync(last ? I2C_STATUS_MR_DATA_NACK : I2C_STATUS_MR_DATA_ACK); + *sync = i2c_sync(last ? I2C_STATUS_MR_DATA_NACK : I2C_STATUS_MR_DATA_ACK); return mmregs->twdr; }