-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add RIOT examples * fixup! Add RIOT examples Fix example makefiles * fixup! Add RIOT examples Add RIOT networking modules to example makefiles * fixup! Add RIOT examples Add RIOT pthread module to examples * fixup! Add RIOT examples Remove -Wcast-align CFLAG to make reactor-uc build for RIOT * fixup! Add RIOT examples Fix examples to build for all boards * fixup! Add RIOT examples Remove -Wstrict-prototypes and -Wold-style-definition CFLAG to make reactor-uc build for RIOT * fixup! Add RIOT examples Migrate blinky example to macros * Automatically enable RIOT modules if NETWORK_POSIX_TCP is defined * Update readme: Add RIOT examples tutorial * Fix RIOT pthread wrapper compatibility * Remove tcp test riot examples * Fix riot blinky example * Add RIOT hello example
- Loading branch information
1 parent
fa23939
commit 0db8386
Showing
17 changed files
with
240 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# name of your application | ||
APPLICATION = lf-test | ||
|
||
# If no BOARD is found in the environment, use this default: | ||
BOARD ?= native | ||
|
||
# Comment this out to disable code in RIOT that does safety checking | ||
# which is not needed in a production environment but helps in the | ||
# development process: | ||
DEVELHELP ?= 1 | ||
|
||
# Change this to 0 show compiler invocation lines by default: | ||
QUIET ?= 1 | ||
|
||
# Enable reactor-uc features | ||
# CFLAGS += -DNETWORK_POSIX_TCP | ||
|
||
include $(CURDIR)/../../../make/riot/riot.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "board.h" | ||
#include "reactor-uc/reactor-uc.h" | ||
#include <inttypes.h> | ||
|
||
DEFINE_TIMER(MyTimer, 1, MSEC(0), MSEC(100)) | ||
DEFINE_REACTION(MyReactor, 0, 0) | ||
|
||
typedef struct { | ||
Reactor super; | ||
MyReactor_0 my_reaction; | ||
MyTimer timer; | ||
Reaction *_reactions[1]; | ||
Trigger *_triggers[1]; | ||
} MyReactor; | ||
|
||
REACTION_BODY(MyReactor, 0, { | ||
LED0_TOGGLE; | ||
printf("Hello World @ %" PRId64 "\n", env->get_elapsed_physical_time(env)); | ||
}) | ||
|
||
void MyReactor_ctor(MyReactor *self, Environment *env) { | ||
self->_reactions[0] = (Reaction *)&self->my_reaction; | ||
self->_triggers[0] = (Trigger *)&self->timer; | ||
|
||
Reactor_ctor(&self->super, "MyReactor", env, NULL, NULL, 0, self->_reactions, 1, self->_triggers, 1); | ||
MyReactor_0_ctor(&self->my_reaction, &self->super); | ||
MyTimer_ctor(&self->timer, &self->super); | ||
|
||
TIMER_REGISTER_EFFECT(self->timer, self->my_reaction); | ||
} | ||
|
||
ENTRY_POINT(MyReactor, FOREVER, true) | ||
|
||
int main(void) { | ||
lf_start(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# name of your application | ||
APPLICATION = lf-test | ||
|
||
# If no BOARD is found in the environment, use this default: | ||
BOARD ?= native | ||
|
||
# Comment this out to disable code in RIOT that does safety checking | ||
# which is not needed in a production environment but helps in the | ||
# development process: | ||
DEVELHELP ?= 1 | ||
|
||
# Change this to 0 show compiler invocation lines by default: | ||
QUIET ?= 1 | ||
|
||
# Enable reactor-uc features | ||
# CFLAGS += -DNETWORK_POSIX_TCP | ||
|
||
include $(CURDIR)/../../../make/riot/riot.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "reactor-uc/reactor-uc.h" | ||
#include <inttypes.h> | ||
|
||
DEFINE_TIMER(MyTimer, 1, 0, MSEC(100)) | ||
DEFINE_REACTION(MyReactor, 0, 0) | ||
|
||
typedef struct { | ||
Reactor super; | ||
MyReactor_0 my_reaction; | ||
MyTimer timer; | ||
Reaction *_reactions[1]; | ||
Trigger *_triggers[1]; | ||
} MyReactor; | ||
|
||
REACTION_BODY(MyReactor, 0, { printf("Hello World @ %lld\n", env->get_elapsed_logical_time(env)); }) | ||
|
||
void MyReactor_ctor(MyReactor *self, Environment *env) { | ||
self->_reactions[0] = (Reaction *)&self->my_reaction; | ||
self->_triggers[0] = (Trigger *)&self->timer; | ||
Reactor_ctor(&self->super, "MyReactor", env, NULL, NULL, 0, self->_reactions, 1, self->_triggers, 1); | ||
MyReactor_0_ctor(&self->my_reaction, &self->super); | ||
Timer_ctor(&self->timer.super, &self->super, MSEC(0), MSEC(100), self->timer.effects, 1); | ||
TIMER_REGISTER_EFFECT(self->timer, self->my_reaction); | ||
} | ||
|
||
ENTRY_POINT(MyReactor, FOREVER, true) | ||
|
||
int main() { | ||
lf_start(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
include $(RIOTBASE)/Makefile.base | ||
|
||
SRC_DIR := $(realpath $(CURDIR)/../../../../external/nanopb) | ||
|
||
all: | ||
$(QQ)"$(MAKE)" -C $(SRC_DIR) -f $(CURDIR)/nanopb.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CFLAGS += -DPLATFORM_RIOT=1 | ||
|
||
# Use an immediate variable to evaluate `MAKEFILE_LIST` now | ||
USEMODULE_INCLUDES_nanopb := $(LAST_MAKEFILEDIR)/../../../../external | ||
USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_nanopb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
MODULE = nanopb | ||
|
||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
include $(RIOTBASE)/Makefile.base | ||
|
||
SRC_DIR := $(realpath $(CURDIR)/../../../../external/proto) | ||
|
||
all: | ||
$(QQ)"$(MAKE)" -C $(SRC_DIR) -f $(CURDIR)/proto.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CFLAGS += -DPLATFORM_RIOT=1 | ||
|
||
# Use an immediate variable to evaluate `MAKEFILE_LIST` now | ||
USEMODULE_INCLUDES_proto := $(LAST_MAKEFILEDIR)/../../../../external | ||
USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_proto) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
MODULE = proto | ||
|
||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
include $(RIOTBASE)/Makefile.base | ||
|
||
SRC_DIR := $(realpath $(CURDIR)/../../../../src) | ||
|
||
all: | ||
$(QQ)"$(MAKE)" -C $(SRC_DIR) -f $(CURDIR)/reactor-uc.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
USEMODULE += ztimer64 | ||
USEMODULE += ztimer64_usec | ||
USEMODULE += nanopb | ||
USEMODULE += proto | ||
|
||
# If Feature NETWORK_POSIX_TCP is enabled | ||
ifeq ($(filter -DNETWORK_POSIX_TCP, $(CFLAGS)), -DNETWORK_POSIX_TCP) | ||
# Enable networking | ||
USEMODULE += netdev_default | ||
USEMODULE += auto_init_gnrc_netif | ||
|
||
# Enable sockets | ||
USEMODULE += gnrc_ipv6_default | ||
USEMODULE += sock_tcp | ||
USEMODULE += posix_sockets | ||
USEMODULE += posix_sleep | ||
USEMODULE += posix_inet | ||
|
||
# Enable posix threads | ||
ifneq ($(BOARD),native) | ||
USEMODULE += pthread | ||
endif | ||
endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
CFLAGS += -DPLATFORM_RIOT=1 | ||
|
||
# Remove the -Wcast-align flag for this module | ||
CFLAGS := $(filter-out -Wcast-align,$(CFLAGS)) | ||
|
||
# Remove the -Wstrict-prototypes flag for this module | ||
CFLAGS := $(filter-out -Wstrict-prototypes,$(CFLAGS)) | ||
|
||
# Remove the -Wold-style-definition flag for this module | ||
CFLAGS := $(filter-out -Wold-style-definition,$(CFLAGS)) | ||
|
||
# Use an immediate variable to evaluate `MAKEFILE_LIST` now | ||
USEMODULE_INCLUDES_reactor-uc := $(LAST_MAKEFILEDIR)/../../../../include | ||
USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_reactor-uc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
MODULE = reactor-uc | ||
|
||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
RIOT_MK_DIR := $(dir $(lastword $(MAKEFILE_LIST))) | ||
|
||
# This has to be the absolute path to the RIOT base directory: | ||
RIOTBASE ?= $(RIOT_MK_DIR)/../../../RIOT | ||
|
||
# Comment this out to disable code in RIOT that does safety checking | ||
# which is not needed in a production environment but helps in the | ||
# development process: | ||
DEVELHELP ?= 1 | ||
|
||
# Change this to 0 show compiler invocation lines by default: | ||
QUIET ?= 1 | ||
|
||
# Use a peripheral timer for the delay, if available | ||
FEATURES_OPTIONAL += periph_timer | ||
|
||
# External modules | ||
EXTERNAL_MODULE_DIRS += $(RIOT_MK_DIR)/external_modules | ||
USEMODULE += reactor-uc | ||
|
||
|
||
|
||
include $(RIOTBASE)/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters