-
Notifications
You must be signed in to change notification settings - Fork 2.1k
pkg/openwsn: re-integrate the network stack as a package #8570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,6 +147,9 @@ void at86rf2xx_tx_prepare(at86rf2xx_t *dev) | |
| if (state != AT86RF2XX_STATE_TX_ARET_ON) { | ||
| dev->idle_state = state; | ||
| } | ||
|
|
||
| at86rf2xx_set_state(dev, AT86RF2XX_STATE_PLL_ON); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably also a TODO, but hard-wiring states required for OpenWSN seems like a bad idea to me. |
||
|
|
||
| dev->tx_frame_len = IEEE802154_FCS_LEN; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,13 +190,13 @@ static int _set_state(at86rf2xx_t *dev, netopt_state_t state) | |
| { | ||
| switch (state) { | ||
| case NETOPT_STATE_STANDBY: | ||
| at86rf2xx_set_state(dev, AT86RF2XX_STATE_TRX_OFF); | ||
| at86rf2xx_set_state(dev, AT86RF2XX_STATE_FORCE_TRX_OFF); | ||
| break; | ||
| case NETOPT_STATE_SLEEP: | ||
| at86rf2xx_set_state(dev, AT86RF2XX_STATE_SLEEP); | ||
| break; | ||
| case NETOPT_STATE_IDLE: | ||
| at86rf2xx_set_state(dev, AT86RF2XX_STATE_RX_AACK_ON); | ||
| at86rf2xx_set_state(dev, AT86RF2XX_STATE_RX_ON); | ||
| break; | ||
| case NETOPT_STATE_TX: | ||
| if (dev->netdev.flags & AT86RF2XX_OPT_PRELOADING) { | ||
|
|
@@ -216,7 +216,7 @@ static int _set_state(at86rf2xx_t *dev, netopt_state_t state) | |
| * know when to switch back to the idle state. */ | ||
| ++dev->pending_tx; | ||
| } | ||
| at86rf2xx_set_state(dev, AT86RF2XX_STATE_TX_ARET_ON); | ||
| at86rf2xx_set_state(dev, AT86RF2XX_STATE_PLL_ON); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dito. |
||
| at86rf2xx_tx_exec(dev); | ||
| } | ||
| break; | ||
|
|
@@ -607,7 +607,8 @@ static void _isr(netdev_t *netdev) | |
|
|
||
| if (irq_mask & AT86RF2XX_IRQ_STATUS_MASK__TRX_END) { | ||
| if ((state == AT86RF2XX_STATE_RX_AACK_ON) | ||
| || (state == AT86RF2XX_STATE_BUSY_RX_AACK)) { | ||
| || (state == AT86RF2XX_STATE_BUSY_RX_AACK) | ||
| || (state == AT86RF2XX_STATE_RX_ON)) { | ||
| DEBUG("[at86rf2xx] EVT - RX_END\n"); | ||
| if (!(dev->netdev.flags & AT86RF2XX_OPT_TELL_RX_END)) { | ||
| return; | ||
|
|
@@ -663,6 +664,21 @@ static void _isr(netdev_t *netdev) | |
| trac_status >> 5); | ||
| } | ||
| } | ||
| } else if (state == AT86RF2XX_STATE_PLL_ON) { | ||
| at86rf2xx_set_state(dev, dev->idle_state); | ||
| DEBUG("[at86rf2xx] return to state 0x%x\n",dev->idle_state); | ||
|
|
||
| DEBUG("[at86rf2xx] EVT - TX_END\n"); | ||
| if (netdev->event_callback && (dev->netdev.flags & AT86RF2XX_OPT_TELL_TX_END)) { | ||
| if ((trac_status>>5)==7 || trac_status==AT86RF2XX_TRX_STATE__TRAC_SUCCESS) { | ||
| /* Even though the reset value for register bits TRAC_STATUS is 0, the RX_AACK and | ||
| * TX_ARET procedures set the register bits to TRAC_STATUS = 7 (INVALID) when it is started. */ | ||
| netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE); | ||
| DEBUG("[at86rf2xx] TX SUCCESS\n"); | ||
| } else { | ||
| DEBUG("[at86rf2xx] Unhandled TRAC_STATUS: %d\n",trac_status >> 5); | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move to separate PR? |
||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| PKG_NAME=openwsn-fw | ||
| PKG_URL=https://github.com/openwsn-berkeley/openwsn-fw.git | ||
| PKG_VERSION=dcf26e99b65ace4b1d8551a9962ee976fe7f0359 | ||
| PKG_BUILDDIR ?= $(BINDIRBASE)/pkg/$(BOARD)/$(PKG_NAME) | ||
| PKG_LICENSE=BSD-3-Clause | ||
|
|
||
| .PHONY: all | ||
|
|
||
| all: git-download | ||
| "$(MAKE)" -C $(PKG_BUILDDIR) | ||
|
|
||
| include $(RIOTBASE)/pkg/pkg.mk |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| ifneq (,$(filter openwsn,$(USEPKG))) | ||
| USEMODULE += openwsn_openstack | ||
| USEMODULE += openwsn_drivers | ||
| USEMODULE += openwsn_scheduler | ||
| USEMODULE += openwsn_mac_low | ||
| USEMODULE += openwsn_mac_high | ||
| USEMODULE += openwsn_iphc | ||
| USEMODULE += openwsn_ipv6 | ||
| USEMODULE += openwsn_transport | ||
| USEMODULE += openwsn_crosslayers | ||
|
|
||
| USEMODULE += luid | ||
| USEMODULE += netdev_default | ||
| FEATURES_REQUIRED += periph_gpio | ||
| FEATURES_REQUIRED += periph_rtt | ||
| FEATURES_REQUIRED += periph_spi | ||
| FEATURES_REQUIRED += periph_timer | ||
| FEATURES_REQUIRED += periph_uart | ||
| endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| OPENWSN_DIR = $(RIOTBASE)/pkg/openwsn | ||
|
|
||
| INCLUDES += -I$(PKGDIRBASE)/openwsn-fw \ | ||
| -I$(PKGDIRBASE)/openwsn-fw/kernel \ | ||
| -I$(PKGDIRBASE)/openwsn-fw/inc \ | ||
| -I$(PKGDIRBASE)/openwsn-fw/drivers/common \ | ||
| -I$(PKGDIRBASE)/openwsn-fw/bsp/boards/ \ | ||
| -I$(PKGDIRBASE)/openwsn-fw/openstack/ \ | ||
| -I$(PKGDIRBASE)/openwsn-fw/openstack/02a-MAClow \ | ||
| -I$(PKGDIRBASE)/openwsn-fw/openstack/02b-MAChigh \ | ||
| -I$(PKGDIRBASE)/openwsn-fw/openstack/03a-IPHC \ | ||
| -I$(PKGDIRBASE)/openwsn-fw/openstack/03b-IPv6 \ | ||
| -I$(PKGDIRBASE)/openwsn-fw/openstack/04-TRAN \ | ||
| -I$(PKGDIRBASE)/openwsn-fw/openstack/cross-layers \ | ||
| -I$(OPENWSN_DIR)/include \ | ||
|
|
||
| DIRS += $(OPENWSN_DIR)/contrib | ||
|
|
||
| CFLAGS += -DISR_STACKSIZE=1024 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| MODULE = openwsn | ||
|
|
||
| include $(RIOTBASE)/Makefile.base |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * Copyright (C) 2018 Hamburg University of Applied Sciences | ||
| * | ||
| * This file is subject to the terms and conditions of the GNU Lesser | ||
| * General Public License v2.1. See the file LICENSE in the top level | ||
| * directory for more details. | ||
| */ | ||
|
|
||
| /** | ||
| * @ingroup pkg_openwsn | ||
| * @{ | ||
| * | ||
| * @file | ||
| * @brief RIOT adaption definition of the "board" bsp module | ||
| * | ||
| * @author Thomas Watteyne <[email protected]>, February 2012 | ||
| * @author Tengfei Chang <[email protected]>, July 2012 | ||
| * @author Peter Kietzmann <[email protected]>, July 2017 | ||
| * | ||
| * @} | ||
| */ | ||
|
|
||
| #include <stdio.h> | ||
|
|
||
| #include "sctimer.h" | ||
| #include "radio.h" | ||
| #include "uart_ow.h" | ||
| #include "board_ow.h" | ||
| #include "debugpins_riot.h" | ||
| #include "ledpins_riot.h" | ||
| #include "thread.h" | ||
| #include "periph/pm.h" | ||
|
|
||
| #define ENABLE_DEBUG (0) | ||
| #include "debug.h" | ||
|
|
||
| void board_init_ow(void) | ||
| { | ||
| DEBUG("OpenWSN board_init\n"); | ||
|
|
||
| DEBUG("pins & leds init\n"); | ||
| #if defined (BOARD_NUCLEO_F103) || defined (BOARD_SAMR21_XPRO) | ||
| ledpins_riot_init(openwsn_ledpins_params); | ||
| #else | ||
| ledpins_riot_init(NULL); | ||
| #endif | ||
| #if defined (BOARD_NUCLEO_F103) | ||
| debugpins_riot_init(openwsn_debugpins_params); | ||
| #else | ||
| debugpins_riot_init(NULL); | ||
| #endif | ||
|
|
||
| DEBUG("sctimer_init\n"); | ||
| sctimer_init(); | ||
|
|
||
| DEBUG("uart_ow init\n"); | ||
| uart_init_ow(); | ||
|
|
||
| DEBUG("Finished board_init\n"); | ||
| } | ||
|
|
||
| void board_sleep(void) | ||
| { | ||
| } | ||
|
|
||
| void board_reset(void) | ||
| { | ||
| puts("OpenWSN board_reset"); | ||
| pm_reboot(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| /* | ||
| * Copyright (C) 2017 Hamburg University of Applied Sciences | ||
| * | ||
| * This file is subject to the terms and conditions of the GNU Lesser | ||
| * General Public License v2.1. See the file LICENSE in the top level | ||
| * directory for more details. | ||
| */ | ||
|
|
||
| /** | ||
| * @ingroup pkg_openwsn | ||
| * @{ | ||
| * | ||
| * @file | ||
| * | ||
| * @author Michael Frey <[email protected]> | ||
| * @author Peter Kietzmann <[email protected]> | ||
| * | ||
| * @} | ||
| */ | ||
|
|
||
| #include "debugpins.h" | ||
| #include "debugpins_riot.h" | ||
|
|
||
| #include <stdint.h> | ||
| #include <string.h> | ||
|
|
||
| /** holds the internal configuration for debug pins */ | ||
| static debugpins_config_t configuration = { | ||
| GPIO_UNDEF, | ||
| GPIO_UNDEF, | ||
| GPIO_UNDEF, | ||
| GPIO_UNDEF, | ||
| GPIO_UNDEF, | ||
| GPIO_UNDEF | ||
| }; | ||
|
|
||
| /** | ||
| * Sets the debug pins for a specific board for OpenWSN | ||
| * | ||
| * @param[in] user_config A configuration of GPIO pins used for debugging. Unused pins need to be defined as GPIO_UNDEF | ||
| */ | ||
| void debugpins_riot_init(const debugpins_config_t *user_config) | ||
| { | ||
| memset(&configuration, GPIO_UNDEF, sizeof(debugpins_config_t)); | ||
|
|
||
| if (user_config != NULL) { | ||
| memcpy(&configuration, user_config, sizeof(debugpins_config_t)); | ||
| debugpins_init(); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_init(void) | ||
| { | ||
| gpio_init(configuration.frame, GPIO_OUT); | ||
| gpio_init(configuration.slot, GPIO_OUT); | ||
| gpio_init(configuration.fsm, GPIO_OUT); | ||
| gpio_init(configuration.task, GPIO_OUT); | ||
| gpio_init(configuration.isr, GPIO_OUT); | ||
| gpio_init(configuration.radio, GPIO_OUT); | ||
|
|
||
| debugpins_frame_clr(); | ||
| debugpins_slot_clr(); | ||
| debugpins_fsm_clr(); | ||
| debugpins_task_clr(); | ||
| debugpins_isr_clr(); | ||
| debugpins_radio_clr(); | ||
| } | ||
|
|
||
| void debugpins_frame_toggle(void) | ||
| { | ||
| if (configuration.frame != GPIO_UNDEF) { | ||
| gpio_toggle(configuration.frame); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_frame_clr(void) | ||
| { | ||
| if (configuration.frame != GPIO_UNDEF) { | ||
| gpio_clear(configuration.frame); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_frame_set(void) | ||
| { | ||
| if (configuration.frame != GPIO_UNDEF) { | ||
| gpio_set(configuration.frame); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_slot_toggle(void) | ||
| { | ||
| if (configuration.slot != GPIO_UNDEF) { | ||
| gpio_toggle(configuration.slot); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_slot_clr(void) | ||
| { | ||
| if (configuration.slot != GPIO_UNDEF) { | ||
| gpio_clear(configuration.slot); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_slot_set(void) | ||
| { | ||
| if (configuration.slot != GPIO_UNDEF) { | ||
| gpio_set(configuration.slot); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_fsm_toggle(void) | ||
| { | ||
| if (configuration.fsm != GPIO_UNDEF) { | ||
| gpio_toggle(configuration.fsm); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_fsm_clr(void) | ||
| { | ||
| if (configuration.fsm != GPIO_UNDEF) { | ||
| gpio_clear(configuration.fsm); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_fsm_set(void) | ||
| { | ||
| if (configuration.fsm != GPIO_UNDEF) { | ||
| gpio_set(configuration.fsm); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_task_toggle(void) | ||
| { | ||
| if (configuration.task != GPIO_UNDEF) { | ||
| gpio_toggle(configuration.task); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_task_clr(void) | ||
| { | ||
| if (configuration.task != GPIO_UNDEF) { | ||
| gpio_clear(configuration.task); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_task_set(void) | ||
| { | ||
| if (configuration.task != GPIO_UNDEF) { | ||
| gpio_set(configuration.task); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_isr_toggle(void) | ||
| { | ||
| if (configuration.isr != GPIO_UNDEF) { | ||
| gpio_toggle(configuration.isr); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_isr_clr(void) | ||
| { | ||
| if (configuration.isr != GPIO_UNDEF) { | ||
| gpio_clear(configuration.isr); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_isr_set(void) | ||
| { | ||
| if (configuration.isr != GPIO_UNDEF) { | ||
| gpio_set(configuration.isr); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_radio_toggle(void) | ||
| { | ||
| if (configuration.radio != GPIO_UNDEF) { | ||
| gpio_toggle(configuration.radio); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_radio_clr(void) | ||
| { | ||
| if (configuration.radio != GPIO_UNDEF) { | ||
| gpio_clear(configuration.radio); | ||
| } | ||
| } | ||
|
|
||
| void debugpins_radio_set(void) | ||
| { | ||
| if (configuration.radio != GPIO_UNDEF) { | ||
| gpio_set(configuration.radio); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably still a TODO, but these should be configured at compile-time, when OpenWSN is present.