Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
59 changes: 20 additions & 39 deletions firmware/libsi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,38 @@ cmake_minimum_required(VERSION "3.21")
project(si LANGUAGES C)

# Define the library
add_library(si STATIC "src/crc8.c" "src/device/commands.c" "src/device/gc_controller.c")

# Configure SI peripheral selection
if(DEFINED SI_RX_TIMER_IDX)
target_compile_definitions(si PUBLIC SI_RX_TIMER_IDX=${SI_RX_TIMER_IDX})
endif()

if(DEFINED SI_TX_USART_IDX)
target_compile_definitions(si PUBLIC SI_TX_USART_IDX=${SI_TX_USART_IDX})
endif()
add_library(si STATIC src/crc8.c src/device/commands.c src/device/gc_controller.c)

# Specify the include paths
target_include_directories(si PUBLIC include)

# EFR32 platform specific settings
if(CMAKE_CROSSCOMPILING)
if(DEFINED ZEPHYR_BASE)
# Building for EFR32 using Zephyr
# Note: rail_config.h and rail_config.c are not automatically generated by Zephyr,
# so we expect them to be already present in the src/autogen directory.
if(NOT CONFIG_SOC_FAMILY_SILABS_S2)
message(FATAL_ERROR "Only EFR32 Series 2 SoCs are currently supported.")
endif()

# Pull in the Zephyr interface library
target_link_libraries(si PUBLIC zephyr_interface)

