mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
* added support for sht11 for msb-430-common
* fixed some jamfile isssues for msb-430 * fixed arch32 detection for scheduler * changed sht11 driver to be platform independent
This commit is contained in:
parent
4ba5cfbeca
commit
f38f32f6cc
1
Jamrules
1
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 ] ;
|
||||
|
@ -34,3 +34,4 @@ FLASHFLAGS ?= -d $(FLASH_PORT) -j uif ;
|
||||
|
||||
RESET ?= $(FLASHER) $(FLASHFLAGS) reset ;
|
||||
|
||||
HDRS += [ FPath $(TOP) board msb-430-common drivers include ] ;
|
||||
|
@ -201,7 +201,7 @@ void board_init() {
|
||||
msp430_cpu_init();
|
||||
msb_ports_init();
|
||||
|
||||
RED_ON;
|
||||
LED_RED_ON;
|
||||
|
||||
msp430_set_cpu_speed(7372800uL);
|
||||
}
|
||||
|
61
board/msb-430-common/drivers/include/sht11-board.h
Normal file
61
board/msb-430-common/drivers/include/sht11-board.h
Normal file
@ -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 <msp430x16x.h>
|
||||
#include <bitarithm.h>
|
||||
|
||||
/* 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_ */
|
@ -15,8 +15,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define ARCH_32_BIT (__INT_MAX__ == 2147483647)
|
||||
|
||||
unsigned
|
||||
number_of_highest_bit(unsigned v)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -37,7 +37,6 @@ and the mailinglist (subscription via web site)
|
||||
* @note $Id: sht11.c 2396 2010-07-06 15:12:35Z ziegert $
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@ -46,6 +45,9 @@ and the mailinglist (subscription via web site)
|
||||
#include <sht11.h>
|
||||
#include <sht11-board.h>
|
||||
|
||||
//#define ENABLE_DEBUG (1)
|
||||
#include <debug.h>
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
Loading…
Reference in New Issue
Block a user