Zolertia Re-Mote platform ported to Contiki, developed whitin RERUM FP7 European project (grant #609094).
The port was done jointly by Zolertia and George Oikonomou (University of Bristol).
This commit is contained in:
parent
2cee62eb33
commit
330e450ba4
33 changed files with 4002 additions and 0 deletions
9
examples/remote/Makefile
Normal file
9
examples/remote/Makefile
Normal file
|
@ -0,0 +1,9 @@
|
|||
DEFINES+=PROJECT_CONF_H=\"project-conf.h\"
|
||||
CONTIKI_PROJECT = remote-demo test-tsl2563 test-sht25
|
||||
CONTIKI_TARGET_SOURCEFILES += tsl2563.c sht25.c
|
||||
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
CONTIKI = ../..
|
||||
CONTIKI_WITH_RIME = 1
|
||||
include $(CONTIKI)/Makefile.include
|
1
examples/remote/Makefile.target
Normal file
1
examples/remote/Makefile.target
Normal file
|
@ -0,0 +1 @@
|
|||
TARGET = remote
|
38
examples/remote/node-red/README.md
Normal file
38
examples/remote/node-red/README.md
Normal file
|
@ -0,0 +1,38 @@
|
|||
Re-Mote + Node Red README
|
||||
========================
|
||||
|
||||
A very basic example of how to use MQTT-Demo + Mosquitto + Node Red
|
||||
|
||||
Install Mosquitto
|
||||
-----------------
|
||||
* Install and run [mosquitto](http://mosquitto.org/). Default configuration
|
||||
options should work.
|
||||
|
||||
Fire up a Re-Mote
|
||||
-----------------
|
||||
* Compile the MQTT demo example from `../../cc2538dk/mqtt-demo.c` following
|
||||
the instructions of the README.md therein.
|
||||
* Program your Re-Mote.
|
||||
* If you are running mosquitto with `-v`, a few seconds later you should see
|
||||
the Re-Mote connect, subscribe and start publishing.
|
||||
|
||||
Deploy your Node Red
|
||||
--------------------
|
||||
* Install and run [Node Red](https://github.com/node-red/node-red) as per the
|
||||
instructions
|
||||
* Open `mqtt-remote-demo.json` from this directory with your favourite text
|
||||
editor, select all and copy.
|
||||
* Once you have the opened the Node Red page, click the menu icon on the top
|
||||
right and go to Import -> Clipboard. Paste the copied text.
|
||||
* Double click the `MQTT input from Re-Mote` box on the top left. Set `Broker`
|
||||
IP and port to those corresponding to your running mosquitto.
|
||||
* Hit Deploy
|
||||
* Optionally, export the flow to a file for future use
|
||||
|
||||
Browse
|
||||
------
|
||||
Fire up a browser and browse to `http://<Node-Red's IP or hostname>/remote`
|
||||
|
||||
Do more cool stuff
|
||||
------------------
|
||||
Come up with more cool flows and share!
|
2
examples/remote/node-red/mqtt-remote-demo.json
Normal file
2
examples/remote/node-red/mqtt-remote-demo.json
Normal file
|
@ -0,0 +1,2 @@
|
|||
[{"id":"d95a1e7f.43a","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":""},{"id":"ddd5cc1c.723e18","type":"mqtt in","name":"MQTT input from Re-Mote","topic":"iot-2/evt/status/fmt/json","broker":"d95a1e7f.43a","x":131.11109924316406,"y":98.88890075683594,"z":"9b2868a4.2cef5","wires":[["12ea094e.3c2447"]]},{"id":"7728d120.25c64","type":"function","name":"Parse and Store Data","func":"var dat = msg.payload.d;\n\nif(dat) {\n var ret = [\n {\n name: \"Name\",\n value: dat.myName,\n unit: \"\",\n },\n {\n name: \"Seq #\",\n value: dat[\"Seq #\"],\n unit: \"\",\n },\n {\n name: \"Uptime\",\n value: dat[\"Uptime (sec)\"],\n unit: \"sec\",\n },\n {\n name: \"On-Chip Temp\",\n value: dat[\"On-Chip Temp (mC)\"],\n unit: \"C\",\n },\n {\n name: \"VDD/3\",\n value: dat[\"VDD3 (mV)\"],\n unit: \"V\",\n },\n {\n name: \"Parent RSSI\",\n value: dat[\"RSSI (dBm)\"],\n unit: \"dBm\",\n },\n ];\n \n context.ret = ret;\n} else {\n if(context.ret) {\n msg.has_data = true;\n msg.payload = context.ret;\n } else {\n msg.payload = \"No Data!\";\n }\n return [msg, msg];\n}\nreturn [msg, null];","outputs":"2","x":545.1110992431641,"y":346.38890075683594,"z":"9b2868a4.2cef5","wires":[["4249c5c.35b5c3c"],["dacab617.9133c8"]]},{"id":"12ea094e.3c2447","type":"json","name":"Convert to JS Object","x":305.61109924316406,"y":263.13890075683594,"z":"9b2868a4.2cef5","wires":[["7728d120.25c64"]]},{"id":"e5e8271c.99c2d","type":"http response","name":"Send HTTP Reponse","x":1252.2220611572266,"y":488.38890075683594,"z":"9b2868a4.2cef5","wires":[]},{"id":"4b2260f8.436808","type":"http in","name":"","url":"/remote","method":"get","x":327.11109924316406,"y":429.88890075683594,"z":"9b2868a4.2cef5","wires":[["8a3f88a9.ec77d8","7728d120.25c64"]]},{"id":"8a3f88a9.ec77d8","type":"debug","name":"","active":false,"console":"false","complete":"req","x":459.61109924316406,"y":522.3889007568359,"z":"9b2868a4.2cef5","wires":[]},{"id":"ac349e33.beb47","type":"template","name":"Render HTML from Data","field":"payload","template":"<html>\n<body>\n<ul>\n {{#payload}}\n <li>{{name}}: {{value}}{{#unit}} {{unit}}{{/unit}}</li>\n {{/payload}}\n</ul>\n</body>\n</html>","x":1046.361099243164,"y":347.13890075683594,"z":"9b2868a4.2cef5","wires":[["e5e8271c.99c2d","530bf522.d773dc"]]},{"id":"4249c5c.35b5c3c","type":"debug","name":"","active":false,"console":"false","complete":"false","x":620.1110992431641,"y":247.88890075683594,"z":"9b2868a4.2cef5","wires":[]},{"id":"dacab617.9133c8","type":"switch","name":"","property":"has_data","rules":[{"t":"true"},{"t":"else"}],"checkall":"false","outputs":2,"x":765.1110992431641,"y":352.88890075683594,"z":"9b2868a4.2cef5","wires":[["124554c4.5b82b3","ac349e33.beb47"],["e5e8271c.99c2d"]]},{"id":"530bf522.d773dc","type":"debug","name":"","active":false,"console":"false","complete":"payload","x":1228.361099243164,"y":217.88890075683594,"z":"9b2868a4.2cef5","wires":[]},{"id":"124554c4.5b82b3","type":"debug","name":"","active":false,"console":"false","complete":"payload","x":898.1110992431641,"y":220.88890075683594,"z":"9b2868a4.2cef5","wires":[]}]
|
||||
|
45
examples/remote/project-conf.h
Normal file
45
examples/remote/project-conf.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup remote-examples
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Project specific configuration defines for the basic Re-Mote examples
|
||||
*/
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
#define NETSTACK_CONF_RDC nullrdc_driver
|
||||
|
||||
#endif /* PROJECT_CONF_H_ */
|
||||
|
||||
/** @} */
|
196
examples/remote/remote-demo.c
Normal file
196
examples/remote/remote-demo.c
Normal file
|
@ -0,0 +1,196 @@
|
|||
/*
|
||||
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
|
||||
* 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 copyright holder 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 COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup remote
|
||||
* @{
|
||||
*
|
||||
* \defgroup remote-examples Re-Mote Example Projects
|
||||
* @{
|
||||
*
|
||||
* \defgroup remote-demo Re-Mote Demo Project
|
||||
*
|
||||
* Example project demonstrating the Re-Mote functionality
|
||||
*
|
||||
* - Boot sequence: LEDs flashing (Red, then yellow, finally green)
|
||||
*
|
||||
* - etimer/clock : Every LOOP_INTERVAL clock ticks (LOOP_PERIOD secs) the LED
|
||||
* defined as LEDS_PERIODIC will turn on
|
||||
* - rtimer : Exactly LEDS_OFF_HYSTERISIS rtimer ticks later,
|
||||
* LEDS_PERIODIC will turn back off
|
||||
* - ADC sensors : On-chip VDD / 3, temperature, and Phidget sensor
|
||||
* values are printed over UART periodically.
|
||||
* - UART : Every LOOP_INTERVAL the Remote will print something over
|
||||
* the UART. Receiving an entire line of text over UART (ending
|
||||
* in \\r) will cause LEDS_SERIAL_IN to toggle
|
||||
* - Radio comms : BTN_USER sends a rime broadcast. Reception of a rime
|
||||
* packet will toggle LEDs defined as LEDS_RF_RX
|
||||
* - Button : Keeping the button pressed will print a counter that
|
||||
* increments every BUTTON_PRESS_EVENT_INTERVAL ticks
|
||||
* - TMP102 : Built-in digital temperature sensor, every LOOP_INTERVAL
|
||||
* clock ticks a sensor reading will be taken
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Example demonstrating the Re-Mote platform
|
||||
*/
|
||||
#include "contiki.h"
|
||||
#include "cpu.h"
|
||||
#include "sys/etimer.h"
|
||||
#include "sys/rtimer.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/uart.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/remote-sensors.h"
|
||||
#include "dev/watchdog.h"
|
||||
#include "dev/serial-line.h"
|
||||
#include "dev/sys-ctrl.h"
|
||||
#include "net/rime/broadcast.h"
|
||||
#include "dev/antenna-sw.h"
|
||||
#include "dev/tmp102.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define LOOP_PERIOD 8
|
||||
#define LOOP_INTERVAL (CLOCK_SECOND * LOOP_PERIOD)
|
||||
#define LEDS_OFF_HYSTERISIS ((RTIMER_SECOND * LOOP_PERIOD) >> 1)
|
||||
#define LEDS_PERIODIC LEDS_BLUE
|
||||
#define LEDS_BUTTON LEDS_RED
|
||||
#define LEDS_SERIAL_IN LEDS_GREEN
|
||||
#define LEDS_REBOOT LEDS_ALL
|
||||
#define LEDS_RF_RX (LEDS_YELLOW | LEDS_RED)
|
||||
#define BROADCAST_CHANNEL 129
|
||||
|
||||
#define BUTTON_PRESS_EVENT_INTERVAL (CLOCK_SECOND)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static struct etimer et;
|
||||
static struct rtimer rt;
|
||||
static uint16_t counter, temperature;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(cc2538_demo_process, "cc2538 demo process");
|
||||
AUTOSTART_PROCESSES(&cc2538_demo_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
broadcast_recv(struct broadcast_conn *c, const linkaddr_t *from)
|
||||
{
|
||||
leds_toggle(LEDS_RF_RX);
|
||||
printf("*** Received %u bytes from %u:%u: '0x%04x'\n", packetbuf_datalen(),
|
||||
from->u8[0], from->u8[1], *(uint16_t *)packetbuf_dataptr());
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static const struct broadcast_callbacks bc_rx = { broadcast_recv };
|
||||
static struct broadcast_conn bc;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rt_callback(struct rtimer *t, void *ptr)
|
||||
{
|
||||
leds_off(LEDS_PERIODIC);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(cc2538_demo_process, ev, data)
|
||||
{
|
||||
PROCESS_EXITHANDLER(broadcast_close(&bc))
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
counter = 0;
|
||||
broadcast_open(&bc, BROADCAST_CHANNEL, &bc_rx);
|
||||
|
||||
/* Enable antenna */
|
||||
antenna_sw_select(ANTENNA_SW_SELECT_INTERNAL);
|
||||
|
||||
button_sensor.configure(BUTTON_SENSOR_CONFIG_TYPE_INTERVAL,
|
||||
BUTTON_PRESS_EVENT_INTERVAL);
|
||||
|
||||
tmp102_init();
|
||||
|
||||
printf("Re-Mote test application, initial values:\n");
|
||||
|
||||
etimer_set(&et, LOOP_INTERVAL);
|
||||
|
||||
while(1) {
|
||||
|
||||
PROCESS_YIELD();
|
||||
|
||||
if(ev == PROCESS_EVENT_TIMER) {
|
||||
leds_on(LEDS_PERIODIC);
|
||||
|
||||
printf("-----------------------------------------\n"
|
||||
"Counter = 0x%08x\n", counter);
|
||||
|
||||
printf("VDD = %d mV\n",
|
||||
vdd3_sensor.value(CC2538_SENSORS_VALUE_TYPE_CONVERTED));
|
||||
|
||||
printf("Temperature = %d mC\n",
|
||||
cc2538_temp_sensor.value(CC2538_SENSORS_VALUE_TYPE_CONVERTED));
|
||||
|
||||
printf("Phidget ADC2 = %d raw\n",
|
||||
phidget_sensor.value(PHIDGET_SENSORS_ADC2));
|
||||
|
||||
printf("Phidget ADC3 = %d raw\n",
|
||||
phidget_sensor.value(PHIDGET_SENSORS_ADC3));
|
||||
|
||||
tmp102_read(&temperature);
|
||||
printf("TMP102 sensor = %u mC\n", temperature);
|
||||
|
||||
etimer_set(&et, LOOP_INTERVAL);
|
||||
rtimer_set(&rt, RTIMER_NOW() + LEDS_OFF_HYSTERISIS, 1,
|
||||
rt_callback, NULL);
|
||||
counter++;
|
||||
} else if(ev == sensors_event) {
|
||||
if(data == &button_sensor) {
|
||||
if(button_sensor.value(BUTTON_SENSOR_VALUE_TYPE_LEVEL) ==
|
||||
BUTTON_SENSOR_PRESSED_LEVEL) {
|
||||
printf("Press\n");
|
||||
packetbuf_copyfrom(&counter, sizeof(counter));
|
||||
broadcast_send(&bc);
|
||||
} else {
|
||||
printf("Release\n");
|
||||
}
|
||||
}
|
||||
} else if(ev == serial_line_event_message) {
|
||||
leds_toggle(LEDS_SERIAL_IN);
|
||||
} else if(ev == button_press_duration_exceeded) {
|
||||
printf("Button pressed for %d ticks [%u events]\n",
|
||||
(*((uint8_t *)data) * BUTTON_PRESS_EVENT_INTERVAL),
|
||||
button_sensor.value(BUTTON_SENSOR_VALUE_TYPE_PRESS_DURATION));
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
63
examples/remote/test-sht25.c
Normal file
63
examples/remote/test-sht25.c
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright (c) 2015, Zolertia <http://www.zolertia.com>
|
||||
* 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
|
||||
* A quick program for testing the SHT25 temperature and humidity sensor
|
||||
* \author
|
||||
* Antonio Lignan <alinan@zolertia.com>
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "contiki.h"
|
||||
#include "dev/sht25.h"
|
||||
|
||||
PROCESS(test_sht25_process, "SHT25 test");
|
||||
AUTOSTART_PROCESSES(&test_sht25_process);
|
||||
|
||||
static struct etimer et;
|
||||
|
||||
PROCESS_THREAD(test_sht25_process, ev, data)
|
||||
{
|
||||
int16_t temperature, humidity;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
SENSORS_ACTIVATE(sht25);
|
||||
|
||||
while(1) {
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||
temperature = sht25.value(SHT25_VAL_TEMP);
|
||||
printf("Temperature %d.%d ºC\n", temperature / 100, temperature % 100);
|
||||
humidity = sht25.value(SHT25_VAL_HUM);
|
||||
printf("Humidity %d.%d RH\n", humidity / 100, humidity % 100);
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
85
examples/remote/test-tsl2563.c
Normal file
85
examples/remote/test-tsl2563.c
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright (c) 2015, Zolertia - http://www.zolertia.com
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup remote-examples
|
||||
* @{
|
||||
*
|
||||
* \defgroup remote-tsl2563-test Re-Mote TSL2563 light sensor test
|
||||
*
|
||||
* Demonstrates the use of the TSL2563 digital ambient light sensor
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Driver for the Re-Mote external TSL2563 light sensor (Ziglet)
|
||||
*
|
||||
* \author
|
||||
* Antonio Lignan <alinan@zolertia.com>
|
||||
* Toni Lozano <tlozano@zolertia.com>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "contiki.h"
|
||||
#include "dev/i2c.h"
|
||||
#include "dev/tsl2563.h"
|
||||
|
||||
#if 1
|
||||
#define PRINTF(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
|
||||
#define SENSOR_READ_INTERVAL (CLOCK_SECOND / 2)
|
||||
|
||||
PROCESS(test_process, "Test TSL2563 light ziglet process");
|
||||
AUTOSTART_PROCESSES(&test_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static struct etimer et;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(test_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
int light;
|
||||
SENSORS_ACTIVATE(tsl2563);
|
||||
|
||||
while(1) {
|
||||
etimer_set(&et, SENSOR_READ_INTERVAL);
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||
light = tsl2563.value(TSL2563_VAL_READ);
|
||||
PRINTF("Light = %u\n", light);
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue