Initial Commit.

This commit is contained in:
Ulysse Cura 2026-09-27 13:02:22 +02:00
commit e0e624f659
9 changed files with 271 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.vscode/ccls-cache
build

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "lib/Pico_I2C"]
path = lib/Pico_I2C
url = https://gitea.skadubpc.net/ulysse/Pico_I2C_Lib

26
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -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
}

114
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,114 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Configure",
"detail": "configure project",
"type": "shell",
"command": "cmake",
"args": [
"-H.",
"-Bbuild"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": true
}
},
{
"label": "Build",
"detail": "Build project",
"dependsOn": [
"Configure"
],
"type": "shell",
"command": "make",
"args": [
"-C",
"build",
"-j$(nproc)"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": true
}
},
{
"label": "Flash Master",
"detail": "Build and flash master",
"type": "shell",
"dependsOn": [
"Configure"
],
"command": "make",
"args": [
"-C",
"build",
"-j$(nproc)",
"Flash_Master"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": true
}
},
{
"label": "Flash Slave",
"detail": "Build and flash slave",
"type": "shell",
"dependsOn": [
"Configure"
],
"command": "make",
"args": [
"-C",
"build",
"-j$(nproc)",
"Flash_Slave"
],
"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",
"args": [
"-rf",
"build"
],
"group": "build",
"presentation": {
"echo": false,
"reveal": "never",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
}
}
]
}

60
CMakeLists.txt Normal file
View File

@ -0,0 +1,60 @@
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()
# Include pico-sdk cmake support
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)
project(Pico_I2C_Tests C CXX ASM)
set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD 17)
pico_sdk_init()
# Executables and sources
add_executable(Pico_Master
src/main_master.c
)
add_executable(Pico_Slave
src/main_slave.c
)
# Libs
add_subdirectory(lib/Pico_I2C)
target_link_libraries(Pico_Master
pico_stdlib
Pico_I2C
)
target_link_libraries(Pico_Slave
pico_stdlib
Pico_I2C
)
# Stdio configuration
pico_enable_stdio_usb(Pico_Master 1)
pico_enable_stdio_uart(Pico_Master 1)
pico_enable_stdio_usb(Pico_Slave 1)
pico_enable_stdio_uart(Pico_Slave 1)
# Output
pico_add_extra_outputs(Pico_Master)
pico_add_extra_outputs(Pico_Slave)
# Flash target
add_custom_target(Flash_Master
DEPENDS Pico_Master
COMMAND picotool load -f ${PROJECT_BINARY_DIR}/Pico_Master.uf2
)
add_custom_target(Flash_Slave
DEPENDS Pico_Slave
COMMAND picotool load -f ${PROJECT_BINARY_DIR}/Pico_Slave.uf2
)

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# PicoW_UDP_Tests
Test of the library PicoW_UDP_Lib.

1
lib/Pico_I2C Submodule

@ -0,0 +1 @@
Subproject commit 2ec3b6816b2c863b03d3dceb4bb247dd48781ec5

41
src/main_master.c Normal file
View File

@ -0,0 +1,41 @@
#include <pico/stdlib.h>
#include <pico/cyw43_arch.h>
#include "Pico_I2C.h"
int main(void)
{
stdio_init_all();
if(cyw43_arch_init_with_country(CYW43_COUNTRY_FRANCE)) return PICO_ERROR_GENERIC;
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, true);
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)
{
static uint64_t last_time = 0;
uint64_t time = time_us_64();
if(time - last_time > 1000 * 1000)
{
last_time = time;
static bool led_state = true;
led_state = !led_state;
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, led_state);
}
tight_loop_contents();
}
cyw43_arch_deinit();
return PICO_OK;
}

21
src/main_slave.c Normal file
View File

@ -0,0 +1,21 @@
#include <pico/stdlib.h>
#include <pico/cyw43_arch.h>
#include "Pico_I2C.h"
int main(void)
{
stdio_init_all();
if(cyw43_arch_init_with_country(CYW43_COUNTRY_FRANCE)) return PICO_ERROR_GENERIC;
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, true);
while(true)
{
tight_loop_contents();
}
cyw43_arch_deinit();
return PICO_OK;
}