diff --git a/Jamrules b/Jamrules index 8eca19afc7..85c1a1d70c 100644 --- a/Jamrules +++ b/Jamrules @@ -53,7 +53,6 @@ CCFLAGS += -DBOARD=BOARD_$(BOARD:U) ; # core source directories HDRS += $(TOP) ; HDRS += [ FPath $(TOP) core include ] ; -HDRS += [ FPath $(TOP) hal include ] ; HDRS += [ FPath $(TOP) sys include ] [ FPath $(TOP) sys config ] [ FPath $(TOP) sys drivers include ] [ FPath $(TOP) sys drivers cc110x ] [ FPath $(TOP) sys drivers nanopan5375 ] ; HDRS += [ FPath $(TOP) sys net ] ; HDRS += [ FPath $(TOP) sys lib ] [ FPath $(TOP) sys lib fat include ] ; diff --git a/board/msb-430-common/Jamrules.msb-430-common b/board/msb-430-common/Jamrules.msb-430-common index db12fc6763..bfe5a1a6f8 100644 --- a/board/msb-430-common/Jamrules.msb-430-common +++ b/board/msb-430-common/Jamrules.msb-430-common @@ -34,3 +34,4 @@ FLASHFLAGS ?= -d $(FLASH_PORT) -j uif ; RESET ?= $(FLASHER) $(FLASHFLAGS) reset ; +HDRS += [ FPath $(TOP) board msb-430-common drivers include ] ; diff --git a/board/msb-430-common/board_init.c b/board/msb-430-common/board_init.c index 7dee70e3b1..4673600445 100644 --- a/board/msb-430-common/board_init.c +++ b/board/msb-430-common/board_init.c @@ -201,7 +201,7 @@ void board_init() { msp430_cpu_init(); msb_ports_init(); - RED_ON; + LED_RED_ON; msp430_set_cpu_speed(7372800uL); } diff --git a/board/msb-430-common/drivers/include/sht11-board.h b/board/msb-430-common/drivers/include/sht11-board.h new file mode 100644 index 0000000000..a4debd4473 --- /dev/null +++ b/board/msb-430-common/drivers/include/sht11-board.h @@ -0,0 +1,61 @@ +/****************************************************************************** +Copyright 2009, Freie Universitaet Berlin (FUB). All rights reserved. + +These sources were developed at the Freie Universitaet Berlin, Computer Systems +and Telematics group (http://cst.mi.fu-berlin.de). +------------------------------------------------------------------------------- +This file is part of FeuerWare. + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +FeuerWare is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see http://www.gnu.org/licenses/ . +-------------------------------------------------------------------------------- +For further information and questions please use the web site + http://scatterweb.mi.fu-berlin.de +and the mailinglist (subscription via web site) + scatterweb@lists.spline.inf.fu-berlin.de +*******************************************************************************/ + +#ifndef SHT11BOARD_H_ +#define SHT11BOARD_H_ + +/** + * @ingroup msb_430h + * @{ + */ + +/** + * @file + * @brief SHT11 Device Driver Configuration For MSB-430 Platform + * + * @author Freie Universität Berlin, Computer Systems & Telematics, µkleos + * @version $Revision$ + * + * @note $Id$ + */ +#include +#include + +/* SCK = P3B5 + * DATA = P3B4 + */ + +#define SHT11_SCK_LOW P3OUT &= ~(BIT5); /**< serial clock line low */ +#define SHT11_SCK_HIGH P3OUT |= BIT5; /**< serial clock line high */ +#define SHT11_DATA (P3IN & BIT5) /**< read serial I/O */ +#define SHT11_DATA_LOW P3OUT &= ~(BIT5); /**< serial I/O line low */ +#define SHT11_DATA_HIGH P3OUT |= BIT5; /**< serial I/O line high */ +#define SHT11_DATA_IN P3DIR &= ~(BIT5); /**< serial I/O as input */ +#define SHT11_DATA_OUT P3DIR |= BIT5; /**< serial I/O as output */ +#define SHT11_INIT P3DIR |= BIT5; /* FIO1DIR |= BIT25; PINSEL3 &= ~(BIT14|BIT15 | BIT16|BIT17); */ + +/** @} */ +#endif /* SHT11BOARD_H_ */ diff --git a/core/bitarithm.c b/core/bitarithm.c index bf9ee86991..7ffd031400 100644 --- a/core/bitarithm.c +++ b/core/bitarithm.c @@ -15,8 +15,6 @@ #include -#define ARCH_32_BIT (__INT_MAX__ == 2147483647) - unsigned number_of_highest_bit(unsigned v) { diff --git a/core/include/bitarithm.h b/core/include/bitarithm.h index de06c50241..d159f33348 100644 --- a/core/include/bitarithm.h +++ b/core/include/bitarithm.h @@ -64,6 +64,8 @@ #endif /** @} */ +#define ARCH_32_BIT (__INT_MAX__ == 2147483647) + /** * @brief Returns the number of the highest '1' bit in a value * @param[in] v Input value diff --git a/core/include/sched.h b/core/include/sched.h index ca5f74ddb1..a506d3cc36 100644 --- a/core/include/sched.h +++ b/core/include/sched.h @@ -15,7 +15,7 @@ #define MAXTHREADS 32 -#ifdef ARCH_32_BIT +#if ARCH_32_BIT #define SCHED_PRIO_LEVELS 32 #else #define SCHED_PRIO_LEVELS 16 diff --git a/drivers/include/sht11.h b/drivers/include/sht11.h index c649f402d8..9119d911db 100644 --- a/drivers/include/sht11.h +++ b/drivers/include/sht11.h @@ -50,6 +50,11 @@ and the mailinglist (subscription via web site) #define SHT11_MEASURE_HUMI (0x05) //000 0010 1 #define SHT11_RESET (0x1E) //000 1111 0 +/* time to wait after toggling the data line */ +#define SHT11_DATA_WAIT (HWTIMER_TICKS(5)) +/* time to wait after toggling the clock line */ +#define SHT11_CLK_WAIT (HWTIMER_TICKS(1)) + /* set measurement timeout to 1 second */ #define SHT11_MEASURE_TIMEOUT (1000) diff --git a/drivers/sht11.c b/drivers/sht11.c index b0d77e03ab..70e4039e85 100644 --- a/drivers/sht11.c +++ b/drivers/sht11.c @@ -37,7 +37,6 @@ and the mailinglist (subscription via web site) * @note $Id: sht11.c 2396 2010-07-06 15:12:35Z ziegert $ */ -#include #include #include @@ -46,6 +45,9 @@ and the mailinglist (subscription via web site) #include #include +//#define ENABLE_DEBUG (1) +#include + /** * @brief Perform measurement * @@ -147,6 +149,7 @@ static uint8_t read_byte (uint8_t ack) value = value << 1; SHT11_SCK_HIGH; hwtimer_wait(SHT11_CLK_WAIT); + if (SHT11_DATA) { /* increase data by one when DATA is high */ value++; @@ -230,10 +233,10 @@ static uint8_t measure(uint8_t *p_value, uint8_t *p_checksum, uint8_t mode) uint8_t ack = 1; uint16_t i; - transmission_start(); + transmission_start(); error = write_byte(mode); - hwtimer_wait(HWTIMER_MSEC); + hwtimer_wait(HWTIMER_TICKS(1000)); /* wait untile sensor has finished measurement or timeout */ for (i = 0; (i < SHT11_MEASURE_TIMEOUT) && (!error); i++) { @@ -242,7 +245,7 @@ static uint8_t measure(uint8_t *p_value, uint8_t *p_checksum, uint8_t mode) if (!ack) { break; } - hwtimer_wait(HWTIMER_MSEC); + hwtimer_wait(HWTIMER_TICKS(1000)); } error += ack; @@ -259,7 +262,7 @@ static uint8_t measure(uint8_t *p_value, uint8_t *p_checksum, uint8_t mode) void sht11_init(void) { mutex_init(&sht11_mutex); SHT11_INIT; - hwtimer_wait(11 * HWTIMER_MSEC); + hwtimer_wait(11 * HWTIMER_TICKS(1000)); } /*---------------------------------------------------------------------------*/ uint8_t sht11_read_status(uint8_t *p_value, uint8_t *p_checksum) { @@ -303,7 +306,9 @@ uint8_t sht11_read_sensor(sht11_val_t *value, sht11_mode_t mode) { const float T2 = +0.00008; /* check for valid buffer */ - assert(value != NULL); + if (value == NULL) { + return 0; + } value->temperature = 0; value->relhum = 0;