Merge branch 'release-4.1' into contrib/root-old-version-reset-trickle

This commit is contained in:
Simon Duquennoy 2018-04-13 15:52:25 +02:00 committed by GitHub
commit 36bb007b19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 607 additions and 231 deletions

View File

@ -1,7 +1,7 @@
# Contiki-NG: The OS for Next Generation IoT Devices
[![Build Status](https://travis-ci.org/contiki-ng/contiki-ng.svg?branch=master)](https://travis-ci.org/contiki-ng/contiki-ng/branches)
[![License](https://img.shields.io/badge/License-3--Clause%20BSD-brightgreen.svg)](https://github.com/contiki-ng/contiki-ng/blob/master/LICENSE.md)
[![license](https://img.shields.io/badge/license-3--clause%20bsd-brightgreen.svg)](https://github.com/contiki-ng/contiki-ng/blob/master/LICENSE.md)
[![Latest release](https://img.shields.io/github/release/contiki-ng/contiki-ng.svg)](https://github.com/contiki-ng/contiki-ng/releases/latest)
[![GitHub Release Date](https://img.shields.io/github/release-date/contiki-ng/contiki-ng.svg)](https://github.com/contiki-ng/contiki-ng/releases/latest)
[![Last commit](https://img.shields.io/github/last-commit/contiki-ng/contiki-ng.svg)](https://github.com/contiki-ng/contiki-ng/commit/HEAD)
@ -9,7 +9,7 @@
Contiki-NG is an open-source, cross-platform operating system for Next-Generation IoT devices. It focuses on dependable (secure and reliable) low-power communication and standard protocols, such as IPv6/6LoWPAN, 6TiSCH, RPL, and CoAP. Contiki-NG comes with extensive documentation, tutorials, a roadmap, release cycle, and well-defined development flow for smooth integration of community contributions.
Unless excplicitly stated otherwise, Contiki-NG sources are distributed under
the terms of the [3-clause BSD license](LICENSE.md).
the terms of the [3-clause BSD license](LICENSE.md).
Contiki-NG started as a fork of the Contiki OS and retains some of its original features.

View File

@ -55,7 +55,7 @@
* - SPIX_FLUSH(x)
*
* Some of the old functions and macros are still supported.
* When using these deprecated functions, the SSI module to use
* When using these deprecated functions, the SSI module to use
* has to be be selected by means of the macro SPI_CONF_DEFAULT_INSTANCE.
*
* This SPI driver depends on the following defines:
@ -95,14 +95,14 @@
#endif
/*---------------------------------------------------------------------------*/
/* Default values for the clock rate divider */
#ifdef SPI0_CONF_CPRS_CPSDVSR
#define SPI0_CPRS_CPSDVSR SPI0_CONF_CPRS_CPSDVSR
#ifdef SPI0_CONF_CPRS_CPSDVSR
#define SPI0_CPRS_CPSDVSR SPI0_CONF_CPRS_CPSDVSR
#else
#define SPI0_CPRS_CPSDVSR 2
#endif
#ifdef SPI1_CONF_CPRS_CPSDVSR
#define SPI1_CPRS_CPSDVSR SPI1_CONF_CPRS_CPSDVSR
#ifdef SPI1_CONF_CPRS_CPSDVSR
#define SPI1_CPRS_CPSDVSR SPI1_CONF_CPRS_CPSDVSR
#else
#define SPI1_CPRS_CPSDVSR 2
#endif
@ -120,7 +120,7 @@
} while(0)
#define SPIX_FLUSH(spi) do { \
while(REG(SSI_BASE(spi) + SSI_SR) & SSI_SR_RNE) { \
SPIX_BUF(spi); \
SPIX_BUF(spi); \
} \
} while(0)
#define SPIX_CS_CLR(port, pin) do { \
@ -144,7 +144,7 @@
#endif
#define SPI_CS_CLR(port, pin) SPIX_CS_CLR(port, pin)
#define SPI_CS_SET(port, pin) SPIX_CS_SET(port, pin)
#endif /* #ifdef SPI_DEFAULT_INSTANCE */
#endif /* #ifdef SPI_DEFAULT_INSTANCE */
/*---------------------------------------------------------------------------*/
/** \name Arch-specific SPI functions
* @{
@ -183,7 +183,7 @@ void spix_disable(uint8_t spi);
*
* See section 19.4.4 in the CC2538 user guide for more information.
*
* \param spi The SSI instance to use.
* \param spi The SSI instance to use.
* \param frame_format Set the SSI frame format. Use SSI_CR0_FRF_MOTOROLA,
* SSI_CR0_FRF_TI, or SSI_CR0_FRF_MICROWIRE.
* \param clock_polarity In Motorola mode, set whether the clock is high or low

View File

@ -1,30 +1,30 @@
/*
* Copyright (c) 2006, Swedish Institute of Computer Science
* All rights reserved.
* 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.
* 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 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.
*
*/
@ -35,7 +35,7 @@
* exclusive. Set spi_busy so that interrupt handlers can check if
* they are allowed to use the bus or not. Only the CC2420 radio needs
* this in practice.
*
*
*/
unsigned char spi_busy = 0;

View File

@ -1,30 +1,30 @@
/*
* Copyright (c) 2007, Swedish Institute of Computer Science
* All rights reserved.
* 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.
* 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 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.
*/
#ifndef MSP430_DEF_H_

View File

@ -1,6 +1,7 @@
CONTIKI_CPU_DIRS = . net dev
CONTIKI_SOURCEFILES += rtimer-arch.c watchdog.c eeprom.c
CONTIKI_SOURCEFILES += rtimer-arch.c watchdog.c eeprom.c int-master.c
CONTIKI_SOURCEFILES += gpio-hal-arch.c
### Compiler definitions
CC ?= gcc

View File

@ -0,0 +1,216 @@
/*
* 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.
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/gpio-hal.h"
#include "sys/log.h"
#include <stdint.h>
/*---------------------------------------------------------------------------*/
/* Log configuration */
#define LOG_MODULE "GPIO arch"
#define LOG_LEVEL LOG_LEVEL_NONE
/*---------------------------------------------------------------------------*/
static gpio_hal_pin_cfg_t pin_cfg[GPIO_HAL_PIN_COUNT];
static uint8_t pin_state[GPIO_HAL_PIN_COUNT];
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_interrupt_enable(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
LOG_DBG("Pin %u: Enabled interrupt\n", pin);
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_interrupt_disable(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
LOG_DBG("Pin %u: Disabled interrupt\n", pin);
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_pin_cfg_set(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
pin_cfg[pin] = cfg;
LOG_DBG("Pin %u: Set config=0x%02x\n", pin, pin_cfg[pin]);
}
/*---------------------------------------------------------------------------*/
gpio_hal_pin_cfg_t
gpio_hal_arch_pin_cfg_get(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return 0;
}
LOG_DBG("Pin %u: Config=0x%02x\n", pin, pin_cfg[pin]);
return pin_cfg[pin];
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_pin_set_input(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
LOG_DBG("Pin %u: Set input\n", pin);
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_pin_set_output(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
LOG_DBG("Pin %u: Set output\n", pin);
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_set_pin(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
pin_state[pin] = 1;
LOG_DBG("Pin %u: Set\n", pin);
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_clear_pin(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
pin_state[pin] = 0;
LOG_DBG("Pin %u: Clear\n", pin);
}
/*---------------------------------------------------------------------------*/
uint8_t
gpio_hal_arch_read_pin(gpio_hal_pin_t pin)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return 0;
}
LOG_DBG("Pin %u: Read=%u\n", pin, pin_state[pin]);
return pin_state[pin];
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_write_pin(gpio_hal_pin_t pin, uint8_t value)
{
if(pin >= GPIO_HAL_PIN_COUNT) {
LOG_ERR("Pin %u out of bounds\n", pin);
return;
}
pin_state[pin] = value;
LOG_DBG("Pin %u: Write=%u\n", pin, pin_state[pin]);
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_set_pins(gpio_hal_pin_mask_t pins)
{
gpio_hal_pin_t pin;
for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) {
if(pins & (1 << pin)) {
pin_state[pin] = 1;
}
}
LOG_DBG("Set pins 0x%08" PRIx32 "\n", pins);
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_clear_pins(gpio_hal_pin_mask_t pins)
{
gpio_hal_pin_t pin;
for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) {
if(pins & (1 << pin)) {
pin_state[pin] = 0;
}
}
LOG_DBG("Clear pins 0x%08" PRIx32 "\n", pins);
}
/*---------------------------------------------------------------------------*/
gpio_hal_pin_mask_t
gpio_hal_arch_read_pins(gpio_hal_pin_mask_t pins)
{
gpio_hal_pin_t pin;
gpio_hal_pin_mask_t state = 0;
for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) {
state |= (pin_state[pin] << pin);
}
LOG_DBG("Read pins 0x%08" PRIx32 "\n", state);
return state;
}
/*---------------------------------------------------------------------------*/
void
gpio_hal_arch_write_pins(gpio_hal_pin_mask_t pins, gpio_hal_pin_mask_t value)
{
gpio_hal_pin_t pin;
for(pin = 0; pin < GPIO_HAL_PIN_COUNT; pin++) {
if(pins & (1 << pin)) {
pin_state[pin] = (value & (1 << pin)) == 0 ? 0 : 1;
}
}
LOG_DBG("Write pins 0x%08" PRIx32 "->0x%08" PRIx32 "\n", pins, value);
}
/*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,67 @@
/*
* 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.
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "sys/int-master.h"
#include <stdbool.h>
/*---------------------------------------------------------------------------*/
#define DISABLED 0
#define ENABLED 1
/*---------------------------------------------------------------------------*/
static int_master_status_t stat = DISABLED;
/*---------------------------------------------------------------------------*/
void
int_master_enable(void)
{
stat = ENABLED;
}
/*---------------------------------------------------------------------------*/
int_master_status_t
int_master_read_and_disable(void)
{
int_master_status_t rv = stat;
stat = DISABLED;
return rv;
}
/*---------------------------------------------------------------------------*/
void
int_master_status_set(int_master_status_t status)
{
stat = status;
}
/*---------------------------------------------------------------------------*/
bool
int_master_is_enabled(void)
{
return stat == DISABLED ? false : true;
}
/*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,38 @@
/*
* 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.
*/
/*---------------------------------------------------------------------------*/
#ifndef NATIVE_DEF_H_
#define NATIVE_DEF_H_
/*---------------------------------------------------------------------------*/
#define GPIO_HAL_CONF_ARCH_SW_TOGGLE 1
/*---------------------------------------------------------------------------*/
#endif /* NATIVE_DEF_H_ */
/*---------------------------------------------------------------------------*/

View File

@ -113,13 +113,15 @@ static spi_device_t flash_spi_configuration_default = {
/**
* Get spi configuration, return default configuration if NULL
*/
static spi_device_t*
get_spi_conf(spi_device_t *conf) {
static spi_device_t *
get_spi_conf(spi_device_t *conf)
{
if(conf == NULL) {
return &flash_spi_configuration_default;
}
return conf;
}/*---------------------------------------------------------------------------*/
}
/*---------------------------------------------------------------------------*/
/**
* Clear external flash CSN line
*/
@ -334,7 +336,7 @@ ext_flash_open(spi_device_t *conf)
/* Put the part is standby mode */
power_standby(flash_spi_configuration);
if (verify_part(flash_spi_configuration) == VERIFY_PART_OK) {
if(verify_part(flash_spi_configuration) == VERIFY_PART_OK) {
return true;
}
@ -353,7 +355,7 @@ ext_flash_close(spi_device_t *conf)
/* Put the part in low power mode */
ret = power_down(flash_spi_configuration);
/* SPI is released no matter if power_down() succeeds or fails */
if(spi_release(flash_spi_configuration) != SPI_DEV_STATUS_OK) {
return false;
@ -474,7 +476,7 @@ ext_flash_erase(spi_device_t *conf, uint32_t offset, uint32_t length)
uint8_t wbuf[4];
uint32_t i, numsectors;
uint32_t endoffset = offset + length - 1;
spi_device_t *flash_spi_configuration;
flash_spi_configuration = get_spi_conf(conf);

View File

@ -57,5 +57,3 @@ const leds_t leds_arch_leds[] = {
#endif
};
/*---------------------------------------------------------------------------*/

View File

@ -6,8 +6,8 @@ endif
CONTIKI_TARGET_DIRS = . dev
CONTIKI_TARGET_MAIN = ${addprefix $(OBJECTDIR)/,contiki-main.o}
CONTIKI_TARGET_SOURCEFILES += platform.c clock.c xmem.c leds-arch.c
CONTIKI_TARGET_SOURCEFILES += cfs-posix.c cfs-posix-dir.c
CONTIKI_TARGET_SOURCEFILES += platform.c clock.c xmem.c
CONTIKI_TARGET_SOURCEFILES += cfs-posix.c cfs-posix-dir.c buttons.c
ifeq ($(HOST_OS),Windows)
CONTIKI_TARGET_SOURCEFILES += wpcap-drv.c wpcap.c

View File

@ -37,7 +37,9 @@
#ifdef PROJECT_CONF_PATH
#include PROJECT_CONF_PATH
#endif /* PROJECT_CONF_PATH */
/*---------------------------------------------------------------------------*/
#include "native-def.h"
/*---------------------------------------------------------------------------*/
#include <inttypes.h>
#ifndef WIN32_LEAN_AND_MEAN
#include <sys/select.h>
@ -60,8 +62,6 @@ int select_set_callback(int fd, const struct select_callback *callback);
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
@ -91,6 +91,8 @@ typedef unsigned long clock_time_t;
#define LOG_CONF_ENABLED 1
#define PLATFORM_SUPPORTS_BUTTON_HAL 1
/* Not part of C99 but actually present */
int strcasecmp(const char*, const char*);

View File

@ -0,0 +1,40 @@
/*
* 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.
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/button-hal.h"
#include <stdint.h>
#include <string.h>
/*---------------------------------------------------------------------------*/
button_hal_button_t *button_hal_buttons[] = { NULL };
const uint8_t button_hal_button_count = 0;
/*---------------------------------------------------------------------------*/

View File

@ -1,60 +0,0 @@
/*
* Copyright (c) 2005, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
*/
/**
* \file
* A brief description of what this file is.
* \author
* Adam Dunkels <adam@sics.se>
*/
#include "dev/leds.h"
static leds_mask_t leds;
/*---------------------------------------------------------------------------*/
void
leds_arch_init(void)
{
leds = 0;
}
/*---------------------------------------------------------------------------*/
leds_mask_t
leds_arch_get(void)
{
return leds;
}
/*---------------------------------------------------------------------------*/
void
leds_arch_set(leds_mask_t l)
{
leds = l;
}
/*---------------------------------------------------------------------------*/

View File

@ -56,6 +56,9 @@
#include "net/netstack.h"
#include "dev/serial-line.h"
#include "dev/button-hal.h"
#include "dev/gpio-hal.h"
#include "dev/leds.h"
#include "net/ipv6/uip.h"
#include "net/ipv6/uip-debug.h"
@ -251,6 +254,9 @@ platform_process_args(int argc, char**argv)
void
platform_init_stage_one()
{
gpio_hal_init();
button_hal_init();
leds_init();
return;
}
/*---------------------------------------------------------------------------*/

View File

@ -54,5 +54,3 @@ const leds_t leds_arch_leds[] = {
},
};
/*---------------------------------------------------------------------------*/

View File

@ -43,44 +43,41 @@
#include "contiki-conf.h"
#include "dev/xmem.h"
/*** MX25R8035F Memory Organization
The memory is organized as:
8Mbit = 1048576 bytes (8 bits each)
256 sectors (32 Kbits, 4096 bytes each)
4096 pages (256 bytes each).
Each page can be individually programmed (bits are programmed from 1 to 0). The device is
sector or bulk erasable (bits are erased from 0 to 1) but not page erasable
*/
#define COFFEE_XMEM_TOTAL_SIZE_KB 1024UL //Total size of the External Flash Memory in the Z1
/*
* MX25R8035F Memory Organization
* The memory is organized as:
* 8Mbit = 1048576 bytes (8 bits each)
* 256 sectors (32 Kbits, 4096 bytes each)
* 4096 pages (256 bytes each).
* Each page can be individually programmed (bits are programmed from 1 to 0).
* The device is sector or bulk erasable (bits are erased from 0 to 1) but not
* page erasable
*/
#define COFFEE_XMEM_TOTAL_SIZE_KB 1024UL /* Total size of the External Flash Memory in the Z1 */
/* Coffee configuration parameters. */
#define COFFEE_SECTOR_SIZE 4096UL
#define COFFEE_SECTOR_SIZE 4096UL
#define COFFEE_PAGE_SIZE 256UL
#define COFFEE_START 0UL //COFFEE_SECTOR_SIZE
#define COFFEE_START 0UL /* COFFEE_SECTOR_SIZE */
#define COFFEE_SIZE (COFFEE_XMEM_TOTAL_SIZE_KB * 1024UL - COFFEE_START)
#define COFFEE_NAME_LENGTH 16
#define COFFEE_MAX_OPEN_FILES 6
#define COFFEE_FD_SET_SIZE 8
#define COFFEE_LOG_TABLE_LIMIT 256
#define COFFEE_DYN_SIZE 2*1024
#define COFFEE_DYN_SIZE 2 * 1024
#define COFFEE_LOG_SIZE 1024
#define COFFEE_MICRO_LOGS 1
/* Flash operations. */
#define COFFEE_WRITE(buf, size, offset) \
xmem_pwrite((char *)(buf), (size), COFFEE_START + (offset))
#define COFFEE_WRITE(buf, size, offset) \
xmem_pwrite((char *)(buf), (size), COFFEE_START + (offset))
#define COFFEE_READ(buf, size, offset) \
xmem_pread((char *)(buf), (size), COFFEE_START + (offset))
#define COFFEE_READ(buf, size, offset) \
xmem_pread((char *)(buf), (size), COFFEE_START + (offset))
#define COFFEE_ERASE(sector) \
xmem_erase(COFFEE_SECTOR_SIZE, COFFEE_START + (sector) * COFFEE_SECTOR_SIZE)
#define COFFEE_ERASE(sector) \
xmem_erase(COFFEE_SECTOR_SIZE, COFFEE_START + (sector) * COFFEE_SECTOR_SIZE)
/* Coffee types. */
typedef int16_t coffee_page_t;

View File

@ -49,21 +49,17 @@
#define XMEM_BUFF_LENGHT 128
#if 0
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...) do {} while (0)
#define PRINTF(...) do {} while(0)
#endif
void
xmem_init(void)
{
ext_flash_open(NULL);
}
int
xmem_pread(void *_p, int size, unsigned long addr)
{
@ -80,21 +76,20 @@ xmem_pread(void *_p, int size, unsigned long addr)
}
rv = ext_flash_read(NULL, addr, size, _p);
for (i = 0; i < size; i++){
for(i = 0; i < size; i++) {
x = ~*((uint8_t *)_p + i);
*((uint8_t *)_p+i) = x;
*((uint8_t *)_p + i) = x;
}
ext_flash_close(NULL);
if(rv)
if(rv) {
return size;
}
PRINTF("Could not read flash memory!\n");
return -1;
}
}
int
xmem_pwrite(const void *_buf, int size, unsigned long addr)
{
@ -112,13 +107,13 @@ xmem_pwrite(const void *_buf, int size, unsigned long addr)
return -1;
}
for (remain = size, j = 0; remain > 0; remain -= XMEM_BUFF_LENGHT, j += XMEM_BUFF_LENGHT) {
for(remain = size, j = 0; remain > 0; remain -= XMEM_BUFF_LENGHT, j += XMEM_BUFF_LENGHT) {
int to_write = MIN(XMEM_BUFF_LENGHT, remain);
for (i = 0; i < to_write; i++) {
for(i = 0; i < to_write; i++) {
tmp_buf[i] = ~*((uint8_t *)_buf + j + i);
}
rv = ext_flash_write(NULL, addr + j, to_write, tmp_buf);
if (!rv) {
if(!rv) {
PRINTF("Could not write flash memory!\n");
return size - remain;
}
@ -128,8 +123,6 @@ xmem_pwrite(const void *_buf, int size, unsigned long addr)
return size;
}
int
xmem_erase(long size, unsigned long addr)
{
@ -137,7 +130,6 @@ xmem_erase(long size, unsigned long addr)
rv = ext_flash_open(NULL);
if(!rv) {
PRINTF("Could not open flash to save config\n");
ext_flash_close(NULL);
@ -160,8 +152,9 @@ xmem_erase(long size, unsigned long addr)
watchdog_periodic();
if(rv)
if(rv) {
return size;
}
PRINTF("Could not erase flash memory\n");
return -1;

View File

@ -41,5 +41,3 @@ const leds_t leds_arch_leds[] = {
{ .pin = BOARD_IOID_LED_2, .negative_logic = false },
};
/*---------------------------------------------------------------------------*/

View File

@ -39,5 +39,3 @@ const leds_t leds_arch_leds[] = {
{ .pin = BOARD_IOID_LED_1, .negative_logic = false },
};
/*---------------------------------------------------------------------------*/

View File

@ -40,5 +40,3 @@ const leds_t leds_arch_leds[] = {
{ .pin = BOARD_IOID_LED_2, .negative_logic = false },
};
/*---------------------------------------------------------------------------*/

View File

@ -42,5 +42,3 @@ const leds_t leds_arch_leds[] = {
{ .pin = BOARD_IOID_LED_4, .negative_logic = false },
};
/*---------------------------------------------------------------------------*/

View File

@ -50,5 +50,3 @@ const leds_t leds_arch_leds[] = {
},
};
/*---------------------------------------------------------------------------*/

View File

@ -3,6 +3,6 @@ CONTIKI = ../../..
all: $(CONTIKI_PROJECT)
PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul
PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul native
include $(CONTIKI)/Makefile.include

View File

@ -47,10 +47,13 @@ PROCESS_THREAD(button_hal_example, ev, data)
printf("Button HAL example.\n");
printf("Device button count: %u.\n", button_hal_button_count);
printf("%s on pin %u with ID=0, Logic=%s, Pull=%s\n",
BUTTON_HAL_GET_DESCRIPTION(btn), btn->pin,
btn->negative_logic ? "Negative" : "Positive",
btn->pull == GPIO_HAL_PIN_CFG_PULL_UP ? "Pull Up" : "Pull Down");
if(btn) {
printf("%s on pin %u with ID=0, Logic=%s, Pull=%s\n",
BUTTON_HAL_GET_DESCRIPTION(btn), btn->pin,
btn->negative_logic ? "Negative" : "Positive",
btn->pull == GPIO_HAL_PIN_CFG_PULL_UP ? "Pull Up" : "Pull Down");
}
while(1) {

View File

@ -1,7 +1,7 @@
CONTIKI_PROJECT = gpio-hal-example
CONTIKI = ../../..
PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul
PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul native
include $(CONTIKI)/Makefile.identify-target

View File

@ -36,6 +36,7 @@
#include "dev/button-hal.h"
#include <stdio.h>
#include <inttypes.h>
/*---------------------------------------------------------------------------*/
extern gpio_hal_pin_t out_pin1, out_pin2, out_pin3;
extern gpio_hal_pin_t btn_pin;
@ -43,6 +44,13 @@ extern gpio_hal_pin_t btn_pin;
static struct etimer et;
static uint8_t counter;
/*---------------------------------------------------------------------------*/
/* Print gpio_hal_pin_mask_t using the correct format */
#if GPIO_HAL_PIN_COUNT > 32
#define PIN_MASK_FMT PRIx64
#else
#define PIN_MASK_FMT PRIx32
#endif
/*---------------------------------------------------------------------------*/
PROCESS(gpio_hal_example, "GPIO HAL Example");
AUTOSTART_PROCESSES(&gpio_hal_example);
/*---------------------------------------------------------------------------*/
@ -119,7 +127,8 @@ PROCESS_THREAD(gpio_hal_example, ev, data)
}
/* Test read */
printf("%u: Pins are 1-%u, 2=%u, 3=%u, mask=0x%08lx\n", counter & 7,
printf("%u: Pins are 1-%u, 2=%u, 3=%u, mask=0x%08" PIN_MASK_FMT "\n",
counter & 7,
gpio_hal_arch_read_pin(out_pin1),
gpio_hal_arch_read_pin(out_pin2),
gpio_hal_arch_read_pin(out_pin3),

View File

@ -0,0 +1,40 @@
/*
* 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.
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/gpio-hal.h"
/*---------------------------------------------------------------------------*/
gpio_hal_pin_t out_pin1 = 0;
gpio_hal_pin_t out_pin2 = 1;
gpio_hal_pin_t out_pin3 = 2;
/*---------------------------------------------------------------------------*/
gpio_hal_pin_t btn_pin = 4;
/*---------------------------------------------------------------------------*/

View File

@ -8,6 +8,6 @@ CONTIKI = ../..
MODULES_REL += arch/platform/$(TARGET)
PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul
PLATFORMS_ONLY = srf06-cc26xx cc2538dk openmote-cc2538 zoul native
include $(CONTIKI)/Makefile.include

View File

@ -6,7 +6,7 @@ can be exchanged using BLE connections (IPv6 over BLE).
This Contiki extenstion implements [BLEach][bleachWeb], a fully open-source IPv6-over-BLE stack for Contiki.
BLEach in Contiki-NG can be used for node (BLE slave) devices.
It was developed by
It was developed by
* [Michael Spoerk](http://www.michaelspoerk.com), Graz University of Technology, michael.spoerk@tugraz.at, github user: [spoerk](https://github.com/spoerk)
This IPv6-over-BLE stack is presented and evaluated in the paper:
@ -21,7 +21,7 @@ This implementation includes:
* BLE link layer support for version [4.1][bleSpec]:
* BLE advertisement
* BLE connection slave
It has been tested on the TI CC2650 SensorTag and the TI CC2650 LaunchPad hardware.
## Modules
@ -78,4 +78,3 @@ specifies the used advertisement interval in milliseconds.
[rfc7668]: https://tools.ietf.org/html/rfc7668
[bleSpec]: https://www.bluetooth.com/specifications/bluetooth-core-specification/legacy-specifications
[bleachWeb]: http://www.iti.tugraz.at/BLEach

View File

@ -53,7 +53,7 @@ typedef struct strformat_context_s {
/*---------------------------------------------------------------------------*/
int format_str(const strformat_context_t *ctxt, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2,3)));
int
format_str_v(const strformat_context_t *ctxt, const char *format, va_list ap);
/*---------------------------------------------------------------------------*/

View File

@ -1115,13 +1115,10 @@ coap_set_header_size1(coap_message_t *coap_pkt, uint32_t size)
int
coap_get_payload(coap_message_t *coap_pkt, const uint8_t **payload)
{
if(coap_pkt->payload) {
if(payload != NULL) {
*payload = coap_pkt->payload;
return coap_pkt->payload_len;
} else {
*payload = NULL;
return 0;
}
return coap_pkt->payload != NULL ? coap_pkt->payload_len : 0;
}
int
coap_set_payload(coap_message_t *coap_pkt, const void *payload, size_t length)

View File

@ -97,6 +97,7 @@
/* define the buffer as a byte array */
#define PACKETBUF_IPHC_BUF ((uint8_t *)(packetbuf_ptr + packetbuf_hdr_len))
#define PACKETBUF_PAYLOAD_END ((uint8_t *)(packetbuf_ptr + mac_max_payload))
#define PACKETBUF_6LO_PTR (packetbuf_ptr + packetbuf_hdr_len)
#define PACKETBUF_6LO_DISPATCH 0 /* 8 bit */
@ -197,6 +198,11 @@ static int packetbuf_payload_len;
*/
static uint8_t uncomp_hdr_len;
/**
* mac_max_payload is the maimum payload space on the MAC frame.
*/
static int mac_max_payload;
/**
* The current page (RFC 4944)
*/
@ -663,8 +669,9 @@ uncompress_addr(uip_ipaddr_t *ipaddr, uint8_t const prefix[],
* compress the IID.
* \param link_destaddr L2 destination address, needed to compress IP
* dest
* \return 1 if success, else 0
*/
static void
static int
compress_hdr_iphc(linkaddr_t *link_destaddr)
{
uint8_t tmp, iphc0, iphc1, *next_hdr, *next_nhc;
@ -681,7 +688,23 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
LOG_DBG_("\n");
}
/* Macro used only internally, during header compression. Checks if there
* is sufficient space in packetbuf before writing any further. */
#define CHECK_BUFFER_SPACE(writelen) do { \
if(hc06_ptr + (writelen) >= PACKETBUF_PAYLOAD_END) { \
LOG_WARN("Not enough packetbuf space to compress header (%u bytes, %u left). Aborting.\n", \
(unsigned)(writelen), (unsigned)(PACKETBUF_PAYLOAD_END - hc06_ptr)); \
return 0; \
} \
} while(0);
hc06_ptr = PACKETBUF_IPHC_BUF + 2;
/* Check if there is enough space for the compressed IPv6 header, in the
* worst case (least compressed case). Extension headers and transport
* layer will be checked when they are compressed. */
CHECK_BUFFER_SPACE(38);
/*
* As we copy some bit-length fields, in the IPHC encoding bytes,
* we sometimes use |=
@ -910,11 +933,13 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
NHC byte extra - before the next header here. This is due to
next not being elided in that case. */
if(!IS_COMPRESSABLE_PROTO(*next_hdr)) {
CHECK_BUFFER_SPACE(1);
hc06_ptr++;
LOG_INFO("Keeping the next header in this ext hdr: %d\n",
ext_hdr->next);
}
/* copy the ext-hdr into the hc06 buffer */
CHECK_BUFFER_SPACE(len);
memcpy(hc06_ptr, ext_hdr, len);
/* modify the len to octets */
ext_hdr = (struct uip_ext_hdr *) hc06_ptr;
@ -944,6 +969,7 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
/* we can compress 12 bits of both source and dest */
*next_nhc = SICSLOWPAN_NHC_UDP_CS_P_11;
LOG_INFO("IPHC: remove 12 b of both source & dest with prefix 0xFOB\n");
CHECK_BUFFER_SPACE(1);
*hc06_ptr =
(uint8_t)((UIP_HTONS(udp_buf->srcport) -
SICSLOWPAN_UDP_4_BIT_PORT_MIN) << 4) +
@ -954,6 +980,7 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
/* we can compress 8 bits of dest, leave source. */
*next_nhc = SICSLOWPAN_NHC_UDP_CS_P_01;
LOG_INFO("IPHC: leave source, remove 8 bits of dest with prefix 0xF0\n");
CHECK_BUFFER_SPACE(3);
memcpy(hc06_ptr, &udp_buf->srcport, 2);
*(hc06_ptr + 2) =
(uint8_t)((UIP_HTONS(udp_buf->destport) -
@ -963,6 +990,7 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
/* we can compress 8 bits of src, leave dest. Copy compressed port */
*next_nhc = SICSLOWPAN_NHC_UDP_CS_P_10;
LOG_INFO("IPHC: remove 8 bits of source with prefix 0xF0, leave dest. hch: %i\n", *next_nhc);
CHECK_BUFFER_SPACE(3);
*hc06_ptr =
(uint8_t)((UIP_HTONS(udp_buf->srcport) -
SICSLOWPAN_UDP_8_BIT_PORT_MIN));
@ -972,10 +1000,12 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
/* we cannot compress. Copy uncompressed ports, full checksum */
*next_nhc = SICSLOWPAN_NHC_UDP_CS_P_00;
LOG_INFO("IPHC: cannot compress UDP headers\n");
CHECK_BUFFER_SPACE(4);
memcpy(hc06_ptr, &udp_buf->srcport, 4);
hc06_ptr += 4;
}
/* always inline the checksum */
CHECK_BUFFER_SPACE(2);
memcpy(hc06_ptr, &udp_buf->udpchksum, 2);
hc06_ptr += 2;
uncomp_hdr_len += UIP_UDPH_LEN;
@ -1006,6 +1036,8 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
}
packetbuf_hdr_len = hc06_ptr - packetbuf_ptr;
return 1;
}
/*--------------------------------------------------------------------*/
@ -1477,7 +1509,6 @@ static uint8_t
output(const linkaddr_t *localdest)
{
int framer_hdrlen;
int max_payload;
/* The MAC address of the destination of the packet */
linkaddr_t dest;
@ -1513,6 +1544,20 @@ output(const linkaddr_t *localdest)
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS,
uipbuf_get_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS));
/* Calculate NETSTACK_FRAMER's header length, that will be added in the NETSTACK_MAC */
#ifndef SICSLOWPAN_USE_FIXED_HDRLEN
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &dest);
framer_hdrlen = NETSTACK_FRAMER.length();
if(framer_hdrlen < 0) {
/* Framing failed, we assume the maximum header length */
framer_hdrlen = SICSLOWPAN_FIXED_HDRLEN;
}
#else /* USE_FRAMER_HDRLEN */
framer_hdrlen = SICSLOWPAN_FIXED_HDRLEN;
#endif /* USE_FRAMER_HDRLEN */
mac_max_payload = MAC_MAX_PAYLOAD - framer_hdrlen;
/* Try to compress the headers */
#if SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_IPV6
compress_hdr_ipv6(&dest);
@ -1526,26 +1571,14 @@ output(const linkaddr_t *localdest)
}
#endif /* SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_6LORH */
#if SICSLOWPAN_COMPRESSION >= SICSLOWPAN_COMPRESSION_IPHC
compress_hdr_iphc(&dest);
if(compress_hdr_iphc(&dest) == 0) {
/* Warning should already be issued by function above */
return 0;
}
#endif /* SICSLOWPAN_COMPRESSION >= SICSLOWPAN_COMPRESSION_IPHC */
LOG_INFO("output: header of len %d\n", packetbuf_hdr_len);
/* Calculate NETSTACK_FRAMER's header length, that will be added in the NETSTACK_MAC.
* We calculate it here only to make a better decision of whether the outgoing packet
* needs to be fragmented or not. */
#ifndef SICSLOWPAN_USE_FIXED_HDRLEN
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &dest);
framer_hdrlen = NETSTACK_FRAMER.length();
if(framer_hdrlen < 0) {
/* Framing failed, we assume the maximum header length */
framer_hdrlen = SICSLOWPAN_FIXED_HDRLEN;
}
#else /* USE_FRAMER_HDRLEN */
framer_hdrlen = SICSLOWPAN_FIXED_HDRLEN;
#endif /* USE_FRAMER_HDRLEN */
max_payload = MAC_MAX_PAYLOAD - framer_hdrlen;
if((int)uip_len - (int)uncomp_hdr_len > max_payload - (int)packetbuf_hdr_len) {
if((int)uip_len - (int)uncomp_hdr_len > mac_max_payload - (int)packetbuf_hdr_len) {
#if SICSLOWPAN_CONF_FRAG
/* Number of bytes processed. */
uint16_t processed_ip_out_len;
@ -1560,7 +1593,7 @@ output(const linkaddr_t *localdest)
* IPv6/IPHC/HC_UDP dispatchs/headers.
* The following fragments contain only the fragn dispatch.
*/
int estimated_fragments = ((int)uip_len) / (max_payload - SICSLOWPAN_FRAGN_HDR_LEN) + 1;
int estimated_fragments = ((int)uip_len) / (mac_max_payload - SICSLOWPAN_FRAGN_HDR_LEN) + 1;
int freebuf = queuebuf_numfree() - 1;
LOG_INFO("uip_len: %d, fragments: %d, free bufs: %d\n", uip_len, estimated_fragments, freebuf);
if(freebuf < estimated_fragments) {
@ -1590,8 +1623,17 @@ output(const linkaddr_t *localdest)
/* Copy payload and send */
packetbuf_hdr_len += SICSLOWPAN_FRAG1_HDR_LEN;
packetbuf_payload_len = (max_payload - packetbuf_hdr_len) & 0xfffffff8;
packetbuf_payload_len = (mac_max_payload - packetbuf_hdr_len) & 0xfffffff8;
LOG_INFO_("(len %d, tag %d)\n", packetbuf_payload_len, frag_tag);
if(packetbuf_payload_len < 0) {
/* The current implementation requires that all headers fit in the first
* fragment. Here is a corner case where the header did fit packetbuf
* but do no longer fit after truncating for a length multiple of 8. */
LOG_WARN("compressed header does not fit first fragment\n");
return 0;
}
memcpy(packetbuf_ptr + packetbuf_hdr_len,
(uint8_t *)UIP_IP_BUF + uncomp_hdr_len, packetbuf_payload_len);
packetbuf_set_datalen(packetbuf_payload_len + packetbuf_hdr_len);
@ -1626,7 +1668,7 @@ output(const linkaddr_t *localdest)
/* uip_htons((SICSLOWPAN_DISPATCH_FRAGN << 8) | uip_len); */
SET16(PACKETBUF_FRAG_PTR, PACKETBUF_FRAG_DISPATCH_SIZE,
((SICSLOWPAN_DISPATCH_FRAGN << 8) | uip_len));
packetbuf_payload_len = (max_payload - packetbuf_hdr_len) & 0xfffffff8;
packetbuf_payload_len = (mac_max_payload - packetbuf_hdr_len) & 0xfffffff8;
while(processed_ip_out_len < uip_len) {
LOG_INFO("output: fragment ");
PACKETBUF_FRAG_PTR[PACKETBUF_FRAG_OFFSET] = processed_ip_out_len >> 3;

View File

@ -829,7 +829,7 @@ rpl_select_dag(rpl_instance_t *instance, rpl_parent_t *p)
if(best_dag->preferred_parent != last_parent) {
rpl_set_default_route(instance, rpl_parent_get_ipaddr(best_dag->preferred_parent));
PRINTF("RPL: Changed preferred parent, rank changed from %u to %u\n",
(unsigned)old_rank, best_dag->rank);
(unsigned)old_rank, best_dag->rank);
RPL_STAT(rpl_stats.parent_switch++);
if(RPL_IS_STORING(instance)) {
if(last_parent != NULL) {
@ -848,7 +848,7 @@ rpl_select_dag(rpl_instance_t *instance, rpl_parent_t *p)
#endif
} else if(best_dag->rank != old_rank) {
PRINTF("RPL: Preferred parent update, rank changed from %u to %u\n",
(unsigned)old_rank, best_dag->rank);
(unsigned)old_rank, best_dag->rank);
}
return best_dag;
}

View File

@ -45,7 +45,6 @@
* On startup, fills the area between the stack and the heap with a known pattern.
* During execution, the fill can be checked in order to find out
* the extent to which the stack has been used.
*
*
* @{
*/

View File

@ -22,6 +22,7 @@ rpl-border-router/sky \
slip-radio/sky \
ipv6-hooks/sky \
nullnet/native \
mqtt-client/native \
TOOLS=

View File

@ -6,7 +6,7 @@ while(true) {
YIELD();
log.log(time + " " + "node-" + id + " "+ msg + "\n");
if(msg.contains("=check-me=") == false) {
continue;
}
@ -23,4 +23,3 @@ if(failed) {
log.testFailed();
}
log.testOK();

View File

@ -11,12 +11,12 @@ while(true) {
log.log("> " + msg + "\n");
var found = msg.match(re);
if(found) {
var n = parseInt(found[1]);
minusage = minusage < n ? minusage : n;
maxusage = maxusage > n ? maxusage : n;
if(minusage < 800 && maxusage >= 1000) {
log.testOK();
}

View File

@ -24,4 +24,3 @@ if(failed) {
log.testFailed();
}
log.testOK();