fixed read loop to be slightly less CPU speed dependent

This commit is contained in:
Joakim Eriksson 2012-10-01 13:09:16 +02:00
parent d84a97103f
commit 621790f156
1 changed files with 4 additions and 3 deletions

View File

@ -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;