Skip to content

Commit 62830c9

Browse files
authored
Merge pull request #21 from loopj/zephyr-modules
Move zephyr-specific build into zephyr module format
2 parents 879fcc7 + 7975a1c commit 62830c9

File tree

6 files changed

+101
-70
lines changed

6 files changed

+101
-70
lines changed

firmware/libsi/CMakeLists.txt

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,38 @@ cmake_minimum_required(VERSION "3.21")
55
project(si LANGUAGES C)
66

77
# Define the library
8-
add_library(si STATIC "src/crc8.c" "src/device/commands.c" "src/device/gc_controller.c")
9-
10-
# Configure SI peripheral selection
11-
if(DEFINED SI_RX_TIMER_IDX)
12-
target_compile_definitions(si PUBLIC SI_RX_TIMER_IDX=${SI_RX_TIMER_IDX})
13-
endif()
14-
15-
if(DEFINED SI_TX_USART_IDX)
16-
target_compile_definitions(si PUBLIC SI_TX_USART_IDX=${SI_TX_USART_IDX})
17-
endif()
8+
add_library(si STATIC src/crc8.c src/device/commands.c src/device/gc_controller.c)
189

1910
# Specify the include paths
2011
target_include_directories(si PUBLIC include)
2112

2213
# EFR32 platform specific settings
2314
if(CMAKE_CROSSCOMPILING)
24-
if(DEFINED ZEPHYR_BASE)
25-
# Building for EFR32 using Zephyr
26-
# Note: rail_config.h and rail_config.c are not automatically generated by Zephyr,
27-
# so we expect them to be already present in the src/autogen directory.
28-
if(NOT CONFIG_SOC_FAMILY_SILABS_S2)
29-
message(FATAL_ERROR "Only EFR32 Series 2 SoCs are currently supported.")
30-
endif()
31-
32-
# Pull in the Zephyr interface library
33-
target_link_libraries(si PUBLIC zephyr_interface)
34-
35-
# Pull in additional EMLIB sources required for libsi
36-
zephyr_library_sources(
37-
${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/emlib/src/em_timer.c
38-
${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/emlib/src/em_ldma.c
39-
${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/emdrv/dmadrv/src/dmadrv.c
15+
# Building for EFR32 using gecko-sdk-cmake
16+
if(NOT GeckoSDK_FOUND)
17+
include(FetchContent)
18+
FetchContent_Declare(
19+
GeckoSDK
20+
GIT_REPOSITORY https://github.com/loopj/gecko-sdk-cmake.git
21+
GIT_TAG main
4022
)
41-
else()
42-
# Building for EFR32 using gecko-sdk-cmake
43-
if(NOT GeckoSDK_FOUND)
44-
include(FetchContent)
45-
FetchContent_Declare(
46-
GeckoSDK
47-
GIT_REPOSITORY https://github.com/loopj/gecko-sdk-cmake.git
48-
GIT_TAG main
49-
)
50-
FetchContent_MakeAvailable(GeckoSDK)
51-
endif()
23+
FetchContent_MakeAvailable(GeckoSDK)
24+
endif()
5225

53-
# Depend on emlib from the Gecko SDK
54-
target_link_libraries(si GeckoSDK::emlib GeckoSDK::emdrv::dmadrv)
26+
# Configure SI peripheral selection
27+
if(DEFINED SI_RX_TIMER_IDX)
28+
target_compile_definitions(si PUBLIC SI_RX_TIMER_IDX=${SI_RX_TIMER_IDX})
29+
endif()
30+
31+
if(DEFINED SI_TX_USART_IDX)
32+
target_compile_definitions(si PUBLIC SI_TX_USART_IDX=${SI_TX_USART_IDX})
5533
endif()
5634

5735
# Add the platform-specific source files
5836
target_sources(si PRIVATE "src/platform/efr32/si_efr32_emlib.c")
37+
38+
# Depend on emlib from the Gecko SDK
39+
target_link_libraries(si GeckoSDK::emlib GeckoSDK::emdrv::dmadrv)
5940
endif()
6041

6142
# Add the test target
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Define the library
2+
zephyr_library_named(si)
3+
4+
# Set the library path
5+
set(LIBSI_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
6+
7+
# Add the common source files
8+
zephyr_library_sources(
9+
${LIBSI_DIR}/src/crc8.c
10+
${LIBSI_DIR}/src/device/commands.c
11+
${LIBSI_DIR}/src/device/gc_controller.c
12+
)
13+
14+
# Specify the include paths
15+
zephyr_include_directories(${LIBSI_DIR}/include)
16+
17+
# Link against Zephyr
18+
target_link_libraries(si PUBLIC zephyr_interface)
19+
20+
# EFR32-specific settings
21+
if(DEFINED SI_RX_TIMER_IDX)
22+
target_compile_definitions(si PUBLIC SI_RX_TIMER_IDX=${SI_RX_TIMER_IDX})
23+
endif()
24+
25+
if(DEFINED SI_TX_USART_IDX)
26+
target_compile_definitions(si PUBLIC SI_TX_USART_IDX=${SI_TX_USART_IDX})
27+
endif()
28+
29+
zephyr_library_sources(${LIBSI_DIR}/src/platform/efr32/si_efr32_emlib.c)
30+
31+
zephyr_library_sources(
32+
${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/emlib/src/em_timer.c
33+
${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/emlib/src/em_ldma.c
34+
${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk/platform/emdrv/dmadrv/src/dmadrv.c
35+
)

firmware/libsi/zephyr/module.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: libsi
2+
build:
3+
cmake: zephyr

firmware/libwavebird/CMakeLists.txt

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,25 @@ target_include_directories(wavebird PRIVATE src/autogen PUBLIC include)
1212

1313
# EFR32 platform specific settings
1414
if(CMAKE_CROSSCOMPILING)
15-
if(DEFINED ZEPHYR_BASE)
16-
# Building for EFR32 using Zephyr
17-
# Note: rail_config.h and rail_config.c are not automatically generated by Zephyr,
18-
# so we expect them to be already present in the src/autogen directory.
19-
if(NOT CONFIG_SOC_FAMILY_SILABS_S2)
20-
message(FATAL_ERROR "Only EFR32 Series 2 SoCs are currently supported.")
21-
endif()
22-
23-
if(NOT CONFIG_SOC_GECKO_USE_RAIL)
24-
message(FATAL_ERROR "Custom radio PHY is required for EFR32 platforms, set CONFIG_SOC_GECKO_CUSTOM_RADIO_PHY in prj.conf.")
25-
endif()
26-
27-
# Pull in the Zephyr interface library
28-
target_link_libraries(wavebird PUBLIC zephyr_interface)
29-
else()
30-
# Building for EFR32 using gecko-sdk-cmake
31-
if(NOT GeckoSDK_FOUND)
32-
include(FetchContent)
33-
FetchContent_Declare(
34-
GeckoSDK
35-
GIT_REPOSITORY https://github.com/loopj/gecko-sdk-cmake.git
36-
GIT_TAG main
37-
)
38-
FetchContent_MakeAvailable(GeckoSDK)
39-
endif()
40-
41-
# Configure automatic generation of rail_config.c and rail_config.h files
42-
set_rail_config_paths("config/rail/radio_settings_${GECKO_SDK_RAIL_LIB_NAME}.radioconf" "src/autogen")
43-
44-
# Depend on emlib and rail_lib from the Gecko SDK
45-
target_link_libraries(wavebird GeckoSDK::emlib GeckoSDK::rail_lib)
15+
# Building for EFR32 using gecko-sdk-cmake
16+
if(NOT GeckoSDK_FOUND)
17+
include(FetchContent)
18+
FetchContent_Declare(
19+
GeckoSDK
20+
GIT_REPOSITORY https://github.com/loopj/gecko-sdk-cmake.git
21+
GIT_TAG main
22+
)
23+
FetchContent_MakeAvailable(GeckoSDK)
4624
endif()
4725

26+
# Configure automatic generation of rail_config.c and rail_config.h files
27+
set_rail_config_paths("config/rail/radio_settings_${GECKO_SDK_RAIL_LIB_NAME}.radioconf" "src/autogen")
28+
4829
# Add platform-specific source files
4930
target_sources(wavebird PRIVATE "src/platform/efr32/radio_efr32.c" "src/autogen/rail_config.c")
31+
32+
# Depend on emlib and rail_lib from the Gecko SDK
33+
target_link_libraries(wavebird GeckoSDK::emlib GeckoSDK::rail_lib)
5034
endif()
5135

5236
# Add the test target
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Define the library
2+
zephyr_library_named(wavebird)
3+
4+
# Set the library path
5+
set(LIBWAVEBIRD_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
6+
7+
# Add the source files
8+
zephyr_library_sources(
9+
${LIBWAVEBIRD_DIR}/src/bch3121.c
10+
${LIBWAVEBIRD_DIR}/src/packet.c
11+
)
12+
13+
# Specify the include paths
14+
zephyr_include_directories(${LIBWAVEBIRD_DIR}/include)
15+
16+
# Link against Zephyr
17+
target_link_libraries(wavebird PUBLIC zephyr_interface)
18+
19+
# EFR32-specific settings
20+
zephyr_library_sources(
21+
${LIBWAVEBIRD_DIR}/src/autogen/rail_config.c
22+
${LIBWAVEBIRD_DIR}/src/platform/efr32/radio_efr32.c
23+
)
24+
25+
zephyr_include_directories(${LIBWAVEBIRD_DIR}/src/autogen)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: libwavebird
2+
build:
3+
cmake: zephyr

0 commit comments

Comments
 (0)