1## 2## ______ _ 3## / _____) _ | | 4## ( (____ _____ ____ _| |_ _____ ____| |__ 5## \____ \| ___ | (_ _) ___ |/ ___) _ \ 6## _____) ) ____| | | || |_| ____( (___| | | | 7## (______/|_____)_|_|_| \__)_____)\____)_| |_| 8## (C)2013-2017 Semtech 9## ___ _____ _ ___ _ _____ ___ ___ ___ ___ 10## / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 11## \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 12## |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 13## embedded.connectivity.solutions.============== 14## 15## License: Revised BSD License, see LICENSE.TXT file included in the project 16## Authors: Johannes Bruder (STACKFORCE), Miguel Luis (Semtech) 17## 18project(LoRaMac) 19cmake_minimum_required(VERSION 3.6) 20 21#--------------------------------------------------------------------------------------- 22# Options 23#--------------------------------------------------------------------------------------- 24 25# Allow switching of sub projects 26set(SUB_PROJECT_LIST periodic-uplink-lpp fuota-test-01) 27set(SUB_PROJECT periodic-uplink-lpp CACHE STRING "Default sub project is periodic-uplink-lpp") 28set_property(CACHE SUB_PROJECT PROPERTY STRINGS ${SUB_PROJECT_LIST}) 29 30# Allow LORAWAN_DEFAULT_CLASS overriding for periodic-uplink-lpp project 31if(SUB_PROJECT STREQUAL periodic-uplink-lpp) 32 set(LORAWAN_DEFAULT_CLASS_LIST CLASS_A CLASS_B CLASS_C) 33 set(LORAWAN_DEFAULT_CLASS CLASS_A CACHE STRING "Default LoRaWAN class is ClassA") 34 set_property(CACHE LORAWAN_DEFAULT_CLASS PROPERTY STRINGS ${LORAWAN_DEFAULT_CLASS_LIST}) 35endif() 36 37# Allow switching of active region 38set(ACTIVE_REGION_LIST LORAMAC_REGION_EU868 LORAMAC_REGION_US915 LORAMAC_REGION_CN779 39 LORAMAC_REGION_EU433 LORAMAC_REGION_AU915 LORAMAC_REGION_AS923 LORAMAC_REGION_CN470 40 LORAMAC_REGION_KR920 LORAMAC_REGION_IN865 LORAMAC_REGION_RU864 41) 42set(ACTIVE_REGION LORAMAC_REGION_EU868 CACHE STRING "Default active region is EU868") 43set_property(CACHE ACTIVE_REGION PROPERTY STRINGS ${ACTIVE_REGION_LIST}) 44 45if((SUB_PROJECT STREQUAL periodic-uplink-lpp OR SUB_PROJECT STREQUAL fuota-test-01) AND NOT CLASSB_ENABLED ) 46 message(FATAL_ERROR "Please turn on Class B support of LoRaMac ( CLASSB_ENABLED=ON ) to use periodic-uplink-lpp, fuota-test-01 sub projects") 47endif() 48 49# Allow selection of secure-element provisioning method 50option(SECURE_ELEMENT_PRE_PROVISIONED "Secure-element pre-provisioning" ON) 51 52if(SUB_PROJECT STREQUAL periodic-uplink-lpp) 53 54 #--------------------------------------------------------------------------------------- 55 # Application common features handling 56 #--------------------------------------------------------------------------------------- 57 list(APPEND ${PROJECT_NAME}_COMMON 58 "${CMAKE_CURRENT_LIST_DIR}/common/CayenneLpp.c" 59 "${CMAKE_CURRENT_LIST_DIR}/common/cli.c" 60 "${CMAKE_CURRENT_LIST_DIR}/common/LmHandlerMsgDisplay.c" 61 "${CMAKE_CURRENT_LIST_DIR}/common/NvmDataMgmt.c" 62 ) 63 64 #--------------------------------------------------------------------------------------- 65 # Application LoRaMac handler 66 #--------------------------------------------------------------------------------------- 67 list(APPEND ${PROJECT_NAME}_LMH 68 "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/LmHandler.c" 69 ) 70 71 #--------------------------------------------------------------------------------------- 72 # LoRaMac handler applicative packages 73 #--------------------------------------------------------------------------------------- 74 list(APPEND ${PROJECT_NAME}_LMHP 75 "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/FragDecoder.c" 76 "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpClockSync.c" 77 "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpCompliance.c" 78 "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpFragmentation.c" 79 "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpRemoteMcastSetup.c" 80 ) 81 82elseif(SUB_PROJECT STREQUAL fuota-test-01) 83 84 #--------------------------------------------------------------------------------------- 85 # Application common features handling 86 #--------------------------------------------------------------------------------------- 87 list(APPEND ${PROJECT_NAME}_COMMON 88 "${CMAKE_CURRENT_LIST_DIR}/common/cli.c" 89 "${CMAKE_CURRENT_LIST_DIR}/common/LmHandlerMsgDisplay.c" 90 "${CMAKE_CURRENT_LIST_DIR}/common/NvmDataMgmt.c" 91 ) 92 93 #--------------------------------------------------------------------------------------- 94 # Application LoRaMac handler 95 #--------------------------------------------------------------------------------------- 96 list(APPEND ${PROJECT_NAME}_LMH 97 "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/LmHandler.c" 98 ) 99 100 #--------------------------------------------------------------------------------------- 101 # LoRaMac handler applicative packages 102 #--------------------------------------------------------------------------------------- 103 list(APPEND ${PROJECT_NAME}_LMHP 104 "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/FragDecoder.c" 105 "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpClockSync.c" 106 "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpCompliance.c" 107 "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpFragmentation.c" 108 "${CMAKE_CURRENT_LIST_DIR}/common/LmHandler/packages/LmhpRemoteMcastSetup.c" 109 ) 110 111else() 112 message(FATAL_ERROR "Unknown SUB_PROJECT") 113endif() 114 115#--------------------------------------------------------------------------------------- 116# Application 117#--------------------------------------------------------------------------------------- 118file(GLOB ${PROJECT_NAME}_SOURCES "${CMAKE_CURRENT_LIST_DIR}/${SUB_PROJECT}/${BOARD}/*.c") 119 120add_executable(${PROJECT_NAME}-${SUB_PROJECT} 121 ${${PROJECT_NAME}_COMMON} 122 ${${PROJECT_NAME}_LMH} 123 ${${PROJECT_NAME}_LMHP} 124 ${${PROJECT_NAME}_SOURCES} 125 $<TARGET_OBJECTS:mac> 126 $<TARGET_OBJECTS:system> 127 $<TARGET_OBJECTS:radio> 128 $<TARGET_OBJECTS:peripherals> 129 $<TARGET_OBJECTS:${BOARD}> 130) 131 132target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PRIVATE $<$<BOOL:${CLASSB_ENABLED}>:LORAMAC_CLASSB_ENABLED>) 133target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PRIVATE ACTIVE_REGION=${ACTIVE_REGION}) 134if(SUB_PROJECT STREQUAL periodic-uplink-lpp) 135 target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PRIVATE LORAWAN_DEFAULT_CLASS=${LORAWAN_DEFAULT_CLASS}) 136endif() 137if(${SECURE_ELEMENT_PRE_PROVISIONED} MATCHES ON) 138 target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PRIVATE -DSECURE_ELEMENT_PRE_PROVISIONED) 139endif() 140if(${SECURE_ELEMENT} MATCHES SOFT_SE) 141 target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PRIVATE -DSOFT_SE) 142endif() 143target_compile_definitions(${PROJECT_NAME}-${SUB_PROJECT} PUBLIC 144 $<BUILD_INTERFACE:$<TARGET_PROPERTY:mac,INTERFACE_COMPILE_DEFINITIONS>> 145) 146 147target_include_directories(${PROJECT_NAME}-${SUB_PROJECT} PUBLIC 148 ${CMAKE_CURRENT_SOURCE_DIR}/common 149 ${CMAKE_CURRENT_SOURCE_DIR}/common/LmHandler 150 ${CMAKE_CURRENT_SOURCE_DIR}/common/LmHandler/packages 151 ${CMAKE_CURRENT_SOURCE_DIR}/${SUB_PROJECT}/${BOARD} 152 $<BUILD_INTERFACE:$<TARGET_PROPERTY:mac,INTERFACE_INCLUDE_DIRECTORIES>> 153 $<BUILD_INTERFACE:$<TARGET_PROPERTY:system,INTERFACE_INCLUDE_DIRECTORIES>> 154 $<BUILD_INTERFACE:$<TARGET_PROPERTY:radio,INTERFACE_INCLUDE_DIRECTORIES>> 155 $<BUILD_INTERFACE:$<TARGET_PROPERTY:peripherals,INTERFACE_INCLUDE_DIRECTORIES>> 156 $<BUILD_INTERFACE:$<TARGET_PROPERTY:${BOARD},INTERFACE_INCLUDE_DIRECTORIES>> 157) 158 159set_property(TARGET ${PROJECT_NAME}-${SUB_PROJECT} PROPERTY C_STANDARD 11) 160 161target_link_libraries(${PROJECT_NAME}-${SUB_PROJECT} m) 162 163#--------------------------------------------------------------------------------------- 164# Debugging and Binutils 165#--------------------------------------------------------------------------------------- 166 167include(gdb-helper) 168include(binutils-arm-none-eabi) 169 170# Generate debugger configurations 171generate_run_gdb_stlink(${PROJECT_NAME}-${SUB_PROJECT}) 172generate_run_gdb_openocd(${PROJECT_NAME}-${SUB_PROJECT}) 173generate_vscode_launch_openocd(${PROJECT_NAME}-${SUB_PROJECT}) 174 175# Print section sizes of target 176print_section_sizes(${PROJECT_NAME}-${SUB_PROJECT}) 177 178# Create output in hex and binary format 179create_bin_output(${PROJECT_NAME}-${SUB_PROJECT}) 180create_hex_output(${PROJECT_NAME}-${SUB_PROJECT}) 181