uses interface GeneralIO as CLOCK;
uses interface GpioInterrupt as InterruptDATA;
+ uses interface BusyWait<TMicro, uint8_t>;
uses interface Timer<TMilli>;
uses interface Leds;
enum {
TIMEOUT_RESET = 11,
- TIMEOUT_14BIT = 250,
- TIMEOUT_12BIT = 250, //70,
- TIMEOUT_8BIT = 250, //15,
+
+ /* SHT1x_SHT7x_E data sheet v3.01 indicates readings take at most
+ * 320 ms for 14 bits, 80 ms for 12 bits and 20 ms for 8 bits.
+ * Add 20% as a safety margin.
+ */
+ TIMEOUT_14BIT = 393,
+ TIMEOUT_12BIT = 98,
+ TIMEOUT_8BIT = 25,
} sht_timeout_t;
bool on = TRUE;
call DATA.makeOutput();
call DATA.set();
call CLOCK.clr();
+ call BusyWait.wait(5);
call CLOCK.set();
+ call BusyWait.wait(5);
call DATA.clr();
+ call BusyWait.wait(5);
call CLOCK.clr();
+ call BusyWait.wait(5);
call CLOCK.set();
+ call BusyWait.wait(5);
call DATA.set();
+ call BusyWait.wait(5);
call CLOCK.clr();
}
call DATA.clr();
byte = byte << 1;
call CLOCK.set();
+ call BusyWait.wait(5);
call CLOCK.clr();
}
}
call DATA.makeOutput();
call DATA.clr();
call CLOCK.set();
+ call BusyWait.wait(5);
call CLOCK.clr();
call DATA.makeInput();
call DATA.set();
call DATA.makeOutput();
call DATA.set();
call CLOCK.set();
+ call BusyWait.wait(5);
call CLOCK.clr();
}