Contiki-Inga 3.x
light-ziglet.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 light ziglet sensor in Zolertia Z1 WSN Platform.
36  * \author
37  * Antonio Lignan, Zolertia <alinan@zolertia.com>
38  * Marcus Lundén, SICS <mlunden@sics.se>
39  */
40 
41 #ifndef LIGHT_ZIGLET_H_
42 #define LIGHT_ZIGLET_H_
43 #include <stdio.h>
44 #include "i2cmaster.h"
45 
46 /* -------------------------------------------------------------------------- */
47 /* Init the light ziglet sensor: ports, pins, I2C, interrupts (XXX none so far),
48 */
49 void light_ziglet_init(void);
50 
51 /* Write to a register.
52  args:
53  reg register to write to
54  val value to write
55 */
56 void tsl2563_write_reg(uint8_t reg, uint16_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 uint16_t tsl2563_read_reg(uint8_t reg);
64 
65 /* Takes a single light reading
66  args: none
67  returns a lux value
68 */
69 uint16_t light_ziglet_read();
70 
71 /* Calculates the lux values from the calibration table
72  args: raw values from sensor
73  returns a lux value
74 */
75 uint16_t calculateLux(uint16_t *readRaw);
76 
77 /* Turns the light ziglet ON and polls the sensor for a light reading */
78 uint16_t light_ziglet_on(void);
79 
80 /* -------------------------------------------------------------------------- */
81 /* Reference definitions */
82 
83 /* TSL2563 slave address */
84 #define TSL2563_ADDR 0x39
85 
86 /* Registers */
87 #define TSL2563_READ 0xAC
88 #define TSL2563_PWRN 0x03
89 
90 /* Calibration settings */
91 #define K1T 0X0040
92 #define B1T 0x01f2
93 #define M1T 0x01b2
94 
95 #define K2T 0x0080
96 #define B2T 0x0214
97 #define M2T 0x02d1
98 
99 #define K3T 0x00c0
100 #define B3T 0x023f
101 #define M3T 0x037b
102 
103 #define K4T 0x0100
104 #define B4T 0x0270
105 #define M4T 0x03fe
106 
107 #define K5T 0x0138
108 #define B5T 0x016f
109 #define M5T 0x01fc
110 
111 #define K6T 0x019a
112 #define B6T 0x00d2
113 #define M6T 0x00fb
114 
115 #define K7T 0x029a
116 #define B7T 0x0018
117 #define M7T 0x0012
118 
119 #define K8T 0x029a
120 #define B8T 0x0000
121 #define M8T 0x0000
122 
123 /* -------------------------------------------------------------------------- */
124 #endif /* ifndef LIGHT_ZIGLET_H_ */
125 
126 
127