Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9e35f8b
Add support for the ESP32 platform and related example projects.
sbgaia Sep 15, 2025
d3f0a58
Add sdkconfig to .gitignore
sbgaia Sep 18, 2025
9aadfc8
Remove IDF setup from buildAll.sh script
sbgaia Sep 18, 2025
eb59df8
Refactor platform name from ESP32 to ESPIDF, updating related CMake a…
sbgaia Sep 18, 2025
a6772fc
Add platform support to include FreeRTOS and ESP-IDF, updating CMake …
sbgaia Sep 19, 2025
15aefa0
Revert unused parameter handling to (void)super for consistency.
sbgaia Sep 19, 2025
91feffc
Format code.
sbgaia Sep 19, 2025
ef8c296
Remove sdkconfig
sbgaia Sep 25, 2025
9922666
Update CPU clock frequency in FreeRTOSConfig.h for raspberry pico
sbgaia Sep 25, 2025
08e341b
Improve comments for unused parameter suppression in CMakeLists.txt
sbgaia Oct 22, 2025
7821fbc
Refactor timeout handling in CMakeLists.txt files and update build sc…
sbgaia Oct 22, 2025
ee4ca35
Add README.md for Reactor-UC examples
sbgaia Oct 22, 2025
e5e19ee
Add startup reaction in TimerSource for initialization procedures (e.…
sbgaia Oct 23, 2025
039fcb2
Add startup reaction in hello and blink examples
sbgaia Oct 23, 2025
ca7e405
Enable tick hook and add overflow handling for 32-bit architectures i…
sbgaia Oct 23, 2025
d1b2c3c
Enable tick hook in FreeRTOSConfig
sbgaia Oct 23, 2025
7b593ba
Refactor pico_toggle_led invoked in startup reaction
sbgaia Oct 23, 2025
435f07c
Refactor pico_toggle_led invoked in startup reaction
sbgaia Oct 23, 2025
42785c9
Enable USB and UART for blinky example
sbgaia Oct 23, 2025
8f09e15
Add TimerSource startup reaction
sbgaia Oct 23, 2025
a7e1763
Add startup reaction in riot examples
sbgaia Oct 23, 2025
eb84f3e
Add startup reaction in zephyr examples
sbgaia Oct 23, 2025
ea9bb7c
Format code
sbgaia Oct 23, 2025
ba85baa
Fix platform default to FREERTOS in CMakeLists.txt
sbgaia Oct 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ cmake-build-release
doc/html
doc/latex
doc/markdown/platform
sdkconfig
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ elseif (PLATFORM STREQUAL "PICO")

elseif (PLATFORM STREQUAL "PATMOS")
add_library(reactor-uc STATIC ${SOURCES})
elseif( PLATFORM STREQUAL "FREERTOS")
add_library(reactor-uc STATIC ${SOURCES})
# Include FreeRTOSConfig directory
target_include_directories(reactor-uc PUBLIC ${FREERTOS_CONFIG_PATH})

target_link_libraries(reactor-uc PUBLIC FreeRTOS-Kernel FreeRTOS-Kernel-Heap1)
elseif (PLATFORM STREQUAL "ESP_IDF")
add_library(reactor-uc STATIC ${SOURCES})
target_link_libraries(reactor-uc PUBLIC idf::freertos idf::spi_flash idf::esp_timer)
else ()
message(FATAL_ERROR "No valid platform specified")
endif ()
Expand Down
8 changes: 7 additions & 1 deletion examples/common/timer_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ LF_REACTOR_CTOR_SIGNATURE(TimerSource) {
LF_TIMER_REGISTER_EFFECT(self->t, self->r);
}

LF_ENTRY_POINT(TimerSource,32,32, SEC(1), false, false);
#ifdef TIMEOUT
LF_ENTRY_POINT(TimerSource,32,32, SEC(TIMEOUT), false, false);
#elif defined(TIMEOUT_FOREVER)
LF_ENTRY_POINT(TimerSource,32,32, FOREVER, false, false);
#else
LF_ENTRY_POINT(TimerSource,32,32, SEC(1), false, false);
#endif
46 changes: 46 additions & 0 deletions examples/esp-idf/blink/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@


cmake_minimum_required(VERSION 3.20.0)
set(PLATFORM "ESP_IDF" CACHE STRING "Platform to target")
set(BUILD_EXAMPLES OFF CAHCHE BOOL)
set(TIMEOUT "1" ON CACHE STRING "Timeout in seconds, disable for infinite")

if(TIMEOUT)
add_compile_definitions(TIMEOUT=${TIMEOUT})
else()
add_compile_definitions(TIMEOUT_FOREVER)
endif()

set(IDF_COMPONENTS "freertos" "esptool_py" "driver" "led_strip")

if(DEFINED ENV{IDF_PATH})
else()
message(FATAL_ERROR "IDF_PATH environment variable not set")
endif()

# Include for ESP-IDF build system functions
include($ENV{IDF_PATH}/tools/cmake/idf.cmake)
# Set led_strip component path
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/../idf-extra-components/led_strip)
idf_build_component($ENV{IDF_PATH}/../idf-extra-components/led_strip)

