Reputation: 1
I have written a code for Pico Pi, and basically the program is about one LED and two buttons where one button turns on the LED and one turns it off. I am pretty new to raspberry and so I don't know much, I am using a virtual machine for cmake and make, but unfortunately, I can't turn my code into uf2, because I have not defined my link_gpio_get function in the sdlink.c file, which I don't know how to do so cmake is failing due to an undefined reference...
.EQU LED_PIN1, 0
.EQU BUT_PIN1, 1
.EQU BUT_PIN2, 2
.EQU GPIO_IN, 0
.EQU GPIO_OUT, 1
.thumb_func
.global main
main:
MOV R0, #LED_PIN1
BL gpio_init
MOV R0, #LED_PIN1
MOV R1, #GPIO_OUT
BL link_gpio_set_dir @ Initialize PIN1
MOV R0, #BUT_PIN1
BL gpio_init
MOV R0, #BUT_PIN1
MOV R1, #GPIO_IN
BL link_gpio_set_dir
MOV R0, #BUT_PIN2
BL gpio_init
MOV R0, #BUT_PIN2
MOV R1, #GPIO_IN
BL link_gpio_set_dir
wait_on:
MOV R0, #BUT_PIN1 @ Wait for turn on button
BL link_gpio_get
CMP R0, #1
BEQ turn_on
B wait_on
turn_on:
MOV R0, #LED_PIN1
MOV R1, #1
BL link_gpio_put @ Turn on led
B wait_off
turn_off:
MOV R0, #LED_PIN1
MOV R1, #0
BL link_gpio_put @ Turn off led
B wait_on
wait_off:
MOV R0, #BUT_PIN2 @ Wait for off
BL link_gpio_get
CMP R0, #1
BEQ turn_off
B wait_off
Here is my sdlink.c file
/* C wrapper functions for the RP2040 SDK
* Incline functions gpio_set_dir and gpio_put.
*/
#include "hardware/gpio.h"
void link_gpio_set_dir(int pin, int dir)
{
gpio_set_dir(pin, dir);
}
void link_gpio_put(int pin, int value)
{
gpio_put(pin, value);
}
Upvotes: 0
Views: 300
Reputation: 361
I've been working to output uf2, using cmake on Windows 10 and I after watching a Youtube video, reviewing hackster and making my own edits I was able to get it working.
I'm not sure what OS you are using but hopefully these links and my edit can help guide you to identify the issue with your project.
https://www.youtube.com/watch?v=mUF9xjDtFfY
https://www.hackster.io/lawrence-wiznet-io/how-to-setup-raspberry-pi-pico-c-c-sdk-in-window10-f2b816
The following is my edit that allowed me to build and output I hope it helps! After you've cloned the pico-examples project, navigate to the pico-examples directory. I opened pico_sdk_import.cmake in a text editor and I changed line 6 from if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH)) to if (DEFINED ENV{PICO_SDK_PATH})
If you can provide a link to where you obtained the code you posted, maybe I can help further figure our what sdlink.c should contain.
Upvotes: 0