From 425edf3a441b21a64ea9fc2db6ee2fd3de42d762 Mon Sep 17 00:00:00 2001 From: "Enric M. Calvo" Date: Wed, 16 Mar 2011 17:41:03 +0100 Subject: [PATCH] Cleaned up some files, moved z1-websense example --- examples/rime/example-broadcast-button.c | 91 ------------------ examples/rime/example-unicast2.c | 94 ------------------ examples/rime/example-unicast3.c | 96 ------------------- examples/z1/TODO | 2 - examples/{ => z1}/ipv6/z1-websense/Makefile | 6 +- .../{ => z1}/ipv6/z1-websense/Makefile.target | 0 examples/{ => z1}/ipv6/z1-websense/README | 4 +- .../z1-websense/example-sky-websense.csc} | 0 .../{ => z1}/ipv6/z1-websense/project-conf.h | 0 .../ipv6/z1-websense/websense-remote.c | 0 examples/{ => z1}/ipv6/z1-websense/wget.c | 0 examples/{ => z1}/ipv6/z1-websense/wget.h | 0 .../{ => z1}/ipv6/z1-websense/z1-websense.c | 6 +- examples/z1/rssi_scanner/Makefile | 0 examples/z1/rssi_scanner/ViewRSSI.java | 0 examples/z1/rssi_scanner/project-conf.h | 0 examples/z1/rssi_scanner/rssi-scanner.c | 0 examples/z1/test-battery.c | 79 +++++++++++---- examples/z1/test-battery_mv.c | 35 ------- examples/z1/test-potent.c | 69 +++++++++---- examples/z1/test-tmp102.c | 64 ++++++------- examples/z1/{example2 => tutorials}/Makefile | 0 .../example-unicast-temp.c | 0 .../example-unicast2.c | 0 examples/z1sp/test-potentiometer.c | 66 ++++++++++--- 25 files changed, 204 insertions(+), 408 deletions(-) delete mode 100644 examples/rime/example-broadcast-button.c delete mode 100644 examples/rime/example-unicast2.c delete mode 100644 examples/rime/example-unicast3.c delete mode 100644 examples/z1/TODO rename examples/{ => z1}/ipv6/z1-websense/Makefile (89%) rename examples/{ => z1}/ipv6/z1-websense/Makefile.target (100%) rename examples/{ => z1}/ipv6/z1-websense/README (89%) rename examples/{ipv6/z1-websense/example-z1-websense.csc => z1/ipv6/z1-websense/example-sky-websense.csc} (100%) rename examples/{ => z1}/ipv6/z1-websense/project-conf.h (100%) rename examples/{ => z1}/ipv6/z1-websense/websense-remote.c (100%) rename examples/{ => z1}/ipv6/z1-websense/wget.c (100%) rename examples/{ => z1}/ipv6/z1-websense/wget.h (100%) rename examples/{ => z1}/ipv6/z1-websense/z1-websense.c (97%) mode change 100755 => 100644 examples/z1/rssi_scanner/Makefile mode change 100755 => 100644 examples/z1/rssi_scanner/ViewRSSI.java mode change 100755 => 100644 examples/z1/rssi_scanner/project-conf.h mode change 100755 => 100644 examples/z1/rssi_scanner/rssi-scanner.c delete mode 100755 examples/z1/test-battery_mv.c rename examples/z1/{example2 => tutorials}/Makefile (100%) rename examples/z1/{example2 => tutorials}/example-unicast-temp.c (100%) rename examples/z1/{example2 => tutorials}/example-unicast2.c (100%) diff --git a/examples/rime/example-broadcast-button.c b/examples/rime/example-broadcast-button.c deleted file mode 100644 index 47224ad33..000000000 --- a/examples/rime/example-broadcast-button.c +++ /dev/null @@ -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 - */ - -#include "contiki.h" -#include "net/rime.h" -#include "random.h" - -#include "dev/button-sensor.h" - -#include "dev/leds.h" - -#include -/*---------------------------------------------------------------------------*/ -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(); -} -/*---------------------------------------------------------------------------*/ - diff --git a/examples/rime/example-unicast2.c b/examples/rime/example-unicast2.c deleted file mode 100644 index efdc422a7..000000000 --- a/examples/rime/example-unicast2.c +++ /dev/null @@ -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 - */ - -#include "contiki.h" -#include "net/rime.h" - -#include "dev/button-sensor.h" - -#include "dev/leds.h" - -#include - -/*---------------------------------------------------------------------------*/ -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(); -} -/*---------------------------------------------------------------------------*/ diff --git a/examples/rime/example-unicast3.c b/examples/rime/example-unicast3.c deleted file mode 100644 index 5d8c3c9f2..000000000 --- a/examples/rime/example-unicast3.c +++ /dev/null @@ -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 - */ - -#include "contiki.h" -#include "net/rime.h" - -#include "dev/button-sensor.h" - -#include "dev/leds.h" - -#include - -/*---------------------------------------------------------------------------*/ -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(); -} -/*---------------------------------------------------------------------------*/ diff --git a/examples/z1/TODO b/examples/z1/TODO deleted file mode 100644 index ef6a47d57..000000000 --- a/examples/z1/TODO +++ /dev/null @@ -1,2 +0,0 @@ -+ clean-up test-battery.c -+ sht11 drier compat. with i2c diff --git a/examples/ipv6/z1-websense/Makefile b/examples/z1/ipv6/z1-websense/Makefile similarity index 89% rename from examples/ipv6/z1-websense/Makefile rename to examples/z1/ipv6/z1-websense/Makefile index 4809f8dfd..a786595f4 100644 --- a/examples/ipv6/z1-websense/Makefile +++ b/examples/z1/ipv6/z1-websense/Makefile @@ -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 diff --git a/examples/ipv6/z1-websense/Makefile.target b/examples/z1/ipv6/z1-websense/Makefile.target similarity index 100% rename from examples/ipv6/z1-websense/Makefile.target rename to examples/z1/ipv6/z1-websense/Makefile.target diff --git a/examples/ipv6/z1-websense/README b/examples/z1/ipv6/z1-websense/README similarity index 89% rename from examples/ipv6/z1-websense/README rename to examples/z1/ipv6/z1-websense/README index c42235683..0acd2f4fa 100644 --- a/examples/ipv6/z1-websense/README +++ b/examples/z1/ipv6/z1-websense/README @@ -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 diff --git a/examples/ipv6/z1-websense/example-z1-websense.csc b/examples/z1/ipv6/z1-websense/example-sky-websense.csc similarity index 100% rename from examples/ipv6/z1-websense/example-z1-websense.csc rename to examples/z1/ipv6/z1-websense/example-sky-websense.csc diff --git a/examples/ipv6/z1-websense/project-conf.h b/examples/z1/ipv6/z1-websense/project-conf.h similarity index 100% rename from examples/ipv6/z1-websense/project-conf.h rename to examples/z1/ipv6/z1-websense/project-conf.h diff --git a/examples/ipv6/z1-websense/websense-remote.c b/examples/z1/ipv6/z1-websense/websense-remote.c similarity index 100% rename from examples/ipv6/z1-websense/websense-remote.c rename to examples/z1/ipv6/z1-websense/websense-remote.c diff --git a/examples/ipv6/z1-websense/wget.c b/examples/z1/ipv6/z1-websense/wget.c similarity index 100% rename from examples/ipv6/z1-websense/wget.c rename to examples/z1/ipv6/z1-websense/wget.c diff --git a/examples/ipv6/z1-websense/wget.h b/examples/z1/ipv6/z1-websense/wget.h similarity index 100% rename from examples/ipv6/z1-websense/wget.h rename to examples/z1/ipv6/z1-websense/wget.h diff --git a/examples/ipv6/z1-websense/z1-websense.c b/examples/z1/ipv6/z1-websense/z1-websense.c similarity index 97% rename from examples/ipv6/z1-websense/z1-websense.c rename to examples/z1/ipv6/z1-websense/z1-websense.c index 36c36b04c..0de72e69f 100644 --- a/examples/ipv6/z1-websense/z1-websense.c +++ b/examples/z1/ipv6/z1-websense/z1-websense.c @@ -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 * Joakim Eriksson * Joel Hoglund + * Enric M. Calvo */ #include "contiki.h" diff --git a/examples/z1/rssi_scanner/Makefile b/examples/z1/rssi_scanner/Makefile old mode 100755 new mode 100644 diff --git a/examples/z1/rssi_scanner/ViewRSSI.java b/examples/z1/rssi_scanner/ViewRSSI.java old mode 100755 new mode 100644 diff --git a/examples/z1/rssi_scanner/project-conf.h b/examples/z1/rssi_scanner/project-conf.h old mode 100755 new mode 100644 diff --git a/examples/z1/rssi_scanner/rssi-scanner.c b/examples/z1/rssi_scanner/rssi-scanner.c old mode 100755 new mode 100644 diff --git a/examples/z1/test-battery.c b/examples/z1/test-battery.c index f1d407af9..fb39e91d3 100644 --- a/examples/z1/test-battery.c +++ b/examples/z1/test-battery.c @@ -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 + */ + + #include "contiki.h" - #include "dev/battery-sensor.h" -#include /* For printf() */ +#include /* 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(); } -/*---------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ diff --git a/examples/z1/test-battery_mv.c b/examples/z1/test-battery_mv.c deleted file mode 100755 index 555932e47..000000000 --- a/examples/z1/test-battery_mv.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "contiki.h" -#include "dev/battery-sensor.h" -#include /* 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(); -} -/*---------------------------------------------------------------------------*/ - diff --git a/examples/z1/test-potent.c b/examples/z1/test-potent.c index 9c0263c35..7a2881d80 100644 --- a/examples/z1/test-potent.c +++ b/examples/z1/test-potent.c @@ -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 + */ + #include "contiki.h" - #include "dev/potentiometer-sensor.h" -#include /* For printf() */ +#include /*---------------------------------------------------------------------------*/ -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(); } + /*---------------------------------------------------------------------------*/ diff --git a/examples/z1/test-tmp102.c b/examples/z1/test-tmp102.c index 6b25221a3..3f6f37ec4 100644 --- a/examples/z1/test-tmp102.c +++ b/examples/z1/test-tmp102.c @@ -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 + * Enric M. Calvo */ #include @@ -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(); } - diff --git a/examples/z1/example2/Makefile b/examples/z1/tutorials/Makefile similarity index 100% rename from examples/z1/example2/Makefile rename to examples/z1/tutorials/Makefile diff --git a/examples/z1/example2/example-unicast-temp.c b/examples/z1/tutorials/example-unicast-temp.c similarity index 100% rename from examples/z1/example2/example-unicast-temp.c rename to examples/z1/tutorials/example-unicast-temp.c diff --git a/examples/z1/example2/example-unicast2.c b/examples/z1/tutorials/example-unicast2.c similarity index 100% rename from examples/z1/example2/example-unicast2.c rename to examples/z1/tutorials/example-unicast2.c diff --git a/examples/z1sp/test-potentiometer.c b/examples/z1sp/test-potentiometer.c index 5bf58abbe..7a2881d80 100644 --- a/examples/z1sp/test-potentiometer.c +++ b/examples/z1sp/test-potentiometer.c @@ -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 + */ + #include "contiki.h" - #include "dev/potentiometer-sensor.h" -#include /* For printf() */ +#include /*---------------------------------------------------------------------------*/ -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(); } + /*---------------------------------------------------------------------------*/