From 29b57608a54604c7e940577f9e33009cc6d1eb17 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Mon, 10 Oct 2011 00:15:13 +0200 Subject: Yield while waiting for I2C transaction completion. --- i2c.cpp | 9 +++++++-- 1 file 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; -- cgit v1.2.3