Contiki 2.6
|
00001 /* 00002 * Copyright (c) 2010, Swedish Institute of Computer Science. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 3. Neither the name of the Institute nor the names of its contributors 00014 * may be used to endorse or promote products derived from this software 00015 * without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 00018 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 00021 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00023 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00024 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00025 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00026 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00027 * SUCH DAMAGE. 00028 * 00029 * This file is part of the Contiki operating system. 00030 * 00031 */ 00032 00033 /** 00034 * \file 00035 * Device drivers header file for light ziglet sensor in Zolertia Z1 WSN Platform. 00036 * \author 00037 * Antonio Lignan, Zolertia <alinan@zolertia.com> 00038 * Marcus Lundén, SICS <mlunden@sics.se> 00039 */ 00040 00041 #ifndef __LIGHT_ZIGLET_H__ 00042 #define __LIGHT_ZIGLET_H__ 00043 #include <stdio.h> 00044 #include "i2cmaster.h" 00045 00046 /* -------------------------------------------------------------------------- */ 00047 /* Init the light ziglet sensor: ports, pins, I2C, interrupts (XXX none so far), 00048 */ 00049 void light_ziglet_init(void); 00050 00051 /* Write to a register. 00052 args: 00053 reg register to write to 00054 val value to write 00055 */ 00056 void tsl2563_write_reg(uint8_t reg, uint16_t val); 00057 00058 /* Read one register. 00059 args: 00060 reg what register to read 00061 returns the value of the read register 00062 */ 00063 uint16_t tsl2563_read_reg(uint8_t reg); 00064 00065 /* Takes a single light reading 00066 args: none 00067 returns a lux value 00068 */ 00069 uint16_t light_ziglet_read(); 00070 00071 /* Calculates the lux values from the calibration table 00072 args: raw values from sensor 00073 returns a lux value 00074 */ 00075 uint16_t calculateLux(uint16_t *readRaw); 00076 00077 /* Turns the light ziglet ON and polls the sensor for a light reading */ 00078 uint16_t light_ziglet_on(void); 00079 00080 /* -------------------------------------------------------------------------- */ 00081 /* Reference definitions */ 00082 00083 /* TSL2563 slave address */ 00084 #define TSL2563_ADDR 0x39 00085 00086 /* Registers */ 00087 #define TSL2563_READ 0xAC 00088 #define TSL2563_PWRN 0x03 00089 00090 /* Calibration settings */ 00091 #define K1T 0X0040 00092 #define B1T 0x01f2 00093 #define M1T 0x01b2 00094 00095 #define K2T 0x0080 00096 #define B2T 0x0214 00097 #define M2T 0x02d1 00098 00099 #define K3T 0x00c0 00100 #define B3T 0x023f 00101 #define M3T 0x037b 00102 00103 #define K4T 0x0100 00104 #define B4T 0x0270 00105 #define M4T 0x03fe 00106 00107 #define K5T 0x0138 00108 #define B5T 0x016f 00109 #define M5T 0x01fc 00110 00111 #define K6T 0x019a 00112 #define B6T 0x00d2 00113 #define M6T 0x00fb 00114 00115 #define K7T 0x029a 00116 #define B7T 0x0018 00117 #define M7T 0x0012 00118 00119 #define K8T 0x029a 00120 #define B8T 0x0000 00121 #define M8T 0x0000 00122 00123 /* -------------------------------------------------------------------------- */ 00124 #endif /* ifndef __LIGHT_ZIGLET_H__ */ 00125 00126 00127