I was having trouble using this code with a TI TMP102 temperature sensor, where it would stop reading after sending the address + read. After looking at the signals with a logic analyzer, it appeared that the STM32 wasn't transmitting the clock at all, which explained why the reads were failing. After some more investigation, I traced the issue back to this single flag inversion. Since temperature reads from the TMP102 are two bytes wide, the code would branch to what should have been an ACK-enable, but the inverted flag would enable every other flag instead. Getting rid of that one tilde fixed the whole issue, and now it works perfectly.
I was having trouble using this code with a TI TMP102 temperature sensor, where it would stop reading after sending the address + read. After looking at the signals with a logic analyzer, it appeared that the STM32 wasn't transmitting the clock at all, which explained why the reads were failing. After some more investigation, I traced the issue back to this single flag inversion. Since temperature reads from the TMP102 are two bytes wide, the code would branch to what should have been an ACK-enable, but the inverted flag would enable every other flag instead. Getting rid of that one tilde fixed the whole issue, and now it works perfectly.