Merge branch 'develop' into bugfix/cc26xx-rx-packet-size
This commit is contained in:
commit
888063e9e6
@ -14,7 +14,7 @@ before_install:
|
||||
- ant -q -f $CNG_HOST_PATH/tools/cooja/build.xml jar
|
||||
|
||||
script: # The test script for each build.
|
||||
- docker run --privileged -v $CNG_HOST_PATH:/home/user/contiki-ng -ti $DOCKER_IMG bash -c "make -C tests/??-$TEST_NAME";
|
||||
- docker run --privileged -v $CNG_HOST_PATH:/home/user/contiki-ng -ti $DOCKER_IMG bash --login -c "make -C tests/??-$TEST_NAME";
|
||||
# Check outcome of the test
|
||||
- $CNG_HOST_PATH/tests/check-test.sh $CNG_HOST_PATH/tests/??-$TEST_NAME; exit $?;
|
||||
|
||||
|
@ -326,6 +326,14 @@
|
||||
* number.
|
||||
*/
|
||||
#define GPIO_PORT_TO_BASE(PORT) (GPIO_A_BASE + ((PORT) << 12))
|
||||
|
||||
/**
|
||||
* \brief Converts a port/pin pair to GPIO HAL pin number
|
||||
* \param PORT The port number in the range 0 - 3 (GPIO_n_NUM).
|
||||
* \param PIN The pin number in the range 0 - 7.
|
||||
* \return The pin representation using GPIO HAL semantics
|
||||
*/
|
||||
#define GPIO_PORT_PIN_TO_GPIO_HAL_PIN(PORT, PIN) (((PORT) << 3) + (PIN))
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name GPIO Register offset declarations
|
||||
|
@ -46,10 +46,10 @@ leds_arch_init(void)
|
||||
LEDS_PxOUT |= (LEDS_CONF_RED | LEDS_CONF_GREEN | LEDS_CONF_YELLOW);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_mask_t
|
||||
leds_arch_get(void)
|
||||
{
|
||||
unsigned char leds;
|
||||
leds_mask_t leds;
|
||||
leds = LEDS_PxOUT;
|
||||
return ((leds & LEDS_CONF_RED) ? 0 : LEDS_RED)
|
||||
| ((leds & LEDS_CONF_GREEN) ? 0 : LEDS_GREEN)
|
||||
@ -57,7 +57,7 @@ leds_arch_get(void)
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char leds)
|
||||
leds_arch_set(leds_mask_t leds)
|
||||
{
|
||||
LEDS_PxOUT = (LEDS_PxOUT & ~(LEDS_CONF_RED|LEDS_CONF_GREEN|LEDS_CONF_YELLOW))
|
||||
| ((leds & LEDS_RED) ? 0 : LEDS_CONF_RED)
|
||||
|
62
arch/dev/rgb-led/rgb-led.c
Normal file
62
arch/dev/rgb-led/rgb-led.c
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
|
||||
* 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 rgb-led
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of the RGB LED driver.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/rgb-led/rgb-led.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rgb_led_off(void)
|
||||
{
|
||||
leds_off(LEDS_ALL);
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void
|
||||
rgb_led_set(uint8_t colour)
|
||||
{
|
||||
leds_mask_t leds =
|
||||
((colour & RGB_LED_RED) ? LEDS_RED : LEDS_COLOUR_NONE) |
|
||||
((colour & RGB_LED_GREEN) ? LEDS_GREEN : LEDS_COLOUR_NONE) |
|
||||
((colour & RGB_LED_BLUE) ? LEDS_BLUE : LEDS_COLOUR_NONE);
|
||||
|
||||
leds_off(LEDS_ALL);
|
||||
leds_on(leds);
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/** @} */
|
@ -1,17 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Zolertia - http://www.zolertia.com
|
||||
* Copyright (c) 2015, University of Bristol - http://www.bristol.ac.uk
|
||||
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
|
||||
* 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.
|
||||
@ -29,73 +28,60 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef RGB_LED_H_
|
||||
#define RGB_LED_H_
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup zoul
|
||||
* \addtogroup dev
|
||||
* @{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \defgroup rgb-led Generic RGB LED driver
|
||||
*
|
||||
* \defgroup remote-revb-leds RE-Mote revision B arch LED
|
||||
* This is a driver for a tri-color RGB LED part, such as for example the
|
||||
* Broadcom (ex Avago Technologies) PLCC-4 Tricolor Black Surface LED present
|
||||
* on all Zolertia Zoul-based boards.
|
||||
*
|
||||
* LED driver implementation for the RE-Mote revision B
|
||||
*
|
||||
* This driver sits on top of the LED HAL. Therefore, any port that wishes to
|
||||
* use this driver should first implement the GPIO HAL and the new LED API.
|
||||
* This driver will set the colour of the RGB LED by using combinations of
|
||||
* LED_RED, LED_GREEN and LED_BLUE. Therefore, those must be correctly defined
|
||||
* by the platform configuration.
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* LED driver implementation for the RE-Mote revision B
|
||||
* Header file for the RGB LED driver.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "reg.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/gpio.h"
|
||||
#include "dev/ioc.h"
|
||||
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define LEDS_PORTB_PIN_MASK (LEDS_GREEN_PIN_MASK | LEDS_BLUE_PIN_MASK)
|
||||
#define RGB_LED_RED 1
|
||||
#define RGB_LED_GREEN 2
|
||||
#define RGB_LED_BLUE 4
|
||||
#define RGB_LED_MAGENTA (RGB_LED_RED | RGB_LED_BLUE)
|
||||
#define RGB_LED_YELLOW (RGB_LED_RED | RGB_LED_GREEN)
|
||||
#define RGB_LED_CYAN (RGB_LED_GREEN | RGB_LED_BLUE )
|
||||
#define RGB_LED_WHITE (RGB_LED_RED | RGB_LED_GREEN | RGB_LED_BLUE)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_init(void)
|
||||
{
|
||||
/* Initialize LED2 (Green) and LED3 (Blue) */
|
||||
GPIO_SOFTWARE_CONTROL(GPIO_B_BASE, LEDS_PORTB_PIN_MASK);
|
||||
GPIO_SET_OUTPUT(GPIO_B_BASE, LEDS_PORTB_PIN_MASK);
|
||||
GPIO_CLR_PIN(GPIO_B_BASE, LEDS_PORTB_PIN_MASK);
|
||||
/**
|
||||
* \brief Turn off the RGB LED
|
||||
*/
|
||||
void rgb_led_off(void);
|
||||
|
||||
/* Initialize LED1 (Red) */
|
||||
GPIO_SOFTWARE_CONTROL(LEDS_RED_PORT_BASE, LEDS_RED_PIN_MASK);
|
||||
GPIO_SET_OUTPUT(LEDS_RED_PORT_BASE, LEDS_RED_PIN_MASK);
|
||||
GPIO_CLR_PIN(LEDS_RED_PORT_BASE, LEDS_RED_PIN_MASK);
|
||||
}
|
||||
/**
|
||||
* \brief Set the colour of the RGB LED
|
||||
* \param colour The colour to set
|
||||
*
|
||||
* \e colour can take the value of one of the RGB_LED_xyz defines.
|
||||
*/
|
||||
void rgb_led_set(uint8_t colour);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_arch_get(void)
|
||||
{
|
||||
uint8_t mask_leds;
|
||||
|
||||
mask_leds = GPIO_READ_PIN(LEDS_GREEN_PORT_BASE, LEDS_GREEN_PIN_MASK) == 0 ? 0: LEDS_GREEN;
|
||||
mask_leds |= GPIO_READ_PIN(LEDS_BLUE_PORT_BASE, LEDS_BLUE_PIN_MASK) == 0 ? 0 : LEDS_BLUE;
|
||||
mask_leds |= GPIO_READ_PIN(LEDS_RED_PORT_BASE, LEDS_RED_PIN_MASK) == 0 ? 0 : LEDS_RED;
|
||||
|
||||
return mask_leds;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char leds)
|
||||
{
|
||||
if(leds & LEDS_GREEN) {
|
||||
GPIO_SET_PIN(LEDS_GREEN_PORT_BASE, LEDS_GREEN_PIN_MASK);
|
||||
} else {
|
||||
GPIO_CLR_PIN(LEDS_GREEN_PORT_BASE, LEDS_GREEN_PIN_MASK);
|
||||
}
|
||||
|
||||
if(leds & LEDS_BLUE) {
|
||||
GPIO_SET_PIN(LEDS_BLUE_PORT_BASE, LEDS_BLUE_PIN_MASK);
|
||||
} else {
|
||||
GPIO_CLR_PIN(LEDS_BLUE_PORT_BASE, LEDS_BLUE_PIN_MASK);
|
||||
}
|
||||
|
||||
if(leds & LEDS_RED) {
|
||||
GPIO_SET_PIN(LEDS_RED_PORT_BASE, LEDS_RED_PIN_MASK);
|
||||
} else {
|
||||
GPIO_CLR_PIN(LEDS_RED_PORT_BASE, LEDS_RED_PIN_MASK);
|
||||
}
|
||||
}
|
||||
#endif /* RGB_LED_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
@ -6,7 +6,7 @@ endif
|
||||
|
||||
CONTIKI_TARGET_DIRS = . dev
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES += leds.c leds-arch.c
|
||||
CONTIKI_TARGET_SOURCEFILES += leds-arch.c
|
||||
CONTIKI_TARGET_SOURCEFILES += platform.c
|
||||
CONTIKI_TARGET_SOURCEFILES += sensors.c smartrf-sensors.c
|
||||
CONTIKI_TARGET_SOURCEFILES += button-sensor.c als-sensor.c
|
||||
|
@ -71,20 +71,25 @@
|
||||
* @{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define LEDS_YELLOW 2 /**< LED2 (Yellow) -> PC1 */
|
||||
#define LEDS_GREEN 4 /**< LED3 (Green) -> PC2 */
|
||||
#define LEDS_ORANGE 8 /**< LED4 (Orange) -> PC3 */
|
||||
#define LEDS_CONF_YELLOW 1
|
||||
#define LEDS_CONF_GREEN 2
|
||||
#define LEDS_CONF_ORANGE 4
|
||||
|
||||
#define LEDS_ARCH_L1_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L1_PIN 1
|
||||
#define LEDS_ARCH_L2_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L2_PIN 2
|
||||
#define LEDS_ARCH_L3_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L3_PIN 3
|
||||
|
||||
#if USB_SERIAL_CONF_ENABLE
|
||||
#define LEDS_CONF_ALL 14
|
||||
#define LEDS_RED LEDS_ORANGE
|
||||
#define LEDS_CONF_COUNT 3
|
||||
#else
|
||||
#define LEDS_CONF_ALL 15
|
||||
#define LEDS_RED 1 /**< LED1 (Red) -> PC0 */
|
||||
#define LEDS_ARCH_L4_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L4_PIN 0
|
||||
#define LEDS_CONF_RED 8
|
||||
#define LEDS_CONF_COUNT 4
|
||||
#endif
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name USB configuration
|
||||
|
@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
|
||||
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
|
||||
* 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.
|
||||
@ -28,45 +28,34 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup cc2538-smartrf
|
||||
* @{
|
||||
*
|
||||
* \defgroup cc2538dk-leds SmartRF06EB LED driver
|
||||
*
|
||||
* LED driver implementation for the TI SmartRF06EB + cc2538EM
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* LED driver implementation for the TI SmartRF06EB + cc2538EM
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "reg.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/gpio.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "dev/gpio-hal-arch.h"
|
||||
|
||||
#define LEDS_GPIO_PIN_MASK LEDS_ALL
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_init(void)
|
||||
{
|
||||
GPIO_SET_OUTPUT(GPIO_C_BASE, LEDS_GPIO_PIN_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return GPIO_READ_PIN(GPIO_C_BASE, LEDS_GPIO_PIN_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char leds)
|
||||
{
|
||||
GPIO_WRITE_PIN(GPIO_C_BASE, LEDS_GPIO_PIN_MASK, leds);
|
||||
}
|
||||
const leds_t leds_arch_leds[] = {
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L1_PORT, LEDS_ARCH_L1_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L2_PORT, LEDS_ARCH_L2_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L3_PORT, LEDS_ARCH_L3_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
#if !USB_SERIAL_CONF_ENABLE
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L4_PORT, LEDS_ARCH_L4_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
#endif
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
@ -74,7 +74,7 @@
|
||||
#define LOG_LEVEL LOG_LEVEL_MAIN
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
fade(unsigned char l)
|
||||
fade(leds_mask_t l)
|
||||
{
|
||||
volatile int i;
|
||||
int k, j;
|
||||
|
@ -46,6 +46,8 @@
|
||||
|
||||
#define COOJA 1
|
||||
|
||||
#define LEDS_CONF_LEGACY_API 1
|
||||
|
||||
#ifndef EEPROM_CONF_SIZE
|
||||
#define EEPROM_CONF_SIZE 1024
|
||||
#endif
|
||||
|
@ -34,18 +34,18 @@
|
||||
const struct simInterface leds_interface;
|
||||
|
||||
// COOJA variables
|
||||
unsigned char simLedsValue;
|
||||
leds_mask_t simLedsValue;
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void leds_arch_init() {
|
||||
simLedsValue = 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
unsigned char leds_arch_get() {
|
||||
leds_mask_t leds_arch_get() {
|
||||
return simLedsValue;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void leds_arch_set(unsigned char leds) {
|
||||
void leds_arch_set(leds_mask_t leds) {
|
||||
if(leds != simLedsValue) {
|
||||
simLedsValue = leds;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@
|
||||
#define LED_G (1 << 16)
|
||||
#define LED_R (1 << 17)
|
||||
|
||||
static volatile uint8_t leds;
|
||||
static volatile leds_mask_t leds;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
@ -49,14 +49,14 @@ leds_arch_init(void)
|
||||
leds = 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_mask_t
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return leds;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char c)
|
||||
leds_arch_set(leds_mask_t c)
|
||||
{
|
||||
uint32 on_mask = 0;
|
||||
uint32 off_mask = 0;
|
||||
|
@ -196,6 +196,8 @@ typedef uint32_t rtimer_clock_t;
|
||||
#define PLATFORM_HAS_SHT11 0
|
||||
#define PLATFORM_HAS_RADIO 1
|
||||
|
||||
#define LEDS_CONF_LEGACY_API 1
|
||||
|
||||
#define PLATFORM_CONF_PROVIDES_MAIN_LOOP 1
|
||||
|
||||
/* CPU target speed in Hz
|
||||
|
@ -66,6 +66,8 @@ typedef int32_t s32_t;
|
||||
|
||||
typedef unsigned int uip_stats_t;
|
||||
|
||||
#define LEDS_CONF_LEGACY_API 1
|
||||
|
||||
#ifndef UIP_CONF_BYTE_ORDER
|
||||
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
@ -38,7 +38,7 @@
|
||||
*/
|
||||
|
||||
#include "dev/leds.h"
|
||||
static unsigned char leds;
|
||||
static leds_mask_t leds;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_init(void)
|
||||
@ -46,14 +46,14 @@ leds_arch_init(void)
|
||||
leds = 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_mask_t
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return leds;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char l)
|
||||
leds_arch_set(leds_mask_t l)
|
||||
{
|
||||
leds = l;
|
||||
}
|
||||
|
@ -55,14 +55,14 @@ leds_arch_init(void)
|
||||
LEDS_OFF(LEDS_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_mask_t
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return (unsigned char)(LED_IS_ON(LEDS_MASK) >> LED_START);
|
||||
return (leds_mask_t)(LED_IS_ON(LEDS_MASK) >> LED_START);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char leds)
|
||||
leds_arch_set(leds_mask_t leds)
|
||||
{
|
||||
unsigned int mask = (unsigned int)leds << LED_START;
|
||||
LEDS_OFF(LEDS_MASK);
|
||||
|
@ -60,16 +60,17 @@
|
||||
* @{
|
||||
*/
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_LEGACY_API 1
|
||||
|
||||
#define LEDS_1 (1 << (LED_1 - LED_START)) // 1
|
||||
#define LEDS_2 (1 << (LED_2 - LED_START)) // 2
|
||||
#define LEDS_3 (1 << (LED_3 - LED_START)) // 4
|
||||
#define LEDS_4 (1 << (LED_4 - LED_START)) // 8
|
||||
|
||||
#define LEDS_GREEN LEDS_1
|
||||
#define LEDS_YELLOW LEDS_2
|
||||
#define LEDS_RED LEDS_3
|
||||
#define LEDS_BLUE LEDS_4
|
||||
#define LEDS_CONF_GREEN LEDS_1
|
||||
#define LEDS_CONF_YELLOW LEDS_2
|
||||
#define LEDS_CONF_RED LEDS_3
|
||||
#define LEDS_CONF_BLUE LEDS_4
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_1 | LEDS_2 | LEDS_3 | LEDS_4)
|
||||
|
||||
|
@ -63,14 +63,21 @@
|
||||
* @{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define LEDS_RED 16 /**< LED1 (Red) -> PC4 */
|
||||
#define LEDS_YELLOW 64 /**< LED2 (Yellow) -> PC6 */
|
||||
#define LEDS_GREEN 128 /**< LED3 (Green) -> PC7 */
|
||||
#define LEDS_ORANGE 32 /**< LED4 (Orange) -> PC5 */
|
||||
#define LEDS_CONF_ALL 240
|
||||
#define LEDS_ARCH_L1_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L1_PIN 4
|
||||
#define LEDS_ARCH_L2_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L2_PIN 6
|
||||
#define LEDS_ARCH_L3_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L3_PIN 7
|
||||
#define LEDS_ARCH_L4_PORT GPIO_C_NUM
|
||||
#define LEDS_ARCH_L4_PIN 5
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_RED 1
|
||||
#define LEDS_CONF_YELLOW 2
|
||||
#define LEDS_CONF_GREEN 4
|
||||
#define LEDS_CONF_ORANGE 8
|
||||
|
||||
#define LEDS_CONF_COUNT 4
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name USB configuration
|
||||
|
@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
|
||||
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
|
||||
* 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
|
||||
@ -26,48 +27,32 @@
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup openmote-cc2538
|
||||
* @{
|
||||
*
|
||||
* \defgroup openmote-leds OpenMote-CC2538 LED driver
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* LED driver implementation for the OpenMote-CC2538 platform
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "reg.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/gpio.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define LEDS_GPIO_PIN_MASK LEDS_ALL
|
||||
const leds_t leds_arch_leds[] = {
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L1_PORT, LEDS_ARCH_L1_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L2_PORT, LEDS_ARCH_L2_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L3_PORT, LEDS_ARCH_L3_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L4_PORT, LEDS_ARCH_L4_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_init(void)
|
||||
{
|
||||
GPIO_SET_OUTPUT(GPIO_C_BASE, LEDS_GPIO_PIN_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return GPIO_READ_PIN(GPIO_C_BASE, LEDS_GPIO_PIN_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char leds)
|
||||
{
|
||||
GPIO_WRITE_PIN(GPIO_C_BASE, LEDS_GPIO_PIN_MASK, leds);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
@ -82,7 +82,7 @@
|
||||
void board_init(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
fade(unsigned char l)
|
||||
fade(leds_mask_t l)
|
||||
{
|
||||
volatile int i;
|
||||
int k, j;
|
||||
|
@ -75,6 +75,8 @@
|
||||
#define LEDS_CONF_GREEN 0x20
|
||||
#define LEDS_CONF_YELLOW 0x40
|
||||
|
||||
#define LEDS_CONF_LEGACY_API 1
|
||||
|
||||
/* DCO speed resynchronization for more robust UART, etc. */
|
||||
#ifndef DCOSYNCH_CONF_ENABLED
|
||||
#define DCOSYNCH_CONF_ENABLED (!(MAC_CONF_WITH_TSCH)) /* TSCH needs timerB
|
||||
|
@ -14,8 +14,7 @@ CONTIKI_TARGET_DIRS += .
|
||||
PLATFORM_ROOT_DIR = $(CONTIKI)/arch/platform/$(TARGET)
|
||||
-include $(PLATFORM_ROOT_DIR)/$(BOARD)/Makefile.$(notdir $(BOARD))
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES += platform.c
|
||||
CONTIKI_TARGET_SOURCEFILES += sensors.c leds.c
|
||||
CONTIKI_TARGET_SOURCEFILES += platform.c leds-arch.c
|
||||
CONTIKI_TARGET_SOURCEFILES += $(BOARD_SOURCEFILES)
|
||||
|
||||
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
||||
|
@ -2,7 +2,7 @@ CFLAGS += -DBOARD_LAUNCHPAD=1
|
||||
|
||||
CONTIKI_TARGET_DIRS += launchpad common
|
||||
|
||||
BOARD_SOURCEFILES += board.c launchpad-sensors.c leds-arch.c button-sensor.c
|
||||
BOARD_SOURCEFILES += board.c launchpad-sensors.c button-sensor.c
|
||||
BOARD_SOURCEFILES += ext-flash.c board-spi.c
|
||||
|
||||
### Signal that we can be programmed with cc2538-bsl
|
||||
|
@ -55,20 +55,14 @@
|
||||
#include "ioc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name LED configurations
|
||||
* \name LED HAL configuration
|
||||
*
|
||||
* Those values are not meant to be modified by the user
|
||||
* @{
|
||||
*/
|
||||
#define LEDS_RED 1
|
||||
#define LEDS_GREEN 2
|
||||
#define LEDS_YELLOW LEDS_GREEN
|
||||
#define LEDS_ORANGE LEDS_RED
|
||||
|
||||
#define LEDS_CONF_ALL 3
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_COUNT 2
|
||||
#define LEDS_CONF_RED 1
|
||||
#define LEDS_CONF_YELLOW 2
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
@ -79,9 +73,6 @@
|
||||
*/
|
||||
#define BOARD_IOID_LED_1 IOID_6
|
||||
#define BOARD_IOID_LED_2 IOID_7
|
||||
#define BOARD_LED_1 (1 << BOARD_IOID_LED_1)
|
||||
#define BOARD_LED_2 (1 << BOARD_IOID_LED_2)
|
||||
#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2)
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -55,20 +55,14 @@
|
||||
#include "ioc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name LED configurations
|
||||
* \name LED HAL configuration
|
||||
*
|
||||
* Those values are not meant to be modified by the user
|
||||
* @{
|
||||
*/
|
||||
#define LEDS_RED 1
|
||||
#define LEDS_GREEN 2
|
||||
#define LEDS_YELLOW LEDS_GREEN
|
||||
#define LEDS_ORANGE LEDS_RED
|
||||
|
||||
#define LEDS_CONF_ALL 3
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_COUNT 2
|
||||
#define LEDS_CONF_RED 1
|
||||
#define LEDS_CONF_YELLOW 2
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
@ -79,9 +73,6 @@
|
||||
*/
|
||||
#define BOARD_IOID_LED_1 IOID_6
|
||||
#define BOARD_IOID_LED_2 IOID_7
|
||||
#define BOARD_LED_1 (1 << BOARD_IOID_LED_1)
|
||||
#define BOARD_LED_2 (1 << BOARD_IOID_LED_2)
|
||||
#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2)
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -55,20 +55,14 @@
|
||||
#include "ioc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name LED configurations
|
||||
* \name LED HAL configuration
|
||||
*
|
||||
* Those values are not meant to be modified by the user
|
||||
* @{
|
||||
*/
|
||||
#define LEDS_RED 1
|
||||
#define LEDS_GREEN 2
|
||||
#define LEDS_YELLOW LEDS_GREEN
|
||||
#define LEDS_ORANGE LEDS_RED
|
||||
|
||||
#define LEDS_CONF_ALL 3
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_COUNT 2
|
||||
#define LEDS_CONF_RED 1
|
||||
#define LEDS_CONF_YELLOW 2
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
@ -79,9 +73,6 @@
|
||||
*/
|
||||
#define BOARD_IOID_LED_1 IOID_6
|
||||
#define BOARD_IOID_LED_2 IOID_7
|
||||
#define BOARD_LED_1 (1 << BOARD_IOID_LED_1)
|
||||
#define BOARD_LED_2 (1 << BOARD_IOID_LED_2)
|
||||
#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2)
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Texas Instruments Incorporated - http://www.ti.com/
|
||||
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
|
||||
* 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
|
||||
@ -28,54 +29,17 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup launchpad-peripherals
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Driver for LaunchPad LEDs
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/leds.h"
|
||||
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "ti-lib.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned char c;
|
||||
static int inited = 0;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_init(void)
|
||||
{
|
||||
if(inited) {
|
||||
return;
|
||||
}
|
||||
inited = 1;
|
||||
|
||||
ti_lib_rom_ioc_pin_type_gpio_output(BOARD_IOID_LED_1);
|
||||
ti_lib_rom_ioc_pin_type_gpio_output(BOARD_IOID_LED_2);
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const leds_t leds_arch_leds[] = {
|
||||
{ .pin = BOARD_IOID_LED_1, .negative_logic = false },
|
||||
{ .pin = BOARD_IOID_LED_2, .negative_logic = false },
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char leds)
|
||||
{
|
||||
c = leds;
|
||||
ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL);
|
||||
|
||||
if((leds & LEDS_RED) == LEDS_RED) {
|
||||
ti_lib_gpio_set_dio(BOARD_IOID_LED_1);
|
||||
}
|
||||
if((leds & LEDS_YELLOW) == LEDS_YELLOW) {
|
||||
ti_lib_gpio_set_dio(BOARD_IOID_LED_2);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
|
@ -47,8 +47,8 @@
|
||||
#include "ti-lib.h"
|
||||
#include "contiki.h"
|
||||
#include "contiki-net.h"
|
||||
#include "leds.h"
|
||||
#include "lpm.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "dev/oscillators.h"
|
||||
#include "ieee-addr.h"
|
||||
@ -84,7 +84,7 @@ unsigned short node_id = 0;
|
||||
void board_init(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
fade(unsigned char l)
|
||||
fade(leds_mask_t l)
|
||||
{
|
||||
volatile int i;
|
||||
int k, j;
|
||||
|
@ -1,6 +1,3 @@
|
||||
### Add to the source list
|
||||
BOARD_SOURCEFILES += leds-arch.c
|
||||
|
||||
### Will allow the inclusion of the correct CPU makefile
|
||||
CPU_FAMILY = cc13xx
|
||||
|
||||
|
@ -58,20 +58,13 @@
|
||||
#include "ioc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name LED configurations
|
||||
* \name LED HAL configuration
|
||||
*
|
||||
* Those values are not meant to be modified by the user
|
||||
* @{
|
||||
*/
|
||||
#define LEDS_RED 1
|
||||
#define LEDS_GREEN LEDS_RED
|
||||
#define LEDS_YELLOW LEDS_RED
|
||||
#define LEDS_ORANGE LEDS_RED
|
||||
|
||||
#define LEDS_CONF_ALL 1
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_COUNT 1
|
||||
#define LEDS_CONF_RED 1
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
@ -81,8 +74,6 @@
|
||||
* @{
|
||||
*/
|
||||
#define BOARD_IOID_LED_1 IOID_10
|
||||
#define BOARD_LED_1 (1 << BOARD_IOID_LED_1)
|
||||
#define BOARD_LED_ALL BOARD_LED_1
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/
|
||||
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
|
||||
* 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
|
||||
@ -28,50 +29,15 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup sensortag-cc13xx-peripherals
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Driver for the Sensortag-CC1350 LEDs
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
|
||||
#include "ti-lib.h"
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned char c;
|
||||
static int inited = 0;
|
||||
const leds_t leds_arch_leds[] = {
|
||||
{ .pin = BOARD_IOID_LED_1, .negative_logic = false },
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_init(void)
|
||||
{
|
||||
if(inited) {
|
||||
return;
|
||||
}
|
||||
inited = 1;
|
||||
|
||||
ti_lib_rom_ioc_pin_type_gpio_output(BOARD_IOID_LED_1);
|
||||
|
||||
ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char leds)
|
||||
{
|
||||
c = leds;
|
||||
ti_lib_gpio_clear_dio(BOARD_IOID_LED_1);
|
||||
|
||||
if((leds & LEDS_RED) == LEDS_RED) {
|
||||
ti_lib_gpio_set_dio(BOARD_IOID_LED_1);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
|
@ -1,6 +1,3 @@
|
||||
### Add to the source list
|
||||
BOARD_SOURCEFILES += leds-arch.c
|
||||
|
||||
### Will allow the inclusion of the correct CPU makefile
|
||||
CPU_FAMILY = cc26xx
|
||||
|
||||
|
@ -58,20 +58,14 @@
|
||||
#include "ioc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name LED configurations
|
||||
* \name LED HAL configuration
|
||||
*
|
||||
* Those values are not meant to be modified by the user
|
||||
* @{
|
||||
*/
|
||||
#define LEDS_RED 1
|
||||
#define LEDS_GREEN 2
|
||||
#define LEDS_YELLOW LEDS_GREEN
|
||||
#define LEDS_ORANGE LEDS_RED
|
||||
|
||||
#define LEDS_CONF_ALL 3
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_COUNT 2
|
||||
#define LEDS_CONF_RED 1
|
||||
#define LEDS_CONF_GREEN 2
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
@ -82,9 +76,6 @@
|
||||
*/
|
||||
#define BOARD_IOID_LED_1 IOID_10
|
||||
#define BOARD_IOID_LED_2 IOID_15
|
||||
#define BOARD_LED_1 (1 << BOARD_IOID_LED_1)
|
||||
#define BOARD_LED_2 (1 << BOARD_IOID_LED_2)
|
||||
#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2)
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/
|
||||
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
|
||||
* 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
|
||||
@ -28,54 +29,16 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup sensortag-cc26xx-peripherals
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Driver for the Sensortag-CC26XX LEDs
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
|
||||
#include "ti-lib.h"
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned char c;
|
||||
static int inited = 0;
|
||||
const leds_t leds_arch_leds[] = {
|
||||
{ .pin = BOARD_IOID_LED_1, .negative_logic = false },
|
||||
{ .pin = BOARD_IOID_LED_2, .negative_logic = false },
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_init(void)
|
||||
{
|
||||
if(inited) {
|
||||
return;
|
||||
}
|
||||
inited = 1;
|
||||
|
||||
ti_lib_rom_ioc_pin_type_gpio_output(BOARD_IOID_LED_1);
|
||||
ti_lib_rom_ioc_pin_type_gpio_output(BOARD_IOID_LED_2);
|
||||
|
||||
ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char leds)
|
||||
{
|
||||
c = leds;
|
||||
ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL);
|
||||
|
||||
if((leds & LEDS_RED) == LEDS_RED) {
|
||||
ti_lib_gpio_set_dio(BOARD_IOID_LED_1);
|
||||
}
|
||||
if((leds & LEDS_YELLOW) == LEDS_YELLOW) {
|
||||
ti_lib_gpio_set_dio(BOARD_IOID_LED_2);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
|
@ -2,7 +2,7 @@ CFLAGS += -DBOARD_SMARTRF06EB=1
|
||||
|
||||
CONTIKI_TARGET_DIRS += srf06
|
||||
|
||||
BOARD_SOURCEFILES += leds-arch.c srf06-sensors.c button-sensor.c board.c
|
||||
BOARD_SOURCEFILES += srf06-sensors.c button-sensor.c board.c
|
||||
BOARD_SOURCEFILES += als-sensor.c
|
||||
|
||||
### Signal that we can be programmed with cc2538-bsl
|
||||
|
@ -58,20 +58,16 @@
|
||||
#include "ioc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name LED configurations
|
||||
* \name LED HAL configuration
|
||||
*
|
||||
* Those values are not meant to be modified by the user
|
||||
* @{
|
||||
*/
|
||||
#define LEDS_RED 1 /**< LED1 (Red) */
|
||||
#define LEDS_YELLOW 2 /**< LED2 (Yellow) */
|
||||
#define LEDS_GREEN 4 /**< LED3 (Green) */
|
||||
#define LEDS_ORANGE 8 /**< LED4 (Orange) */
|
||||
|
||||
#define LEDS_CONF_ALL 15
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_COUNT 4
|
||||
#define LEDS_CONF_RED 1
|
||||
#define LEDS_CONF_YELLOW 2
|
||||
#define LEDS_CONF_GREEN 4
|
||||
#define LEDS_CONF_ORANGE 8
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
@ -84,12 +80,6 @@
|
||||
#define BOARD_IOID_LED_2 IOID_27
|
||||
#define BOARD_IOID_LED_3 IOID_7
|
||||
#define BOARD_IOID_LED_4 IOID_6
|
||||
#define BOARD_LED_1 (1 << BOARD_IOID_LED_1)
|
||||
#define BOARD_LED_2 (1 << BOARD_IOID_LED_2)
|
||||
#define BOARD_LED_3 (1 << BOARD_IOID_LED_3)
|
||||
#define BOARD_LED_4 (1 << BOARD_IOID_LED_4)
|
||||
#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2 | BOARD_LED_3 | \
|
||||
BOARD_LED_4)
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -58,20 +58,16 @@
|
||||
#include "ioc.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name LED configurations
|
||||
* \name LED HAL configuration
|
||||
*
|
||||
* Those values are not meant to be modified by the user
|
||||
* @{
|
||||
*/
|
||||
#define LEDS_RED 1 /**< LED1 (Red) */
|
||||
#define LEDS_YELLOW 2 /**< LED2 (Yellow) */
|
||||
#define LEDS_GREEN 4 /**< LED3 (Green) */
|
||||
#define LEDS_ORANGE 8 /**< LED4 (Orange) */
|
||||
|
||||
#define LEDS_CONF_ALL 15
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_COUNT 4
|
||||
#define LEDS_CONF_RED 1
|
||||
#define LEDS_CONF_YELLOW 2
|
||||
#define LEDS_CONF_GREEN 4
|
||||
#define LEDS_CONF_ORANGE 8
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
@ -84,12 +80,6 @@
|
||||
#define BOARD_IOID_LED_2 IOID_27
|
||||
#define BOARD_IOID_LED_3 IOID_7
|
||||
#define BOARD_IOID_LED_4 IOID_6
|
||||
#define BOARD_LED_1 (1 << BOARD_IOID_LED_1)
|
||||
#define BOARD_LED_2 (1 << BOARD_IOID_LED_2)
|
||||
#define BOARD_LED_3 (1 << BOARD_IOID_LED_3)
|
||||
#define BOARD_LED_4 (1 << BOARD_IOID_LED_4)
|
||||
#define BOARD_LED_ALL (BOARD_LED_1 | BOARD_LED_2 | BOARD_LED_3 | \
|
||||
BOARD_LED_4)
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/
|
||||
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
|
||||
* 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
|
||||
@ -28,63 +29,18 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \addtogroup srf06-common-peripherals
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Driver for the SmartRF06EB LEDs when a CC13xx/CC26xx EM is mounted on it
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/leds.h"
|
||||
#include "ti-lib.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned char c;
|
||||
static int inited = 0;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_init(void)
|
||||
{
|
||||
if(inited) {
|
||||
return;
|
||||
}
|
||||
inited = 1;
|
||||
#include "dev/gpio-hal.h"
|
||||
|
||||
ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_LED_1);
|
||||
ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_LED_2);
|
||||
ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_LED_3);
|
||||
ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_LED_4);
|
||||
|
||||
ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL);
|
||||
}
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
const leds_t leds_arch_leds[] = {
|
||||
{ .pin = BOARD_IOID_LED_1, .negative_logic = false },
|
||||
{ .pin = BOARD_IOID_LED_2, .negative_logic = false },
|
||||
{ .pin = BOARD_IOID_LED_3, .negative_logic = false },
|
||||
{ .pin = BOARD_IOID_LED_4, .negative_logic = false },
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char leds)
|
||||
{
|
||||
c = leds;
|
||||
|
||||
/* Clear everything */
|
||||
ti_lib_gpio_clear_multi_dio(BOARD_LED_ALL);
|
||||
|
||||
if((leds & LEDS_RED) == LEDS_RED) {
|
||||
ti_lib_gpio_set_dio(BOARD_IOID_LED_1);
|
||||
}
|
||||
if((leds & LEDS_YELLOW) == LEDS_YELLOW) {
|
||||
ti_lib_gpio_set_dio(BOARD_IOID_LED_2);
|
||||
}
|
||||
if((leds & LEDS_GREEN) == LEDS_GREEN) {
|
||||
ti_lib_gpio_set_dio(BOARD_IOID_LED_3);
|
||||
}
|
||||
if((leds & LEDS_ORANGE) == LEDS_ORANGE) {
|
||||
ti_lib_gpio_set_dio(BOARD_IOID_LED_4);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
|
@ -31,7 +31,7 @@ PLATFORM_ROOT_DIR = $(CONTIKI)/arch/platform/$(TARGET)
|
||||
-include $(PLATFORM_ROOT_DIR)/$(BOARD)/Makefile.$(BOARD)
|
||||
|
||||
### Include
|
||||
CONTIKI_TARGET_SOURCEFILES += platform.c
|
||||
CONTIKI_TARGET_SOURCEFILES += platform.c leds-arch.c
|
||||
CONTIKI_TARGET_SOURCEFILES += leds.c cc1200-zoul-arch.c
|
||||
CONTIKI_TARGET_SOURCEFILES += adc-zoul.c button-sensor.c zoul-sensors.c
|
||||
CONTIKI_TARGET_SOURCEFILES += $(BOARD_SOURCEFILES)
|
||||
@ -44,7 +44,7 @@ CLEAN += *.zoul
|
||||
CONTIKI_CPU=$(CONTIKI)/arch/cpu/cc2538
|
||||
include $(CONTIKI_CPU)/Makefile.cc2538
|
||||
|
||||
MODULES += arch/dev/cc1200 os/storage/cfs
|
||||
MODULES += arch/dev/cc1200 arch/dev/rgb-led os/storage/cfs
|
||||
|
||||
BSL = $(CONTIKI)/tools/cc2538-bsl/cc2538-bsl.py
|
||||
|
||||
|
@ -1,17 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Zolertia - http://www.zolertia.com
|
||||
* Copyright (c) 2015, University of Bristol - http://www.bristol.ac.uk
|
||||
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
|
||||
* 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.
|
||||
@ -29,45 +28,27 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**
|
||||
* \addtogroup zoul
|
||||
* @{
|
||||
*
|
||||
* \defgroup zoul-leds Zoul LED driver
|
||||
*
|
||||
* LED driver implementation for the Zoul-based platforms
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* LED driver implementation for the Zoul-based platforms
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "reg.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/gpio.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define LEDS_GPIO_PIN_MASK LEDS_ALL
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_init(void)
|
||||
{
|
||||
GPIO_SET_OUTPUT(GPIO_D_BASE, LEDS_GPIO_PIN_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
leds_arch_get(void)
|
||||
{
|
||||
return GPIO_READ_PIN(GPIO_D_BASE, LEDS_GPIO_PIN_MASK);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_arch_set(unsigned char leds)
|
||||
{
|
||||
GPIO_WRITE_PIN(GPIO_D_BASE, LEDS_GPIO_PIN_MASK, leds);
|
||||
}
|
||||
const leds_t leds_arch_leds[] = {
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L1_PORT, LEDS_ARCH_L1_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L2_PORT, LEDS_ARCH_L2_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PORT_PIN_TO_GPIO_HAL_PIN(LEDS_ARCH_L3_PORT, LEDS_ARCH_L3_PIN),
|
||||
.negative_logic = false
|
||||
},
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
MOTELIST_ZOLERTIA = firefly
|
||||
BOARD_SOURCEFILES += board.c leds-arch.c
|
||||
BOARD_SOURCEFILES += board.c
|
||||
|
@ -98,29 +98,18 @@
|
||||
* @{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */
|
||||
#define LEDS_GREEN_PIN 4
|
||||
#define LEDS_GREEN (1 << LEDS_GREEN_PIN) /**< LED1 (Green) -> PD4 */
|
||||
#define LEDS_ARCH_L1_PORT GPIO_D_NUM
|
||||
#define LEDS_ARCH_L1_PIN 5
|
||||
#define LEDS_ARCH_L2_PORT GPIO_D_NUM
|
||||
#define LEDS_ARCH_L2_PIN 4
|
||||
#define LEDS_ARCH_L3_PORT GPIO_D_NUM
|
||||
#define LEDS_ARCH_L3_PIN 3
|
||||
|
||||
#define LEDS_BLUE_PIN 3
|
||||
#define LEDS_BLUE (1 << LEDS_BLUE_PIN) /**< LED2 (Blue) -> PD3 */
|
||||
#define LEDS_CONF_RED 1
|
||||
#define LEDS_CONF_GREEN 2
|
||||
#define LEDS_CONF_BLUE 4
|
||||
|
||||
#define LEDS_RED_PIN 5
|
||||
#define LEDS_RED (1 << LEDS_RED_PIN) /**< LED3 (Red) -> PD5 */
|
||||
|
||||
#define LEDS_GREEN_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_BLUE_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_RED_PORT_BASE GPIO_D_BASE
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED)
|
||||
|
||||
#define LEDS_LIGHT_BLUE (LEDS_GREEN | LEDS_BLUE) /**< Green + Blue (24) */
|
||||
#define LEDS_YELLOW (LEDS_GREEN | LEDS_RED) /**< Green + Red (48) */
|
||||
#define LEDS_PURPLE (LEDS_BLUE | LEDS_RED) /**< Blue + Red (40) */
|
||||
#define LEDS_WHITE LEDS_ALL /**< Green + Blue + Red (56) */
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_COUNT 3
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name USB configuration
|
||||
|
@ -1,2 +1,2 @@
|
||||
MOTELIST_ZOLERTIA = firefly
|
||||
BOARD_SOURCEFILES += board.c leds-arch.c
|
||||
BOARD_SOURCEFILES += board.c
|
||||
|
@ -98,29 +98,18 @@
|
||||
* @{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */
|
||||
#define LEDS_GREEN_PIN 4
|
||||
#define LEDS_GREEN (1 << LEDS_GREEN_PIN) /**< LED1 (Green) -> PD4 */
|
||||
#define LEDS_ARCH_L1_PORT GPIO_D_NUM
|
||||
#define LEDS_ARCH_L1_PIN 5
|
||||
#define LEDS_ARCH_L2_PORT GPIO_D_NUM
|
||||
#define LEDS_ARCH_L2_PIN 4
|
||||
#define LEDS_ARCH_L3_PORT GPIO_D_NUM
|
||||
#define LEDS_ARCH_L3_PIN 3
|
||||
|
||||
#define LEDS_BLUE_PIN 3
|
||||
#define LEDS_BLUE (1 << LEDS_BLUE_PIN) /**< LED2 (Blue) -> PD3 */
|
||||
#define LEDS_CONF_RED 1
|
||||
#define LEDS_CONF_GREEN 2
|
||||
#define LEDS_CONF_BLUE 4
|
||||
|
||||
#define LEDS_RED_PIN 5
|
||||
#define LEDS_RED (1 << LEDS_RED_PIN) /**< LED3 (Red) -> PD5 */
|
||||
|
||||
#define LEDS_GREEN_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_BLUE_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_RED_PORT_BASE GPIO_D_BASE
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED)
|
||||
|
||||
#define LEDS_LIGHT_BLUE (LEDS_GREEN | LEDS_BLUE) /**< Green + Blue (24) */
|
||||
#define LEDS_YELLOW (LEDS_GREEN | LEDS_RED) /**< Green + Red (48) */
|
||||
#define LEDS_PURPLE (LEDS_BLUE | LEDS_RED) /**< Blue + Red (40) */
|
||||
#define LEDS_WHITE LEDS_ALL /**< Green + Blue + Red (56) */
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_COUNT 3
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name USB configuration
|
||||
|
@ -3,4 +3,4 @@ MODULES += arch/dev/enc28j60
|
||||
CC2538_ENC28J60_ARCH ?= gpio
|
||||
WITH_IP64 ?= 1
|
||||
CFLAGS += -DUIP_FALLBACK_INTERFACE=ip64_uip_fallback_interface
|
||||
BOARD_SOURCEFILES += board.c enc28j60-arch-$(CC2538_ENC28J60_ARCH).c leds-arch.c
|
||||
BOARD_SOURCEFILES += board.c enc28j60-arch-$(CC2538_ENC28J60_ARCH).c
|
||||
|
@ -67,29 +67,18 @@
|
||||
* @{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */
|
||||
#define LEDS_GREEN_PIN 4
|
||||
#define LEDS_GREEN (1 << LEDS_GREEN_PIN) /**< LED1 (Green) -> PD4 */
|
||||
#define LEDS_ARCH_L1_PORT GPIO_D_NUM
|
||||
#define LEDS_ARCH_L1_PIN 5
|
||||
#define LEDS_ARCH_L2_PORT GPIO_D_NUM
|
||||
#define LEDS_ARCH_L2_PIN 4
|
||||
#define LEDS_ARCH_L3_PORT GPIO_D_NUM
|
||||
#define LEDS_ARCH_L3_PIN 3
|
||||
|
||||
#define LEDS_BLUE_PIN 3
|
||||
#define LEDS_BLUE (1 << LEDS_BLUE_PIN) /**< LED2 (Blue) -> PD3 */
|
||||
#define LEDS_CONF_RED 1
|
||||
#define LEDS_CONF_GREEN 2
|
||||
#define LEDS_CONF_BLUE 4
|
||||
|
||||
#define LEDS_RED_PIN 5
|
||||
#define LEDS_RED (1 << LEDS_RED_PIN) /**< LED3 (Red) -> PD5 */
|
||||
|
||||
#define LEDS_GREEN_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_BLUE_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_RED_PORT_BASE GPIO_D_BASE
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED)
|
||||
|
||||
#define LEDS_LIGHT_BLUE (LEDS_GREEN | LEDS_BLUE) /**< Green + Blue (24) */
|
||||
#define LEDS_YELLOW (LEDS_GREEN | LEDS_RED) /**< Green + Red (48) */
|
||||
#define LEDS_PURPLE (LEDS_BLUE | LEDS_RED) /**< Blue + Red (40) */
|
||||
#define LEDS_WHITE LEDS_ALL /**< Green + Blue + Red (56) */
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_COUNT 3
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name USB configuration
|
||||
|
@ -69,6 +69,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
@ -81,7 +82,7 @@
|
||||
void board_init(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
fade(unsigned char l)
|
||||
fade(leds_mask_t l)
|
||||
{
|
||||
volatile int i;
|
||||
int k, j;
|
||||
@ -124,7 +125,7 @@ rtc_init(void)
|
||||
*/
|
||||
|
||||
/* Get the system date in the following format: wd dd mm yy hh mm ss */
|
||||
PRINTF("Setting RTC from system date: %s\n", DATE);
|
||||
LOG_INFO("Setting RTC from system date: %s\n", DATE);
|
||||
|
||||
/* Configure the RTC with the current values */
|
||||
td.weekdays = (uint8_t)strtol(DATE, &next, 10);
|
||||
@ -149,7 +150,7 @@ rtc_init(void)
|
||||
|
||||
/* Set the time and date */
|
||||
if(rtcc_set_time_date(&td) == AB08_ERROR) {
|
||||
PRINTF("Failed to set time and date\n");
|
||||
LOG_ERR("Failed to set time and date\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
MOTELIST_ZOLERTIA = remote
|
||||
BOARD_SOURCEFILES += board.c antenna-sw.c mmc-arch.c rtcc.c power-mgmt.c leds-arch.c
|
||||
BOARD_SOURCEFILES += board.c antenna-sw.c mmc-arch.c rtcc.c power-mgmt.c
|
||||
|
||||
MODULES += os/lib/fs/fat os/lib/fs/fat/option arch/platform/zoul/fs/fat arch/dev/disk/mmc
|
||||
|
@ -102,29 +102,18 @@
|
||||
* @{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* In leds.h the LEDS_BLUE is defined by LED_YELLOW definition */
|
||||
#define LEDS_GREEN_PIN 4
|
||||
#define LEDS_GREEN (1 << LEDS_GREEN_PIN) /**< LED1 (Green) -> PD4 */
|
||||
#define LEDS_ARCH_L1_PORT GPIO_D_NUM
|
||||
#define LEDS_ARCH_L1_PIN 5
|
||||
#define LEDS_ARCH_L2_PORT GPIO_D_NUM
|
||||
#define LEDS_ARCH_L2_PIN 4
|
||||
#define LEDS_ARCH_L3_PORT GPIO_D_NUM
|
||||
#define LEDS_ARCH_L3_PIN 3
|
||||
|
||||
#define LEDS_BLUE_PIN 3
|
||||
#define LEDS_BLUE (1 << LEDS_BLUE_PIN) /**< LED2 (Blue) -> PD3 */
|
||||
#define LEDS_CONF_RED 1
|
||||
#define LEDS_CONF_GREEN 2
|
||||
#define LEDS_CONF_BLUE 4
|
||||
|
||||
#define LEDS_RED_PIN 5
|
||||
#define LEDS_RED (1 << LEDS_RED_PIN) /**< LED3 (Red) -> PD5 */
|
||||
|
||||
#define LEDS_GREEN_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_BLUE_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_RED_PORT_BASE GPIO_D_BASE
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED)
|
||||
|
||||
#define LEDS_LIGHT_BLUE (LEDS_GREEN | LEDS_BLUE) /**< Green + Blue (24) */
|
||||
#define LEDS_YELLOW (LEDS_GREEN | LEDS_RED) /**< Green + Red (48) */
|
||||
#define LEDS_PURPLE (LEDS_BLUE | LEDS_RED) /**< Blue + Red (40) */
|
||||
#define LEDS_WHITE LEDS_ALL /**< Green + Blue + Red (56) */
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_COUNT 3
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name USB configuration
|
||||
|
@ -1,4 +1,4 @@
|
||||
MOTELIST_ZOLERTIA = remote
|
||||
BOARD_SOURCEFILES += board.c antenna-sw.c mmc-arch.c rtcc.c leds-res-arch.c power-mgmt.c
|
||||
BOARD_SOURCEFILES += board.c antenna-sw.c mmc-arch.c rtcc.c power-mgmt.c
|
||||
|
||||
MODULES += os/lib/fs/fat os/lib/fs/fat/option arch/platform/zoul/fs/fat arch/dev/disk/mmc
|
||||
|
@ -105,29 +105,18 @@
|
||||
* @{
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define LEDS_RED 1 /**< LED1 (Red) -> PD4 */
|
||||
#define LEDS_RED_PIN 4
|
||||
#define LEDS_RED_PIN_MASK (1 << LEDS_RED_PIN)
|
||||
#define LEDS_RED_PORT_BASE GPIO_D_BASE
|
||||
#define LEDS_ARCH_L1_PORT GPIO_D_NUM
|
||||
#define LEDS_ARCH_L1_PIN 4
|
||||
#define LEDS_ARCH_L2_PORT GPIO_B_NUM
|
||||
#define LEDS_ARCH_L2_PIN 7
|
||||
#define LEDS_ARCH_L3_PORT GPIO_B_NUM
|
||||
#define LEDS_ARCH_L3_PIN 6
|
||||
|
||||
#define LEDS_GREEN 2 /**< LED2 (Green) -> PB7 */
|
||||
#define LEDS_GREEN_PIN 7
|
||||
#define LEDS_GREEN_PIN_MASK (1 << LEDS_GREEN_PIN)
|
||||
#define LEDS_GREEN_PORT_BASE GPIO_B_BASE
|
||||
#define LEDS_CONF_RED 1
|
||||
#define LEDS_CONF_GREEN 2
|
||||
#define LEDS_CONF_BLUE 4
|
||||
|
||||
#define LEDS_BLUE 4 /**< LED3 (Blue) -> PB6 */
|
||||
#define LEDS_BLUE_PIN 6
|
||||
#define LEDS_BLUE_PIN_MASK (1 << LEDS_BLUE_PIN)
|
||||
#define LEDS_BLUE_PORT_BASE GPIO_B_BASE
|
||||
|
||||
#define LEDS_CONF_ALL (LEDS_GREEN | LEDS_BLUE | LEDS_RED) /* 7 */
|
||||
#define LEDS_LIGHT_BLUE (LEDS_GREEN | LEDS_BLUE) /* 6 */
|
||||
#define LEDS_YELLOW (LEDS_GREEN | LEDS_RED) /* 3 */
|
||||
#define LEDS_PURPLE (LEDS_BLUE | LEDS_RED) /* 5 */
|
||||
#define LEDS_WHITE LEDS_ALL /* 7 */
|
||||
|
||||
/* Notify various examples that we have LEDs */
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
#define LEDS_CONF_COUNT 3
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name USB configuration
|
||||
|
@ -30,11 +30,13 @@
|
||||
|
||||
#include <contiki.h>
|
||||
#include <lib/assert.h>
|
||||
#include <sys/node-id.h>
|
||||
#include <net/mac/tsch/tsch.h>
|
||||
#include <net/mac/tsch/tsch-queue.h>
|
||||
#include <net/mac/tsch/sixtop/sixtop.h>
|
||||
|
||||
/* Hard-coded MAC address of the TSCH coordinator */
|
||||
static linkaddr_t coordinator_addr = {{ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }};
|
||||
|
||||
extern const sixtop_sf_t test_sf;
|
||||
extern int test_sf_start(const linkaddr_t *addr);
|
||||
|
||||
@ -49,7 +51,7 @@ PROCESS_THREAD(sixp_node_process, ev, data)
|
||||
|
||||
sixtop_add_sf(&test_sf);
|
||||
|
||||
if(node_id == COORDINATOR_NODE_ID) {
|
||||
if(linkaddr_cmp(&coordinator_addr, &linkaddr_node_addr)) {
|
||||
tsch_set_coordinator(1);
|
||||
assert(test_sf_start(NULL) == 0);
|
||||
} else {
|
||||
|
@ -37,12 +37,13 @@
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#if PLATFORM_HAS_LEDS
|
||||
#include <string.h>
|
||||
#include "coap-engine.h"
|
||||
#include "dev/leds.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if PLATFORM_HAS_LEDS || LEDS_COUNT
|
||||
|
||||
#define DEBUG 0
|
||||
#if DEBUG
|
||||
#include <stdio.h>
|
||||
|
@ -37,14 +37,13 @@
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#if PLATFORM_HAS_LEDS
|
||||
|
||||
#include <string.h>
|
||||
#include "contiki.h"
|
||||
#include "coap-engine.h"
|
||||
#include "dev/leds.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if PLATFORM_HAS_LEDS || LEDS_COUNT
|
||||
|
||||
static void res_post_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);
|
||||
|
||||
/* A simple actuator example. Toggles the red led */
|
||||
|
@ -32,11 +32,9 @@
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define BASE_TO_PORT_NUM(base) (((base) - GPIO_A_BASE) >> 12)
|
||||
|
||||
gpio_hal_pin_t out_pin1 = (BASE_TO_PORT_NUM(LEDS_GREEN_PORT_BASE) << 3) + LEDS_GREEN_PIN;
|
||||
gpio_hal_pin_t out_pin2 = (BASE_TO_PORT_NUM(LEDS_BLUE_PORT_BASE) << 3) + LEDS_BLUE_PIN;
|
||||
gpio_hal_pin_t out_pin3 = (BASE_TO_PORT_NUM(LEDS_RED_PORT_BASE) << 3) + LEDS_RED_PIN;
|
||||
gpio_hal_pin_t out_pin1 = (LEDS_ARCH_L1_PORT << 3) + LEDS_ARCH_L1_PIN;
|
||||
gpio_hal_pin_t out_pin2 = (LEDS_ARCH_L2_PORT << 3) + LEDS_ARCH_L2_PIN;
|
||||
gpio_hal_pin_t out_pin3 = (LEDS_ARCH_L3_PORT << 3) + LEDS_ARCH_L3_PIN;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
gpio_hal_pin_t btn_pin = (BUTTON_USER_PORT << 3) + BUTTON_USER_PIN;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
8
examples/dev/leds/Makefile
Normal file
8
examples/dev/leds/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
CONTIKI_PROJECT = leds-example
|
||||
CONTIKI = ../../..
|
||||
|
||||
MODULES_REL += $(TARGET)
|
||||
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
include $(CONTIKI)/Makefile.include
|
15
examples/dev/leds/README.md
Normal file
15
examples/dev/leds/README.md
Normal file
@ -0,0 +1,15 @@
|
||||
# LED HAL Example
|
||||
This example demonstrates and tests the functionality of the LED HAL. You can
|
||||
use it to:
|
||||
|
||||
* Understand the logic of the LED HAL.
|
||||
* Test your implementation of arch-specific LED HAL components if you are
|
||||
developing a new port.
|
||||
|
||||
This example assumes a device with at least 1 LED.
|
||||
|
||||
# Supported devices
|
||||
This example is expected to work off-the-shelf on the following boards:
|
||||
|
||||
* All CC13xx/CC26xx devices
|
||||
* All CC2538 devices
|
82
examples/dev/leds/leds-example.c
Normal file
82
examples/dev/leds/leds-example.c
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/leds.h"
|
||||
#include "sys/etimer.h"
|
||||
|
||||
#include <stdio.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static struct etimer et;
|
||||
static uint8_t counter;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(leds_example, "LED HAL Example");
|
||||
AUTOSTART_PROCESSES(&leds_example);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(leds_example, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
counter = 0;
|
||||
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
|
||||
while(1) {
|
||||
|
||||
PROCESS_YIELD();
|
||||
|
||||
if(ev == PROCESS_EVENT_TIMER && data == &et) {
|
||||
if((counter & 7) == 0) {
|
||||
leds_set(LEDS_ALL);
|
||||
} else if((counter & 7) == 1) {
|
||||
leds_off(LEDS_ALL);
|
||||
} else if((counter & 7) == 2) {
|
||||
leds_on(LEDS_ALL);
|
||||
} else if((counter & 7) == 3) {
|
||||
leds_toggle(LEDS_ALL);
|
||||
} else if((counter & 7) == 4) {
|
||||
leds_single_on(LEDS_LED1);
|
||||
} else if((counter & 7) == 5) {
|
||||
leds_single_off(LEDS_LED1);
|
||||
} else if((counter & 7) == 6) {
|
||||
leds_single_toggle(LEDS_LED1);
|
||||
} else if((counter & 7) == 7) {
|
||||
leds_toggle(LEDS_ALL);
|
||||
}
|
||||
|
||||
counter++;
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
8
examples/dev/rgb-led/Makefile
Normal file
8
examples/dev/rgb-led/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
CONTIKI_PROJECT = rgb-led-example
|
||||
CONTIKI = ../../..
|
||||
|
||||
MODULES_REL += $(TARGET)
|
||||
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
include $(CONTIKI)/Makefile.include
|
1
examples/dev/rgb-led/Makefile.target
Normal file
1
examples/dev/rgb-led/Makefile.target
Normal file
@ -0,0 +1 @@
|
||||
TARGET = zoul
|
14
examples/dev/rgb-led/README.md
Normal file
14
examples/dev/rgb-led/README.md
Normal file
@ -0,0 +1,14 @@
|
||||
# RGB LED Example
|
||||
This example demonstrates and tests the functionality of the RGB LED driver.
|
||||
You can use it to:
|
||||
|
||||
* Understand the logic of the RGB LED driver.
|
||||
* Test your implementation if you are developing a new port for a device that
|
||||
features this part.
|
||||
|
||||
This example assumes a device with an RGB LED.
|
||||
|
||||
# Supported devices
|
||||
This example is expected to work off-the-shelf on the following boards:
|
||||
|
||||
* All Zoul-based devices
|
82
examples/dev/rgb-led/rgb-led-example.c
Normal file
82
examples/dev/rgb-led/rgb-led-example.c
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2017, George Oikonomou - http://www.spd.gr
|
||||
* 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.
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/rgb-led/rgb-led.h"
|
||||
#include "sys/etimer.h"
|
||||
|
||||
#include <stdio.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static struct etimer et;
|
||||
static uint8_t counter;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(rgb_led_example, "RGB LED Example");
|
||||
AUTOSTART_PROCESSES(&rgb_led_example);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(rgb_led_example, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
counter = 0;
|
||||
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
|
||||
while(1) {
|
||||
|
||||
PROCESS_YIELD();
|
||||
|
||||
if(ev == PROCESS_EVENT_TIMER && data == &et) {
|
||||
if((counter & 7) == 0) {
|
||||
rgb_led_off();
|
||||
} else if((counter & 7) == 1) {
|
||||
rgb_led_set(RGB_LED_RED);
|
||||
} else if((counter & 7) == 2) {
|
||||
rgb_led_set(RGB_LED_GREEN);
|
||||
} else if((counter & 7) == 3) {
|
||||
rgb_led_set(RGB_LED_BLUE);
|
||||
} else if((counter & 7) == 4) {
|
||||
rgb_led_set(RGB_LED_CYAN);
|
||||
} else if((counter & 7) == 5) {
|
||||
rgb_led_set(RGB_LED_MAGENTA);
|
||||
} else if((counter & 7) == 6) {
|
||||
rgb_led_set(RGB_LED_YELLOW);
|
||||
} else if((counter & 7) == 7) {
|
||||
rgb_led_set(RGB_LED_WHITE);
|
||||
}
|
||||
|
||||
counter++;
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
@ -37,6 +37,7 @@
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "dev/leds.h"
|
||||
#include "services/lwm2m/lwm2m-engine.h"
|
||||
#include "services/lwm2m/lwm2m-rd-client.h"
|
||||
#include "services/lwm2m/lwm2m-device.h"
|
||||
@ -45,6 +46,7 @@
|
||||
#include "services/ipso-objects/ipso-objects.h"
|
||||
#include "services/ipso-objects/ipso-sensor-template.h"
|
||||
#include "services/ipso-objects/ipso-control-template.h"
|
||||
#include "dev/leds.h"
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ipv6/uip-debug.h"
|
||||
@ -97,9 +99,9 @@ static lwm2m_status_t
|
||||
leds_set_val(ipso_control_t *control, uint8_t value)
|
||||
{
|
||||
if(value > 0) {
|
||||
leds_on(LEDS_YELLOW);
|
||||
leds_single_on(LEDS_LED1);
|
||||
} else {
|
||||
leds_off(LEDS_YELLOW);
|
||||
leds_single_off(LEDS_LED1);
|
||||
}
|
||||
return LWM2M_STATUS_OK;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "net/netstack.h"
|
||||
#include "net/ipv6/simple-udp.h"
|
||||
#include "net/ipv6/uipbuf.h"
|
||||
#include "net/ipv6/uip-ds6.h"
|
||||
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "App"
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "contiki-net.h"
|
||||
|
||||
#include "lib/trickle-timer.h"
|
||||
#include "dev/leds.h"
|
||||
#include "lib/random.h"
|
||||
|
||||
#include <string.h>
|
||||
@ -80,7 +79,6 @@ AUTOSTART_PROCESSES(&trickle_protocol_process);
|
||||
static void
|
||||
tcpip_handler(void)
|
||||
{
|
||||
leds_on(LEDS_GREEN);
|
||||
if(uip_newdata()) {
|
||||
PRINTF("At %lu (I=%lu, c=%u): ",
|
||||
(unsigned long)clock_time(), (unsigned long)tt.i_cur, tt.c);
|
||||
@ -109,7 +107,6 @@ tcpip_handler(void)
|
||||
tt.ct.etimer.timer.interval));
|
||||
}
|
||||
}
|
||||
leds_off(LEDS_GREEN);
|
||||
return;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -126,8 +123,6 @@ trickle_tx(void *ptr, uint8_t suppress)
|
||||
return;
|
||||
}
|
||||
|
||||
leds_on(LEDS_RED);
|
||||
|
||||
PRINTF("At %lu (I=%lu, c=%u): ",
|
||||
(unsigned long)clock_time(), (unsigned long)loc_tt->i_cur,
|
||||
loc_tt->c);
|
||||
@ -144,8 +139,6 @@ trickle_tx(void *ptr, uint8_t suppress)
|
||||
|
||||
/* Restore to 'accept incoming from any IP' */
|
||||
uip_create_unspecified(&trickle_conn->ripaddr);
|
||||
|
||||
leds_off(LEDS_RED);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(trickle_protocol_process, ev, data)
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "dev/cc2538-sensors.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* IBM server: messaging.quickstart.internetofthings.ibmcloud.com
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "dev/leds.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* IBM server: quickstart.messaging.internetofthings.ibmcloud.com
|
||||
|
@ -3,7 +3,7 @@ CONTIKI_PROJECT += test-bmp085-bmp180 test-motion test-rotation-sensor
|
||||
CONTIKI_PROJECT += test-grove-light-sensor test-grove-loudness-sensor
|
||||
CONTIKI_PROJECT += test-weather-meter test-grove-gyro test-lcd test-iaq
|
||||
CONTIKI_PROJECT += test-pm10-sensor test-vac-sensor test-aac-sensor
|
||||
CONTIKI_PROJECT += test-zonik test-dht22.c test-ac-dimmer.c test-servo.c
|
||||
CONTIKI_PROJECT += test-zonik test-dht22.c test-ac-dimmer.c
|
||||
CONTIKI_PROJECT += test-bme280
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES += tsl256x.c sht25.c bmpx8x.c motion-sensor.c
|
||||
|
@ -2,5 +2,5 @@ CONTIKI_PROJECT = at-master-test
|
||||
MODULES = os/services/at-master
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
CONTIKI = ../../..
|
||||
CONTIKI = ../../../..
|
||||
include $(CONTIKI)/Makefile.include
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include "dev/ioc.h"
|
||||
#include "lib/list.h"
|
||||
#include "dev/sha256.h"
|
||||
#include "net/linkaddr.h"
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1 +1,2 @@
|
||||
TARGET = zoul
|
||||
BOARD = orion
|
||||
|
@ -1 +1,2 @@
|
||||
TARGET = zoul
|
||||
BOARD = remote-revb
|
||||
|
@ -136,7 +136,7 @@ PROCESS_THREAD(test_remote_pm, ev, data)
|
||||
printf("PM: Soft shutdown, timeout set to %lu\n", pm_get_timeout());
|
||||
|
||||
leds_off(LEDS_ALL);
|
||||
leds_on(LEDS_PURPLE);
|
||||
leds_on(LEDS_RED);
|
||||
|
||||
/* Wait just enough to be able to check the LED result */
|
||||
etimer_set(&et, CLOCK_SECOND * 3);
|
||||
|
@ -65,7 +65,7 @@ gyro_interrupt_callback(uint8_t status)
|
||||
* returns the outcome of the read operation, check to validate if the
|
||||
* data is valid to read
|
||||
*/
|
||||
leds_toggle(LEDS_PURPLE);
|
||||
leds_toggle(LEDS_RED);
|
||||
|
||||
printf("Gyro: X_axis %u, Y_axis %u, Z_axis %u\n", gyro_values.x,
|
||||
gyro_values.y,
|
||||
|
@ -63,7 +63,7 @@ void
|
||||
light_interrupt_callback(uint8_t value)
|
||||
{
|
||||
printf("* Light sensor interrupt!\n");
|
||||
leds_toggle(LEDS_PURPLE);
|
||||
leds_toggle(LEDS_RED);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(remote_tsl256x_process, ev, data)
|
||||
|
187
os/dev/leds.c
187
os/dev/leds.c
@ -1,38 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Swedish Institute of Computer Science
|
||||
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
|
||||
* 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.
|
||||
* 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 leds
|
||||
* @{
|
||||
*
|
||||
* \file
|
||||
* Implementation of the platform-independent aspects of the LED HAL
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "dev/leds.h"
|
||||
#include "sys/clock.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if LEDS_LEGACY_API
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_init(void)
|
||||
@ -59,26 +72,154 @@ leds_get(void) {
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_set(unsigned char ledv)
|
||||
leds_set(leds_mask_t ledv)
|
||||
{
|
||||
leds_arch_set(ledv);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_on(unsigned char ledv)
|
||||
leds_on(leds_mask_t ledv)
|
||||
{
|
||||
leds_arch_set(leds_arch_get() | ledv);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_off(unsigned char ledv)
|
||||
leds_off(leds_mask_t ledv)
|
||||
{
|
||||
leds_arch_set(leds_arch_get() & ~ledv);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_toggle(unsigned char ledv)
|
||||
leds_toggle(leds_mask_t ledv)
|
||||
{
|
||||
leds_arch_set(leds_arch_get() ^ ledv);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#else /* LEDS_LEGACY_API */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
extern const leds_t leds_arch_leds[];
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_init()
|
||||
{
|
||||
leds_num_t led;
|
||||
|
||||
for(led = 0; led < LEDS_COUNT; led++) {
|
||||
gpio_hal_arch_pin_set_output(leds_arch_leds[led].pin);
|
||||
}
|
||||
leds_off(LEDS_ALL);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_single_on(leds_num_t led)
|
||||
{
|
||||
if(led >= LEDS_COUNT) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(leds_arch_leds[led].negative_logic) {
|
||||
gpio_hal_arch_clear_pin(leds_arch_leds[led].pin);
|
||||
} else {
|
||||
gpio_hal_arch_set_pin(leds_arch_leds[led].pin);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_single_off(leds_num_t led)
|
||||
{
|
||||
if(led >= LEDS_COUNT) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(leds_arch_leds[led].negative_logic) {
|
||||
gpio_hal_arch_set_pin(leds_arch_leds[led].pin);
|
||||
} else {
|
||||
gpio_hal_arch_clear_pin(leds_arch_leds[led].pin);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_single_toggle(leds_num_t led)
|
||||
{
|
||||
if(led >= LEDS_COUNT) {
|
||||
return;
|
||||
}
|
||||
|
||||
gpio_hal_arch_toggle_pin(leds_arch_leds[led].pin);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_on(leds_mask_t leds)
|
||||
{
|
||||
leds_num_t led;
|
||||
|
||||
for(led = 0; led < LEDS_COUNT; led++) {
|
||||
if((1 << led) & leds) {
|
||||
if(leds_arch_leds[led].negative_logic) {
|
||||
gpio_hal_arch_clear_pin(leds_arch_leds[led].pin);
|
||||
} else {
|
||||
gpio_hal_arch_set_pin(leds_arch_leds[led].pin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_off(leds_mask_t leds)
|
||||
{
|
||||
leds_num_t led;
|
||||
|
||||
for(led = 0; led < LEDS_COUNT; led++) {
|
||||
if((1 << led) & leds) {
|
||||
if(leds_arch_leds[led].negative_logic) {
|
||||
gpio_hal_arch_set_pin(leds_arch_leds[led].pin);
|
||||
} else {
|
||||
gpio_hal_arch_clear_pin(leds_arch_leds[led].pin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_toggle(leds_mask_t leds)
|
||||
{
|
||||
leds_num_t led;
|
||||
|
||||
for(led = 0; led < LEDS_COUNT; led++) {
|
||||
if((1 << led) & leds) {
|
||||
gpio_hal_arch_toggle_pin(leds_arch_leds[led].pin);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
leds_set(leds_mask_t leds)
|
||||
{
|
||||
leds_off(LEDS_ALL);
|
||||
leds_on(leds);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
leds_mask_t
|
||||
leds_get()
|
||||
{
|
||||
leds_mask_t rv = 0;
|
||||
leds_num_t led;
|
||||
uint8_t pin_state;
|
||||
|
||||
for(led = 0; led < LEDS_COUNT; led++) {
|
||||
pin_state = gpio_hal_arch_read_pin(leds_arch_leds[led].pin);
|
||||
|
||||
if((leds_arch_leds[led].negative_logic == false && pin_state == 1) ||
|
||||
(leds_arch_leds[led].negative_logic == true && pin_state == 0)) {
|
||||
rv |= 1 << led;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* LEDS_LEGACY_API */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
349
os/dev/leds.h
349
os/dev/leds.h
@ -1,98 +1,329 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Swedish Institute of Computer Science
|
||||
* Copyright (c) 2018, George Oikonomou - http://www.spd.gr
|
||||
* 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.
|
||||
* 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 dev
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \defgroup leds LEDs API
|
||||
* \defgroup leds LED Hardware Abstraction Layer
|
||||
*
|
||||
* The LEDs API defines a set of functions for accessing LEDs for
|
||||
* Contiki plaforms with LEDs.
|
||||
* The LED HAL provides a set of functions that can manipulate LEDS.
|
||||
*
|
||||
* A platform with LED support must implement this API.
|
||||
* Currently, the LED HAL supports two APIs:
|
||||
*
|
||||
* - The new, platform-independent API (recommended for all new platforms).
|
||||
* - The legacy API (supported until all existing platforms have been ported
|
||||
* to support the new API).
|
||||
*
|
||||
* The two APIs use very similar semantics and have an overlapping set of
|
||||
* function calls. This is done so that platform-independent examples can
|
||||
* work on all platforms, irrespective of which API each platform supports.
|
||||
*
|
||||
* The legacy API can be enabled by the platform code by defining
|
||||
* LEDS_CONF_LEGACY_API 1.
|
||||
*
|
||||
* Once all platforms supported in contiki-ng/contiki-ng have been ported to
|
||||
* the new API, the legacy API will be deleted without warning. For this
|
||||
* reason, it is strongly recommended to use the new API for new platforms and
|
||||
* for platforms hosted in external repositories.
|
||||
*
|
||||
* The new API provides a set of common LED manipulation functions that can be
|
||||
* used in a platform-independent fashion. Functions exist to manipulate one
|
||||
* LED at a time (\c leds_single_XYZ), as well as to manipulate multiple LEDs
|
||||
* at a time (\c leds_XYZ).
|
||||
*
|
||||
* The assumption is that each LED is connected to a GPIO pin using either
|
||||
* positive or negative logic.
|
||||
*
|
||||
* LEDs on a device are numbered incrementally, starting from 0 and counting
|
||||
* upwards. Thus, if a device has 3 LEDs they will be numbered 0, 1 and 2.
|
||||
* Convenience macros (LEDS_LED_n) are provided to refer to LEDs. These macros
|
||||
* can be used as arguments to functions that manipulate a single LED, such
|
||||
* as leds_single_on() but \e not leds_on().
|
||||
*
|
||||
* The legacy scheme that uses colours to refer to LEDs is maintained, without
|
||||
* semantic changes, but with minor changes in logic:
|
||||
*
|
||||
* - Firstly, we now define 5 LED colours: Red, Green, Blue, Yellow, Orange.
|
||||
* These are sufficient to cover all currently-supported platforms.
|
||||
* - Secondly, unless a platform specifies that a LED of a specific colour
|
||||
* exists, the HAL will assume that it does not.
|
||||
* - Trying to manipulate a non-existent LED will not cause build errors, but
|
||||
* will not cause any changes to LED state either.
|
||||
* - We no longer map non-existing LED colours to existing ones.
|
||||
*
|
||||
* Note that, in order to avoid changes to LED colour semantics between the
|
||||
* two APIs, references to LED by colour are bitwise OR masks and should
|
||||
* therefore only be used as argument to functions that manipulate multiple
|
||||
* LEDS (e.g. leds_off() and \e not leds_single_off()).
|
||||
*
|
||||
* In terms of porting for new platforms, developers simply have to:
|
||||
*
|
||||
* - Define variables of type leds_t to represent their platform's LEDs
|
||||
* - Specify the number of LEDs on their device by defining LEDS_CONF_COUNT
|
||||
* - Map red colours to numbers (e.g. \#define LEDS_CONF_RED 1)
|
||||
*
|
||||
* \file
|
||||
* Header file for the LED HAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef LEDS_H_
|
||||
#define LEDS_H_
|
||||
|
||||
/* Allow platform to override LED numbering */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if LEDS_CONF_LEGACY_API
|
||||
/**
|
||||
* \brief Define to 1 to enabled the legacy LED API.
|
||||
*/
|
||||
#define LEDS_LEGACY_API LEDS_CONF_LEGACY_API
|
||||
#else
|
||||
#define LEDS_LEGACY_API 0
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief A default LED colour for non-existing LEDs
|
||||
*/
|
||||
#define LEDS_COLOUR_NONE 0x00
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* LED colour to number mappings. Applicable to both APIs */
|
||||
#ifdef LEDS_CONF_RED
|
||||
#define LEDS_RED LEDS_CONF_RED
|
||||
#else
|
||||
#define LEDS_RED LEDS_COLOUR_NONE
|
||||
#endif
|
||||
|
||||
#ifdef LEDS_CONF_GREEN
|
||||
#define LEDS_GREEN LEDS_CONF_GREEN
|
||||
#else
|
||||
#define LEDS_GREEN LEDS_COLOUR_NONE
|
||||
#endif
|
||||
|
||||
#ifdef LEDS_CONF_BLUE
|
||||
#define LEDS_BLUE LEDS_CONF_BLUE
|
||||
#else
|
||||
#define LEDS_BLUE LEDS_COLOUR_NONE
|
||||
#endif
|
||||
|
||||
#ifdef LEDS_CONF_YELLOW
|
||||
#define LEDS_YELLOW LEDS_CONF_YELLOW
|
||||
#else
|
||||
#define LEDS_YELLOW LEDS_COLOUR_NONE
|
||||
#endif
|
||||
|
||||
#ifdef LEDS_CONF_ORANGE
|
||||
#define LEDS_ORANGE LEDS_CONF_ORANGE
|
||||
#else
|
||||
#define LEDS_ORANGE LEDS_COLOUR_NONE
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief The LED number
|
||||
*/
|
||||
typedef uint8_t leds_num_t;
|
||||
|
||||
/**
|
||||
* \brief An OR mask datatype to represents multiple LEDs.
|
||||
*/
|
||||
typedef uint8_t leds_mask_t;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if LEDS_LEGACY_API
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifdef LEDS_CONF_ALL
|
||||
#define LEDS_ALL LEDS_CONF_ALL
|
||||
#else
|
||||
#define LEDS_ALL 7
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void leds_blink(void);
|
||||
|
||||
/* Legacy LED API arch-specific functions */
|
||||
void leds_arch_init(void);
|
||||
leds_mask_t leds_arch_get(void);
|
||||
void leds_arch_set(leds_mask_t leds);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#else /* LEDS_LEGACY_API */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifdef LEDS_CONF_COUNT
|
||||
#define LEDS_COUNT LEDS_CONF_COUNT
|
||||
#else
|
||||
/**
|
||||
* \brief The number of LEDs present on a device
|
||||
*/
|
||||
#define LEDS_COUNT 0
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief The OR mask representation of all device LEDs
|
||||
*/
|
||||
#define LEDS_ALL ((1 << LEDS_COUNT) - 1)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* LEDS_LEGACY_API */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define LEDS_LED1 0x00 /**< Convenience macro to refer to the 1st LED (LED 1) */
|
||||
#define LEDS_LED2 0x01 /**< Convenience macro to refer to the 2nd LED (LED 2) */
|
||||
#define LEDS_LED3 0x02 /**< Convenience macro to refer to the 3rd LED (LED 3) */
|
||||
#define LEDS_LED4 0x03 /**< Convenience macro to refer to the 4th LED (LED 4) */
|
||||
#define LEDS_LED5 0x04 /**< Convenience macro to refer to the 5th LED (LED 5) */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief A LED logical representation
|
||||
*
|
||||
* \e pin corresponds to the GPIO pin a LED is driven by, using GPIO HAL pin
|
||||
* representation.
|
||||
*
|
||||
* \e negative_logic should be set to false if the LED is active low.
|
||||
*/
|
||||
typedef struct leds_s {
|
||||
gpio_hal_pin_t pin;
|
||||
bool negative_logic;
|
||||
} leds_t;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Convert a LED number to a mask representation
|
||||
* \param l The pin number (normally a variable of type leds_num_t)
|
||||
* \return An OR mask of type leds_mask_t
|
||||
*/
|
||||
#define LEDS_NUM_TO_MASK(l) (1 << (l))
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Initialise the LED HAL
|
||||
*
|
||||
* This function will set corresponding LED GPIO pins to output and will also
|
||||
* set the initial state of all LEDs to off.
|
||||
*/
|
||||
void leds_init(void);
|
||||
|
||||
/**
|
||||
* Blink all LEDs.
|
||||
* \brief Turn a single LED on
|
||||
* \param led The led
|
||||
*
|
||||
* The \e led argument should be the LED's number, in other words one of the
|
||||
* LED_Ln macros.
|
||||
*
|
||||
* This function will not change the state of other LEDs.
|
||||
*/
|
||||
void leds_blink(void);
|
||||
|
||||
#ifndef LEDS_GREEN
|
||||
#define LEDS_GREEN 1
|
||||
#endif /* LEDS_GREEN */
|
||||
#ifndef LEDS_YELLOW
|
||||
#define LEDS_YELLOW 2
|
||||
#endif /* LEDS_YELLOW */
|
||||
#ifndef LEDS_RED
|
||||
#define LEDS_RED 4
|
||||
#endif /* LEDS_RED */
|
||||
#ifndef LEDS_BLUE
|
||||
#define LEDS_BLUE LEDS_YELLOW
|
||||
#endif /* LEDS_BLUE */
|
||||
|
||||
#ifdef LEDS_CONF_ALL
|
||||
#define LEDS_ALL LEDS_CONF_ALL
|
||||
#else /* LEDS_CONF_ALL */
|
||||
#define LEDS_ALL 7
|
||||
#endif /* LEDS_CONF_ALL */
|
||||
void leds_single_on(leds_num_t led);
|
||||
|
||||
/**
|
||||
* Returns the current status of all leds
|
||||
* \brief Turn a single LED off
|
||||
* \param led The led
|
||||
*
|
||||
* The \e led argument should be the LED's number, in other words one of the
|
||||
* LED_Ln macros.
|
||||
*
|
||||
* This function will not change the state of other LEDs.
|
||||
*/
|
||||
unsigned char leds_get(void);
|
||||
void leds_set(unsigned char leds);
|
||||
void leds_on(unsigned char leds);
|
||||
void leds_off(unsigned char leds);
|
||||
void leds_toggle(unsigned char leds);
|
||||
void leds_single_off(leds_num_t led);
|
||||
|
||||
/**
|
||||
* Leds implementation
|
||||
* \brief Toggle a single LED
|
||||
* \param led The led
|
||||
*
|
||||
* The \e led argument should be the LED's number, in other words one of the
|
||||
* LED_Ln macros.
|
||||
*
|
||||
* This function will not change the state of other LEDs.
|
||||
*/
|
||||
void leds_arch_init(void);
|
||||
unsigned char leds_arch_get(void);
|
||||
void leds_arch_set(unsigned char leds);
|
||||
void leds_single_toggle(leds_num_t led);
|
||||
|
||||
/**
|
||||
* \brief Turn on multiple LEDs
|
||||
* \param leds The leds to be turned on as an OR mask
|
||||
*
|
||||
* The \e led argument should be a bitwise mask of the LEDs to be changed.
|
||||
* For example, to turn on LEDs 1 and 3, you should pass
|
||||
* LED_NUM_TO_MASK(LED_L1) | LED_NUM_TO_MASK(LED_L3) = 1 | 4 = 5
|
||||
*
|
||||
* This function will not change the state of other LEDs.
|
||||
*/
|
||||
void leds_on(leds_mask_t leds);
|
||||
|
||||
/**
|
||||
* \brief Turn off multiple LEDs
|
||||
* \param leds The leds to be turned off as an OR mask
|
||||
*
|
||||
* The \e led argument should be a bitwise mask of the LEDs to be changed.
|
||||
* For example, to turn on LEDs 1 and 3, you should pass
|
||||
* LED_NUM_TO_MASK(LED_L1) | LED_NUM_TO_MASK(LED_L3) = 1 | 4 = 5
|
||||
*
|
||||
* This function will not change the state of other LEDs.
|
||||
*/
|
||||
void leds_off(leds_mask_t leds);
|
||||
|
||||
/**
|
||||
* \brief Toggle multiple LEDs
|
||||
* \param leds The leds to be toggled as an OR mask
|
||||
*
|
||||
* The \e led argument should be a bitwise mask of the LEDs to be changed.
|
||||
* For example, to turn on LEDs 1 and 3, you should pass
|
||||
* LED_NUM_TO_MASK(LED_L1) | LED_NUM_TO_MASK(LED_L3) = 1 | 4 = 5
|
||||
*
|
||||
* This function will not change the state of other LEDs.
|
||||
*/
|
||||
void leds_toggle(leds_mask_t leds);
|
||||
|
||||
/**
|
||||
* \brief Set all LEDs to a specific state
|
||||
* \param leds The state of all LEDs afer this function returns
|
||||
*
|
||||
* The \e led argument should be a bitwise mask of the LEDs to be changed.
|
||||
* For example, to turn on LEDs 1 and 3, you should pass
|
||||
* LED_NUM_TO_MASK(LED_L1) | LED_NUM_TO_MASK(LED_L3) = 1 | 4 = 5
|
||||
*
|
||||
* This function will change the state of all LEDs. LEDs not set in the \e leds
|
||||
* mask will be turned off.
|
||||
*/
|
||||
void leds_set(leds_mask_t leds);
|
||||
|
||||
/**
|
||||
* \brief Get the status of LEDs
|
||||
* \return A bitwise mask indicating whether each individual LED is on or off
|
||||
*
|
||||
* The return value is a bitwise mask. If a bit is set then the corresponding
|
||||
* LED is on.
|
||||
*/
|
||||
leds_mask_t leds_get(void);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* LEDS_H_ */
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
@ -32,6 +32,7 @@
|
||||
#define HTTP_SOCKET_H
|
||||
|
||||
#include "tcp-socket.h"
|
||||
#include "sys/cc.h"
|
||||
|
||||
struct http_socket;
|
||||
|
||||
@ -62,8 +63,6 @@ typedef void (* http_socket_callback_t)(struct http_socket *s,
|
||||
const uint8_t *data,
|
||||
uint16_t datalen);
|
||||
|
||||
#define MAX(n, m) (((n) < (m)) ? (m) : (n))
|
||||
|
||||
#define HTTP_SOCKET_INPUTBUFSIZE UIP_TCP_MSS
|
||||
#define HTTP_SOCKET_OUTPUTBUFSIZE MAX(UIP_TCP_MSS, 128)
|
||||
|
||||
|
@ -66,14 +66,14 @@
|
||||
#ifdef CSMA_CONF_MIN_BE
|
||||
#define CSMA_MIN_BE CSMA_CONF_MIN_BE
|
||||
#else
|
||||
#define CSMA_MIN_BE 0
|
||||
#define CSMA_MIN_BE 3
|
||||
#endif
|
||||
|
||||
/* macMaxBE: Maximum backoff exponent. Range 3--8 */
|
||||
#ifdef CSMA_CONF_MAX_BE
|
||||
#define CSMA_MAX_BE CSMA_CONF_MAX_BE
|
||||
#else
|
||||
#define CSMA_MAX_BE 4
|
||||
#define CSMA_MAX_BE 5
|
||||
#endif
|
||||
|
||||
/* macMaxCSMABackoffs: Maximum number of backoffs in case of channel busy/collision. Range 0--5 */
|
||||
@ -154,9 +154,15 @@ neighbor_queue_from_addr(const linkaddr_t *addr)
|
||||
static clock_time_t
|
||||
backoff_period(void)
|
||||
{
|
||||
#if CONTIKI_TARGET_COOJA
|
||||
/* Increase normal value by 20 to compensate for the coarse-grained
|
||||
radio medium with Cooja motes */
|
||||
return MAX(20 * CLOCK_SECOND / 3125, 1);
|
||||
#else /* CONTIKI_TARGET_COOJA */
|
||||
/* Use the default in IEEE 802.15.4: aUnitBackoffPeriod which is
|
||||
* 20 symbols i.e. 320 usec. That is, 1/3125 second. */
|
||||
return MAX(CLOCK_SECOND / 3125, 1);
|
||||
#endif /* CONTIKI_TARGET_COOJA */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int
|
||||
@ -281,7 +287,7 @@ schedule_transmission(struct neighbor_queue *n)
|
||||
clock_time_t delay;
|
||||
int backoff_exponent; /* BE in IEEE 802.15.4 */
|
||||
|
||||
backoff_exponent = MIN(n->collisions, CSMA_MAX_BE);
|
||||
backoff_exponent = MIN(n->collisions + CSMA_MIN_BE, CSMA_MAX_BE);
|
||||
|
||||
/* Compute max delay as per IEEE 802.15.4: 2^BE-1 backoff periods */
|
||||
delay = ((1 << backoff_exponent) - 1) * backoff_period();
|
||||
@ -310,7 +316,7 @@ free_packet(struct neighbor_queue *n, struct packet_queue *p, int status)
|
||||
if(list_head(n->packet_queue) != NULL) {
|
||||
/* There is a next packet. We reset current tx information */
|
||||
n->transmissions = 0;
|
||||
n->collisions = CSMA_MIN_BE;
|
||||
n->collisions = 0;
|
||||
/* Schedule next transmissions */
|
||||
schedule_transmission(n);
|
||||
} else {
|
||||
@ -365,7 +371,7 @@ collision(struct packet_queue *q, struct neighbor_queue *n,
|
||||
n->collisions += num_transmissions;
|
||||
|
||||
if(n->collisions > CSMA_MAX_BACKOFF) {
|
||||
n->collisions = CSMA_MIN_BE;
|
||||
n->collisions = 0;
|
||||
/* Increment to indicate a next retry */
|
||||
n->transmissions++;
|
||||
}
|
||||
@ -384,7 +390,7 @@ noack(struct packet_queue *q, struct neighbor_queue *n, int num_transmissions)
|
||||
|
||||
metadata = (struct qbuf_metadata *)q->ptr;
|
||||
|
||||
n->collisions = CSMA_MIN_BE;
|
||||
n->collisions = 0;
|
||||
n->transmissions += num_transmissions;
|
||||
|
||||
if(n->transmissions >= metadata->max_transmissions) {
|
||||
|
@ -85,10 +85,10 @@ tsch_log_process_pending(void)
|
||||
while((log_index = ringbufindex_peek_get(&log_ringbuf)) != -1) {
|
||||
struct tsch_log_t *log = &log_array[log_index];
|
||||
if(log->link == NULL) {
|
||||
printf("[INFO: TSCH-LOG ] {asn-%x.%lx link-NULL} ", log->asn.ms1b, log->asn.ls4b);
|
||||
printf("[INFO: TSCH-LOG ] {asn %02x.%08lx link-NULL} ", log->asn.ms1b, log->asn.ls4b);
|
||||
} else {
|
||||
struct tsch_slotframe *sf = tsch_schedule_get_slotframe_by_handle(log->link->slotframe_handle);
|
||||
printf("[INFO: TSCH-LOG ] {asn-%x.%lx link-%u-%u-%u-%u ch-%u} ",
|
||||
printf("[INFO: TSCH-LOG ] {asn %02x.%08lx link %2u %3u %3u %2u ch %2u} ",
|
||||
log->asn.ms1b, log->asn.ls4b,
|
||||
log->link->slotframe_handle, sf ? sf->size.val : 0, log->link->timeslot, log->link->channel_offset,
|
||||
tsch_calculate_channel(&log->asn, log->link->channel_offset));
|
||||
@ -100,10 +100,10 @@ tsch_log_process_pending(void)
|
||||
log_lladdr_compact(&linkaddr_node_addr);
|
||||
printf("->");
|
||||
log_lladdr_compact(&log->tx.dest);
|
||||
printf(", len %u, seq %u, st %d %d",
|
||||
printf(", len %3u, seq %3u, st %d %2d",
|
||||
log->tx.datalen, log->tx.seqno, log->tx.mac_tx_status, log->tx.num_tx);
|
||||
if(log->tx.drift_used) {
|
||||
printf(", dr %d", log->tx.drift);
|
||||
printf(", dr %3d", log->tx.drift);
|
||||
}
|
||||
printf("\n");
|
||||
break;
|
||||
@ -113,12 +113,14 @@ tsch_log_process_pending(void)
|
||||
log_lladdr_compact(&log->rx.src);
|
||||
printf("->");
|
||||
log_lladdr_compact(log->rx.is_unicast ? &linkaddr_node_addr : NULL);
|
||||
printf(", len %u, seq %u",
|
||||
printf(", len %3u, seq %3u",
|
||||
log->rx.datalen, log->rx.seqno);
|
||||
printf(", edr %3d", (int)log->rx.estimated_drift);
|
||||
if(log->rx.drift_used) {
|
||||
printf(", dr %d", log->rx.drift);
|
||||
printf(", dr %3d\n", log->rx.drift);
|
||||
} else {
|
||||
printf("\n");
|
||||
}
|
||||
printf(", edr %d\n", log->rx.estimated_drift);
|
||||
break;
|
||||
case tsch_log_message:
|
||||
printf("%s\n", log->message);
|
||||
|
@ -53,10 +53,10 @@
|
||||
#include "net/linkaddr.h"
|
||||
#include "net/mac/tsch/tsch-asn.h"
|
||||
#include "net/mac/tsch/tsch-conf.h"
|
||||
#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64
|
||||
#if CONTIKI_TARGET_COOJA
|
||||
#include "lib/simEnvChange.h"
|
||||
#include "sys/cooja_mt.h"
|
||||
#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */
|
||||
#endif /* CONTIKI_TARGET_COOJA */
|
||||
|
||||
/************ Types ***********/
|
||||
|
||||
@ -124,7 +124,7 @@ void tsch_disassociate(void);
|
||||
#define TSCH_CLOCK_TO_SLOTS(c, timeslot_length) (TSCH_CLOCK_TO_TICKS(c) / timeslot_length)
|
||||
|
||||
/* Wait for a condition with timeout t0+offset. */
|
||||
#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64
|
||||
#if CONTIKI_TARGET_COOJA
|
||||
#define BUSYWAIT_UNTIL_ABS(cond, t0, offset) \
|
||||
while(!(cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), (t0) + (offset))) { \
|
||||
simProcessRunValue = 1; \
|
||||
@ -133,6 +133,6 @@ void tsch_disassociate(void);
|
||||
#else
|
||||
#define BUSYWAIT_UNTIL_ABS(cond, t0, offset) \
|
||||
while(!(cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), (t0) + (offset))) ;
|
||||
#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */
|
||||
#endif /* CONTIKI_TARGET_COOJA */
|
||||
#endif /* __TSCH_PRIVATE_H__ */
|
||||
/** @} */
|
||||
|
@ -59,10 +59,10 @@
|
||||
#include "net/mac/tsch/tsch-packet.h"
|
||||
#include "net/mac/tsch/tsch-security.h"
|
||||
#include "net/mac/tsch/tsch-adaptive-timesync.h"
|
||||
#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64
|
||||
#if CONTIKI_TARGET_COOJA
|
||||
#include "lib/simEnvChange.h"
|
||||
#include "sys/cooja_mt.h"
|
||||
#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */
|
||||
#endif /* CONTIKI_TARGET_COOJA */
|
||||
|
||||
#include "sys/log.h"
|
||||
/* TSCH debug macros, i.e. to set LEDs or GPIOs on various TSCH
|
||||
@ -107,7 +107,7 @@
|
||||
#if RTIMER_SECOND < (32 * 1024)
|
||||
#error "TSCH: RTIMER_SECOND < (32 * 1024)"
|
||||
#endif
|
||||
#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64
|
||||
#if CONTIKI_TARGET_COOJA
|
||||
/* Use 0 usec guard time for Cooja Mote with a 1 MHz Rtimer*/
|
||||
#define RTIMER_GUARD 0u
|
||||
#elif RTIMER_SECOND >= 200000
|
||||
@ -208,10 +208,10 @@ tsch_get_lock(void)
|
||||
busy_wait = 1;
|
||||
busy_wait_time = RTIMER_NOW();
|
||||
while(tsch_in_slot_operation) {
|
||||
#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64
|
||||
#if CONTIKI_TARGET_COOJA
|
||||
simProcessRunValue = 1;
|
||||
cooja_mt_yield();
|
||||
#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */
|
||||
#endif /* CONTIKI_TARGET_COOJA */
|
||||
}
|
||||
busy_wait_time = RTIMER_NOW() - busy_wait_time;
|
||||
}
|
||||
@ -297,15 +297,16 @@ tsch_schedule_slot_operation(struct rtimer *tm, rtimer_clock_t ref_time, rtimer_
|
||||
"!dl-miss %s %d %d",
|
||||
str, (int)(now-ref_time), (int)offset);
|
||||
);
|
||||
} else {
|
||||
r = rtimer_set(tm, ref_time + offset, 1, (void (*)(struct rtimer *, void *))tsch_slot_operation, NULL);
|
||||
if(r == RTIMER_OK) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
ref_time += offset;
|
||||
r = rtimer_set(tm, ref_time, 1, (void (*)(struct rtimer *, void *))tsch_slot_operation, NULL);
|
||||
if(r != RTIMER_OK) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
/* block until the time to schedule comes */
|
||||
BUSYWAIT_UNTIL_ABS(0, ref_time, offset);
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Schedule slot operation conditionally, and YIELD if success only.
|
||||
@ -315,8 +316,8 @@ tsch_schedule_slot_operation(struct rtimer *tm, rtimer_clock_t ref_time, rtimer_
|
||||
do { \
|
||||
if(tsch_schedule_slot_operation(tm, ref_time, offset - RTIMER_GUARD, str)) { \
|
||||
PT_YIELD(pt); \
|
||||
BUSYWAIT_UNTIL_ABS(0, ref_time, offset); \
|
||||
} \
|
||||
BUSYWAIT_UNTIL_ABS(0, ref_time, offset); \
|
||||
} while(0);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Get EB, broadcast or unicast packet to be sent, and target neighbor. */
|
||||
@ -1010,12 +1011,12 @@ PT_THREAD(tsch_slot_operation(struct rtimer *t, void *ptr))
|
||||
TSCH_ASN_INC(tsch_current_asn, timeslot_diff);
|
||||
/* Time to next wake up */
|
||||
time_to_next_active_slot = timeslot_diff * tsch_timing[tsch_ts_timeslot_length] + drift_correction;
|
||||
time_to_next_active_slot += tsch_timesync_adaptive_compensate(time_to_next_active_slot);
|
||||
drift_correction = 0;
|
||||
is_drift_correction_used = 0;
|
||||
/* Update current slot start */
|
||||
prev_slot_start = current_slot_start;
|
||||
current_slot_start += time_to_next_active_slot;
|
||||
current_slot_start += tsch_timesync_adaptive_compensate(time_to_next_active_slot);
|
||||
} while(!tsch_schedule_slot_operation(t, prev_slot_start, time_to_next_active_slot, "main"));
|
||||
}
|
||||
|
||||
|
@ -56,11 +56,15 @@
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
|
||||
#if LEDS_LEGACY_API
|
||||
#if LEDS_ALL & LEDS_BLUE || LEDS_ALL & LEDS_RED || LEDS_ALL & LEDS_BLUE
|
||||
#define LEDS_CONTROL_NUMBER (((LEDS_ALL & LEDS_BLUE) ? 1 : 0) + ((LEDS_ALL & LEDS_RED) ? 1 : 0) + ((LEDS_ALL & LEDS_GREEN) ? 1 : 0))
|
||||
#else
|
||||
#define LEDS_CONTROL_NUMBER 1
|
||||
#endif
|
||||
#else /* LEDS_LEGACY_API */
|
||||
#define LEDS_CONTROL_NUMBER LEDS_COUNT
|
||||
#endif /* LEDS_LEGACY_API */
|
||||
|
||||
typedef struct led_state {
|
||||
ipso_control_t control;
|
||||
@ -72,7 +76,7 @@ static led_state_t leds_controls[LEDS_CONTROL_NUMBER];
|
||||
static lwm2m_status_t
|
||||
set_value(ipso_control_t *control, uint8_t value)
|
||||
{
|
||||
#if PLATFORM_HAS_LEDS
|
||||
#if PLATFORM_HAS_LEDS || LEDS_COUNT
|
||||
led_state_t *state;
|
||||
|
||||
state = (led_state_t *)control;
|
||||
|
@ -42,6 +42,7 @@
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "dev/leds.h"
|
||||
#include "ipso-objects.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
@ -58,7 +59,7 @@ ipso_objects_init(void)
|
||||
|
||||
#ifdef IPSO_LIGHT_CONTROL
|
||||
ipso_light_control_init();
|
||||
#elif PLATFORM_HAS_LEDS
|
||||
#elif PLATFORM_HAS_LEDS || LEDS_COUNT
|
||||
ipso_leds_control_init();
|
||||
#endif
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
struct keyword {
|
||||
char *string;
|
||||
|
@ -21,6 +21,13 @@ dev/gpio-hal/srf06-cc26xx:BOARD=sensortag/cc2650 \
|
||||
dev/gpio-hal/srf06-cc26xx:BOARD=launchpad/cc1310 \
|
||||
dev/gpio-hal/srf06-cc26xx:BOARD=launchpad/cc1350 \
|
||||
dev/gpio-hal/srf06-cc26xx:BOARD=launchpad/cc2650 \
|
||||
dev/leds/srf06-cc26xx:BOARD=srf06/cc13xx \
|
||||
dev/leds/srf06-cc26xx:BOARD=srf06/cc26xx \
|
||||
dev/leds/srf06-cc26xx:BOARD=sensortag/cc1350 \
|
||||
dev/leds/srf06-cc26xx:BOARD=sensortag/cc2650 \
|
||||
dev/leds/srf06-cc26xx:BOARD=launchpad/cc1310 \
|
||||
dev/leds/srf06-cc26xx:BOARD=launchpad/cc1350 \
|
||||
dev/leds/srf06-cc26xx:BOARD=launchpad/cc2650 \
|
||||
6tisch/etsi-plugtest-2017/srf06-cc26xx:BOARD=launchpad/cc2650 \
|
||||
storage/cfs-coffee/cc2538dk \
|
||||
sensniff/cc2538dk \
|
||||
@ -30,6 +37,7 @@ slip-radio/cc2538dk \
|
||||
ipso-objects/cc2538dk \
|
||||
multicast/cc2538dk \
|
||||
dev/gpio-hal/cc2538dk \
|
||||
dev/leds/cc2538dk \
|
||||
platform-specific/cc2538-common/cc2538dk \
|
||||
platform-specific/cc2538-common/mqtt-demo/cc2538dk \
|
||||
platform-specific/cc2538-common/crypto/cc2538dk \
|
||||
|
@ -8,6 +8,10 @@ platform-specific/cc2538-common/mqtt-demo/zoul \
|
||||
platform-specific/cc2538-common/crypto/zoul \
|
||||
platform-specific/cc2538-common/pka/zoul \
|
||||
platform-specific/zoul/orion/ip64-router/zoul:BOARD=orion \
|
||||
platform-specific/zoul/rev-b/zoul:BOARD=remote-revb \
|
||||
platform-specific/zoul/at-test/zoul \
|
||||
platform-specific/zoul/rtcc/zoul \
|
||||
platform-specific/zoul/zoul \
|
||||
coap/zoul \
|
||||
ipso-objects/zoul \
|
||||
ipso-objects/zoul:MAKE_WITH_DTLS=1 \
|
||||
@ -35,11 +39,22 @@ dev/gpio-hal/zoul:BOARD=remote-revb \
|
||||
dev/gpio-hal/zoul:BOARD=firefly-reva \
|
||||
dev/gpio-hal/zoul:BOARD=firefly \
|
||||
dev/gpio-hal/zoul:BOARD=orion \
|
||||
dev/leds/zoul:BOARD=remote-reva \
|
||||
dev/leds/zoul:BOARD=remote-revb \
|
||||
dev/leds/zoul:BOARD=firefly-reva \
|
||||
dev/leds/zoul:BOARD=firefly \
|
||||
dev/leds/zoul:BOARD=orion \
|
||||
dev/rgb-led/zoul:BOARD=remote-reva \
|
||||
dev/rgb-led/zoul:BOARD=remote-revb \
|
||||
dev/rgb-led/zoul:BOARD=firefly-reva \
|
||||
dev/rgb-led/zoul:BOARD=firefly \
|
||||
dev/rgb-led/zoul:BOARD=orion \
|
||||
storage/cfs-coffee/openmote-cc2538 \
|
||||
sensniff/openmote-cc2538 \
|
||||
hello-world/openmote-cc2538 \
|
||||
rpl-udp/openmote-cc2538 \
|
||||
dev/gpio-hal/openmote-cc2538 \
|
||||
dev/leds/openmote-cc2538 \
|
||||
rpl-border-router/openmote-cc2538
|
||||
|
||||
TOOLS=
|
||||
|
@ -17,9 +17,6 @@ java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$BASENAME.csc -c
|
||||
JPID=$!
|
||||
sleep 20
|
||||
|
||||
echo "Enabling IPv6"
|
||||
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
|
||||
|
||||
# Connect to the simlation
|
||||
echo "Starting tunslip6"
|
||||
make -C $CONTIKI/tools tunslip6
|
||||
|
@ -7,9 +7,6 @@ BASENAME=01-native-ping
|
||||
|
||||
IPADDR=fd00::302:304:506:708
|
||||
|
||||
echo "Enabling IPv6"
|
||||
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
|
||||
|
||||
# Starting Contiki-NG native node
|
||||
echo "Starting native node"
|
||||
make -C $CONTIKI/examples/hello-world > make.log 2> make.err
|
||||
|
@ -10,9 +10,6 @@ IPADDR=fd00::302:304:506:708
|
||||
declare -i OKCOUNT=0
|
||||
declare -i TESTCOUNT=0
|
||||
|
||||
echo "Enabling IPv6"
|
||||
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
|
||||
|
||||
# Starting Contiki-NG native node
|
||||
echo "Starting native CoAP server"
|
||||
make -C $CONTIKI/examples/coap > make.log 2> make.err
|
||||
|
@ -18,9 +18,6 @@ java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$BASENAME.csc -c
|
||||
JPID=$!
|
||||
sleep 20
|
||||
|
||||
echo "Enabling IPv6"
|
||||
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
|
||||
|
||||
# Connect to the simlation
|
||||
echo "Starting tunslip6"
|
||||
make -C $CONTIKI/tools tunslip6
|
||||
|
@ -18,9 +18,6 @@ java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$BASENAME.csc -c
|
||||
JPID=$!
|
||||
sleep 20
|
||||
|
||||
echo "Enabling IPv6"
|
||||
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
|
||||
|
||||
# Connect to the simlation
|
||||
echo "Starting native border-router"
|
||||
nohup make -C $CONTIKI/examples/rpl-border-router/ connect-router-cooja TARGET=native >> $BASENAME.nbr.log 2>&1 &
|
||||
|
@ -7,9 +7,6 @@ BASENAME=06-lwm2m-test
|
||||
|
||||
IPADDR=fd00::302:304:506:708
|
||||
|
||||
echo "Enabling IPv6"
|
||||
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
|
||||
|
||||
# Starting Contiki-NG native node
|
||||
echo "Starting native node - lwm2m/ipso objects"
|
||||
make -C $CONTIKI/examples/ipso-objects > make.log 2> make.err
|
||||
|
@ -67,24 +67,24 @@ WORKDIR ${HOME}
|
||||
RUN echo "#!/bin/bash\nant -Dbasedir=${COOJA} -f ${COOJA}/build.xml run" > ${HOME}/cooja && \
|
||||
chmod +x ${HOME}/cooja
|
||||
|
||||
# Optional: download Contiki-NG and pre-compile Cooja.
|
||||
# Else, use a Docker bind mount to share the repo with the host.
|
||||
# Docker run option:
|
||||
# -v <HOST_CONTIKI_NG_ABS_PATH>:/home/user/contiki-ng
|
||||
#RUN git clone --recursive https://github.com/contiki-ng/contiki-ng.git ${CONTIKI_NG}
|
||||
#RUN ant -q -f ${CONTIKI_NG}/tools/cooja/build.xml jar
|
||||
|
||||
# Enable IPv6 -- must be done at runtime, not in Dockerfile
|
||||
#RUN sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
|
||||
|
||||
# Install coap-cli
|
||||
RUN sudo apt-get install -y npm \
|
||||
&& sudo apt-get clean \
|
||||
&& sudo npm install coap-cli -g \
|
||||
&& sudo ln -s /usr/bin/nodejs /usr/bin/node
|
||||
|
||||
# Optional: download Contiki-NG and pre-compile Cooja.
|
||||
# Else, use a Docker bind mount to share the repo with the host.
|
||||
# Docker run option:
|
||||
# -v <HOST_CONTIKI_NG_ABS_PATH>:/home/user/contiki-ng
|
||||
RUN git clone --recursive https://github.com/contiki-ng/contiki-ng.git ${CONTIKI_NG}
|
||||
RUN ant -q -f ${CONTIKI_NG}/tools/cooja/build.xml jar
|
||||
|
||||
# Working directory
|
||||
WORKDIR ${CONTIKI_NG}
|
||||
|
||||
# Enable IPv6 -- must be done at runtime, not in Dockerfile
|
||||
RUN echo "sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 > /dev/null" >> /home/user/.profile
|
||||
|
||||
# Start a bash
|
||||
CMD bash
|
||||
CMD bash --login
|
||||
|
Loading…
Reference in New Issue
Block a user