# Pull in additional EMLIB sources required for libsi
zephyr_library_sources(
${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/emlib/src/em_timer.c
${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/emlib/src/em_ldma.c
${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/emdrv/dmadrv/src/dmadrv.c
# Building for EFR32 using gecko-sdk-cmake
if(NOT GeckoSDK_FOUND)
include(FetchContent)
FetchContent_Declare(
GeckoSDK
GIT_REPOSITORY https://github.com/loopj/gecko-sdk-cmake.git
GIT_TAG main
)
else()
# Building for EFR32 using gecko-sdk-cmake
if(NOT GeckoSDK_FOUND)
include(FetchContent)
FetchContent_Declare(
GeckoSDK
GIT_REPOSITORY https://github.com/loopj/gecko-sdk-cmake.git
GIT_TAG main
)
FetchContent_MakeAvailable(GeckoSDK)
endif()
FetchContent_MakeAvailable(GeckoSDK)
endif()

# Depend on emlib from the Gecko SDK
target_link_libraries(si GeckoSDK::emlib GeckoSDK::emdrv::dmadrv)
# Configure SI peripheral selection
if(DEFINED SI_RX_TIMER_IDX)
target_compile_definitions(si PUBLIC SI_RX_TIMER_IDX=${SI_RX_TIMER_IDX})
endif()

if(DEFINED SI_TX_USART_IDX)
target_compile_definitions(si PUBLIC SI_TX_USART_IDX=${SI_TX_USART_IDX})
endif()

# Add the platform-specific source files
target_sources(si PRIVATE "src/platform/efr32/si_efr32_emlib.c")

# Depend on emlib from the Gecko SDK
target_link_libraries(si GeckoSDK::emlib GeckoSDK::emdrv::dmadrv)
endif()

# Add the test target
Expand Down
35 changes: 35 additions & 0 deletions firmware/libsi/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Define the library
zephyr_library_named(si)

# Set the library path
set(LIBSI_DIR ${CMAKE_CURRENT_LIST_DIR}/..)

# Add the common source files
zephyr_library_sources(
${LIBSI_DIR}/src/crc8.c
${LIBSI_DIR}/src/device/commands.c
${LIBSI_DIR}/src/device/gc_controller.c
)

# Specify the include paths
zephyr_include_directories(${LIBSI_DIR}/include)

# Link against Zephyr
target_link_libraries(si PUBLIC zephyr_interface)

# EFR32-specific settings
if(DEFINED SI_RX_TIMER_IDX)
target_compile_definitions(si PUBLIC SI_RX_TIMER_IDX=${SI_RX_TIMER_IDX})
endif()

if(DEFINED SI_TX_USART_IDX)
target_compile_definitions(si PUBLIC SI_TX_USART_IDX=${SI_TX_USART_IDX})
endif()

zephyr_library_sources(${LIBSI_DIR}/src/platform/efr32/si_efr32_emlib.c)

zephyr_library_sources(
${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/emlib/src/em_timer.c
${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/emlib/src/em_ldma.c
${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/emdrv/dmadrv/src/dmadrv.c
)
3 changes: 3 additions & 0 deletions firmware/libsi/zephyr/module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: libsi
build:
cmake: zephyr
46 changes: 15 additions & 31 deletions firmware/libwavebird/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,25 @@ target_include_directories(wavebird PRIVATE src/autogen PUBLIC include)

# EFR32 platform specific settings
if(CMAKE_CROSSCOMPILING)
if(DEFINED ZEPHYR_BASE)
# Building for EFR32 using Zephyr
# Note: rail_config.h and rail_config.c are not automatically generated by Zephyr,
# so we expect them to be already present in the src/autogen directory.
if(NOT CONFIG_SOC_FAMILY_SILABS_S2)
message(FATAL_ERROR "Only EFR32 Series 2 SoCs are currently supported.")
endif()

if(NOT CONFIG_SOC_GECKO_USE_RAIL)
message(FATAL_ERROR "Custom radio PHY is required for EFR32 platforms, set CONFIG_SOC_GECKO_CUSTOM_RADIO_PHY in prj.conf.")
endif()

# Pull in the Zephyr interface library
target_link_libraries(wavebird PUBLIC zephyr_interface)
else()
# Building for EFR32 using gecko-sdk-cmake
if(NOT GeckoSDK_FOUND)
include(FetchContent)
FetchContent_Declare(
GeckoSDK
GIT_REPOSITORY https://github.com/loopj/gecko-sdk-cmake.git
GIT_TAG main
)
FetchContent_MakeAvailable(GeckoSDK)
endif()

# Configure automatic generation of rail_config.c and rail_config.h files
set_rail_config_paths("config/rail/radio_settings_${GECKO_SDK_RAIL_LIB_NAME}.radioconf" "src/autogen")

# Depend on emlib and rail_lib from the Gecko SDK
target_link_libraries(wavebird GeckoSDK::emlib GeckoSDK::rail_lib)
# Building for EFR32 using gecko-sdk-cmake
if(NOT GeckoSDK_FOUND)
include(FetchContent)
FetchContent_Declare(
GeckoSDK
GIT_REPOSITORY https://github.com/loopj/gecko-sdk-cmake.git
GIT_TAG main
)
FetchContent_MakeAvailable(GeckoSDK)
endif()

# Configure automatic generation of rail_config.c and rail_config.h files
set_rail_config_paths("config/rail/radio_settings_${GECKO_SDK_RAIL_LIB_NAME}.radioconf" "src/autogen")

# Add platform-specific source files
target_sources(wavebird PRIVATE "src/platform/efr32/radio_efr32.c" "src/autogen/rail_config.c")

# Depend on emlib and rail_lib from the Gecko SDK
target_link_libraries(wavebird GeckoSDK::emlib GeckoSDK::rail_lib)
endif()

# Add the test target
Expand Down
25 changes: 25 additions & 0 deletions firmware/libwavebird/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Define the library
zephyr_library_named(wavebird)

# Set the library path
set(LIBWAVEBIRD_DIR ${CMAKE_CURRENT_LIST_DIR}/..)

# Add the source files
zephyr_library_sources(
${LIBWAVEBIRD_DIR}/src/bch3121.c
${LIBWAVEBIRD_DIR}/src/packet.c
)

# Specify the include paths
zephyr_include_directories(${LIBWAVEBIRD_DIR}/include)

# Link against Zephyr
target_link_libraries(wavebird PUBLIC zephyr_interface)

# EFR32-specific settings
zephyr_library_sources(
${LIBWAVEBIRD_DIR}/src/autogen/rail_config.c
${LIBWAVEBIRD_DIR}/src/platform/efr32/radio_efr32.c
)

zephyr_include_directories(${LIBWAVEBIRD_DIR}/src/autogen)
3 changes: 3 additions & 0 deletions firmware/libwavebird/zephyr/module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: libwavebird
build:
cmake: zephyr