2011-01-20 11:28:00 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2010, Swedish Institute of Computer Science.
|
2016-02-22 10:34:48 +01:00
|
|
|
* Copyright (c) 2016, Zolertia <http://www.zolertia.com>
|
2011-01-20 11:28:00 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the Institute nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* This file is part of the Contiki operating system.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file
|
2016-02-22 10:34:48 +01:00
|
|
|
* Device drivers header file for tmp102 temperature sensor in Zolertia
|
|
|
|
* Z1 WSN Platform.
|
2011-01-20 11:28:00 +01:00
|
|
|
* \author
|
|
|
|
* Enric M. Calvo, Zolertia <ecalvo@zolertia.com>
|
|
|
|
* Marcus Lundén, SICS <mlunden@sics.se>
|
2016-02-22 10:34:48 +01:00
|
|
|
* Antonio Lignan, Zolertia <alinan@zolertia.com>
|
2011-01-20 11:28:00 +01:00
|
|
|
*/
|
2016-02-22 10:34:48 +01:00
|
|
|
/* -------------------------------------------------------------------------- */
|
2013-11-24 16:57:08 +01:00
|
|
|
#ifndef TMP102_H_
|
|
|
|
#define TMP102_H_
|
2011-01-20 11:28:00 +01:00
|
|
|
#include <stdio.h>
|
2016-02-22 10:34:48 +01:00
|
|
|
#include "lib/sensors.h"
|
2011-01-20 11:28:00 +01:00
|
|
|
#include "i2cmaster.h"
|
|
|
|
/* -------------------------------------------------------------------------- */
|
2016-02-22 10:34:48 +01:00
|
|
|
void tmp102_init(void);
|
|
|
|
void tmp102_write_reg(uint8_t reg, uint16_t val);
|
2012-02-20 20:32:05 +01:00
|
|
|
uint16_t tmp102_read_reg(uint8_t reg);
|
|
|
|
uint16_t tmp102_read_temp_raw();
|
2011-01-20 11:28:00 +01:00
|
|
|
int8_t tmp102_read_temp_simple();
|
2012-01-03 19:45:03 +01:00
|
|
|
int16_t tmp102_read_temp_x100();
|
2011-01-20 11:28:00 +01:00
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
#define TMP102_ADDR 0x48
|
2016-02-22 10:34:48 +01:00
|
|
|
#define TMP102_TEMP 0x00
|
2011-01-20 11:28:00 +01:00
|
|
|
#define TMP102_CONF 0x01
|
|
|
|
#define TMP102_TLOW 0x02
|
|
|
|
#define TMP102_THIGH 0x03
|
|
|
|
|
2016-02-22 10:34:48 +01:00
|
|
|
/* TMP102 pin-out */
|
2011-01-20 11:28:00 +01:00
|
|
|
#define TMP102_PWR_DIR P5DIR
|
|
|
|
#define TMP102_PWR_SEL P5SEL
|
|
|
|
#define TMP102_PWR_SEL2 P5SEL2
|
|
|
|
#define TMP102_PWR_REN P5REN
|
|
|
|
#define TMP102_PWR_OUT P5OUT
|
2016-02-22 10:34:48 +01:00
|
|
|
#define TMP102_PWR_PIN (1<<0) /* P5.0 */
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
#define TMP102_SUCCESS 0
|
|
|
|
#define TMP102_ERROR (-1)
|
|
|
|
#define TMP102_READ 0x01
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
#define TMP102_SENSOR "TMP102 sensor"
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
extern const struct sensors_sensor tmp102;
|
2011-01-20 11:28:00 +01:00
|
|
|
/* -------------------------------------------------------------------------- */
|
2013-11-24 16:57:08 +01:00
|
|
|
#endif /* ifndef TMP102_H_ */
|