I am using a STM32F103CBT6 as I2C Master. After sending the I2C Adress of the Slave I need to clear the Addr bit in the SR1 register. The Datasheet states:
"ADDR: Address sent (master mode)/matched (slave mode) This bit is cleared by software reading SR1 register followed reading SR2"
Therefore i have two lines after the busy wait loop checking for the bit like this:
uint16_t a = I2C1->SR1; uint16_t b = I2C1->SR2;
This works fine and the compiler won't optimize the reads, because the Registers are declared as
volatile, but it warns me as the two variables are never read and therefore useless. I would like to get rid of these warnings. Is it guaranteed to work, when i change the lines like this:
Or should i clear the bit manually without reading SR2 ever ?
Thanks in Advance