Cleaned up some files, moved z1-websense example

This commit is contained in:
Enric M. Calvo 2011-03-16 17:41:03 +01:00
parent 07f59a5142
commit 425edf3a44
25 changed files with 204 additions and 408 deletions

View File

@ -1,91 +0,0 @@
/*
* Copyright (c) 2007, Swedish Institute of Computer Science.
* 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.
*
* $Id: example-broadcast.c,v 1.3 2010/11/06 15:03:48 adamdunkels Exp $
*/
/**
* \file
* Testing the broadcast layer in Rime
* \author
* Adam Dunkels <adam@sics.se>
*/
#include "contiki.h"
#include "net/rime.h"
#include "random.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
PROCESS(example_broadcast_process, "Broadcast example");
AUTOSTART_PROCESSES(&example_broadcast_process);
/*---------------------------------------------------------------------------*/
static void
broadcast_recv(struct broadcast_conn *c, const rimeaddr_t *from)
{
printf("broadcast message received from %d.%d: '%s'\n",
from->u8[0], from->u8[1], (char *)packetbuf_dataptr());
}
static const struct broadcast_callbacks broadcast_call = {broadcast_recv};
static struct broadcast_conn broadcast;
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(example_broadcast_process, ev, data)
{
static struct etimer et;
PROCESS_EXITHANDLER(broadcast_close(&broadcast);)
PROCESS_BEGIN();
SENSORS_ACTIVATE(button_sensor);
broadcast_open(&broadcast, 129, &broadcast_call);
while(1) {
/* Delay 2-4 seconds */
//etimer_set(&et, CLOCK_SECOND * 4 + random_rand() % (CLOCK_SECOND * 4));
etimer_set(&et, CLOCK_SECOND);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et) || (ev == sensors_event &&
data == &button_sensor));
packetbuf_copyfrom("Hello", 6);
broadcast_send(&broadcast);
printf("broadcast message sent\n");
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,94 +0,0 @@
/*
* Copyright (c) 2007, Swedish Institute of Computer Science.
* 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.
*
* $Id: example-unicast.c,v 1.5 2010/02/02 16:36:46 adamdunkels Exp $
*/
/**
* \file
* Best-effort single-hop unicast example
* \author
* Adam Dunkels <adam@sics.se>
*/
#include "contiki.h"
#include "net/rime.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
PROCESS(example_unicast_process, "Example unicast");
AUTOSTART_PROCESSES(&example_unicast_process);
/*---------------------------------------------------------------------------*/
static void
recv_uc(struct unicast_conn *c, const rimeaddr_t *from)
{
printf("unicast message received from %d.%d\n",
from->u8[0], from->u8[1]);
leds_toggle(LEDS_GREEN);
}
static const struct unicast_callbacks unicast_callbacks = {recv_uc};
static struct unicast_conn uc;
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(example_unicast_process, ev, data)
{
PROCESS_EXITHANDLER(unicast_close(&uc);)
PROCESS_BEGIN();
cc2420_set_txpower(5);
unicast_open(&uc, 222, &unicast_callbacks);
while(1) {
static struct etimer et;
rimeaddr_t addr;
etimer_set(&et, CLOCK_SECOND);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
packetbuf_copyfrom("Enric1", 6);
addr.u8[0] = 151;
addr.u8[1] = 0;
if(!rimeaddr_cmp(&addr, &rimeaddr_node_addr)) {
unicast_send(&uc, &addr);
leds_toggle(LEDS_RED);
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,96 +0,0 @@
/*
* Copyright (c) 2007, Swedish Institute of Computer Science.
* 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.
*
* $Id: example-unicast.c,v 1.5 2010/02/02 16:36:46 adamdunkels Exp $
*/
/**
* \file
* Best-effort single-hop unicast example
* \author
* Adam Dunkels <adam@sics.se>
*/
#include "contiki.h"
#include "net/rime.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
PROCESS(example_unicast_process, "Example unicast");
AUTOSTART_PROCESSES(&example_unicast_process);
/*---------------------------------------------------------------------------*/
static void
recv_uc(struct unicast_conn *c, const rimeaddr_t *from)
{
char mypkt[16];
printf("unicast message received from %d.%d\n",
from->u8[0], from->u8[1]);
memcpy(mypkt, packetbuf_dataptr(),sizeof(mypkt));
printf("Data = %s\n", mypkt);
leds_toggle(LEDS_GREEN);
}
static const struct unicast_callbacks unicast_callbacks = {recv_uc};
static struct unicast_conn uc;
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(example_unicast_process, ev, data)
{
PROCESS_EXITHANDLER(unicast_close(&uc);)
PROCESS_BEGIN();
cc2420_set_txpower(5);
unicast_open(&uc, 222, &unicast_callbacks);
while(1) {
static struct etimer et;
rimeaddr_t addr;
etimer_set(&et, CLOCK_SECOND);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
packetbuf_copyfrom("Enric2", 6);
addr.u8[0] = 225;
addr.u8[1] = 1;
if(!rimeaddr_cmp(&addr, &rimeaddr_node_addr)) {
unicast_send(&uc, &addr);
leds_toggle(LEDS_RED);
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,2 +0,0 @@
+ clean-up test-battery.c
+ sht11 drier compat. with i2c

View File

@ -1,6 +1,6 @@
all: sky-websense
all: z1-websense
CONTIKI=../../..
CONTIKI=../../../..
WITH_UIP6=1
UIP_CONF_IPV6=1
@ -9,7 +9,7 @@ APPS += webserver webbrowser
CFLAGS += -DPROJECT_CONF_H=1
CONTIKI_SOURCEFILES += wget.c
PROJECTDIRS += ../rpl-border-router
PROJECTDIRS += ../../../ipv6/rpl-border-router
PROJECT_SOURCEFILES += httpd-simple.c
include $(CONTIKI)/Makefile.include

View File

@ -1,6 +1,6 @@
This example features a simple webserver running on top of the IPv6
contiki stack on Sky motes to provide sensor values, and with a RPL
border router to bridge the sensor network to Internet.
contiki stack on Zolertia Z1 motes to provide sensor values, and with
a RPL border router to bridge the sensor network to Internet.
To test the example in COOJA under Linux

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, Swedish Institute of Computer Science.
* Copyright (c) 2011, Zolertia(TM) is a trademark by Advancare,SL
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -26,16 +26,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sky-websense.c,v 1.3 2010/06/08 13:27:06 nifi Exp $
*/
/**
* \file
* Light and temperatur sensor web demo
* Battery and Temperature IPv6 Demo for Zolertia Z1
* \author
* Niclas Finne <nfi@sics.se>
* Joakim Eriksson <joakime@sics.se>
* Joel Hoglund <joel@sics.se>
* Enric M. Calvo <ecalvo@zolertia.com>
*/
#include "contiki.h"

0
examples/z1/rssi_scanner/Makefile Executable file → Normal file
View File

0
examples/z1/rssi_scanner/ViewRSSI.java Executable file → Normal file
View File

0
examples/z1/rssi_scanner/project-conf.h Executable file → Normal file
View File

0
examples/z1/rssi_scanner/rssi-scanner.c Executable file → Normal file
View File

View File

@ -1,32 +1,79 @@
/*
* Copyright (c) 2011, Zolertia(TM) is a trademark of Advancare,SL
* 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
* Testing the internal MSP430 battery sensor on the Zolertia Z1 Platform.
* \author
* Enric M. Calvo <ecalvo@zolertia.com>
*/
#include "contiki.h"
#include "dev/battery-sensor.h"
#include <stdio.h> /* For printf() */
#include <stdio.h> /* For printf() */
float
floor(float x)
{
if(x >= 0.0f) {
return (float) ((int) x);
} else {
return (float) ((int) x - 1);
}
}
/*---------------------------------------------------------------------------*/
PROCESS(aplicacio, "Aplicacio de prova");
AUTOSTART_PROCESSES(&aplicacio);
PROCESS(test_battery_process, "Battery Sensor Test");
AUTOSTART_PROCESSES(&test_battery_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(aplicacio, ev, data)
PROCESS_THREAD(test_battery_process, ev, data)
{
PROCESS_BEGIN();
SENSORS_ACTIVATE(battery_sensor);
while (1)
{
while(1) {
uint16_t bateria = battery_sensor.value(0);
printf("Battery: %i\n", bateria);
float mv = (bateria * 2.500 * 2) / 4096;
printf("Battery: %i (%ld.%03d mV)\n", bateria, (long) mv,
(unsigned) ((mv - floor(mv)) * 1000));
}
SENSORS_DEACTIVATE(battery_sensor);
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

View File

@ -1,35 +0,0 @@
#include "contiki.h"
#include "dev/battery-sensor.h"
#include <stdio.h> /* For printf() */
float floor(float x){
if(x>=0.0f){ return (float) ((int)x);}
else {return(float)((int)x-1);}
}
/*---------------------------------------------------------------------------*/
PROCESS(aplicacio, "Aplicacio de prova");
AUTOSTART_PROCESSES(&aplicacio);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(aplicacio, ev, data)
{
PROCESS_BEGIN();
SENSORS_ACTIVATE(battery_sensor);
while (1)
{
uint16_t bateria = battery_sensor.value(0);
float mv = (bateria*2.500*2)/4096;
printf("Battery: %i (%ld.%03d mV)\n", bateria, (long) mv, (unsigned) ((mv-floor(mv))*1000));
}
SENSORS_DEACTIVATE(battery_sensor);
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,33 +1,68 @@
/*
* Copyright (c) 2011, Zolertia(TM) is a trademark of Advancare,SL
* 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
* Testing the Potentiometer in Zolertia Z1 Starter Platform.
* \author
* Enric M. Calvo <ecalvo@zolertia.com>
*/
#include "contiki.h"
#include "dev/potentiometer-sensor.h"
#include <stdio.h> /* For printf() */
#include <stdio.h>
/*---------------------------------------------------------------------------*/
PROCESS(aplicacio, "Testing Potentiometer");
AUTOSTART_PROCESSES(&aplicacio);
PROCESS(test_potent_process, "Testing Potentiometer in Z1SP");
AUTOSTART_PROCESSES(&test_potent_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(aplicacio, ev, data)
PROCESS_THREAD(test_potent_process, ev, data)
{
PROCESS_BEGIN();
// INSERT LINE HERE TO ENABLE POTENTIOMETER
while (1)
{
uint16_t value
//INSERT LINE HERE TO READ POTENTIOMETER VALUE
SENSORS_ACTIVATE(potentiometer_sensor);
while(1) {
uint16_t value = potentiometer_sensor.value(0);
printf("Potentiometer Value: %i\n", v);
}
SENSORS_DEACTIVATE(potentiometer_sensor);
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Swedish Institute of Computer Science.
* Copyright (c) 2011, Zolertia(TM) is a trademark of Advancare,SL
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -32,9 +32,9 @@
/**
* \file
* A quick program for testing the tmp102 driver
* A quick program for testing the tmp102 driver in the Z1 platform
* \author
* Enric Calvo <ecalvo@zolertia.com>
* Enric M. Calvo <ecalvo@zolertia.com>
*/
#include <stdio.h>
@ -59,45 +59,41 @@
#define TMP102_READ_INTERVAL (CLOCK_SECOND/2)
PROCESS (temp_process, "Test Temperature process");
AUTOSTART_PROCESSES (&temp_process);
PROCESS(temp_process, "Test Temperature process");
AUTOSTART_PROCESSES(&temp_process);
/*---------------------------------------------------------------------------*/
static struct etimer et;
PROCESS_THREAD (temp_process, ev, data)
PROCESS_THREAD(temp_process, ev, data)
{
PROCESS_BEGIN ();
PROCESS_BEGIN();
{
int16_t tempint;
uint16_t tempfrac;
int16_t raw;
uint16_t absraw;
int16_t sign;
char minus = ' ';
int16_t tempint;
uint16_t tempfrac;
int16_t raw;
uint16_t absraw;
int16_t sign;
char minus = ' ';
tmp102_init();
tmp102_init();
while (1)
{
etimer_set(&et, TMP102_READ_INTERVAL);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
while(1) {
etimer_set(&et, TMP102_READ_INTERVAL);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
sign = 1;
sign = 1;
PRINTFDEBUG ("Reading Temp...\n");
raw = tmp102_read_temp_raw();
absraw = raw;
if (raw < 0) { // Perform 2C's if sensor returned negative data
absraw = (raw ^ 0xFFFF) + 1;
sign = -1;
}
tempint = (absraw >> 8) * sign;
tempfrac = ((absraw>>4) % 16) * 625; // Info in 1/10000 of degree
minus = ((tempint == 0) & (sign == -1)) ? '-' : ' ' ;
PRINTF ("Temp = %c%d.%04d\n", minus, tempint, tempfrac);
}
PRINTFDEBUG("Reading Temp...\n");
raw = tmp102_read_temp_raw();
absraw = raw;
if(raw < 0) { // Perform 2C's if sensor returned negative data
absraw = (raw ^ 0xFFFF) + 1;
sign = -1;
}
tempint = (absraw >> 8) * sign;
tempfrac = ((absraw >> 4) % 16) * 625; // Info in 1/10000 of degree
minus = ((tempint == 0) & (sign == -1)) ? '-' : ' ';
PRINTF("Temp = %c%d.%04d\n", minus, tempint, tempfrac);
}
PROCESS_END ();
PROCESS_END();
}

View File

@ -1,32 +1,68 @@
/*
* Copyright (c) 2011, Zolertia(TM) is a trademark of Advancare,SL
* 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
* Testing the Potentiometer in Zolertia Z1 Starter Platform.
* \author
* Enric M. Calvo <ecalvo@zolertia.com>
*/
#include "contiki.h"
#include "dev/potentiometer-sensor.h"
#include <stdio.h> /* For printf() */
#include <stdio.h>
/*---------------------------------------------------------------------------*/
PROCESS(aplicacio, "Aplicacio de prova");
AUTOSTART_PROCESSES(&aplicacio);
PROCESS(test_potent_process, "Testing Potentiometer in Z1SP");
AUTOSTART_PROCESSES(&test_potent_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(aplicacio, ev, data)
PROCESS_THREAD(test_potent_process, ev, data)
{
PROCESS_BEGIN();
SENSORS_ACTIVATE(potentiometer_sensor);
while (1)
{
uint16_t v = potentiometer_sensor.value(0);
while(1) {
uint16_t value = potentiometer_sensor.value(0);
printf("Potentiometer Value: %i\n", v);
}
SENSORS_DEACTIVATE(potentiometer_sensor);
PROCESS_END();
}
/*---------------------------------------------------------------------------*/