diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index e69de29b..f6038816 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/Unit_Tests.xml b/.idea/runConfigurations/Unit_Tests.xml
index d758d7ee..b2220add 100644
--- a/.idea/runConfigurations/Unit_Tests.xml
+++ b/.idea/runConfigurations/Unit_Tests.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/.idea/runConfigurations/all.xml b/.idea/runConfigurations/all.xml
index 81208668..12ca77e4 100644
--- a/.idea/runConfigurations/all.xml
+++ b/.idea/runConfigurations/all.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7282a018..b9dbf7cf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.20...3.24)
+
include(cmake/set_build_target.cmake)
@@ -13,20 +14,6 @@ add_runtime_c()
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
-if(MVC)
- add_compile_options(/W4)
-else()
- add_compile_options(
- -Wall
- -Wextra
- -Wdouble-promotion # warn when float gets promoted to double as this can be quite expensive
- -Wnull-dereference
- -Wimplicit-fallthrough # warn about fall through in switch case
- )
-
-endif ()
-
-# enable debug prints
if (DEBUG_OUTPUT)
add_definitions(-DDEBUG_MODE)
endif ()
@@ -38,40 +25,21 @@ if(NOT BUILDING_FOR_ELASTIC_NODE)
endif ()
project(enV5 C CXX ASM)
+pico_sdk_init()
-# enable test execution via CMake
-include(CTest)
-
-# include unit-test framework
include(cmake/custom_targets.cmake)
+include(cmake/pico_targets.cmake)
+include(CTest)
-pico_sdk_init()
-
-add_freertos()
-
-include(cmake/pico_targets.cmake)
add_subdirectory(src)
add_subdirectory(test/unit)
add_subdirectory(test/hardware/Helper)
add_subdirectory(test/hardware/Sensors)
+add_freertos()
if(BUILDING_FOR_ELASTIC_NODE AND NOT TARGET tinyusb_device)
message(WARNING "not building project, because tinyusb not initialized")
+else()
endif ()
-# if (TARGET tinyusb_device)
-# # include required libraries
-# add_basic_functionality()
-# add_freertos_kernel()
-#
-# add_rp2040_hal()
-# add_sensor_libraries()
-#
-# # include hardware tests
-# add_subdirectory(test/hardware)
-#
-# add_dependency_graph()
-# elseif (PICO_ON_DEVICE)
-# message(WARNING "Not building Project, because TinyUSB submodule is not initialized in the SDK!")
-# endif ()
-#endif ()
+
diff --git a/CMakePresets.json b/CMakePresets.json
index 7a130bb8..931def71 100644
--- a/CMakePresets.json
+++ b/CMakePresets.json
@@ -13,7 +13,8 @@
"generator": "Ninja",
"binaryDir": "build/host/",
"cacheVariables": {
- "ELASTIC_AI_TARGET": "HOST"
+ "ELASTIC_AI_TARGET": "HOST",
+ "CMAKE_BUILD_TYPE": "Release"
}
},
{
@@ -22,7 +23,8 @@
"generator": "Ninja",
"binaryDir": "build/env5_rev2",
"cacheVariables": {
- "ELASTIC_AI_TARGET": "ENV5_REV2"
+ "ELASTIC_AI_TARGET": "ENV5_REV2",
+ "CMAKE_BUILD_TYPE": "Release"
}
}
],
@@ -34,8 +36,7 @@
},
{
"name": "unit_test",
- "configurePreset": "host",
- "jobs": 4,
+ "inherits": "host",
"targets": "all_unit_tests"
}
],
diff --git a/cmake/custom_targets.cmake b/cmake/custom_targets.cmake
index f17d81cd..9b3d2ed3 100644
--- a/cmake/custom_targets.cmake
+++ b/cmake/custom_targets.cmake
@@ -5,26 +5,29 @@
################
-function(__target_use_interfaces target)
- foreach (arg ${ARGN})
- target_link_libraries(${target} PRIVATE ${arg}__hdrs)
+
+function(elastic_ai_target_link_hdrs target)
+ foreach (d ${ARGN})
+ target_link_libraries(${target} PRIVATE ${d}__hdrs)
endforeach ()
endfunction()
-function(__target_add_default_includes target)
- target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_LIST_DIR})
- target_include_directories(${target} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
+function(elastic_ai_target_link_impl target)
+ foreach(d ${ARGN})
+ if (TARGET ${d}__impl)
+ target_link_libraries(${target} INTERFACE ${d}__impl)
+ endif ()
+ endforeach ()
endfunction()
-function(__add_elastic_ai_implementation)
- set(oneValueArgs NAME)
- set(multiValueArgs SOURCES DEPS)
- cmake_parse_arguments(PARSE_ARGV 0 arg
- "${options}" "${oneValueArgs}" "${multiValueArgs}"
- )
- add_library(${arg_NAME})
- target_sources(${arg_NAME} PRIVATE ${arg_SOURCES})
- target_include_directories(${arg_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR})
+function(elastic_ai_connect_libs target)
+ target_include_directories(${target}__hdrs INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
+ if(TARGET ${target}__impl)
+ target_link_libraries(${target}__impl PRIVATE ${target}__hdrs)
+ target_include_directories(${target}__impl PRIVATE ${CMAKE_CURRENT_LIST_DIR})
+ target_link_libraries(${target} INTERFACE ${target}__impl)
+ endif ()
+ target_link_libraries(${target} INTERFACE ${target}__hdrs)
endfunction()
function(add_elastic_ai_lib)
@@ -71,27 +74,18 @@ function(add_elastic_ai_lib)
cmake_parse_arguments(PARSE_ARGV 0 arg
"${options}" "${oneValueArgs}" "${multiValueArgs}"
)
- set(BUILD_IMPLEMENTATION (arg_SRCS AND ((NOT ${arg_HW_ONLY}) OR BUILDING_FOR_ELASTIC_NODE)))
+ set(BUILD_IMPLEMENTATION ((NOT ${arg_HW_ONLY}) OR BUILDING_FOR_ELASTIC_NODE))
- foreach (file ${arg_SRCS})
- if(NOT ((NOT IS_ABSOLUTE ${file} AND EXISTS ${CMAKE_CURRENT_LIST_DIR}/${file}) OR EXISTS ${file}))
- message(FATAL_ERROR "${file} does not exist")
- endif ()
- endforeach ()
+ add_library(${arg_NAME}__hdrs INTERFACE)
if(${BUILD_IMPLEMENTATION})
- __add_elastic_ai_implementation(NAME ${arg_NAME}__impl SOURCES ${arg_SRCS})
- __target_use_interfaces(${arg_NAME}__impl ${arg_DEPS})
+ add_library(${arg_NAME}__impl ${arg_SRCS})
+ elastic_ai_target_link_hdrs(${arg_NAME}__impl ${arg_DEPS})
+ elastic_ai_target_link_impl(${arg_NAME}__impl ${arg_DEPS})
endif ()
-
- add_library(${arg_NAME}__hdrs INTERFACE)
- target_include_directories(${arg_NAME}__hdrs INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
-
add_library(${arg_NAME} INTERFACE)
- if(${BUILD_IMPLEMENTATION})
- target_link_libraries(${arg_NAME} INTERFACE ${arg_NAME}__impl)
- endif ()
- target_link_libraries(${arg_NAME} INTERFACE ${arg_NAME}__hdrs)
+ elastic_ai_connect_libs(${arg_NAME})
+
endfunction()
diff --git a/cmake/env5.cmake b/cmake/env5.cmake
index e7095117..fddd0ecc 100644
--- a/cmake/env5.cmake
+++ b/cmake/env5.cmake
@@ -1,7 +1,7 @@
message("Building for env5")
set(BUILDING_FOR_ELASTIC_NODE ON CACHE INTERNAL "we're building for elastic node")
-set(PICO_BOARD none CACHE STRING "")
-set(PICO_PLATFORM rp2040 CACHE STRING "")
+set(PICO_BOARD none)
+set(PICO_PLATFORM rp2040)
if(${ELASTIC_AI_TARGET} EQUAL ENV5_REV1)
set(REVISION "1" CACHE INTERNAL "")
diff --git a/cmake/host.cmake b/cmake/host.cmake
index c148ec73..5137714d 100644
--- a/cmake/host.cmake
+++ b/cmake/host.cmake
@@ -1,5 +1,5 @@
message("building for native host platform")
set(BUILDING_FOR_ELASTIC_NODE OFF CACHE INTERNAL "we're building for elastic node")
-set(PICO_BOARD none CACHE STRING "")
-set(PICO_PLATFORM host CACHE STRING "")
+set(PICO_BOARD none)
+set(PICO_PLATFORM host)
set(REVISION "1" CACHE INTERNAL "")
diff --git a/cmake/pico_targets.cmake b/cmake/pico_targets.cmake
index ea56bc23..7a1acfcc 100644
--- a/cmake/pico_targets.cmake
+++ b/cmake/pico_targets.cmake
@@ -7,9 +7,11 @@ function(__add_pico_lib original)
endif ()
add_library(Pico::${original}__hdrs ALIAS pico_empty_lib)
add_library(Pico::${original} ALIAS pico_empty_lib)
+ add_library(Pico::${original}__impl ALIAS pico_empty_lib)
else ()
add_library(Pico::${original} ALIAS ${original})
add_library(Pico::${original}__hdrs ALIAS ${original}_headers)
+ add_library(Pico::${original}__impl ALIAS ${original})
endif ()
endfunction()
diff --git a/cmake/third_party_deps.cmake b/cmake/third_party_deps.cmake
index c661411d..1f761f8f 100644
--- a/cmake/third_party_deps.cmake
+++ b/cmake/third_party_deps.cmake
@@ -17,10 +17,11 @@ function(add_cexception)
GIT_TAG v1.3.3
)
FetchContent_Populate(cexception)
- add_library(CException ${cexception_SOURCE_DIR}/lib/CException.c)
+ add_library(CException__impl ${cexception_SOURCE_DIR}/lib/CException.c)
add_library(CException__hdrs INTERFACE)
target_include_directories(CException__hdrs INTERFACE ${cexception_SOURCE_DIR}/lib/)
- target_link_libraries(CException PUBLIC CException__hdrs)
+ add_library(CException INTERFACE)
+ target_link_libraries(CException INTERFACE CException__hdrs CException__impl)
endfunction()
function(add_unity)
diff --git a/src/fpga/stub/CMakeLists.txt b/src/fpga/stub/CMakeLists.txt
index 5f99330a..aba65e67 100644
--- a/src/fpga/stub/CMakeLists.txt
+++ b/src/fpga/stub/CMakeLists.txt
@@ -3,6 +3,6 @@ set(MIDDLEWARE_STUB_VERSION CACHE STRING "2" "use stub version 2, compatible wit
add_elastic_ai_lib(
NAME Stub
- SOURCES stub.c
+ SRCS stub.c
DEPS Common Sleep Middleware
)
\ No newline at end of file
diff --git a/src/hal/enV5HwConfiguration/CMakeLists.txt b/src/hal/enV5HwConfiguration/CMakeLists.txt
index ceb5b081..663d5c49 100644
--- a/src/hal/enV5HwConfiguration/CMakeLists.txt
+++ b/src/hal/enV5HwConfiguration/CMakeLists.txt
@@ -1,7 +1,8 @@
-add_elastic_ai_lib(
- NAME
- EnV5HwConfiguration
-)
+
+add_library(EnV5HwConfiguration INTERFACE)
+add_library(EnV5HwConfiguration__hdrs INTERFACE)
+target_link_libraries(EnV5HwConfiguration INTERFACE EnV5HwConfiguration__hdrs)
+
set(REVISION_FILEPATH ${REVISION} CACHE FILEPATH "Helper variable needed for casting" FORCE)
if(NOT DEFINED REVISION)
diff --git a/src/hal/enV5HwController/CMakeLists.txt b/src/hal/enV5HwController/CMakeLists.txt
index 8e68ea00..32580512 100644
--- a/src/hal/enV5HwController/CMakeLists.txt
+++ b/src/hal/enV5HwController/CMakeLists.txt
@@ -2,6 +2,6 @@ add_elastic_ai_lib(
HW_ONLY
NAME EnV5HwController
SRCS EnV5HwController.c
- DEPS Common EnV5HwConfiguration Gpio I2c Spi Uart Sleep Flash Adxl345b Pac193x Sht3x
-
+ DEPS Common EnV5HwConfiguration Gpio Sleep
)
+
diff --git a/src/hal/enV5HwController/EnV5HwController.c b/src/hal/enV5HwController/EnV5HwController.c
index 935674de..c9d0c43d 100644
--- a/src/hal/enV5HwController/EnV5HwController.c
+++ b/src/hal/enV5HwController/EnV5HwController.c
@@ -4,9 +4,9 @@
#include "Common.h"
#include "EnV5HwConfiguration.h"
+#include "EnV5HwController.h"
#include "Gpio.h"
#include "Sleep.h"
-#include "include/EnV5HwController.h"
void env5HwControllerInit() {
env5HwControllerLedsInit();
diff --git a/src/hal/gpio/CMakeLists.txt b/src/hal/gpio/CMakeLists.txt
index 4b9c3fae..a9dd3f10 100644
--- a/src/hal/gpio/CMakeLists.txt
+++ b/src/hal/gpio/CMakeLists.txt
@@ -1,8 +1,17 @@
# Provides a Facade for the pico-sdk GPIO library
-add_elastic_ai_lib(
- HW_ONLY
- NAME Gpio
- SRCS Gpio.c
- DEPS Common Pico::hardware_gpio
-)
+block(SCOPE_FOR VARIABLES)
+ set(deps Common Pico::hardware_gpio)
+
+ add_library(Gpio__hdrs INTERFACE)
+ if(BUILDING_FOR_ELASTIC_NODE)
+ add_library(Gpio__impl Gpio.c)
+ elastic_ai_target_link_hdrs(Gpio__impl ${deps})
+ elastic_ai_target_link_impl(Gpio__impl ${deps})
+ endif ()
+ add_library(Gpio INTERFACE)
+
+ elastic_ai_connect_libs(Gpio)
+
+
+endblock()
\ No newline at end of file
diff --git a/src/hal/sleep/CMakeLists.txt b/src/hal/sleep/CMakeLists.txt
index 6b3957f7..5c380232 100644
--- a/src/hal/sleep/CMakeLists.txt
+++ b/src/hal/sleep/CMakeLists.txt
@@ -3,6 +3,6 @@
add_elastic_ai_lib(
HW_ONLY
NAME Sleep
- SRCS ${CMAKE_CURRENT_LIST_DIR}/Sleep.c
+ SRCS Sleep.c
DEPS Common Pico::pico_time
)
diff --git a/src/hal/uart/CMakeLists.txt b/src/hal/uart/CMakeLists.txt
index 9d14a7f4..b8a5ce89 100644
--- a/src/hal/uart/CMakeLists.txt
+++ b/src/hal/uart/CMakeLists.txt
@@ -2,5 +2,5 @@ add_elastic_ai_lib(
HW_ONLY
NAME Uart
SRCS Uart.c
- DEPS Common Gpio Pico::hardware_uart Pico::hardware_irq
+ DEPS Common Gpio Pico::hardware_uart Pico::hardware_irq Pico::pico_runtime
)
diff --git a/src/network/atCommands/CMakeLists.txt b/src/network/atCommands/CMakeLists.txt
index b786f3de..7ace747b 100644
--- a/src/network/atCommands/CMakeLists.txt
+++ b/src/network/atCommands/CMakeLists.txt
@@ -1,2 +1,4 @@
-add_elastic_ai_lib(
- NAME AtCommands)
+add_library(AtCommands INTERFACE)
+add_library(AtCommands__hdrs INTERFACE)
+target_include_directories(AtCommands__hdrs INTERFACE include)
+target_link_libraries(AtCommands INTERFACE AtCommands__hdrs)
diff --git a/src/network/broker/CMakeLists.txt b/src/network/broker/CMakeLists.txt
index d12577b2..62b3b46b 100644
--- a/src/network/broker/CMakeLists.txt
+++ b/src/network/broker/CMakeLists.txt
@@ -12,7 +12,7 @@ add_elastic_ai_lib(
target_include_directories(
MqttBroker__impl
- INTERFACE
+ PRIVATE
$
$
)
diff --git a/src/sensor/bmi323/Bmi323.c b/src/sensor/bmi323/Bmi323.c
index e97832d6..6fc807dd 100644
--- a/src/sensor/bmi323/Bmi323.c
+++ b/src/sensor/bmi323/Bmi323.c
@@ -9,11 +9,11 @@
#include "CException.h"
-#include "Bmi323.h"
#include "Common.h"
#include "Sleep.h"
#include "Spi.h"
#include "SpiTypedefs.h"
+#include "include/Bmi323.h"
#include "bmi3.h"
#include "bmi323.h"
diff --git a/src/sensor/bmi323/CMakeLists.txt b/src/sensor/bmi323/CMakeLists.txt
index 7699a454..038533a0 100644
--- a/src/sensor/bmi323/CMakeLists.txt
+++ b/src/sensor/bmi323/CMakeLists.txt
@@ -7,11 +7,15 @@ FetchContent_Declare(
)
FetchContent_Populate(bmi323)
-add_library(__external_bmi323_bosch_lib
+add_library(__external_bmi323_bosch_lib__impl
"${bmi323_SOURCE_DIR}/bmi3.c"
"${bmi323_SOURCE_DIR}/bmi323.c")
-target_include_directories(__external_bmi323_bosch_lib PUBLIC "${bmi323_SOURCE_DIR}")
+add_library(__external_bmi323_bosch_lib__hdrs INTERFACE)
+target_include_directories(__external_bmi323_bosch_lib__hdrs INTERFACE "${bmi323_SOURCE_DIR}")
+target_link_libraries(__external_bmi323_bosch_lib__impl PRIVATE __external_bmi323_bosch_lib__hdrs)
+add_library(__external_bmi323_bosch_lib INTERFACE)
+target_link_libraries(__external_bmi323_bosch_lib INTERFACE __external_bmi323_bosch_lib__hdrs __external_bmi323_bosch_lib__impl)
add_elastic_ai_lib(
HW_ONLY
@@ -19,9 +23,13 @@ add_elastic_ai_lib(
SRCS Bmi323.c
DEPS
__external_bmi323_bosch_lib
+ Common
Pico::pico_stdlib
CException
Sleep
Gpio
Spi
-)
\ No newline at end of file
+)
+
+target_link_libraries(Bmi323__hdrs INTERFACE __external_bmi323_bosch_lib__hdrs)
+
diff --git a/src/sensor/pac193x/CMakeLists.txt b/src/sensor/pac193x/CMakeLists.txt
index e377736a..fc7f37b8 100644
--- a/src/sensor/pac193x/CMakeLists.txt
+++ b/src/sensor/pac193x/CMakeLists.txt
@@ -1,9 +1,23 @@
-add_elastic_ai_lib(
- NAME Pac193x
- SRCS Pac193x.c
- DEPS
- Common
- Sleep
- Gpio
- I2c
-)
\ No newline at end of file
+#add_elastic_ai_lib(
+# NAME Pac193x
+# SRCS Pac193x.c
+# DEPS
+# Common
+# Sleep
+# Gpio
+# I2c
+#)
+
+block(SCOPE_FOR VARIABLES)
+ set(deps Common Sleep Gpio I2c)
+
+ add_library(Pac193x__hdrs INTERFACE)
+ add_library(Pac193x__impl Pac193x.c)
+ elastic_ai_target_link_hdrs(Pac193x__impl ${deps})
+ elastic_ai_target_link_impl(Pac193x__impl ${deps})
+ add_library(Pac193x INTERFACE)
+
+ elastic_ai_connect_libs(Pac193x)
+
+
+endblock()
\ No newline at end of file
diff --git a/src/sensor/sht3x/CMakeLists.txt b/src/sensor/sht3x/CMakeLists.txt
index 79d76089..4af2a941 100644
--- a/src/sensor/sht3x/CMakeLists.txt
+++ b/src/sensor/sht3x/CMakeLists.txt
@@ -1,8 +1,11 @@
-add_elastic_ai_lib(
- NAME Sht3x
- SRCS Sht3x.c
- DEPS
- CException
- Common
- I2c
-)
+block(SCOPE_FOR VARIABLES)
+ set(deps CException Common I2c)
+
+ add_library(Sht3x__hdrs INTERFACE)
+ add_library(Sht3x__impl Sht3x.c)
+ add_library(Sht3x INTERFACE)
+
+ elastic_ai_connect_libs(Sht3x)
+ elastic_ai_target_link_impl(Sht3x__impl ${deps})
+ elastic_ai_target_link_hdrs(Sht3x__impl ${deps})
+endblock()
\ No newline at end of file
diff --git a/test/hardware/Sensors/CMakeLists.txt b/test/hardware/Sensors/CMakeLists.txt
index 56d8fc50..0378231a 100644
--- a/test/hardware/Sensors/CMakeLists.txt
+++ b/test/hardware/Sensors/CMakeLists.txt
@@ -4,116 +4,96 @@ add_executable(hardware-test_sht3 HardwaretestSht3x.c)
create_enV5_executable(hardware-test_sht3)
target_link_libraries(hardware-test_sht3
- pico_util
- pico_stdlib
- pico_stdio_usb
- pico_bootrom
- hardware_i2c
- pico_time
- hardware_sync
- pico_runtime
- I2c
- Gpio
- Time
+ Pico::pico_stdlib
+ Pico::pico_bootrom
+ Pico::hardware_i2c
+ EnV5HwController
Common
EnV5HwConfiguration
- EnV5HwController
+ I2c
Sht3x
CException
+
)
-##############################################
-## region hardware-test_adxl345b
+#############################################
+# region hardware-test_adxl345b
#add_executable(hardware-test_adxl345b HardwaretestAdxl345b.c)
#target_link_libraries(hardware-test_adxl345b
-# common_lib
-# pico_stdlib
-# pico_stdio_usb
-# pico_bootrom
-# pico_time
-# i2c_interface
-# sensor_lib_adxl345b)
+# Common
+# Pico::pico_stdlib
+# Pico::pico_stdio_usb
+#
+# Pico::pico_bootrom
+# I2c
+# Adxl345b
+# Time
+# Pico::pico_time
+#
+#)
#create_enV5_executable(hardware-test_adxl345b)
-### endregion hardware-test_adxl345b
+## endregion hardware-test_adxl345b
###############################################
### hardware-test_pac193x
-#add_executable(hardware-test_pac193x HardwaretestPac193x.c)
-#target_link_libraries(hardware-test_pac193x
-# common_lib
-# pico_stdlib
-# pico_stdio_usb
-# pico_bootrom
-# pico_time
-# i2c_interface
-# enV5_hw_configuration
-# sensor_lib_pac193x)
-#create_enV5_executable(hardware-test_pac193x)
-###############################################
-### hardware-test_pac193x_stream
-#add_executable(hardware-test_pac193x_stream HardwaretestPac193xAccumulator.c)
-#target_link_libraries(hardware-test_pac193x_stream
-# common_lib
-# pico_stdlib
-# pico_stdio_usb
-# pico_bootrom
-# pico_time
-# i2c_interface
-# enV5_hw_configuration
-# enV5_hw_controller
-# sensor_lib_pac193x)
-#create_enV5_executable(hardware-test_pac193x_stream)
-###############################################
-### hardware-test_dualpac193x
-#add_executable(hardware-test_dualpac193x HardwaretestDualPac193x.c)
-#target_link_libraries(hardware-test_dualpac193x
-# common_lib
-# pico_stdlib
-# pico_stdio_usb
-# pico_bootrom
-# pico_time
-# i2c_interface
-# enV5_hw_configuration
-# sensor_lib_pac193x)
-#create_enV5_executable(hardware-test_dualpac193x)
+add_executable(hardware-test_pac193x HardwaretestPac193x.c)
+
+
+add_library(_HWTestLibForPac139x INTERFACE)
+target_link_libraries( _HWTestLibForPac139x INTERFACE
+ Common
+ Pico::pico_stdlib
+ Pico::pico_stdio_usb
+ Pico::pico_bootrom
+ Pico::pico_time
+ I2c
+ EnV5HwConfiguration
+ Pac193x
+)
+
+target_link_libraries(hardware-test_pac193x _HWTestLibForPac139x)
+create_enV5_executable(hardware-test_pac193x)
###############################################
+## hardware-test_pac193x_stream
+add_executable(hardware-test_pac193x_stream HardwaretestPac193xAccumulator.c)
+target_link_libraries(hardware-test_pac193x_stream _HWTestLibForPac139x)
+create_enV5_executable(hardware-test_pac193x_stream)
+##############################################
+## hardware-test_dualpac193x
+add_executable(hardware-test_dualpac193x HardwaretestDualPac193x.c)
+target_link_libraries(hardware-test_dualpac193x _HWTestLibForPac139x)
+
+create_enV5_executable(hardware-test_dualpac193x)
+##############################################
### hardware-test_pac193xbuffer
-#add_executable(hardware-test_pac193xbuffer HardwaretestPac193xBuffer.c)
-#target_link_libraries(hardware-test_pac193xbuffer
-# common_lib
-# pico_stdlib
-# pico_stdio_usb
-# pico_bootrom
-# pico_time
-# i2c_interface
-# enV5_hw_configuration
-# sensor_lib_pac193x)
-#create_enV5_executable(hardware-test_pac193xbuffer)
-###############################################
-#add_executable(hardware-test_bmi323 HardwaretestBmi323.c)
-#target_link_libraries(hardware-test_bmi323
-# pico_stdlib
-# hardware_spi
-#
-# CException
-#
-# common_lib
-# enV5_hw_configuration
-# enV5_hw_controller
-# spi_interface
-# sleep_interface
-# sensor_lib_bmi323
-#)
-#create_enV5_executable(hardware-test_bmi323)
+add_executable(hardware-test_pac193xbuffer HardwaretestPac193xBuffer.c)
+target_link_libraries(hardware-test_pac193xbuffer _HWTestLibForPac139x)
+create_enV5_executable(hardware-test_pac193xbuffer)
+##############################################
+add_executable(hardware-test_bmi323 HardwaretestBmi323.c)
+target_link_libraries(hardware-test_bmi323
+ Pico::pico_stdlib
+ Pico::hardware_spi
+
+ CException
+ Common
+ EnV5HwConfiguration
+ EnV5HwController
+ Spi
+ Sleep
+ Bmi323
+
+)
+create_enV5_executable(hardware-test_bmi323)
### hardware-stresstest_adxl345b
#add_executable(hardware-test_stressTest_adxl345b StressTestAdxl345b.c)
#target_link_libraries(hardware-test_stressTest_adxl345b
-# common_lib
-# pico_stdlib
-# pico_stdio_usb
-# pico_time
+# Pico::common_lib
+# Pico::pico_stdlib
+# Pico::pico_stdio_usb
+# Pico::pico_time
# freeRtosUtils
# espBroker_lib
# middleware_lib
# sensor_lib_adxl345b
# hardware-testHelper)
#create_enV5_executable(hardware-test_stressTest_adxl345b)
-###############################################
+##############################################
diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index 51e94067..f2f4bba9 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -33,7 +33,7 @@ add_elastic_ai_unit_test(
add_elastic_ai_unit_test(
LIB_UNDER_TEST
- Pac193
+ Pac193x
MORE_LIBS
Common
I2cDummy
@@ -89,91 +89,13 @@ add_elastic_ai_unit_test(
Time__hdrs
I2c__hdrs
)
-#add_executable(unit-test_sht3x ${CMAKE_CURRENT_LIST_DIR}/UnittestSht3x.c)
-#target_link_libraries(unit-test_sht3x
-# sensor_lib_sht3x
-# i2c_interface
-# unity)
-#add_test(unit-test_sht3x unit-test_sht3x)
-### endregion
-###############################################
-### region UNIT-TEST: unit-test_adxl345b
-#add_executable(unit-test_adxl345b ${CMAKE_CURRENT_LIST_DIR}/UnittestAdxl345b.c)
-#target_link_libraries(unit-test_adxl345b
-# sensor_lib_adxl345b
-# time_interface
-# unity)
-#add_test(unit-test_adxl345b unit-test_adxl345b)
-### endregion
-###############################################
-### region UNIT-TEST: unit-test_pac193x
-#add_executable(unit-test_pac193x ${CMAKE_CURRENT_LIST_DIR}/UnittestPac193x.c)
-#target_link_libraries(unit-test_pac193x
-# sensor_lib_pac193x
-# unity)
-#add_test(unit-test_pac193x unit-test_pac193x)
-### endregion
-###############################################
-### region UNIT-TEST: unit-test_network
-#add_executable(unit-test_network ${CMAKE_CURRENT_LIST_DIR}/UnittestNetwork.c)
-#target_link_libraries(unit-test_network
-# network_config
-# esp_lib
-# network_lib
-# unity
-# CException)
-#add_test(unit-test_network unit-test_network)
-### endregion
-###############################################
-### region UNIT-TEST: unit-test_mqtt
-#add_executable(unit-test_mqtt ${CMAKE_CURRENT_LIST_DIR}/UnittestMqtt.c)
-#target_link_libraries(unit-test_mqtt
-# network_config
-# esp_lib
-# espBroker_lib
-# unity
-# CException)
-#add_test(unit-test_mqtt unit-test_mqtt)
-### endregion
-###############################################
-### region UNIT-TEST: unit-test_http
-#add_executable(unit-test_http ${CMAKE_CURRENT_LIST_DIR}/UnittestHTTP.c)
-#target_link_libraries(unit-test_http
-# http_lib
-# unity
-# CException)
-#add_test(unit-test_http unit-test_http)
-### endregion
-###############################################
-### region UNIT-TEST: unit-test_fpgaConfigurationHandler
-## replace http lib with dummy
-#get_target_property(FPGA_CONFIG_LIBS fpga_configuration_handler INTERFACE_LINK_LIBRARIES)
-#list(REMOVE_ITEM FPGA_CONFIG_LIBS http_lib)
-#list(APPEND FPGA_CONFIG_LIBS http_lib_dummy)
-#set_property(TARGET fpga_configuration_handler PROPERTY INTERFACE_LINK_LIBRARIES ${FPGA_CONFIG_LIBS})
-## replace http lib with dummy
-#get_target_property(NET_LIBS network_lib INTERFACE_LINK_LIBRARIES)
-#list(REMOVE_ITEM NET_LIBS http_lib)
-#list(APPEND NET_LIBS http_lib_dummy)
-#set_property(TARGET network_lib PROPERTY INTERFACE_LINK_LIBRARIES ${NET_LIBS})
-## add test executable
-#add_executable(unit-test_fpgaConfigurationHandler ${CMAKE_CURRENT_LIST_DIR}/UnittestFpgaConfigurationHandler.c)
-#target_link_libraries(unit-test_fpgaConfigurationHandler
-# http_lib_dummy
-# flash_lib
-# fpga_configuration_handler
-# unity)
-#add_test(unit-test_fpgaConfigurationHandler unit-test_fpgaConfigurationHandler)
-### endregion
-###############################################
-
add_custom_target(all_unit_tests)
add_dependencies(all_unit_tests
UnitTestSht3x
UnitTestFpgaConfigurationHandler
- UnitTestPac193
+ UnitTestPac193x
UnitTestNetwork
UnitTestHttp
UnitTestMqttBroker
diff --git a/test/unit/UnittestAdxl345b.c b/test/unit/UnitTestAdxl345b.c
similarity index 100%
rename from test/unit/UnittestAdxl345b.c
rename to test/unit/UnitTestAdxl345b.c
diff --git a/test/unit/UnitTestPac193.c b/test/unit/UnitTestPac193x.c
similarity index 99%
rename from test/unit/UnitTestPac193.c
rename to test/unit/UnitTestPac193x.c
index c18b5f21..bbfa7c9c 100644
--- a/test/unit/UnitTestPac193.c
+++ b/test/unit/UnitTestPac193x.c
@@ -47,7 +47,6 @@ void tearDown(void) {}
void pac193xGetSensorInfoReturnSendCommandErrorIfHardwareFails(void) {
pac193xSensorId_t info;
i2cUnittestWriteCommand = i2cUnittestWriteCommandHardwareDefect;
-
pac193xErrorCode_t errorCode = pac193xGetSensorInfo(SENSOR, &info);
TEST_ASSERT_EQUAL_UINT8(PAC193X_SEND_COMMAND_ERROR, errorCode);
}
diff --git a/test/unit/UnittestHTTP.c b/test/unit/UnittestHTTP.c
deleted file mode 100644
index 50eb25be..00000000
--- a/test/unit/UnittestHTTP.c
+++ /dev/null
@@ -1,84 +0,0 @@
-#include "Esp.h"
-#include "EspUnitTest.h"
-#include "HTTP.h"
-
-#include "CException.h"
-#include "unity.h"
-
-#include
-
-void setUp() {
- ESPDUMMY_RETURN_CODE = ESP_WRONG_ANSWER_RECEIVED;
-}
-
-void tearDown() {}
-
-static char *generateString(int lengthOfString) {
- char *generatedString = malloc(sizeof('a') * lengthOfString);
- for (int i = 0; i < lengthOfString; i++) {
- generatedString[i] = 'a';
- }
- return generatedString;
-}
-
-void test_HttpEmptyBufferReturnsOnNullInput(void) {
- HttpResponse_t *testResponse = NULL;
- HTTPCleanResponseBuffer(testResponse);
- TEST_ABORT();
-}
-
-void test_HTTPConnectionFailedThrowsException(void) {
- espStatus.ChipStatus = ESP_CHIP_NOT_OK;
- espStatus.WIFIStatus = NOT_CONNECTED;
-
- CEXCEPTION_T e;
- Try {
- HTTPGet(NULL, NULL);
- TEST_FAIL_MESSAGE("Should have thrown HTTP_CONNECTION_FAILED!");
- }
- Catch(e) {
- TEST_ASSERT_EQUAL(HTTP_CONNECTION_FAILED, e);
- }
-}
-
-void test_HTTPURLtoLongThrowsException(void) {
- espStatus.ChipStatus = ESP_CHIP_OK;
- espStatus.WIFIStatus = CONNECTED;
- char *url = generateString(257);
-
- CEXCEPTION_T e;
- Try {
- HTTPGet(url, NULL);
- TEST_FAIL_MESSAGE("Should have thrown HTTP_CONNECTION_FAILED!");
- }
- Catch(e) {
- TEST_ASSERT_EQUAL(HTTP_URL_TO_LONG, e);
- }
-}
-void test_HTTPwrongCommand(void) {
- espStatus.ChipStatus = ESP_CHIP_OK;
- espStatus.WIFIStatus = CONNECTED;
- HttpResponse_t *ptr;
- HttpResponse_t **data = &ptr;
- char *url = generateString(256);
-
- CEXCEPTION_T e;
- Try {
- HTTPGet(url, data);
- TEST_FAIL_MESSAGE("Should have thrown HTTP_CONNECTION_FAILED!");
- }
- Catch(e) {
- TEST_ASSERT_EQUAL(HTTP_WRONG_RESPONSE, e);
- }
-}
-
-int main(void) {
- UNITY_BEGIN();
-
- RUN_TEST(test_HttpEmptyBufferReturnsOnNullInput);
- RUN_TEST(test_HTTPConnectionFailedThrowsException);
- RUN_TEST(test_HTTPURLtoLongThrowsException);
- RUN_TEST(test_HTTPwrongCommand);
-
- return UNITY_END();
-}
diff --git a/test/unit/UnittestNetwork.c b/test/unit/UnittestNetwork.c
deleted file mode 100644
index e2bbe6d7..00000000
--- a/test/unit/UnittestNetwork.c
+++ /dev/null
@@ -1,89 +0,0 @@
-#include "Esp.h"
-#include "EspUnitTest.h"
-#include "Network.h"
-
-#include "unity.h"
-
-networkCredentials_t credentials = {.ssid = "SSID", .password = "password"};
-
-void setUp(void) {
- espStatus.ChipStatus = ESP_CHIP_OK;
- espStatus.WIFIStatus = NOT_CONNECTED;
- espStatus.MQTTStatus = NOT_CONNECTED;
-
- ESPDUMMY_RETURN_CODE = ESP_NO_ERROR;
-}
-
-void tearDown(void) {}
-
-/* region Test Functions */
-
-void testConnectToNetworkSuccessful(void) {
- TEST_ASSERT_EQUAL(NOT_CONNECTED, espStatus.WIFIStatus);
- networkErrorCode_t networkErrorCode = networkConnectToNetwork();
- TEST_ASSERT_EQUAL(NETWORK_NO_ERROR, networkErrorCode);
- TEST_ASSERT_EQUAL(CONNECTED, espStatus.WIFIStatus);
-}
-void testConnectToNetworkAlreadyConnected(void) {
- espStatus.WIFIStatus = CONNECTED;
- TEST_ASSERT_EQUAL(CONNECTED, espStatus.WIFIStatus);
- networkErrorCode_t networkErrorCode = networkConnectToNetwork();
- TEST_ASSERT_EQUAL(NETWORK_WIFI_ALREADY_CONNECTED, networkErrorCode);
- TEST_ASSERT_EQUAL(CONNECTED, espStatus.WIFIStatus);
-}
-void testConnectToNetworkEspChipFailed(void) {
- espStatus.ChipStatus = ESP_CHIP_NOT_OK;
- TEST_ASSERT_EQUAL(NOT_CONNECTED, espStatus.WIFIStatus);
- TEST_ASSERT_EQUAL(ESP_CHIP_NOT_OK, espStatus.ChipStatus);
- networkErrorCode_t networkErrorCode = networkConnectToNetwork();
- TEST_ASSERT_EQUAL(NETWORK_ESP_CHIP_FAILED, networkErrorCode);
- TEST_ASSERT_EQUAL(NOT_CONNECTED, espStatus.WIFIStatus);
-}
-void testConnectToNetworkSendFailed(void) {
- ESPDUMMY_RETURN_CODE = ESP_WRONG_ANSWER_RECEIVED;
- TEST_ASSERT_EQUAL(NOT_CONNECTED, espStatus.WIFIStatus);
- networkErrorCode_t networkErrorCode = networkConnectToNetwork();
- TEST_ASSERT_EQUAL(NETWORK_ESTABLISH_CONNECTION_FAILED, networkErrorCode);
- TEST_ASSERT_EQUAL(NOT_CONNECTED, espStatus.WIFIStatus);
-}
-
-void testDisconnectFromNetwork(void) {
- espStatus.WIFIStatus = CONNECTED;
- espStatus.MQTTStatus = CONNECTED;
- TEST_ASSERT_EQUAL(CONNECTED, espStatus.WIFIStatus);
- TEST_ASSERT_EQUAL(CONNECTED, espStatus.MQTTStatus);
- networkDisconnectFromNetwork();
- TEST_ASSERT_EQUAL(ESP_CHIP_OK, espStatus.ChipStatus);
- TEST_ASSERT_EQUAL(NOT_CONNECTED, espStatus.WIFIStatus);
- TEST_ASSERT_EQUAL(NOT_CONNECTED, espStatus.MQTTStatus);
-}
-void testDisconnectFromNetworkTwice(void) {
- espStatus.WIFIStatus = CONNECTED;
- espStatus.MQTTStatus = CONNECTED;
- TEST_ASSERT_EQUAL(CONNECTED, espStatus.WIFIStatus);
- TEST_ASSERT_EQUAL(CONNECTED, espStatus.MQTTStatus);
- networkDisconnectFromNetwork();
- TEST_ASSERT_EQUAL(ESP_CHIP_OK, espStatus.ChipStatus);
- TEST_ASSERT_EQUAL(NOT_CONNECTED, espStatus.WIFIStatus);
- TEST_ASSERT_EQUAL(NOT_CONNECTED, espStatus.MQTTStatus);
- networkDisconnectFromNetwork();
- TEST_ASSERT_EQUAL(ESP_CHIP_OK, espStatus.ChipStatus);
- TEST_ASSERT_EQUAL(NOT_CONNECTED, espStatus.WIFIStatus);
- TEST_ASSERT_EQUAL(NOT_CONNECTED, espStatus.MQTTStatus);
-}
-
-/* endregion */
-
-int main(void) {
- UNITY_BEGIN();
-
- RUN_TEST(testConnectToNetworkSuccessful);
- RUN_TEST(testConnectToNetworkAlreadyConnected);
- RUN_TEST(testConnectToNetworkEspChipFailed);
- RUN_TEST(testConnectToNetworkSendFailed);
-
- RUN_TEST(testDisconnectFromNetwork);
- RUN_TEST(testDisconnectFromNetworkTwice);
-
- return UNITY_END();
-}