diff options
-rw-r--r-- | i2c.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -1,6 +1,7 @@ #include "i2c.h" #include "stm32.h" +#include "thread.h" I2C* I2C::self; @@ -116,7 +117,9 @@ void I2C::write_reg(uint8_t addr_, uint8_t reg, uint8_t data) { I2C1.CR1 |= 0x100; - while(busy); + while(busy) { + Thread::yield(); + } /* while(!(I2C1.SR1 & 0x01)); // Wait for SB. @@ -144,7 +147,9 @@ void I2C::read_reg(uint8_t addr_, uint8_t reg, uint8_t len, uint8_t* buf) { I2C1.CR1 |= 0x100; - while(busy); + while(busy) { + Thread::yield(); + } /* I2C1.CR1 |= 0x100; |