2019-10-26 16:53:43 +02:00
|
|
|
cmake_minimum_required(VERSION 3.10)
|
2019-11-02 10:02:24 +01:00
|
|
|
project(candleLightFirmware C ASM)
|
2019-10-26 16:53:43 +02:00
|
|
|
|
|
|
|
add_compile_options(
|
|
|
|
-std=gnu11
|
|
|
|
-mcpu=cortex-m0 -mthumb
|
|
|
|
-Wall -Wextra -Werror
|
|
|
|
-fmessage-length=0
|
|
|
|
-fsigned-char
|
|
|
|
-ffunction-sections -fdata-sections
|
|
|
|
-ffreestanding
|
|
|
|
-fno-move-loop-invariants
|
|
|
|
-Os -g3
|
|
|
|
)
|
|
|
|
|
|
|
|
add_link_options(
|
|
|
|
-mcpu=cortex-m0 -mthumb -O
|
|
|
|
-Wall -Wextra -g3
|
|
|
|
-nostartfiles -Xlinker --gc-sections --specs=nano.specs
|
|
|
|
-T ${CMAKE_SOURCE_DIR}/ldscripts/ldscript.ld
|
|
|
|
)
|
|
|
|
|
2019-10-30 20:36:42 +01:00
|
|
|
|
2019-10-26 16:53:43 +02:00
|
|
|
add_subdirectory(libs/STM32_HAL)
|
|
|
|
add_subdirectory(libs/STM32_USB_Device_Library)
|
|
|
|
|
|
|
|
set(
|
|
|
|
SOURCE_FILES
|
|
|
|
include/config.h
|
|
|
|
|
|
|
|
include/gs_usb.h
|
|
|
|
include/usbd_desc.h src/usbd_desc.c
|
|
|
|
include/usbd_gs_can.h src/usbd_gs_can.c
|
|
|
|
src/usbd_conf.c
|
|
|
|
|
|
|
|
include/can.h src/can.c
|
|
|
|
include/dfu.h src/dfu.c
|
|
|
|
include/flash.h src/flash.c
|
|
|
|
include/gpio.h src/gpio.c
|
|
|
|
include/led.h src/led.c
|
|
|
|
include/queue.h src/queue.c
|
|
|
|
include/timer.h src/timer.c
|
|
|
|
include/util.h src/util.c
|
|
|
|
|
|
|
|
src/main.c
|
|
|
|
src/interrupts.c
|
|
|
|
)
|
|
|
|
|
2019-10-27 16:09:02 +01:00
|
|
|
function(make_bin_file target)
|
|
|
|
add_custom_command(
|
|
|
|
TARGET ${target} POST_BUILD
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
COMMAND ${CMAKE_OBJCOPY} -O binary ${target} ${target}.bin
|
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(show_object_size target)
|
|
|
|
string(REPLACE "objcopy" "size" CMAKE_OBJSIZE "${CMAKE_OBJCOPY}")
|
|
|
|
add_custom_command(
|
|
|
|
TARGET ${target} POST_BUILD
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
COMMAND ${CMAKE_OBJSIZE} ${target}
|
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
2019-10-30 20:36:42 +01:00
|
|
|
function(add_flash_target target)
|
|
|
|
add_custom_target(
|
|
|
|
flash-${target} dfu-util -d 1d50:606f -a 0 -R -s 0x08000000 -D ${target}.bin
|
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
|
2019-10-26 16:53:43 +02:00
|
|
|
add_executable(candleLight_fw ${SOURCE_FILES})
|
|
|
|
target_include_directories(candleLight_fw PRIVATE include/)
|
|
|
|
target_compile_definitions(candleLight_fw PRIVATE BOARD=BOARD_candleLight)
|
2019-11-03 11:11:16 +01:00
|
|
|
target_link_libraries(candleLight_fw PRIVATE STM32_HAL_STM32F072xB STM32_USB_Device_Library_STM32F072xB)
|
2019-10-27 16:09:02 +01:00
|
|
|
make_bin_file(candleLight_fw)
|
|
|
|
show_object_size(candleLight_fw)
|
2019-10-30 20:36:42 +01:00
|
|
|
add_flash_target(candleLight_fw)
|
2019-10-26 16:53:43 +02:00
|
|
|
|
|
|
|
add_executable(cantact_fw ${SOURCE_FILES})
|
|
|
|
target_include_directories(cantact_fw PRIVATE include/)
|
|
|
|
target_compile_definitions(cantact_fw PRIVATE BOARD=BOARD_cantact)
|
2019-11-03 11:11:16 +01:00
|
|
|
target_link_libraries(cantact_fw PRIVATE STM32_HAL_STM32F042x6 STM32_USB_Device_Library_STM32F042x6)
|
2019-10-27 16:09:02 +01:00
|
|
|
make_bin_file(cantact_fw)
|
|
|
|
show_object_size(cantact_fw)
|
2019-10-30 20:36:42 +01:00
|
|
|
add_flash_target(cantact_fw)
|