aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-06-18 18:34:08 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-06-18 18:34:08 +0200
commit752dca0a41581282498ccb0d3e2aedb15181e4a8 (patch)
tree8dd27b7e6cff31b05fbc4c8ea0a9d5cec15f2b87 /lib
parent35129b2ba8e416f99f4095d93ae748762b0e36fb (diff)
WIP main controller puzzle bus behavior + fix build system / client
Diffstat (limited to 'lib')
-rw-r--r--lib/pbdrv/CMakeLists.txt11
-rw-r--r--lib/pbdrv/drv/arduino/cfg.cmake10
-rw-r--r--lib/pbdrv/drv/arduino/include.cmake1
-rw-r--r--lib/pbdrv/ext/freertos/include.cmake9
-rw-r--r--lib/pbdrv/ext/freertos/pb-mem.c6
-rw-r--r--lib/pbdrv/ext/stdlib/include.cmake4
-rw-r--r--lib/pbdrv/ext/stdlib/pb-mem.c9
-rw-r--r--lib/pbdrv/pb.h17
8 files changed, 23 insertions, 44 deletions
diff --git a/lib/pbdrv/CMakeLists.txt b/lib/pbdrv/CMakeLists.txt
index 91932b8..998ed4d 100644
--- a/lib/pbdrv/CMakeLists.txt
+++ b/lib/pbdrv/CMakeLists.txt
@@ -17,7 +17,7 @@ target_compile_definitions(mpack PRIVATE MPACK_HAS_CONFIG=1)
target_include_directories(mpack PRIVATE .)
# generic puzzle bus message handling library functions
-add_library(pbdrv OBJECT
+add_library(pbdrv STATIC
pb-msg.c
pb-serial.c
pb-buf.c
@@ -25,21 +25,14 @@ add_library(pbdrv OBJECT
target_include_directories(pbdrv SYSTEM INTERFACE .)
target_link_libraries(pbdrv mpack)
-# TODO: pbdrv-mod should ideally only include sources specific to it, and link
-# 'plain' pbdrv to provide the other functions. this seems to cause linker
-# errors and I don't know why
-
# puzzle bus *module* specific code
add_library(pbdrv-mod OBJECT
- pb-msg.c
- pb-serial.c
- pb-buf.c
pb-mod.c
pb-send.c
pb-route.c
)
target_include_directories(pbdrv-mod SYSTEM INTERFACE .)
-target_link_libraries(pbdrv-mod mpack)
+target_link_libraries(pbdrv-mod pbdrv)
# puzzle bus drivers
include(drv/arduino/include.cmake)
diff --git a/lib/pbdrv/drv/arduino/cfg.cmake b/lib/pbdrv/drv/arduino/cfg.cmake
deleted file mode 100644
index 47f54a4..0000000
--- a/lib/pbdrv/drv/arduino/cfg.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
-if(NOT DEFINED ARDUINO)
- return()
-endif()
-
-target_sources(pbdrv-mod PRIVATE "${CMAKE_CURRENT_LIST_DIR}/mod.cpp")
-target_link_arduino_libraries(pbdrv-mod core Wire)
-
-# arduino must use freertos
-include("${CMAKE_CURRENT_LIST_DIR}/../../ext/freertos/include.cmake")
-
diff --git a/lib/pbdrv/drv/arduino/include.cmake b/lib/pbdrv/drv/arduino/include.cmake
index 50f56d6..1e2ff08 100644
--- a/lib/pbdrv/drv/arduino/include.cmake
+++ b/lib/pbdrv/drv/arduino/include.cmake
@@ -2,7 +2,6 @@ if(NOT DEFINED ARDUINO)
return()
endif()
-target_compile_definitions(pbdrv-mod PRIVATE PB_TARGET_FREERTOS)
target_sources(pbdrv-mod PRIVATE "${CMAKE_CURRENT_LIST_DIR}/mod.cpp")
target_link_arduino_libraries(pbdrv-mod core Wire)
diff --git a/lib/pbdrv/ext/freertos/include.cmake b/lib/pbdrv/ext/freertos/include.cmake
index d01afe7..e7ab7fd 100644
--- a/lib/pbdrv/ext/freertos/include.cmake
+++ b/lib/pbdrv/ext/freertos/include.cmake
@@ -1,10 +1,9 @@
-target_sources(pbdrv-mod PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}/pb-mem.c"
- "${CMAKE_CURRENT_LIST_DIR}/pb-mod.c"
- )
-target_link_libraries(pbdrv-mod
+target_sources(pbdrv PRIVATE "${CMAKE_CURRENT_LIST_DIR}/pb-mem.c")
+target_link_libraries(pbdrv
freertos_kernel
freertos_kernel_include
freertos_config
)
+target_sources(pbdrv-mod PRIVATE "${CMAKE_CURRENT_LIST_DIR}/pb-mod.c")
+
diff --git a/lib/pbdrv/ext/freertos/pb-mem.c b/lib/pbdrv/ext/freertos/pb-mem.c
index 96c48d1..b18d79f 100644
--- a/lib/pbdrv/ext/freertos/pb-mem.c
+++ b/lib/pbdrv/ext/freertos/pb-mem.c
@@ -3,11 +3,11 @@
#include "../../pb-mem.h"
#include "../../pb-types.h"
-__weak inline void * pb_malloc(size_t sz) {
+inline void * pb_malloc(size_t sz) {
return pvPortMalloc(sz);
}
-__weak inline void pb_free(void * ptr) {
+inline void pb_free(void * ptr) {
vPortFree(ptr);
}
@@ -21,7 +21,7 @@ __weak void * pb_memcpy(void * dest, const void * src, size_t sz) {
return dest;
}
-int pb_memcmp(const void * a, const void * b, size_t sz) {
+__weak int pb_memcmp(const void * a, const void * b, size_t sz) {
for (size_t offset = 0; offset < sz; offset++) {
int diff = *((char*) a + offset) - *((char*) b + offset);
if (diff != 0) return diff;
diff --git a/lib/pbdrv/ext/stdlib/include.cmake b/lib/pbdrv/ext/stdlib/include.cmake
index fce788d..67fe80e 100644
--- a/lib/pbdrv/ext/stdlib/include.cmake
+++ b/lib/pbdrv/ext/stdlib/include.cmake
@@ -1,4 +1,2 @@
-target_sources(pbdrv-mod PRIVATE
- "${CMAKE_CURRENT_LIST_DIR}/pb-mem.c"
- )
+target_sources(pbdrv PRIVATE "${CMAKE_CURRENT_LIST_DIR}/pb-mem.c")
diff --git a/lib/pbdrv/ext/stdlib/pb-mem.c b/lib/pbdrv/ext/stdlib/pb-mem.c
index 1f59a84..b260c2c 100644
--- a/lib/pbdrv/ext/stdlib/pb-mem.c
+++ b/lib/pbdrv/ext/stdlib/pb-mem.c
@@ -2,21 +2,20 @@
#include <string.h>
#include "../../pb-mem.h"
-#include "../../pb-types.h"
-__weak inline void * pb_malloc(size_t sz) {
+inline void * pb_malloc(size_t sz) {
return malloc(sz);
}
-__weak inline void pb_free(void * ptr) {
+inline void pb_free(void * ptr) {
free(ptr);
}
-__weak inline void * pb_realloc(void * ptr, size_t sz) {
+inline void * pb_realloc(void * ptr, size_t sz) {
return realloc(ptr, sz);
}
-__weak void * pb_memcpy(void * dest, const void * src, size_t sz) {
+void * pb_memcpy(void * dest, const void * src, size_t sz) {
return memcpy(dest, src, sz);
}
diff --git a/lib/pbdrv/pb.h b/lib/pbdrv/pb.h
index b6efed0..0f2e9d1 100644
--- a/lib/pbdrv/pb.h
+++ b/lib/pbdrv/pb.h
@@ -10,13 +10,14 @@
#define PB_ADDR_ADA_NEO_3 0x30
#define PB_ADDR_ADA_NEO_4 0x32
-// TODO: ???
-#define PB_ADDR_MOD_NEOTRELLIS 0
-#define PB_ADDR_MOD_SOFTWARE 0
-#define PB_ADDR_MOD_HARDWARE 0
-#define PB_ADDR_MOD_VAULT 0
-// #define BUSADDR_MOD_AUTOMATION 0
+// Main controller
+#define PB_ADDR_MOD_MAIN 0x08
-// main controller
-#define PB_ADDR_MOD_MAIN 0x00
+// Puzzle modules
+#define PB_ADDR_MOD_NEOTRELLIS 0x21
+#define PB_ADDR_MOD_SOFTWARE 0x22
+#define PB_ADDR_MOD_HARDWARE 0x23
+#define PB_ADDR_MOD_VAULT 0x24
+// #define BUSADDR_MOD_AUTOMATION 0x25
+#define PB_ADDR_MOD_DUMMY 0x69