summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i2c.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/i2c.cpp b/i2c.cpp
index 03dd6b6..ff081ae 100644
--- a/i2c.cpp
+++ b/i2c.cpp
@@ -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;