License headers and code style fixes.
This commit is contained in:
parent
875bfd0a1a
commit
fc65757114
45 changed files with 12232 additions and 12337 deletions
|
@ -1,39 +1,39 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file contiki-spirit1-main.c
|
||||
* @author System LAB
|
||||
* @version V1.0.0
|
||||
* @date 17-June-2015
|
||||
* @brief Contiki main file for SPIRIT1 platform
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||
*
|
||||
* 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 STMicroelectronics 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
******************************************************************************
|
||||
* @file contiki-spirit1-main.c
|
||||
* @author System LAB
|
||||
* @version V1.0.0
|
||||
* @date 17-June-2015
|
||||
* @brief Contiki main file for SPIRIT1 platform
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||
*
|
||||
* 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 STMicroelectronics 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* A very simple Contiki application showing sensor values for ST Nucleo
|
||||
|
@ -66,7 +66,7 @@
|
|||
#define DEBUG DEBUG_PRINT
|
||||
#include "net/ip/uip-debug.h"
|
||||
|
||||
#define PRINT_INTERVAL 5*CLOCK_SECOND
|
||||
#define PRINT_INTERVAL 5 * CLOCK_SECOND
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(sensor_demo_process, "Sensor demo process");
|
||||
|
@ -76,7 +76,7 @@ PROCESS_THREAD(sensor_demo_process, ev, data)
|
|||
{
|
||||
static struct etimer etimer;
|
||||
static unsigned long _button_pressed;
|
||||
static int sensor_value = 0;
|
||||
static int sensor_value = 0;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
PROCESS_PAUSE();
|
||||
|
@ -94,64 +94,61 @@ PROCESS_THREAD(sensor_demo_process, ev, data)
|
|||
SENSORS_ACTIVATE(gyroscope_sensor);
|
||||
#endif
|
||||
|
||||
while(1)
|
||||
{
|
||||
while(1) {
|
||||
etimer_set(&etimer, PRINT_INTERVAL);
|
||||
|
||||
|
||||
PROCESS_WAIT_EVENT();
|
||||
if (ev == sensors_event && data == &button_sensor)
|
||||
{
|
||||
if(ev == sensors_event && data == &button_sensor) {
|
||||
printf("Sensor event detected: Button Pressed.\n\n");
|
||||
printf("Toggling Leds\n");
|
||||
_button_pressed++;
|
||||
leds_toggle(LEDS_ALL);
|
||||
}
|
||||
|
||||
|
||||
printf("Button state:\t%s (pressed %lu times)\n", button_sensor.value(0)?"Released":"Pressed",
|
||||
_button_pressed);
|
||||
printf("Button state:\t%s (pressed %lu times)\n", button_sensor.value(0) ? "Released" : "Pressed",
|
||||
_button_pressed);
|
||||
|
||||
#ifdef COMPILE_SENSORS
|
||||
printf("LEDs status:\tRED:n/a GREEN:%s\n", leds_get()&LEDS_GREEN?"on":"off");
|
||||
printf("LEDs status:\tRED:n/a GREEN:%s\n", leds_get() & LEDS_GREEN ? "on" : "off");
|
||||
#else
|
||||
printf("LEDs status:\tRED:%s GREEN:%s\n", leds_get()&LEDS_RED?"on":"off",
|
||||
leds_get()&LEDS_GREEN?"on":"off");
|
||||
printf("LEDs status:\tRED:%s GREEN:%s\n", leds_get() & LEDS_RED ? "on" : "off",
|
||||
leds_get() & LEDS_GREEN ? "on" : "off");
|
||||
#endif /*COMPILE_SENSORS*/
|
||||
sensor_value = radio_sensor.value(RADIO_SENSOR_LAST_PACKET);
|
||||
printf("Radio (RSSI):\t%d.%d dBm\n", sensor_value/10, ABS_VALUE(sensor_value)%10);
|
||||
printf("Radio (RSSI):\t%d.%d dBm\n", sensor_value / 10, ABS_VALUE(sensor_value) % 10);
|
||||
printf("Radio (LQI):\t%d\n", radio_sensor.value(RADIO_SENSOR_LAST_VALUE));
|
||||
|
||||
#ifdef COMPILE_SENSORS
|
||||
sensor_value = temperature_sensor.value(0);
|
||||
printf("Temperature:\t%d.%d C\n", sensor_value/10, ABS_VALUE(sensor_value)%10);
|
||||
printf("Temperature:\t%d.%d C\n", sensor_value / 10, ABS_VALUE(sensor_value) % 10);
|
||||
|
||||
sensor_value = humidity_sensor.value(0);
|
||||
printf("Humidity:\t%d.%d rH\n", sensor_value/10, ABS_VALUE(sensor_value)%10);
|
||||
printf("Humidity:\t%d.%d rH\n", sensor_value / 10, ABS_VALUE(sensor_value) % 10);
|
||||
|
||||
sensor_value = pressure_sensor.value(0);
|
||||
printf("Pressure:\t%d.%d mbar\n", sensor_value/10, ABS_VALUE(sensor_value)%10);
|
||||
printf("Pressure:\t%d.%d mbar\n", sensor_value / 10, ABS_VALUE(sensor_value) % 10);
|
||||
|
||||
/* NOTE: this demo uses the mapping of ST Nucleo sensors on Contiki sensor API.
|
||||
* For a real use case of sensors like acceleration, magneto and gyroscope,
|
||||
* it is better to directly call the ST lib to get the three value (X/Y/Z)
|
||||
* at once.
|
||||
*/
|
||||
/* NOTE: this demo uses the mapping of ST Nucleo sensors on Contiki sensor API.
|
||||
* For a real use case of sensors like acceleration, magneto and gyroscope,
|
||||
* it is better to directly call the ST lib to get the three value (X/Y/Z)
|
||||
* at once.
|
||||
*/
|
||||
printf("Magneto:\t%d/%d/%d (X/Y/Z) mgauss\n", magneto_sensor.value(X_AXIS),
|
||||
magneto_sensor.value(Y_AXIS),
|
||||
magneto_sensor.value(Z_AXIS));
|
||||
magneto_sensor.value(Y_AXIS),
|
||||
magneto_sensor.value(Z_AXIS));
|
||||
|
||||
printf("Acceleration:\t%d/%d/%d (X/Y/Z) mg\n", acceleration_sensor.value(X_AXIS),
|
||||
acceleration_sensor.value(Y_AXIS),
|
||||
acceleration_sensor.value(Z_AXIS));
|
||||
acceleration_sensor.value(Y_AXIS),
|
||||
acceleration_sensor.value(Z_AXIS));
|
||||
|
||||
printf("Gyroscope:\t%d/%d/%d (X/Y/Z) mdps\n", gyroscope_sensor.value(X_AXIS),
|
||||
gyroscope_sensor.value(Y_AXIS),
|
||||
gyroscope_sensor.value(Z_AXIS));
|
||||
gyroscope_sensor.value(Y_AXIS),
|
||||
gyroscope_sensor.value(Z_AXIS));
|
||||
#endif
|
||||
|
||||
printf ("\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue