aboutsummaryrefslogtreecommitdiffstats
path: root/testhal/STM32F1xx/I2C/tmp75.c
diff options
context:
space:
mode:
authorbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-12-30 20:45:56 +0000
committerbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-12-30 20:45:56 +0000
commit2234fd3e31d4ce6e2b3990340b52719951e65731 (patch)
tree3d8dadab8ab98a46ab2f98ed0b94d648e86ce837 /testhal/STM32F1xx/I2C/tmp75.c
parent08feb80580ca82cfebd77a43d14d1197ec7c4f99 (diff)
downloadChibiOS-2234fd3e31d4ce6e2b3990340b52719951e65731.tar.gz
ChibiOS-2234fd3e31d4ce6e2b3990340b52719951e65731.tar.bz2
ChibiOS-2234fd3e31d4ce6e2b3990340b52719951e65731.zip
I2C. API changes mostly done.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3692 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal/STM32F1xx/I2C/tmp75.c')
-rw-r--r--testhal/STM32F1xx/I2C/tmp75.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/testhal/STM32F1xx/I2C/tmp75.c b/testhal/STM32F1xx/I2C/tmp75.c
index 23410843f..9d41e0a0f 100644
--- a/testhal/STM32F1xx/I2C/tmp75.c
+++ b/testhal/STM32F1xx/I2C/tmp75.c
@@ -45,11 +45,17 @@ static i2cflags_t errors = 0;
/* This is main function. */
void request_temperature(void){
int16_t t_int = 0, t_frac = 0;
+ msg_t status = RDY_OK;
+ systime_t tmo = MS2ST(4);
i2cAcquireBus(&I2CD1);
- i2cMasterReceive(&I2CD1, tmp75_addr, tmp75_rx_data, 2, &errors, TIME_INFINITE);
+ status = i2cMasterReceiveTimeout(&I2CD1, tmp75_addr, tmp75_rx_data, 2, tmo);
i2cReleaseBus(&I2CD1);
+ if (status != RDY_OK){
+ errors = i2cGetErrors(&I2CD1);
+ }
+
t_int = tmp75_rx_data[0] * 100;
t_frac = (tmp75_rx_data[1] * 100) >> 8;
temperature = t_int + t_frac;