From 573643a1d3220830de47c810cb1a6be629ce7abd Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 10 May 2024 14:49:36 +0200 Subject: WIP protobuf hello world --- lib/FreeRTOS-Kernel | 1 + lib/googletest | 1 + lib/pico-sdk | 1 + 3 files changed, 3 insertions(+) create mode 160000 lib/FreeRTOS-Kernel create mode 160000 lib/googletest create mode 160000 lib/pico-sdk (limited to 'lib') diff --git a/lib/FreeRTOS-Kernel b/lib/FreeRTOS-Kernel new file mode 160000 index 0000000..dbf7055 --- /dev/null +++ b/lib/FreeRTOS-Kernel @@ -0,0 +1 @@ +Subproject commit dbf70559b27d39c1fdb68dfb9a32140b6a6777a0 diff --git a/lib/googletest b/lib/googletest new file mode 160000 index 0000000..5197b1a --- /dev/null +++ b/lib/googletest @@ -0,0 +1 @@ +Subproject commit 5197b1a8e6a1ef9f214f4aa537b0be17cbf91946 diff --git a/lib/pico-sdk b/lib/pico-sdk new file mode 160000 index 0000000..6a7db34 --- /dev/null +++ b/lib/pico-sdk @@ -0,0 +1 @@ +Subproject commit 6a7db34ff63345a7badec79ebea3aaef1712f374 -- cgit v1.2.3 From cddfbb715d6f4f9d022d383ab8737b6af57a1d6f Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sat, 18 May 2024 15:08:20 +0200 Subject: cmake build config for mpack --- .gitmodules | 5 +++++ lib/mpack | 1 + main/CMakeLists.txt | 2 ++ proto/.gitignore | 1 - proto/include.cmake | 12 ++++++++++++ proto/lib | 1 + proto/makefile | 7 ------- proto/puzbusv1.c | 13 +++++++++++++ proto/puzbusv1.h | 22 ++++++++++++++++++++++ proto/puzbusv1.proto | 12 ------------ 10 files changed, 56 insertions(+), 20 deletions(-) create mode 160000 lib/mpack delete mode 100644 proto/.gitignore create mode 120000 proto/lib delete mode 100644 proto/makefile create mode 100644 proto/puzbusv1.c create mode 100644 proto/puzbusv1.h delete mode 100644 proto/puzbusv1.proto (limited to 'lib') diff --git a/.gitmodules b/.gitmodules index fc98963..1a813e0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,8 @@ url = https://github.com/FreeRTOS/FreeRTOS-Kernel branch = V11.1.0 shallow = true +[submodule "lib/mpack"] + path = lib/mpack + url = https://github.com/ludocode/mpack + branch = v1.1.1 + shallow = true diff --git a/lib/mpack b/lib/mpack new file mode 160000 index 0000000..79d3fcd --- /dev/null +++ b/lib/mpack @@ -0,0 +1 @@ +Subproject commit 79d3fcd3e04338b06e82d01a62f4aa98c7bad5f7 diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 7b8d567..cd90499 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -7,6 +7,7 @@ set(PICO_BOARD pico_w) include(lib/pico-sdk/pico_sdk_init.cmake) include(lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake) +include(../proto/include.cmake) project(puzzlebox_main C CXX ASM) @@ -30,5 +31,6 @@ target_link_libraries(main pico_stdlib FreeRTOS-Kernel FreeRTOS-Kernel-Heap4 + mpack ) diff --git a/proto/.gitignore b/proto/.gitignore deleted file mode 100644 index 75feca5..0000000 --- a/proto/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pb.* diff --git a/proto/include.cmake b/proto/include.cmake index d5beaef..c8a90b6 100644 --- a/proto/include.cmake +++ b/proto/include.cmake @@ -1 +1,13 @@ include_directories(${CMAKE_CURRENT_LIST_DIR}) + +# mpack +include_directories(${CMAKE_CURRENT_LIST_DIR}/lib/mpack/src/mpack) +add_library(mpack STATIC + ${CMAKE_CURRENT_LIST_DIR}/lib/mpack/src/mpack/mpack-common.c + ${CMAKE_CURRENT_LIST_DIR}/lib/mpack/src/mpack/mpack-expect.c + ${CMAKE_CURRENT_LIST_DIR}/lib/mpack/src/mpack/mpack-node.c + ${CMAKE_CURRENT_LIST_DIR}/lib/mpack/src/mpack/mpack-platform.c + ${CMAKE_CURRENT_LIST_DIR}/lib/mpack/src/mpack/mpack-reader.c + ${CMAKE_CURRENT_LIST_DIR}/lib/mpack/src/mpack/mpack-writer.c + ) + diff --git a/proto/lib b/proto/lib new file mode 120000 index 0000000..dc598c5 --- /dev/null +++ b/proto/lib @@ -0,0 +1 @@ +../lib \ No newline at end of file diff --git a/proto/makefile b/proto/makefile deleted file mode 100644 index 3bc4ca4..0000000 --- a/proto/makefile +++ /dev/null @@ -1,7 +0,0 @@ -PROTOCARGS += --cpp_out . - -all: puzbusv1.pb.cc puzbusv1.pb.h - -%.pb.cc %.pb.h &: %.proto - protoc $(PROTOCARGS) $< - diff --git a/proto/puzbusv1.c b/proto/puzbusv1.c new file mode 100644 index 0000000..9d1335e --- /dev/null +++ b/proto/puzbusv1.c @@ -0,0 +1,13 @@ +#include + +#include "puzbusv1.h" + +int pb_read(struct pb_msg* target, char* buf, size_t buf_sz) { + mpack_reader_t reader; + + return 0; +} + +void pb_free(struct pb_msg* msg); + + diff --git a/proto/puzbusv1.h b/proto/puzbusv1.h new file mode 100644 index 0000000..071c887 --- /dev/null +++ b/proto/puzbusv1.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct pb_msg { + uint16_t addr; + char* data; + size_t length; +}; + +int pb_read(struct pb_msg* target, char* buf, size_t buf_sz); +void pb_free(struct pb_msg* msg); + +#ifdef __cplusplus +} +#endif + diff --git a/proto/puzbusv1.proto b/proto/puzbusv1.proto deleted file mode 100644 index 6b4fa52..0000000 --- a/proto/puzbusv1.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto2"; - -package puzbus; - -message I2CMsg { - // 32-bit is the smallest integer format supported by protobuf, even though - // we only need 7-10 bits for the I2C address. - required uint32 address = 1; - - optional bytes data = 2; -} - -- cgit v1.2.3