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(ping-pong)
19cmake_minimum_required(VERSION 3.6)
20
21#---------------------------------------------------------------------------------------
22# Options
23#---------------------------------------------------------------------------------------
24
25# Allow selection of region
26option(REGION_EU868 "Region EU868" ON)
27option(REGION_US915 "Region US915" OFF)
28option(REGION_CN779 "Region CN779" OFF)
29option(REGION_EU433 "Region EU433" OFF)
30option(REGION_AU915 "Region AU915" OFF)
31option(REGION_AS923 "Region AS923" OFF)
32option(REGION_CN470 "Region CN470" OFF)
33option(REGION_KR920 "Region KR920" OFF)
34option(REGION_IN865 "Region IN865" OFF)
35option(REGION_RU864 "Region RU864" OFF)
36set(REGION_LIST REGION_EU868 REGION_US915 REGION_CN779 REGION_EU433 REGION_AU915 REGION_AS923 REGION_CN470 REGION_KR920 REGION_IN865 REGION_RU864)
37
38# Allow switching of modulation
39set(MODULATION_LIST LORA FSK)
40set(MODULATION LORA CACHE STRING "Default modulation is LoRa")
41set_property(CACHE MODULATION PROPERTY STRINGS ${MODEM_LIST})
42
43#---------------------------------------------------------------------------------------
44# Target
45#---------------------------------------------------------------------------------------
46
47file(GLOB ${PROJECT_NAME}_SOURCES "${CMAKE_CURRENT_LIST_DIR}/${BOARD}/*.c")
48
49add_executable(${PROJECT_NAME}
50                            ${${PROJECT_NAME}_SOURCES}
51                            $<TARGET_OBJECTS:system>
52                            $<TARGET_OBJECTS:radio>
53                            $<TARGET_OBJECTS:peripherals>
54                            $<TARGET_OBJECTS:${BOARD}>
55)
56
57# Loops through all regions and add compile time definitions for the enabled ones.
58foreach( REGION ${REGION_LIST} )
59    if(${REGION})
60        target_compile_definitions(${PROJECT_NAME} PUBLIC -D"${REGION}")
61    endif()
62endforeach()
63
64if(MODULATION STREQUAL LORA)
65    target_compile_definitions(${PROJECT_NAME} PRIVATE USE_MODEM_LORA)
66elseif(MODULATION STREQUAL FSK)
67    target_compile_definitions(${PROJECT_NAME} PRIVATE USE_MODEM_FSK)
68endif()
69
70# Add compile time definition for the mbed shield if set.
71target_compile_definitions(${PROJECT_NAME} PUBLIC -D${MBED_RADIO_SHIELD})
72
73target_compile_definitions(${PROJECT_NAME}  PUBLIC
74    $<BUILD_INTERFACE:$<TARGET_PROPERTY:mac,INTERFACE_COMPILE_DEFINITIONS>>
75)
76
77target_include_directories(${PROJECT_NAME} PUBLIC
78    $<BUILD_INTERFACE:$<TARGET_PROPERTY:system,INTERFACE_INCLUDE_DIRECTORIES>>
79    $<BUILD_INTERFACE:$<TARGET_PROPERTY:radio,INTERFACE_INCLUDE_DIRECTORIES>>
80    $<BUILD_INTERFACE:$<TARGET_PROPERTY:peripherals,INTERFACE_INCLUDE_DIRECTORIES>>
81    $<BUILD_INTERFACE:$<TARGET_PROPERTY:${BOARD},INTERFACE_INCLUDE_DIRECTORIES>>
82)
83
84set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11)
85
86target_link_libraries(${PROJECT_NAME} m)
87
88#---------------------------------------------------------------------------------------
89# Debugging and Binutils
90#---------------------------------------------------------------------------------------
91
92include(gdb-helper)
93include(binutils-arm-none-eabi)
94
95# Generate debugger configurations
96generate_run_gdb_stlink(${PROJECT_NAME})
97generate_run_gdb_openocd(${PROJECT_NAME})
98generate_vscode_launch_openocd(${PROJECT_NAME})
99
100# Print section sizes of target
101print_section_sizes(${PROJECT_NAME})
102
103# Create output in hex and binary format
104create_bin_output(${PROJECT_NAME})
105create_hex_output(${PROJECT_NAME})
106