Skip to content

Commit

Permalink
Merge pull request #8 from Cascoda/codegen-update
Browse files Browse the repository at this point in the history
update from latest codegen
  • Loading branch information
tiniuclx committed Jun 17, 2024
2 parents e3289f7 + 66b10fe commit 130fd12
Show file tree
Hide file tree
Showing 32 changed files with 4,817 additions and 1,541 deletions.
44 changes: 28 additions & 16 deletions BATTLESHIP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,19 @@ set(KNX_IOT_STACK_REF master CACHE STRING "The branch of the KNX IoT Stack to us
set(USE_GITLAB OFF CACHE BOOL "use gitlab as source for KNX IoT Stack")

if(CASCODA_USE_PRIVATE_SDK)
set(CASCODA_REPO cascoda-sdk-priv)
set(CASCODA_SDK_REPO https://github.com/Cascoda/cascoda-sdk-priv.git CACHE STRING "")
else()
set(CASCODA_REPO cascoda-sdk)
set(CASCODA_SDK_REPO https://github.com/Cascoda/cascoda-sdk.git CACHE STRING "")
endif()
set(CASCODA_SDK_REPO https://github.com/Cascoda/${CASCODA_REPO}.git)

set(CASCODA_REPO cascoda-sdk)

if(USE_GITLAB)
set(KNX_REPO knx-iot-stack-gitlab)
set(KNX_IOT_STACK_REPO https://gitlab.knx.org/shared-projects/knx-iot-point-api-public-stack/)
set(KNX_IOT_STACK_REPO https://gitlab.knx.org/shared-projects/knx-iot-point-api-public-stack/ CACHE STRING "")
else()
set(KNX_REPO knx-iot-stack)
set(KNX_IOT_STACK_REPO https://github.com/KNX-IOT/KNX-IOT-STACK.git)
set(KNX_IOT_STACK_REPO https://github.com/cascoda/knx-iot-stack.git CACHE STRING "")
endif()

# KNX IoT Stack
Expand All @@ -70,6 +71,7 @@ FetchContent_Declare(
GIT_TAG ${CASCODA_SDK_REF}
)


if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL M2351)

set(USE_CONSOLE OFF CACHE BOOL "use console (for output logging)")
Expand All @@ -86,7 +88,8 @@ if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL M2351)
FetchContent_MakeAvailable(${KNX_REPO})

add_executable(knx_eink_battleships
${PROJECT_SOURCE_DIR}/knx_eink_battleships.c )
${PROJECT_SOURCE_DIR}/knx_eink_battleships.c
${PROJECT_SOURCE_DIR}/knx_eink_battleships_virtual.c)
target_link_libraries(knx_eink_battleships kisClientServer)

if(WIN32)
Expand All @@ -101,7 +104,8 @@ if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL M2351)
add_executable(knx_eink_battleships_gui WIN32
${PROJECT_SOURCE_DIR}/knx_eink_battleships_gui.cpp
# ${PROJECT_SOURCE_DIR}/knx_eink_battleships_logic.c
${PROJECT_SOURCE_DIR}/knx_eink_battleships.c)
${PROJECT_SOURCE_DIR}/knx_eink_battleships.c
${PROJECT_SOURCE_DIR}/knx_eink_battleships_virtual.c)
target_link_libraries(knx_eink_battleships_gui wx::net wx::core wx::base kisClientServer)
# enable flag to compile the console in, so that the printf of the stack are shown.
target_compile_definitions(knx_eink_battleships_gui PUBLIC KNX_GUI)
Expand All @@ -113,9 +117,11 @@ if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL M2351)
endif()




else()
set(CASCODA_CHILI2_CONFIG_STRING "DEV_BOARD" CACHE STRING "KNX only supported on Devboard" FORCE)
set(CASCODA_CHILI2_REV "1" CACHE STRING "KNX only supported for Chili2 Rev 1" FORCE)
set(CASCODA_CHILI2_CONFIG_STRING "DEV_BOARD" CACHE STRING "KNX only supported on Devboard")
set(CASCODA_CHILI2_REV "1" CACHE STRING "KNX only supported for Chili2 Rev 1")
set(CASCODA_OTA_UPGRADE_ENABLED 0 CACHE BOOL "Enables OTA upgrade")
set(USE_DEMO_MODE OFF CACHE BOOL "demo mode (no reset)")
option(CASCODA_BUILD_KNX "Enable the KNX-IoT Port" ON)
Expand All @@ -132,8 +138,6 @@ else()
${PROJECT_SOURCE_DIR}/knx_eink_battleships_logic.c
# Embedded specific main loop, which initialises the MCU, communications & then runs the KNX application
${PROJECT_SOURCE_DIR}/knx_iot_wakeful_main.c
#
# ${PROJECT_SOURCE_DIR}/KNX_EINK_BS.c
)
target_link_libraries(knx_eink_battleships_ed
kisClientServer
Expand All @@ -153,8 +157,6 @@ else()
${PROJECT_SOURCE_DIR}/knx_eink_battleships_logic.c
# Embedded specific main loop, which initialises the MCU, communications & then runs the KNX application
${PROJECT_SOURCE_DIR}/knx_iot_wakeful_main.c
#
# ${PROJECT_SOURCE_DIR}/KNX_EINK_BS.c
)
target_link_libraries(knx_eink_battleships_reed
kisClientServer
Expand All @@ -174,8 +176,6 @@ else()
${PROJECT_SOURCE_DIR}/knx_eink_battleships_logic.c
# Embedded specific main loop, which initialises the MCU, communications & then runs the KNX application
${PROJECT_SOURCE_DIR}/knx_iot_sleepy_main.c
#
# ${PROJECT_SOURCE_DIR}/KNX_EINK_BS.c
)
target_link_libraries(knx_eink_battleships_sleepy
kisClientServer
Expand All @@ -187,6 +187,9 @@ else()
eink-driver-waveshare-1-54-half-res
)

# include device cmake files, after all the targets have been created so that they may be altered within


if(USE_DEMO_MODE)
target_compile_definitions(knx_eink_battleships_ed PUBLIC DEMO_MODE)
target_compile_definitions(knx_eink_battleships_reed PUBLIC DEMO_MODE)
Expand All @@ -202,7 +205,7 @@ else()
set(STACK_SIZE_KB "5" CACHE STRING "Number of KB to alloc stack")
endif()
if(NOT DEFINED HEAP_SIZE_BASE_KB)
set(HEAP_SIZE_BASE_KB "40" CACHE STRING "Number of KB to alloc heap")
set(HEAP_SIZE_BASE_KB "20" CACHE STRING "Number of KB to alloc heap")
endif()
math(EXPR STACK_SIZE "1024 * ${STACK_SIZE_KB}")
math(EXPR HEAP_SIZE_ED "1024 * (${HEAP_SIZE_BASE_KB})")
Expand Down Expand Up @@ -242,12 +245,21 @@ else()


if (NOT TARGET copy-ldrom)
if (CASCODA_BM_INTERFACE STREQUAL "USB")
add_custom_target(copy-ldrom ALL DEPENDS ldrom_hid)
add_custom_command(TARGET copy-ldrom
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_hid ${PROJECT_BINARY_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_hid.bin ${PROJECT_BINARY_DIR}/bin
)
elseif (CASCODA_BM_INTERFACE STREQUAL "UART")
add_custom_target(copy-ldrom ALL DEPENDS ldrom_uart)
add_custom_command(TARGET copy-ldrom
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_uart ${PROJECT_BINARY_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_uart.bin ${PROJECT_BINARY_DIR}/bin
)
endif()
endif()

if (CASCODA_OTA_UPGRADE_ENABLED EQUAL 1)
Expand Down
21 changes: 13 additions & 8 deletions BATTLESHIP/TopLevelCMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ project(knx_iot_demos)

option(CASCODA_USE_PRIVATE_SDK "" OFF)

if(CASCODA_USE_PRIVATE_SDK)
set(CASCODA_REPO cascoda-sdk-priv)
else()
set(CASCODA_REPO cascoda-sdk)
endif()
set(CASCODA_REPO cascoda-sdk)

if(CMAKE_SYSTEM_PROCESSOR STREQUAL M2351)
if (CASCODA_BM_INTERFACE STREQUAL "USB")
add_custom_target(copy-ldrom ALL DEPENDS ldrom_hid)
add_custom_command(TARGET copy-ldrom
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_hid ${PROJECT_BINARY_DIR}/bin/ldrom_hid
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_hid.bin ${PROJECT_BINARY_DIR}/bin/ldrom_hid.bin
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_hid ${PROJECT_BINARY_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_hid.bin ${PROJECT_BINARY_DIR}/bin
)
elseif (CASCODA_BM_INTERFACE STREQUAL "UART")
add_custom_target(copy-ldrom ALL DEPENDS ldrom_uart)
add_custom_command(TARGET copy-ldrom
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_uart ${PROJECT_BINARY_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/_deps/${CASCODA_REPO}-build/bin/ldrom_uart.bin ${PROJECT_BINARY_DIR}/bin
)
endif()

if (CASCODA_OTA_UPGRADE_ENABLED EQUAL 1)
add_custom_target(copy-ota-bootloader ALL DEPENDS ota-bootloader)
Expand Down
7 changes: 5 additions & 2 deletions BATTLESHIP/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@

mkdir -p build
cd build
cmake .. -DOC_DNS_SD_ENABLED=OFF -DOC_OSCORE_ENABLED=ON -DUSE_CONSOLE=ON
cmake .. -DOC_DNS_SD_ENABLED=ON -DOC_OSCORE_ENABLED=ON -DUSE_CONSOLE=ON
# build step
cmake --build .
# default is all targets
#cmake --build .
cmake --build . --target knx_eink_battleships
cmake --build . --target knx_eink_battleships_gui
2 changes: 2 additions & 0 deletions BATTLESHIP/build_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ CLI:

- knx_eink_battleships Application (CLI) using the following files:
- knx_eink_battleships.c
- knx_eink_battleships_virtual.c
- knx_eink_battleships.h

Windows GUI using WxWidgets:

- knx_eink_battleships_gui Application (wxWidgets) using the following files:
- knx_eink_battleships.c
- knx_eink_battleships_virtual.c
- knx_eink_battleships.h
- knx_eink_battleships.cpp

Expand Down
3 changes: 2 additions & 1 deletion BATTLESHIP/build_win_bin_ninja.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ mkdir -p build_win_bin
cd build_win_bin
# create the make files for Windows/Linux
cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE=../arm_gcc_m2351.cmake -DOC_OSCORE_ENABLED=ON \
-DOC_DNS_SD_ENABLED=ON -DOC_PRINT_ENABLED=OFF -DOC_PRINT_APP_ENABLED=OFF
-DOC_DNS_SD_ENABLED=ON -DOC_PRINT_ENABLED=OFF -DOC_PRINT_APP_ENABLED=OFF
#-DCASCODA_USE_PRIVATE_SDK=ON
cmake .
# build it
ninja
Expand Down
47 changes: 47 additions & 0 deletions BATTLESHIP/build_win_bin_ninja_ota.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright (c) 2022-2023 Cascoda Ltd
# All rights reserved.
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list
# of conditions and the following disclaimer.
#
# 2. Redistributions in binary form, except as embedded into a Cascoda Limited.
# integrated circuit in a product or a software update for such product, must
# reproduce the above copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of Cascoda Limited nor the names of its contributors may be used to
# endorse or promote products derived from this software without specific prior written
# permission.
#
# 4. This software, whether provided in binary or any other form must not be decompiled,
# disassembled, reverse engineered or otherwise modified.
#
# 5. This software, in whole or in part, must only be used with a Cascoda Limited circuit.
#
# THIS SOFTWARE IS PROVIDED BY CASCODA LIMITED "AS IS" AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL CASCODA LIMITED OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


# build script for creating a binary for the dev board
# on windows/linux using the ninja toolchain
echo "using Ninja"

mkdir -p build_win_bin
cd build_win_bin
# create the make files for Windows/Linux
cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE=../arm_gcc_m2351.cmake -DOC_OSCORE_ENABLED=ON \
-DOC_DNS_SD_ENABLED=ON -DOC_PRINT_ENABLED=OFF -DOC_PRINT_APP_ENABLED=OFF -DCASCODA_OTA_UPGRADE_ENABLED=1
cmake .
# build it
ninja

Loading

0 comments on commit 130fd12

Please sign in to comment.