# https://github.com/Infineon/mtb-example-psoc6-dfu-basic/tree/master/bootloader_cm4/COMPONENT_CUSTOM_DESIGN_MODUS
psoc6_check_bsp(
  CY8CKIT-062-BLE
  CY8CPROTO-062-4343W
  CY8CKIT-062-WIFI-BT
  CY8CPROTO-063-BLE
  CY8CKIT-062S2-43012
  CYW9P62S1-43438EVB-01
  CYW9P62S1-43012EVB-01
  CY8CPROTO-062S3-4343W
  CY8CKIT-062S4
)

project(dfu-basic)

psoc6_load_application(
  NAME mtb-example-psoc6-dfu-basic
  VERSION 1.3.0
)
psoc6_add_executable(
  NAME
    dfu-basic-bootloader
  SOURCES
    ${APP_DIR}/bootloader_cm4/main.c
    ${APP_DIR}/bootloader_cm4/source/dfu_user.h
    ${APP_DIR}/bootloader_cm4/source/dfu_user.c
  INCLUDE_DIRS
    ${APP_DIR}/bootloader_cm4/source
  LINK_LIBRARIES
    mtb-hal-cat1
    dfu-i2c
  LINKER_SCRIPT
    ${APP_DIR}/bootloader_cm4/linker_script/TARGET_${BSP_NAME}/TOOLCHAIN_${MTB_TOOLCHAIN}/dfu_cm4_app0${TOOLCHAIN_SUFFIX_LS}
  DESIGN_MODUS
    ${APP_DIR}/bootloader_cm4/COMPONENT_CUSTOM_DESIGN_MODUS/TARGET_${BSP_NAME}/design.modus
)
if(${TOOLCHAIN} STREQUAL ARM)
  target_include_directories(dfu-basic-bootloader PRIVATE
    ${APP_DIR}/bootloader_cm4/linker_script/TARGET_${BSP_NAME}/TOOLCHAIN_${MTB_TOOLCHAIN}
  )
  target_sources(dfu-basic-bootloader PRIVATE
    ${APP_DIR}/bootloader_cm4/linker_script/TARGET_${BSP_NAME}/TOOLCHAIN_${MTB_TOOLCHAIN}/dfu_elf_symbols.c
  )
endif()
psoc6_add_executable(
  NAME
    dfu-basic-blinky
  SOURCES
    ${APP_DIR}/blinky_cm4/main.c
    ${APP_DIR}/blinky_cm4/dfu_user.h
  INCLUDE_DIRS
    ${APP_DIR}/blinky_cm4
  LINK_LIBRARIES
    mtb-hal-cat1
    dfu
  LINKER_SCRIPT
    ${APP_DIR}/blinky_cm4/linker_script/TARGET_${BSP_NAME}/TOOLCHAIN_${MTB_TOOLCHAIN}/dfu_cm4_app1${TOOLCHAIN_SUFFIX_LS}
)
if(${TOOLCHAIN} STREQUAL ARM)
  target_include_directories(dfu-basic-blinky PRIVATE
    ${APP_DIR}/blinky_cm4/linker_script/TARGET_${BSP_NAME}/TOOLCHAIN_${MTB_TOOLCHAIN}
  )
  target_sources(dfu-basic-blinky PRIVATE
    ${APP_DIR}/blinky_cm4/linker_script/TARGET_${BSP_NAME}/TOOLCHAIN_${MTB_TOOLCHAIN}/dfu_elf_symbols.c
  )
endif()
psoc6_add_cyacd2(dfu-basic-blinky)