project(blink)

# Create idf::{target} and idf::freertos static libraries
idf_build_process(${IDF_TARGET}
COMPONENTS ${IDF_COMPONENTS}
SDKCONFIG ${CMAKE_CURRENT_LIST_DIR}/sdkconfig
BUILD_DIR ${CMAKE_BINARY_DIR})

add_subdirectory(../../../ reactor-uc)

# suppress unused parameter warnings
target_compile_options(reactor-uc PRIVATE -Wno-unused-parameter)

set(elf_file ${CMAKE_PROJECT_NAME}.elf)
add_executable(${elf_file} main.c)
target_link_libraries(${elf_file} PRIVATE reactor-uc idf::led_strip idf::driver)

idf_build_executable(${elf_file})


100 changes: 100 additions & 0 deletions examples/esp-idf/blink/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#include <stdio.h>
#include <inttypes.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_chip_info.h"
#include "esp_flash.h"
#include "esp_system.h"
#include "reactor-uc/reactor-uc.h"
#include "reactor-uc/environment.h"
#include "sys/time.h"
#include "esp_timer.h"
#include "../../common/timer_source.h"
#include "led_strip.h"
#include "driver/gpio.h"

#define BLINK_GPIO 8
#define CONFIG_BLINK_LED_STRIP 1
#define CONFIG_BLINK_LED_STRIP_BACKEND_SPI 1
static uint8_t s_led_state = 0;

#ifdef CONFIG_BLINK_LED_STRIP

static led_strip_handle_t led_strip;

static void blink_led(void)
{
/* If the addressable LED is enabled */
if (s_led_state) {
/* Set the LED pixel using RGB from 0 (0%) to 255 (100%) for each color */
led_strip_set_pixel(led_strip, 0, 16, 16, 16);
/* Refresh the strip to send data */
led_strip_refresh(led_strip);
} else {
/* Set all LED off to clear all pixels */
led_strip_clear(led_strip);
}
}

static void configure_led(void)
{
printf("Example configured to blink addressable LED!");
/* LED strip initialization with the GPIO and pixels number*/
led_strip_config_t strip_config = {
.strip_gpio_num = BLINK_GPIO,
.max_leds = 1, // at least one LED on board
};
#if CONFIG_BLINK_LED_STRIP_BACKEND_RMT
led_strip_rmt_config_t rmt_config = {
.resolution_hz = 10 * 1000 * 1000, // 10MHz
.flags.with_dma = false,
};
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));
#elif CONFIG_BLINK_LED_STRIP_BACKEND_SPI
led_strip_spi_config_t spi_config = {
.spi_bus = SPI2_HOST,
.flags.with_dma = true,
};
ESP_ERROR_CHECK(led_strip_new_spi_device(&strip_config, &spi_config, &led_strip));
#else
#error "unsupported LED strip backend"
#endif
/* Set all LED off to clear all pixels */
led_strip_clear(led_strip);
}

#elif CONFIG_BLINK_LED_GPIO

static void blink_led(void)
{
/* Set the GPIO level according to the state (LOW or HIGH)*/
gpio_set_level(BLINK_GPIO, s_led_state);
}

static void configure_led(void)
{
ESP_LOGI(TAG, "Example configured to blink GPIO LED!");
gpio_reset_pin(BLINK_GPIO);
/* Set the GPIO as a push/pull output */
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
}

#else
#error "unsupported LED type"
#endif

LF_DEFINE_REACTION_BODY(TimerSource, r) {
LF_SCOPE_SELF(TimerSource);
LF_SCOPE_ENV();
printf("Turning the LED %s! @ lt=%lld, pt=%lld\n", s_led_state == true ? "ON" : "OFF", env->get_elapsed_logical_time(env), env->get_physical_time(env));
blink_led();
/* Toggle the LED state */
s_led_state = !s_led_state;
}

void app_main(void)
{
configure_led();
lf_start();
}
18 changes: 18 additions & 0 deletions examples/esp-idf/buildAll.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -e

# Set the target platform
IDF_TARGET="esp32c6"
# List of folders
FOLDERS=("hello" "blink")

# Iterate over each folder and execute the command
for dir in "${FOLDERS[@]}"; do
echo "Entering $dir"
pushd $dir

rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=$IDF_PATH/tools/cmake/toolchain-${IDF_TARGET}.cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DPLATFORM=ESP_IDF -DIDF_TARGET=${IDF_TARGET} -GNinja
cmake --build . -j
popd
done
39 changes: 39 additions & 0 deletions examples/esp-idf/hello/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
cmake_minimum_required(VERSION 3.20.0)
set(PLATFORM "ESP_IDF" CACHE STRING "Platform to target")
set(BUILD_EXAMPLES OFF CAHCHE BOOL)
set(TIMEOUT "1" ON CACHE STRING "Timeout in seconds, disable for infinite")

if(TIMEOUT)
add_compile_definitions(TIMEOUT=${TIMEOUT})
else()
add_compile_definitions(TIMEOUT_FOREVER)
endif()

set(IDF_COMPONENTS "freertos" "esptool_py")

