diff options
Diffstat (limited to 'testhal/STM32F1xx/I2C/fake.c')
-rw-r--r-- | testhal/STM32F1xx/I2C/fake.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/testhal/STM32F1xx/I2C/fake.c b/testhal/STM32F1xx/I2C/fake.c index b06ffbdfd..9d46f448d 100644 --- a/testhal/STM32F1xx/I2C/fake.c +++ b/testhal/STM32F1xx/I2C/fake.c @@ -42,14 +42,17 @@ static i2cflags_t errors = 0; /* This is main function. */
void request_fake(void){
+ msg_t status = RDY_OK;
+ systime_t tmo = MS2ST(4);
i2cAcquireBus(&I2CD1);
- i2cMasterReceive(&I2CD1, addr, rx_data, 2, &errors, TIME_INFINITE);
+ status = i2cMasterReceiveTimeout(&I2CD1, addr, rx_data, 2, tmo);
i2cReleaseBus(&I2CD1);
- if (errors == I2CD_ACK_FAILURE){
- __NOP();
+ if (status != RDY_OK){
+ errors = i2cGetErrors(&I2CD1);
}
+
else{
temperature = (rx_data[0] << 8) + rx_data[1];
}
|