From 8adfcb9a3d27cf5fef9595d158e4e22700ce8a01 Mon Sep 17 00:00:00 2001 From: Laila van Reenen Date: Thu, 9 Jan 2025 19:16:11 +0000 Subject: [PATCH] Initial commit --- .gitignore | 3 +++ .gitmodules | 3 +++ CMakeLists.txt | 20 ++++++++++++++++++++ init.sh | 16 ++++++++++++++++ src/main.c | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 100644 init.sh create mode 100644 src/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5a8d6a8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ + +/build + diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..1891415 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libs/pico-sdk"] + path = libs/pico-sdk + url = https://github.com/raspberrypi/pico-sdk.git diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..39b3bbe --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.13) + +# initialize the SDK based on PICO_SDK_PATH +# note: this must happen before project() +include(libs/pico-sdk/pico_sdk_init.cmake) + +project(my_project) + +# initialize the Raspberry Pi Pico SDK +pico_sdk_init() + +add_executable(my_project + src/main.c +) + +# Add pico_stdlib library which aggregates commonly used features +target_link_libraries(my_project pico_stdlib) + +# create map/bin/hex/uf2 file in addition to ELF. +pico_add_extra_outputs(my_project) diff --git a/init.sh b/init.sh new file mode 100644 index 0000000..48e553c --- /dev/null +++ b/init.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +modules=$(git config -f .gitmodules --list | grep -E '^submodule\.') + +for moduleUrl in $(echo "$modules" | grep '\.url=') +do + moduleName=$(echo "$moduleUrl" | sed -e 's/^submodule\.\(.*\).url=\(.*\)$/\1/') + moduleUrl=$(echo "$moduleUrl" | sed -e 's/^submodule\.\(.*\).url=\(.*\)$/\2/') + modulePath=$(echo "$modules" | grep ".*$moduleName\.path=" | sed -e 's/^.*path=\(.*\)$/\1/') + + echo "$moduleUrl -> $modulePath" + git submodule add "$moduleUrl" "$modulePath" +done + +git submodule init +git submodule update diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..411626b --- /dev/null +++ b/src/main.c @@ -0,0 +1,36 @@ +#include +#include "pico/stdlib.h" + +// pin rgb led on Seeed XIAO RP2040 +#define PIN_RGB_R 17 +#define PIN_RGB_G 16 +#define PIN_RGB_B 25 + +int main() { + setup_default_uart(); + printf("Hello, world!\n"); + + gpio_init(PIN_RGB_R); + gpio_set_dir(PIN_RGB_R, GPIO_OUT); + gpio_init(PIN_RGB_G); + gpio_set_dir(PIN_RGB_G, GPIO_OUT); + gpio_init(PIN_RGB_B); + gpio_set_dir(PIN_RGB_B, GPIO_OUT); + while (true) + { + gpio_put(PIN_RGB_G, 1); + sleep_ms(250); + gpio_put(PIN_RGB_R, 0); + sleep_ms(250); + gpio_put(PIN_RGB_B, 1); + sleep_ms(250); + gpio_put(PIN_RGB_G, 0); + sleep_ms(250); + gpio_put(PIN_RGB_R, 1); + sleep_ms(250); + gpio_put(PIN_RGB_B, 0); + sleep_ms(250); + } + return 0; +} +