Move the sdk project to a subdir.

Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
Mariano Uvalle 2025-05-18 23:11:20 -07:00
parent 5611462c08
commit b5796f0d6e
3 changed files with 1 additions and 1 deletions

View file

@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.13...3.27)
# initialize pico-sdk from submodule
# note: this must happen before project()
include(../../../pico-sdk/pico_sdk_init.cmake)
project(my_project)
# initialize the Raspberry Pi Pico SDK
set(PICO_BOARD, "pico")
pico_sdk_init()
# rest of your project
add_executable(hello_world
hello_world.c
led.s
)
# Add pico_stdlib library which aggregates commonly used features
target_link_libraries(hello_world pico_stdlib)
# create map/bin/hex/uf2 file in addition to ELF.
pico_add_extra_outputs(hello_world)

View file

@ -0,0 +1,56 @@
/**
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "pico/stdlib.h"
// Pico W devices use a GPIO on the WIFI chip for the LED,
// so when building for Pico W, CYW43_WL_GPIO_LED_PIN will be defined
#ifdef CYW43_WL_GPIO_LED_PIN
#include "pico/cyw43_arch.h"
#endif
#ifndef LED_DELAY_MS
#define LED_DELAY_MS 250
#endif
// Perform initialisation
int pico_led_init(void) {
#if defined(PICO_DEFAULT_LED_PIN)
// A device like Pico that uses a GPIO for the LED will define PICO_DEFAULT_LED_PIN
// so we can use normal GPIO functionality to turn the led on and off
gpio_init(PICO_DEFAULT_LED_PIN);
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
return PICO_OK;
#elif defined(CYW43_WL_GPIO_LED_PIN)
// For Pico W devices we need to initialise the driver etc
return cyw43_arch_init();
#endif
}
// Turn the led on or off
void pico_set_led(bool led_on) {
#if defined(PICO_DEFAULT_LED_PIN)
// Just set the GPIO on or off
gpio_put(PICO_DEFAULT_LED_PIN, led_on);
#elif defined(CYW43_WL_GPIO_LED_PIN)
// Ask the wifi "driver" to set the GPIO on or off
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, led_on);
#endif
}
void blink();
int main() {
int rc = pico_led_init();
hard_assert(rc == PICO_OK);
blink();
/* while (true) { */
/* pico_set_led(true); */
/* sleep_ms(LED_DELAY_MS); */
/* pico_set_led(false); */
/* sleep_ms(LED_DELAY_MS); */
/* } */
}

View file

@ -0,0 +1,25 @@
.section .text
.equ sio_base, 0xd0000000
.equ big_num, 0x00f00000 // For the delay.
.thumb_func
.global blink
blink:
ldr r0, =sio_base
mov r1, #1
lsl r1, r1, #25
led_loop:
str r1, [r0, #0x18] // GPIO_OUT_SET
ldr r3, =big_num
bl delay
str r1, [r0, #0x20] // GPIO_OUT_CLR
ldr r3, =big_num
bl delay
b led_loop
delay:
sub r3, #1
bne delay
bx lr