diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-06-01 19:16:43 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-06-01 19:16:43 +0200 |
commit | 69d0e2466f871fb1a4f33abb529863b87361a1ee (patch) | |
tree | 6aa3133ec5cbfc08f75d244d2b05345c380a033a | |
parent | 68c16d40df01838f203338cbaec678896cf56066 (diff) | |
download | phone_remote_nrf51-master.tar.gz phone_remote_nrf51-master.tar.bz2 phone_remote_nrf51-master.tar.xz phone_remote_nrf51-master.zip |
-rw-r--r-- | CMakeLists.txt | 79 | ||||
-rw-r--r-- | nrf51_toolchain.cmake | 52 |
2 files changed, 131 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..f7776bc --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,79 @@ +cmake_minimum_required(VERSION 3.2) +project(phone_remote_nrf51) + +list(APPEND CMAKE_REQUIRED_DEFINITIONS BLE_STACK_SUPPORT_REQD) +list(APPEND CMAKE_REQUIRED_DEFINITIONS SOFTDEVICE_PRESENT) + +set(SOURCE_FILES) +list(APPEND SOURCE_FILES main.c) +list(APPEND SOURCE_FILES phone_remote.c) +list(APPEND SOURCE_FILES LiquidCrystal.c) + +add_definitions(-DNRF51) +add_definitions(-DBOARD_PCA10031) +add_definitions(-DBLE_STACK_SUPPORT_REQD) +#add_compile_options(-std=gnu99) +#add_compile_options(-march=cortex-m0) +#add_compile_options(-mthumb) +#add_compile_options(-mabi=aapcs) + +list(APPEND SOURCE_FILES ${NRF_SDK}/components/ble/common/ble_advdata.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/ble/common/ble_conn_params.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/ble/common/ble_srv_common.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/ble/device_manager/device_manager_peripheral.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/drivers_nrf/hal/nrf_delay.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/drivers_nrf/pstorage/pstorage.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/drivers_nrf/uart/app_uart_fifo.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/libraries/button/app_button.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/libraries/fifo/app_fifo.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/libraries/gpiote/app_gpiote.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/libraries/timer/app_timer.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/libraries/trace/app_trace.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/libraries/sensorsim/ble_sensorsim.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/libraries/util/app_error.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/libraries/util/nrf_assert.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/libraries/uart/retarget.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/components/softdevice/common/softdevice_handler/softdevice_handler.c) +list(APPEND SOURCE_FILES ${NRF_SDK}/examples/bsp/bsp.c) + +#include_directories(AFTER /usr/lib/gcc/arm-none-eabi/4.9/include) +include_directories(AFTER ${NRF_SDK}/components/ble/common) +include_directories(AFTER ${NRF_SDK}/components/ble/ble_services/ble_bas) +include_directories(AFTER ${NRF_SDK}/components/ble/ble_services/ble_hrs) +include_directories(AFTER ${NRF_SDK}/components/ble/ble_services/ble_dis) +include_directories(AFTER ${NRF_SDK}/components/ble/device_manager) +include_directories(AFTER ${NRF_SDK}/components/ble/device_manager/config) +include_directories(AFTER ${NRF_SDK}/components/drivers_nrf/hal) +include_directories(AFTER ${NRF_SDK}/components/drivers_nrf/pstorage) +include_directories(AFTER ${NRF_SDK}/components/drivers_nrf/pstorage/config) +include_directories(AFTER ${NRF_SDK}/components/drivers_nrf/uart) +include_directories(AFTER ${NRF_SDK}/components/libraries/button) +include_directories(AFTER ${NRF_SDK}/components/libraries/gpiote) +include_directories(AFTER ${NRF_SDK}/components/libraries/sensorsim) +include_directories(AFTER ${NRF_SDK}/components/libraries/scheduler) +include_directories(AFTER ${NRF_SDK}/components/libraries/timer) +include_directories(AFTER ${NRF_SDK}/components/libraries/trace) +include_directories(AFTER ${NRF_SDK}/components/libraries/util) +include_directories(AFTER ${NRF_SDK}/components/libraries/fifo) +include_directories(AFTER ${NRF_SDK}/components/softdevice/common/softdevice_handler) +include_directories(AFTER ${NRF_SDK}/components/toolchain) +include_directories(AFTER ${NRF_SDK}/components/toolchain/gcc) +include_directories(AFTER ${NRF_SDK}/examples/bsp) + +set(NRF_SOFTDEVICE s110) + +if(${NRF_SOFTDEVICE} STREQUAL s110) +include_directories(AFTER ${NRF_SDK}/components/softdevice/s110/headers) +add_definitions(-DSOFTDEVICE_PRESENT) +add_definitions(-DS110) +elseif(${NRF_SOFTDEVICE} STREQUAL s120) +include_directories(AFTER ${NRF_SDK}/components/softdevice/s120/headers) +add_definitions(-DSOFTDEVICE_PRESENT) +add_definitions(-DS120) +elseif(${NRF_SOFTDEVICE} STREQUAL s130) +include_directories(AFTER ${NRF_SDK}/components/softdevice/s130/headers) +add_definitions(-DSOFTDEVICE_PRESENT) +add_definitions(-DS130) +endif() + +add_executable(phone_remote_nrf51 ${SOURCE_FILES} ${NRF_SOURCE_FILES} ${NRF_SDK}/components/softdevice/s110/headers/nrf_error.h) diff --git a/nrf51_toolchain.cmake b/nrf51_toolchain.cmake new file mode 100644 index 0000000..938f6a6 --- /dev/null +++ b/nrf51_toolchain.cmake @@ -0,0 +1,52 @@ +include(CMakeForceCompiler) + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_VERSION 1) +#set(CMAKE_SYSTEM_PROCESSOR cortex-m0) + +find_program(ARM_CC arm-none-eabi-gcc ${TOOLCHAIN_DIR}/bin) +find_program(ARM_CXX arm-none-eabi-g++ ${TOOLCHAIN_DIR}/bin) +find_program(ARM_OBJCOPY arm-none-eabi-objcopy ${TOOLCHAIN_DIR}/bin) +find_program(ARM_SIZE_TOOL arm-none-eabi-size ${TOOLCHAIN_DIR}/bin) + +CMAKE_FORCE_C_COMPILER(${ARM_CC} GNU) +CMAKE_FORCE_CXX_COMPILER(${ARM_CXX} GNU) + +list(APPEND ARM_CFLAGS "-mcpu=cortex-m0") +list(APPEND ARM_CFLAGS "-mthumb") +list(APPEND ARM_CFLAGS "-mabi=aapcs") +list(APPEND ARM_CFLAGS "--std=gnu99") +list(APPEND ARM_CFLAGS "-Wall") +list(APPEND ARM_CFLAGS "-mfloat-abi=soft") + +# "/usr/bin/arm-none-eabi-gcc" +# -Xlinker +# -Map=build/phone_remote_nrf51_s110_xxac_BOARD_PCA10028.map +# -mcpu=cortex-m0 +# -mthumb +# -mabi=aapcs +# -L/home/trygvis/opt/nrf/7.2/components/toolchain/gcc +# -T/home/trygvis/opt/nrf/7.2/components/toolchain/gcc/gcc_nrf51_s110_xxac.ld +# -o build/phone_remote_nrf51_s110_xxac_BOARD_PCA10028.out +# build/main.o + +list(APPEND ARM_LDFLAGS "-L${NRF_SDK}/components/toolchain/gcc") +list(APPEND ARM_LDFLAGS "-T${NRF_SDK}/components/toolchain/gcc/gcc_nrf51_s110_xxac.ld") + +#list(APPEND ARM_CFLAGS "-DBLE_STACK_SUPPORT_REQD") +#list(APPEND ARM_CFLAGS "-DSOFTDEVICE_PRESENT") +#list(APPEND ARM_CFLAGS "-DS110") +#list(APPEND ARM_CFLAGS "-DSOFTDEVICE_PRESENT") +#list(APPEND ARM_CFLAGS "-DNRF51") +#list(APPEND ARM_CFLAGS "-DBOARD_PCA10028") +#list(APPEND ARM_CFLAGS "-DNRF51422_QFAC_AB") + +set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS}" "${ARM_LDFLAGS}") +string(REGEX REPLACE ";" " " CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS}") +set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS}" CACHE STRING "") + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" "${ARM_CFLAGS}") +string(REGEX REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "") + +set(BUILD_SHARED_LIBS OFF) |