generated from LailaTheElf/rp2040_c
Initial commit
This commit is contained in:
commit
8adfcb9a3d
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
/build
|
||||||
|
|
||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "libs/pico-sdk"]
|
||||||
|
path = libs/pico-sdk
|
||||||
|
url = https://github.com/raspberrypi/pico-sdk.git
|
||||||
20
CMakeLists.txt
Normal file
20
CMakeLists.txt
Normal file
@ -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)
|
||||||
16
init.sh
Normal file
16
init.sh
Normal file
@ -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
|
||||||
36
src/main.c
Normal file
36
src/main.c
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user