arch: add function to sync I2C device that returs current status (ATmega48P)

This is more flexible than the previous sync function that expected a
specific status.

Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
1 files changed, 9 insertions(+), 3 deletions(-)

M arch/atmega48p_i2c.h
M arch/atmega48p_i2c.h +9 -3
@@ 53,13 53,19 @@ static inline void i2c_init_master(uint3
 	mmregs->twcr = REG_TWCR_TWEN;
 }
 
-/* wait for action to complete */
-static inline bool i2c_sync(uint8_t status)
+/* wait for action to complete - return status */
+static inline uint8_t i2c_sync_raw(void)
 {
 	while (!(mmregs->twcr & REG_TWCR_TWINT))
 		;
 
-	return (mmregs->twsr & REG_TWSR_STATUS_MASK) == status;
+	return mmregs->twsr & REG_TWSR_STATUS_MASK;
+}
+
+/* wait for action to complete - expect specified status */
+static inline bool i2c_sync(uint8_t status)
+{
+	return i2c_sync_raw() == status;
 }
 
 /* transmit a START condition */