summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-10-10 00:15:13 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-10-10 00:15:13 +0200
commit29b57608a54604c7e940577f9e33009cc6d1eb17 (patch)
tree67481777328a4e3c4b9664a37bef654191727fc2
parent8c7d77006f9427ddb8b563e928cfab319157866c (diff)
Yield while waiting for I2C transaction completion.
-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;