Create a blinky LED with RaspberryPI Pico board with RP2040
microcontroller using the native C/C++ SDK.
Refer Getting started with Raspberry Pi Pico PDF document for Linux or Windows.
cd CHOOSE_YOUR_PICO_SDK_PATH
git clone [email protected]:raspberrypi/pico-sdk.git
brew install cmake
brew tap ArmMbed/homebrew-formulae
brew install arm-none-eabi-gcc
# vs code extensions
code --install-extension marus25.cortex-debug
code --install-extension ms-vscode.cmake-tools
code --install-extension ms-vscode.cpptools
# environment variable for the pico-sdk installation apth
export PICO_SDK_PATH=~/PATH/TO/pico-sdk
#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/gpio.h"
#include "pico/binary_info.h"
const uint LED_PIN = 25;
int main() {
stdio_init_all();
gpio_init(LED_PIN);
gpio_set_dir(LED_PIN, GPIO_OUT);
while (true) {
gpio_put(LED_PIN, 0);
sleep_ms(250);
gpio_put(LED_PIN, 1);
puts("Hello World blinky!");
sleep_ms(1000);
}
}
.PHONY: default lint all flash clean
default: lint all flash clean
lint:
cpplint --extensions=c --filter=-legal/copyright,-build/include_subdir,-runtime/threadsafe_fn *.c
build:
mkdir build
cd build; cmake ..
cd build; make -j4
all: clean build
flash:
cp build/*.uf2 /Volumes/RPI-RP2
sleep 2
ls -al /dev/cu.usb*
clean:
rm -rf build