From ceb423c007c42203993662d0b06924801e4462e7 Mon Sep 17 00:00:00 2001 From: bg- Date: Mon, 28 May 2007 16:24:58 +0000 Subject: [PATCH] * Add sht11_off. --- platform/sky/dev/sht11.c | 29 +++++++++++++++++++++++++---- platform/sky/dev/sht11.h | 13 ++++++++++++- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/platform/sky/dev/sht11.c b/platform/sky/dev/sht11.c index eb4481588..1691c7c3f 100644 --- a/platform/sky/dev/sht11.c +++ b/platform/sky/dev/sht11.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)$Id: sht11.c,v 1.1 2007/04/04 12:48:50 bg- Exp $ + * @(#)$Id: sht11.c,v 1.2 2007/05/28 16:25:29 bg- Exp $ */ /* @@ -194,6 +194,10 @@ crc8_add(unsigned acc, unsigned byte) } #endif /* CRC_CHECK */ +/* + * Power up the device. The device can be used after an additional + * 11ms waiting time. + */ void sht11_init(void) { @@ -207,6 +211,17 @@ sht11_init(void) P1DIR |= BV(PWR) | BV(SCL); } +/* + * Power of device. + */ +void +sht11_off(void) +{ + P1OUT &= ~BV(PWR); + P1OUT &= ~(BV(SDA) | BV(SCL)); + P1DIR |= BV(PWR) | BV(SCL); +} + /* * Only commands MEASURE_HUMI or MEASURE_TEMP! */ @@ -246,12 +261,18 @@ scmd(unsigned cmd) return -1; } +/* + * Call may take up to 210ms. + */ unsigned sht11_temp(void) { return scmd(MEASURE_TEMP); } +/* + * Call may take up to 210ms. + */ unsigned sht11_humidity(void) { @@ -260,7 +281,7 @@ sht11_humidity(void) #if 0 /* But ok! */ unsigned -sget_sreg(void) +sht11_sreg(void) { unsigned sreg, rcrc; @@ -290,8 +311,8 @@ sget_sreg(void) #endif #if 0 -unsigned -sset_sreg(unsigned sreg) +int +sht11_set_sreg(unsigned sreg) { sstart(); /* Start transmission */ if (!swrite(STATUS_REG_W)) diff --git a/platform/sky/dev/sht11.h b/platform/sky/dev/sht11.h index 5d0dec87e..7231dc0dc 100644 --- a/platform/sky/dev/sht11.h +++ b/platform/sky/dev/sht11.h @@ -26,15 +26,26 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)$Id: sht11.h,v 1.1 2007/04/04 12:48:50 bg- Exp $ + * @(#)$Id: sht11.h,v 1.2 2007/05/28 16:24:58 bg- Exp $ */ #ifndef SHT11_H #define SHT11_H void sht11_init(void); +void sht11_off(void); unsigned sht11_temp(void); unsigned sht11_humidity(void); +unsigned sht11_sreg(void); +int sht11_set_sreg(unsigned); + +/* + * Relative Humidity in percent (h in 12 bits resolution) + * RH = -4 + 0.0405*h - 2.8e-6*(h*h) + * + * Temperature in Celsius (t in 14 bits resolution at 3 Volts) + * T = -39.60 + 0.01*t + */ #endif /* SHT11_H */