From 621790f156a091c1a2c2c3bbfcd14595d3281840 Mon Sep 17 00:00:00 2001 From: Joakim Eriksson Date: Mon, 1 Oct 2012 13:09:16 +0200 Subject: [PATCH] fixed read loop to be slightly less CPU speed dependent --- core/dev/sht11.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/dev/sht11.c b/core/dev/sht11.c index 957728193..815bf6aa5 100644 --- a/core/dev/sht11.c +++ b/core/dev/sht11.c @@ -250,7 +250,7 @@ sht11_off(void) static unsigned int scmd(unsigned cmd) { - unsigned long n; + unsigned int n; if(cmd != MEASURE_HUMI && cmd != MEASURE_TEMP) { PRINTF("Illegal command: %d\n", cmd); @@ -263,7 +263,7 @@ scmd(unsigned cmd) goto fail; } - for(n = 0; n < 250000; n++) { + for(n = 0; n < 20000; n++) { if(!SDA_IS_1) { unsigned t0, t1, rcrc; t0 = sread(1); @@ -285,8 +285,9 @@ scmd(unsigned cmd) #endif return (t0 << 8) | t1; } + /* short wait before next loop */ + clock_wait(1); } - fail: sreset(); return -1;