diff --git a/CMakeLists.txt b/CMakeLists.txt index 312688202..81971e4b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,4 +18,10 @@ project(loramac-node) cmake_minimum_required(VERSION 3.6) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) +option(LORAMAC_AS_LIB "If enabled, will configure LoRaMac-node to be built as a static library, otherwise will build example projects" OFF) + +if (LORAMAC_AS_LIB) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/as-lib) +else() + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) +endif() diff --git a/as-lib/CMakeLists.txt b/as-lib/CMakeLists.txt new file mode 100644 index 000000000..d250c0cab --- /dev/null +++ b/as-lib/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.23) + +cmake_path(SET LORAMAC_SOURCE_DIR NORMALIZE ${CMAKE_CURRENT_SOURCE_DIR}/../src) + +add_subdirectory(board) +add_subdirectory(system) +add_subdirectory(radio) +add_subdirectory(peripheral) +add_subdirectory(mac) diff --git a/as-lib/README.md b/as-lib/README.md new file mode 100644 index 000000000..4e52fc94a --- /dev/null +++ b/as-lib/README.md @@ -0,0 +1,124 @@ +# LoRaMac-node 'as-lib' + +**WIP** + +## Purpose + +This directory is provided to allow LoRaMac-node to be built as a static library for inclusion in other projects. + +This directory contains a set of CMakeLists.txt files that shadow the directory structure under `src`. A backwards +compatible change is made to the project root CMakeLists.txt which, when provided with the option `LORAMAC_AS_LIB`, +will direct CMake to reference the as-lib directory instead of src. The option default is OFF so that the past +build behaviour is preserved as the default. + +CMake configuration options are provided that mirror equivalent options in the `src` configuration tree, but a +standard `LORAMAC_` prefix is applied to all options to aid interoperability with other project sources. + +## Supported CMake Configuration Options + +- LORAMAC_AS_LIB:BOOL Whether to build the project as a static library (when ON), or to build the example applications +- LORAMAC_SUFFIX:STRING Defaults to empty, but can be set to any string to allow for multiple static libraries to + be build (for example with different region support) +- LORAMAC_SECURE_ELEMENT:STRING Name of the secure element, defaults to SOFT_SE +- LORAMAC_SECURE_ELEMENT_PRE_PROVISIONED:BOOL Whether the secure element is pre-provisioned (default ON) +- LORAMAC_RADIO:STRING Name of the radio driver, defaults to sx1272 +- LORAMAC_USE_RADIO_DEBUG:BOOL Enable Radio Debug GPIO's (default OFF) + +## Region support + +Note that unlike the `src` build, the supported regions are not configured as CMake cache options. This is to +support easier override when building multiple regions (where cache FORCE would be needed to override which). + +At least one region must be enabled, and there are no regions enabled by default. A fatal CMake configure error +will be generated if no regions are supported. + +- LORAMAC_REGION_EU868:BOOL Enable support for EU868 +- LORAMAC_REGION_US915:BOOL Enable support for US915 +- LORAMAC_REGION_CN779:BOOL Enable support for CN779 +- LORAMAC_REGION_EU433:BOOL Enable support for EU433 +- LORAMAC_REGION_AU915:BOOL Enable support for AU915 +- LORAMAC_REGION_AS923:BOOL Enable support for AS923 +- LORAMAC_REGION_CN470:BOOL Enable support for CN470 +- LORAMAC_REGION_KR920:BOOL Enable support for KR920 +- LORAMAC_REGION_IN865:BOOL Enable support for IN865 +- LORAMAC_REGION_RU864:BOOL Enable support for RU864 + +## Preparation for loading and building + +You must establish your toolchain prior to your first CMake `project()` call (which triggers toolchain detection). It +is beyond the scope of this document to describe how to do that for your platform. + +You will need to provide a board implementation that suits your project. A number of standard boards are provided +in the LoRaMac-node project which can be copied after the first CMake configure pass. Typically you will copy one of these +(from the `/src/boards` directory) into your own project sources and make any necessary changes. + +NB: Pre-built board implementation targets are not provided due to the complexity of providing included or project +specific HAL libraries. `CMakeLists.txt` files are included in the board implementation directories that can be used +as a starting point for your own project. + +Depending on your platform, you may need to obtain Hardware Abstraction Libraries that are used by the board +implementation that you choose. LoRaMac-node includes some of these for the provided board implementations (in the +`/src/board/mcu` directory), but you may wish provide your own version (perhaps via FetchContent from the official +sources). + +## Configuring via FetchContent to create a single library + +``` +FetchContent_Declare( + loramac + GIT_REPOSITORY https://github.com/Lora-net/LoRaMac-node + GIT_TAG master # branch or version tag, such a v4.7.0 +) + +set(LORAMAC_AS_LIB ON) +set(LORAMAC_RADIO sx1276) +set(REGION_EU868 ON) +FetchContent_MakeAvailable(loramac) + +# add your own target + +add_executable(MyProject C) +target_sources(MyProject main.c) +target_link_libraries(MyProject loramac) +``` + +## Configuring via FetchContent to create multiple libraries + +FetchContent should be used to load the project at CMake configure time (rather than build time using ExternalProject). + +`ExternalProject_Add` is not supported at this time. + +NB: If building multiple static libraries for regional variants, ensure that you set the previous passes region to OFF + +``` +FetchContent_Declare( + loramac + GIT_REPOSITORY https://github.com/Lora-net/LoRaMac-node + GIT_TAG master # branch or version tag, such a v4.7.0 +) + +FetchContent_GetProperties(loramac) +if (NOT loramac_POPULATED) + FetchContent_Populate(loramac) +endif() + +set(LORAMAC_AS_LIB ON) +set(LORAMAC_RADIO sx1276) +set(LORAMAC_SUFFIX -Europe CACHE STRING "" FORCE) # must force override +set(REGION_EU868 ON) +add_subdirectory(loramac_SOURCE_DIR loramac${LORAMAC_SUFFIX}) + +set(REGION_EU868 OFF) # NB: Override last pass +set(REGION_US915 ON) +set(LORAMAC_SUFFIX -US CACHE STRING "" FORCE) # must force override +add_subdirectory(loramac_SOURCE_DIR loramac${LORAMAC_SUFFIX}) + +# You now have targets loramac-Europe and loramac-US to link to your own targets + +add_executable(MyProject C) +target_sources(MyProject main.c) +target_link_libraries(MyProject loramac-Europe) +``` + +## TODO + diff --git a/as-lib/board/CMakeLists.txt b/as-lib/board/CMakeLists.txt new file mode 100644 index 000000000..8588679c0 --- /dev/null +++ b/as-lib/board/CMakeLists.txt @@ -0,0 +1,43 @@ +cmake_minimum_required(VERSION 3.23) + +project(loramac-board C) + +if (NOT TARGET ${PROJECT_NAME}) + + add_library(${PROJECT_NAME} STATIC) + + target_sources( + ${PROJECT_NAME} + + PUBLIC + ${LORAMAC_SOURCE_DIR}/boards/adc-board.h + ${LORAMAC_SOURCE_DIR}/boards/board.h + ${LORAMAC_SOURCE_DIR}/boards/delay-board.h + ${LORAMAC_SOURCE_DIR}/boards/display-board.h + ${LORAMAC_SOURCE_DIR}/boards/eeprom-board.h + ${LORAMAC_SOURCE_DIR}/boards/gpio-board.h + ${LORAMAC_SOURCE_DIR}/boards/gps-board.h + ${LORAMAC_SOURCE_DIR}/boards/i2c-board.h + ${LORAMAC_SOURCE_DIR}/boards/lpm-board.h + ${LORAMAC_SOURCE_DIR}/boards/lr1110-board.h + ${LORAMAC_SOURCE_DIR}/boards/pinName-board.h + ${LORAMAC_SOURCE_DIR}/boards/pinName-ioe.h + ${LORAMAC_SOURCE_DIR}/boards/rtc-board.h + ${LORAMAC_SOURCE_DIR}/boards/sx126x-board.h + ${LORAMAC_SOURCE_DIR}/boards/sx1272-board.h + ${LORAMAC_SOURCE_DIR}/boards/sx1276-board.h + ${LORAMAC_SOURCE_DIR}/boards/uart-board.h + ${LORAMAC_SOURCE_DIR}/boards/uart-usb-board.h + ${LORAMAC_SOURCE_DIR}/boards/utilities.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/boards/mcu/utilities.c + ) + + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/boards + ) + +endif() diff --git a/as-lib/mac/CMakeLists.txt b/as-lib/mac/CMakeLists.txt new file mode 100644 index 000000000..ea1b33459 --- /dev/null +++ b/as-lib/mac/CMakeLists.txt @@ -0,0 +1,114 @@ +cmake_minimum_required(VERSION 3.23) + +if (NOT DEFINED LORAMAC_SUFFIX) + set(LORAMAC_SUFFIX "" CACHE STRING "Default suffix for LoRaMac Static Library builds") +endif() + +project(loramac${LORAMAC_SUFFIX} C) + +if (NOT TARGET ${PROJECT_NAME}) + + set(LORAMAC_REGION_LIST EU868 US915 CN779 EU433 AU915 AS923 CN470 KR920 IN865 RU864) + + add_library(${PROJECT_NAME} STATIC) + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/mac/LoRaMac.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacAdr.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacClassB.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacClassBConfig.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacClassBNvm.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacCommands.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacConfirmQueue.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacCrypto.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacCryptoNvm.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacHeaderTypes.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacMessageTypes.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacParser.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacSerializer.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacTest.h + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacTypes.h + ${LORAMAC_SOURCE_DIR}/mac/secure-element.h + ${LORAMAC_SOURCE_DIR}/mac/secure-element-nvm.h + ${LORAMAC_SOURCE_DIR}/mac/region/Region.h + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.h + $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.h> + $<$: + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A20.h + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B20.h + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A26.h + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B26.h + > + + PRIVATE + ${LORAMAC_SOURCE_DIR}/mac/LoRaMac.c + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacAdr.c + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacClassB.c + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacCommands.c + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacConfirmQueue.c + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacCrypto.c + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacParser.c + ${LORAMAC_SOURCE_DIR}/mac/LoRaMacSerializer.c + ${LORAMAC_SOURCE_DIR}/mac/region/Region.c + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCommon.c + $<$,$>:${LORAMAC_SOURCE_DIR}/mac/region/RegionBaseUS.c> + $<$: + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A20.c + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B20.c + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470A26.c + ${LORAMAC_SOURCE_DIR}/mac/region/RegionCN470B26.c + > + ) + + set(ACTIVE_REGION_COUNT 0) + + foreach(REGION ${LORAMAC_REGION_LIST}) + if (${LORAMAC_REGION_${REGION}}) + + MATH(EXPR ACTIVE_REGION_COUNT "${ACTIVE_REGION_COUNT}+1") + + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/mac/region/Region${REGION}.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/mac/region/Region${REGION}.c + ) + + target_compile_definitions( + ${PROJECT_NAME} + PUBLIC + $<$:REGION_${REGION}> + ) + + endif() + endforeach() + + if (${ACTIVE_REGION_COUNT} LESS 1) + message(FATAL_ERROR "No LORAMAC_REGION_xxx's specified") + endif() + + target_compile_definitions( + ${PROJECT_NAME} + PUBLIC + ) + + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/mac + ${LORAMAC_SOURCE_DIR}/mac/region + ) + + target_link_libraries( + ${PROJECT_NAME} + PUBLIC + loramac-board + loramac-system + loramac-radio + loramac-peripheral + ) + +endif() \ No newline at end of file diff --git a/as-lib/peripheral/CMakeLists.txt b/as-lib/peripheral/CMakeLists.txt new file mode 100644 index 000000000..f614193a9 --- /dev/null +++ b/as-lib/peripheral/CMakeLists.txt @@ -0,0 +1,147 @@ +cmake_minimum_required(VERSION 3.23) + +project(loramac-peripheral C) + +if (NOT TARGET ${PROJECT_NAME}) + + option(LORAMAC_SECURE_ELEMENT_PRE_PROVISIONED "Secure-element pre-provisioning" ON) + + set(LORAMAC_SECURE_ELEMENT_LIST SOFT_SE LR1110_SE ATECC608A_TNGLORA_SE) + set(LORAMAC_SECURE_ELEMENT SOFT_SE CACHE STRING "Default secure element is SOFT_SE") + set_property(CACHE LORAMAC_SECURE_ELEMENT PROPERTY STRINGS ${LORAMAC_SECURE_ELEMENT_LIST}) + + add_library(${PROJECT_NAME} STATIC) + + if (LORAMAC_SECURE_ELEMENT MATCHES SOFT_SE) + list( + APPEND + ${PROJECT_NAME}_HEADERS + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/aes.h + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/cmac.h + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/se-identity.h + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/soft-se-hal.h + ) + list( + APPEND + ${PROJECT_NAME}_SOURCES + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/aes.c + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/cmac.c + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/soft-se.c + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se/soft-se-hal.c + ) + target_compile_definitions( + ${PROJECT_NAME} + PUBLIC + SOFT_SE + ) + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/peripherals/soft-se + ${LORAMAC_SOURCE_DIR}/mac + ) + elseif(LORAMAC_SECURE_ELEMENT MATCHES LR1110_SE) + if (LORAMAC_RADIO MATCHES lr1110) + list( + APPEND + ${PROJECT_NAME}_HEADERS + ${LORAMAC_SOURCE_DIR}/peripherals/lr1110-se/lr1110-se-hal.h + ${LORAMAC_SOURCE_DIR}/peripherals/lr1110-se/se-identity.h + ) + list( + APPEND + ${PROJECT_NAME}_SOURCES + ${LORAMAC_SOURCE_DIR}/peripherals/lr1110-se/lr1110-se.c + ${LORAMAC_SOURCE_DIR}/peripherals/lr1110-se/lr1110-se-hal.c + ) + target_include_directories( + ${PROJECT_NAME} PUBLIC + ${LORAMAC_SOURCE_DIR}/peripherals/lr1110-se + ) + else() + message(FATAL_ERROR "LR1110_SE secure element can only be used when LR1110 radio is selected.") + endif() + elseif(LORAMAC_SECURE_ELEMENT MATCHES ATECC608A_TNGLORA_SE) + file( + GLOB + ${PROJECT_NAME}_HEADERS + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/*.h + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/*.h + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/basic/*.h + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/crypto/*.h + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/crypto/hashes/*.h + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/hal/atca_hal.h + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/host/*.h + ) + file( + GLOB + ${PROJECT_NAME}_SOURCES + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/*.c + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/*.c + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/basic/*.c + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/crypto/*.c + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/crypto/hashes/*.c + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/hal/atca_hal.c + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/host/*.c + ) + target_include_directories( + ${PROJECT_NAME} PUBLIC + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/basic + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/crypto + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/crypto/hashes + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/hal + ${LORAMAC_SOURCE_DIR}/peripherals/atecc608a-tnglora-se/cryptoauthlib/lib/host + ) + else() + message(FATAL_ERROR "LORAMAC_SECURE_ELEMENT not defined") + endif() + + list( + APPEND + ${PROJECT_NAME}_HEADERS + ${LORAMAC_SOURCE_DIR}/peripherals/gpio-ioe.h + ${LORAMAC_SOURCE_DIR}/peripherals/mag3110.h + ${LORAMAC_SOURCE_DIR}/peripherals/mma8451.h + ${LORAMAC_SOURCE_DIR}/peripherals/mpl3115.h + ${LORAMAC_SOURCE_DIR}/peripherals/pam7q.h + ${LORAMAC_SOURCE_DIR}/peripherals/sx1509.h + ${LORAMAC_SOURCE_DIR}/peripherals/sx9500.h + ) + + list( + APPEND + ${PROJECT_NAME}_SOURCES + ${LORAMAC_SOURCE_DIR}/peripherals/gpio-ioe.c + ${LORAMAC_SOURCE_DIR}/peripherals/mag3110.c + ${LORAMAC_SOURCE_DIR}/peripherals/mma8451.c + ${LORAMAC_SOURCE_DIR}/peripherals/mpl3115.c + ${LORAMAC_SOURCE_DIR}/peripherals/pam7q.c + ${LORAMAC_SOURCE_DIR}/peripherals/sx1509.c + ${LORAMAC_SOURCE_DIR}/peripherals/sx9500.c + ) + + target_sources( + ${PROJECT_NAME} + PUBLIC + ${${PROJECT_NAME}_HEADERS} + + PRIVATE + ${${PROJECT_NAME}_SOURCES} + ) + + target_compile_definitions( + ${PROJECT_NAME} + PRIVATE + $<$:SECURE_ELEMENT_PRE_PROVISIONED> + ) + + target_link_libraries( + ${PROJECT_NAME} + PUBLIC + loramac-board + loramac-radio + loramac-system + ) +endif() diff --git a/as-lib/radio/CMakeLists.txt b/as-lib/radio/CMakeLists.txt new file mode 100644 index 000000000..bb0762212 --- /dev/null +++ b/as-lib/radio/CMakeLists.txt @@ -0,0 +1,119 @@ +cmake_minimum_required(VERSION 3.23) + +project(loramac-radio C) + +if (NOT TARGET ${PROJECT_NAME}) + + set(LORAMAC_RADIO_LIST sx1272 sx1276 sx126x lr1110) + set(LORAMAC_RADIO sx1272 CACHE STRING "Default radio is sx1272") + set_property(CACHE LORAMAC_RADIO PROPERTY STRINGS ${LORAMAC_RADIO_LIST}) + set_property(CACHE LORAMAC_RADIO PROPERTY ADVANCED) + + add_library(${PROJECT_NAME} STATIC) + + if (${LORAMAC_RADIO} MATCHES lr1110) + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_bootloader.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_bootloader_types.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_crypto_engine.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_crypto_engine_types.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_driver_version.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_gnss.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_gnss_types.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_radio.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_radio_types.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_regmem.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_system.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_system_types.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_wifi.h + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_wifi_types.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/radio/lr1110/radio.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_bootloader.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_crypto_engine.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_driver_version.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_gnss.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_radio.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_regmem.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_system.c + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src/lr1110_wifi.c + ) + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/lr1110 + ${LORAMAC_SOURCE_DIR}/radio/lr1110/lr1110_driver/src + + ) + elseif (${LORAMAC_RADIO} MATCHES sx126x) + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/sx126x/sx126x.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/radio/sx126x/radio.c + ${LORAMAC_SOURCE_DIR}/radio/sx126x/sx126x.c + ) + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/sx126x + ) + elseif (${LORAMAC_RADIO} MATCHES sx1272) + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/sx1272/sx1272.h + ${LORAMAC_SOURCE_DIR}/radio/sx1272/sx1272Regs-Fsk.h + ${LORAMAC_SOURCE_DIR}/radio/sx1272/sx1272Regs-LoRa.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/radio/sx1272/sx1272.c + ) + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/sx1272 + ) + elseif (${LORAMAC_RADIO} MATCHES sx1276) + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/radio.h + ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276.h + ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276Regs-Fsk.h + ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276Regs-LoRa.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/radio/sx1276/sx1276.c + ) + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio/sx1276 + ) + else() + message(FATAL_ERROR "Unsupported radio driver selected...") + endif() + + option(LORAMAC_USE_RADIO_DEBUG "Enable Radio Debug GPIO's" OFF) + target_compile_definitions(${PROJECT_NAME} PUBLIC $<$:USE_RADIO_DEBUG>) + + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/radio + ) + + target_link_libraries( + ${PROJECT_NAME} + PUBLIC + loramac-system + ) + +endif() diff --git a/as-lib/system/CMakeLists.txt b/as-lib/system/CMakeLists.txt new file mode 100644 index 000000000..6a7f87359 --- /dev/null +++ b/as-lib/system/CMakeLists.txt @@ -0,0 +1,49 @@ +cmake_minimum_required(VERSION 3.23) + +project(loramac-system C) + +if (NOT TARGET ${PROJECT_NAME}) + + add_library(${PROJECT_NAME} STATIC) + + target_sources( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/system/adc.h + ${LORAMAC_SOURCE_DIR}/system/delay.h + ${LORAMAC_SOURCE_DIR}/system/fifo.h + ${LORAMAC_SOURCE_DIR}/system/gpio.h + ${LORAMAC_SOURCE_DIR}/system/gps.h + ${LORAMAC_SOURCE_DIR}/system/i2c.h + ${LORAMAC_SOURCE_DIR}/system/nvmm.h + ${LORAMAC_SOURCE_DIR}/system/serial.h + ${LORAMAC_SOURCE_DIR}/system/spi.h + ${LORAMAC_SOURCE_DIR}/system/systime.h + ${LORAMAC_SOURCE_DIR}/system/timer.h + ${LORAMAC_SOURCE_DIR}/system/uart.h + + PRIVATE + ${LORAMAC_SOURCE_DIR}/system/adc.c + ${LORAMAC_SOURCE_DIR}/system/delay.c + ${LORAMAC_SOURCE_DIR}/system/fifo.c + ${LORAMAC_SOURCE_DIR}/system/gpio.c + ${LORAMAC_SOURCE_DIR}/system/gps.c + ${LORAMAC_SOURCE_DIR}/system/i2c.c + ${LORAMAC_SOURCE_DIR}/system/nvmm.c + ${LORAMAC_SOURCE_DIR}/system/systime.c + ${LORAMAC_SOURCE_DIR}/system/timer.c + ${LORAMAC_SOURCE_DIR}/system/uart.c + ) + + target_include_directories( + ${PROJECT_NAME} + PUBLIC + ${LORAMAC_SOURCE_DIR}/system + ) + + target_link_libraries( + ${PROJECT_NAME} + PUBLIC + loramac-board + ) +endif()