From ca79a9201e87693fae2c0133cf686e2cfa2145d3 Mon Sep 17 00:00:00 2001 From: Ulysse Cura Date: Thu, 1 Oct 2026 23:21:26 +0200 Subject: [PATCH] Initial commit. --- .gitignore | 1 + .gitmodules | 6 ++++ .vscode/c_cpp_properties.json | 26 ++++++++++++++++ .vscode/tasks.json | 57 +++++++++++++++++++++++++++++++++++ CMakeLists.txt | 40 ++++++++++++++++++++++++ lib/PicoW_UDP | 1 + lib/PicoW_WiFi_Operator | 1 + src/main.c | 46 ++++++++++++++++++++++++++++ 8 files changed, 178 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/tasks.json create mode 100644 CMakeLists.txt create mode 160000 lib/PicoW_UDP create mode 160000 lib/PicoW_WiFi_Operator create mode 100644 src/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c795b05 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..9bea999 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "lib/PicoW_UDP"] + path = lib/PicoW_UDP + url = https://gitea.skadubpc.net/ulysse/PicoW_UDP_Lib.git +[submodule "lib/PicoW_WiFi_Operator"] + path = lib/PicoW_WiFi_Operator + url = https://gitea.skadubpc.net/ulysse/PicoW_WiFi_Operator_Lib.git diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..5d9ccf7 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,26 @@ +{ + "configurations": [ + { + "name": "Linux", + "intelliSenseMode": "linux-gcc-arm", + "includePath": [ + "${env:PICO_SDK_PATH}/src/**/include/", + "${env:PICO_SDK_PATH}/lib/**/include/", + "${env:PICO_SDK_PATH}/lib/**/src/", + "${workspaceFolder}/build/generated/pico_base/", + "${workspaceFolder}/src/", + "${workspaceFolder}/lib/**/" + ], + "compilerPath": "/usr/bin/arm-none-eabi-gcc", + "cStandard": "c17", + "browse": { + "path": [ + "${workspaceFolder}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..e0f10a9 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,57 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build", + "detail": "Build project", + "type": "shell", + "command": "cmake -H. -Bbuild && make -j$(nproc) -C build", + "args": [ + ], + "group": "build", + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "showReuseMessage": true, + "clear": true + } + }, + { + "label": "Clean", + "detail": "Clean build directory and executable", + "type": "shell", + "command": "rm -rf build", + "args": [ + ], + "group": "build", + "presentation": { + "echo": false, + "reveal": "never", + "focus": false, + "panel": "shared", + "showReuseMessage": false, + "clear": true + } + }, + { + "label": "Flash", + "detail": "Flash executable", + "type": "shell", + "dependsOn": "Build", + "command": "make Flash -C build", + "args": [ + ], + "group": "build", + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "showReuseMessage": true, + "clear": true + } + } + ] +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..2bfe178 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.13) + +# Explicitely define board. +set(PICO_BOARD pico_w) +if(NOT DEFINED PICO_BOARD) + add_definitions(-DPICO_BOARD=${PICO_BOARD}) +endif() + +# Need to include pico-sdk cmake support. Must happen before project. +include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake) + +project(Controller C CXX ASM) +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) + +pico_sdk_init() + +add_executable(Controller + src/main.c +) + +add_subdirectory(lib/PicoW_WiFi_Operator) +add_subdirectory(lib/PicoW_UDP) + +target_link_libraries(Controller + pico_stdlib + PicoW_WiFi_Operator + PicoW_UDP +) + +# Stdio configuration +pico_enable_stdio_usb(Controller 1) +pico_enable_stdio_uart(Controller 1) + +pico_add_extra_outputs(Controller) + +add_custom_target(Flash + DEPENDS Controller + COMMAND picotool load -f ${PROJECT_BINARY_DIR}/Controller.uf2 +) diff --git a/lib/PicoW_UDP b/lib/PicoW_UDP new file mode 160000 index 0000000..66f06c7 --- /dev/null +++ b/lib/PicoW_UDP @@ -0,0 +1 @@ +Subproject commit 66f06c7ef5301235230d57fe066ddfb1d0fdc692 diff --git a/lib/PicoW_WiFi_Operator b/lib/PicoW_WiFi_Operator new file mode 160000 index 0000000..9dc7a91 --- /dev/null +++ b/lib/PicoW_WiFi_Operator @@ -0,0 +1 @@ +Subproject commit 9dc7a912ec94f2bcf2819adf4306c1c34151204c diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..e85fb91 --- /dev/null +++ b/src/main.c @@ -0,0 +1,46 @@ +#include +#include +#include "PicoW_WiFi_Operator.h" +#include "PicoW_UDP.h" + +int main(void) +{ + // Initialisation + stdio_init_all(); + + if(cyw43_arch_init_with_country(CYW43_COUNTRY_FRANCE)) + { + printf("Failed initialising cyw43 arch."); + return PICO_ERROR_GENERIC; + } + + cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, true); + + if(wifi_operator_init(WIFI_OPERATOR_MODE_ACCESS_POINT)) return PICO_ERROR_GENERIC; + + struct udp_server_t udp_server; + + if(udp_server_init(&udp_server)) return PICO_ERROR_GENERIC; + + // Initialisation done + for(int i = 0; i < 3; i++) + { + cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, false); + sleep_ms(100); + cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, true); + sleep_ms(100); + } + + while(true) + { + cyw43_arch_poll(); + + tight_loop_contents(); + } + + if(wifi_operator_exit()) return PICO_ERROR_GENERIC; + + cyw43_arch_deinit(); + + return PICO_OK; +} \ No newline at end of file