Contiki 2.5
tmp102.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  *
31  */
32 
33 /**
34  * \file
35  * Device drivers header file for tmp102 temperature sensor in Zolertia Z1 WSN Platform.
36  * \author
37  * Enric M. Calvo, Zolertia <ecalvo@zolertia.com>
38  * Marcus Lundén, SICS <mlunden@sics.se>
39  */
40 
41 #ifndef __TMP102_H__
42 #define __TMP102_H__
43 #include <stdio.h>
44 #include "i2cmaster.h"
45 
46 /* -------------------------------------------------------------------------- */
47 /* Init the temperature sensor: ports, pins, I2C, interrupts (XXX none so far),
48 */
49 void tmp102_init(void);
50 
51 /* Write to a register.
52  args:
53  reg register to write to
54  val value to write
55 */
56 void tmp102_write_reg(u8_t reg, u16_t val);
57 
58 /* Read one register.
59  args:
60  reg what register to read
61  returns the value of the read register
62 */
63 u16_t tmp102_read_reg(u8_t reg);
64 
65 /* Read temperature in raw format
66  no args needed
67 */
68 u16_t tmp102_read_temp_raw();
69 
70 /* Read only integer part of the temperature in 1deg. precision.
71  no args needed
72 */
73 int8_t tmp102_read_temp_simple();
74 
75 /* -------------------------------------------------------------------------- */
76 /* Reference definitions */
77 /* TMP102 slave address */
78 #define TMP102_ADDR 0x48
79 
80 /* TMP102 registers */
81 #define TMP102_TEMP 0x00 // read only
82 #define TMP102_CONF 0x01
83 #define TMP102_TLOW 0x02
84 #define TMP102_THIGH 0x03
85 
86 /* TMP102 Ports */
87 /* Accelerometer hardware ports, pins and registers on the msp430 µC */
88 #define TMP102_PWR_DIR P5DIR
89 #define TMP102_PWR_SEL P5SEL
90 #define TMP102_PWR_SEL2 P5SEL2
91 #define TMP102_PWR_REN P5REN
92 #define TMP102_PWR_OUT P5OUT
93 #define TMP102_PWR_PIN (1<<0) // P5.0
94 //#define TMP102_INT_PIN (1<<7) // P1.7
95 
96 
97 /* -------------------------------------------------------------------------- */
98 #endif /* ifndef __TMP102_H__ */
99 
100 
101