From c5e9d688a5a6589669e5e4553a3d2c35df264dc6 Mon Sep 17 00:00:00 2001 From: Antonio Lignan Date: Thu, 16 Aug 2012 13:38:11 +0200 Subject: [PATCH] Fixed sht11 driver, now ensures the i2c bus is disabled when initializing --- core/dev/sht11.c | 11 +++++++++++ examples/z1/Makefile | 2 +- platform/wismote/dev/sht11-arch.h | 1 + platform/z1/dev/sht11-arch.h | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core/dev/sht11.c b/core/dev/sht11.c index 2b7f255ba..957728193 100644 --- a/core/dev/sht11.c +++ b/core/dev/sht11.c @@ -212,6 +212,17 @@ sht11_init(void) #ifdef SHT11_INIT SHT11_INIT(); #else + /* As this driver is bit-bang based, disable the I2C first + This assumes the SDA/SCL pins passed in the -arch.h file are + actually the same used for I2C operation, else comment out the following + */ + #warning SHT11: DISABLING I2C BUS + SHT11_PxSEL &= ~(BV(SHT11_ARCH_SDA) | BV(SHT11_ARCH_SCL)); + #if defined(__MSP430_HAS_MSP430X_CPU__) || defined(__MSP430_HAS_MSP430XV2_CPU__) + SHT11_PxREN &= ~(BV(SHT11_ARCH_SDA) | BV(SHT11_ARCH_SCL)); + #endif + + /* Configure SDA/SCL as GPIOs */ SHT11_PxOUT |= BV(SHT11_ARCH_PWR); SHT11_PxOUT &= ~(BV(SHT11_ARCH_SDA) | BV(SHT11_ARCH_SCL)); SHT11_PxDIR |= BV(SHT11_ARCH_PWR) | BV(SHT11_ARCH_SCL); diff --git a/examples/z1/Makefile b/examples/z1/Makefile index b9065d58d..3e9362b06 100644 --- a/examples/z1/Makefile +++ b/examples/z1/Makefile @@ -3,7 +3,7 @@ TARGET=z1 endif CONTIKI_PROJECT = test-phidgets blink test-adxl345 test-tmp102 test-light-ziglet test-battery test-sht11 test-relay-phidget #test-potent -CONTIKI_SOURCEFILES += sht11.c potentiometer-sensor.c +CONTIKI_SOURCEFILES += sht11.c# potentiometer-sensor.c APPS=serial-shell diff --git a/platform/wismote/dev/sht11-arch.h b/platform/wismote/dev/sht11-arch.h index 8df629f65..1cc7c9019 100644 --- a/platform/wismote/dev/sht11-arch.h +++ b/platform/wismote/dev/sht11-arch.h @@ -48,5 +48,6 @@ #define SHT11_PxIN P1IN #define SHT11_PxOUT P1OUT #define SHT11_PxSEL P1SEL +#define SHT11_PxREN P1REN #endif diff --git a/platform/z1/dev/sht11-arch.h b/platform/z1/dev/sht11-arch.h index d1d833d29..6c190e399 100644 --- a/platform/z1/dev/sht11-arch.h +++ b/platform/z1/dev/sht11-arch.h @@ -56,5 +56,6 @@ #define SHT11_PxIN P5IN #define SHT11_PxOUT P5OUT #define SHT11_PxSEL P5SEL +#define SHT11_PxREN P5REN #endif