if(DEFINED ENV{IDF_PATH})
else()
message(FATAL_ERROR "IDF_PATH environment variable not set")
endif()

# Include for ESP-IDF build system functions
include($ENV{IDF_PATH}/tools/cmake/idf.cmake)

project(hello)

# Create idf::{target} and idf::freertos static libraries
idf_build_process(${IDF_TARGET}
COMPONENTS ${IDF_COMPONENTS}
SDKCONFIG ${CMAKE_CURRENT_LIST_DIR}/sdkconfig
BUILD_DIR ${CMAKE_BINARY_DIR})

add_subdirectory(../../../ reactor-uc)

# suppress unused parameter warnings
target_compile_options(reactor-uc PRIVATE -Wno-unused-parameter)

set(elf_file ${CMAKE_PROJECT_NAME}.elf)
add_executable(${elf_file} main.c)
target_link_libraries(${elf_file} PRIVATE reactor-uc)

idf_build_executable(${elf_file})
51 changes: 51 additions & 0 deletions examples/esp-idf/hello/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <stdio.h>
#include <inttypes.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_chip_info.h"
#include "esp_flash.h"
#include "esp_system.h"
#include "reactor-uc/reactor-uc.h"
#include "reactor-uc/environment.h"
#include "sys/time.h"
#include "esp_timer.h"
#include "../../common/timer_source.h"

LF_DEFINE_REACTION_BODY(TimerSource, r) {
LF_SCOPE_SELF(TimerSource);
LF_SCOPE_ENV();
printf("Hello World @ lt=%lld, pt=%lld\n", env->get_elapsed_logical_time(env), env->get_physical_time(env));

/* Print chip information */
esp_chip_info_t chip_info;
uint32_t flash_size;
esp_chip_info(&chip_info);

printf("This is %s chip with %d CPU core(s), %s%s%s%s, ",
CONFIG_IDF_TARGET,
chip_info.cores,
(chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "",
(chip_info.features & CHIP_FEATURE_BT) ? "BT" : "",
(chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "",
(chip_info.features & CHIP_FEATURE_IEEE802154) ? ", 802.15.4 (Zigbee/Thread)" : "");

unsigned major_rev = chip_info.revision / 100;
unsigned minor_rev = chip_info.revision % 100;
printf("silicon revision v%d.%d, ", major_rev, minor_rev);

if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) {
printf("Get flash size failed");
return;
}

printf("%" PRIu32 "MB %s flash\n", flash_size / (uint32_t)(1024 * 1024),
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");

printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size());
}

void app_main(void)
{
lf_start();
}
13 changes: 13 additions & 0 deletions examples/freertos/buildAll.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

# Set the target board
PICO_BOARD="pico_w"
PICO_FOLDER="pico"
echo "Entering $PICO_FOLDER"
pushd $PICO_FOLDER

rm -rf build && mkdir build && cd build
cmake -DPICO_BOARD=pico_w -DPLATFORM=FREERTOS -DTIMEOUT=OFF ..
cmake --build . -j
popd
47 changes: 47 additions & 0 deletions examples/freertos/pico/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
cmake_minimum_required(VERSION 3.20.0)
set(PLATFORM "PICO" CACHE STRING "Platform to target")
set(BUILD_EXAMPLES OFF CAHCHE BOOL)
set(TIMEOUT "1" ON CACHE STRING "Timeout in seconds, disable for infinite")

if(TIMEOUT)
add_compile_definitions(TIMEOUT=${TIMEOUT})
else()
add_compile_definitions(TIMEOUT_FOREVER)
endif()

if (DEFINED ENV{PICO_SDK_PATH})
include("$ENV{PICO_SDK_PATH}/pico_sdk_init.cmake")
else()
message(FATAL_ERROR "PICO_SDK_PATH environment variable not set")
endif()

if (DEFINED ENV{FREERTOS_KERNEL_PATH})
include("$ENV{FREERTOS_KERNEL_PATH}/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake")
else()
message(FATAL_ERROR "FREERTOS_KERNEL_PATH environment variable not set")
endif()

if (NOT DEFINED ENV{FREERTOS_DEMO_PATH})
message(FATAL_ERROR "FREERTOS_DEMO_PATH environment variable not set")
endif()

project(reactor-uc-pico)
pico_sdk_init()

add_executable(blinky src/blinky.c)

pico_enable_stdio_usb(blinky 1)
pico_enable_stdio_uart(blinky 0)
target_include_directories(blinky PRIVATE
${CMAKE_CURRENT_LIST_DIR}
$ENV{FREERTOS_DEMO_PATH}/Common/include)

# Set FreeRTOSConfig path for the reactor-uc library
set(FREERTOS_CONFIG_PATH ${CMAKE_CURRENT_LIST_DIR}/include)

add_subdirectory(../../../ reactor-uc)
target_link_libraries(blinky PRIVATE reactor-uc pico_stdlib pico_sync)

if (PICO_CYW43_SUPPORTED)
target_link_libraries(blinky PRIVATE pico_cyw43_arch_none)
endif()
Loading
Loading