Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

License

NotificationsYou must be signed in to change notification settings

raspberrypi/pico-sdk

Repository files navigation

The Raspberry Pi Pico SDK (henceforth the SDK) provides the headers, libraries and build systemnecessary to write programs for the RP-series microcontroller-based devices such as the Raspberry Pi Pico or Raspberry Pi Pico 2in C, C++ or assembly language.

The SDK is designed to provide an API and programming environment that is familiar both to non-embedded C developers and embedded C developers alike.A single program runs on the device at a time and starts with a conventionalmain() method. Standard C/C++ libraries are supported along withC-level libraries/APIs for accessing all of the RP-series microcontroller's hardware including PIO (Programmable IO).

Additionally, the SDK provides higher level libraries for dealing with timers, synchronization, Wi-Fi and Bluetooth networking, USB and multicore programming. These libraries should be comprehensive enough that your application code rarely, if at all, needs to access hardware registers directly. However, if you do need or prefer to access the raw hardware registers, you will also find complete and fully-commented register definition headers in the SDK. There's no need to look up addresses in the datasheet.

The SDK can be used to build anything from simple applications, fully-fledged runtime environments such as MicroPython, to low level softwaresuch as the RP-series microcontroller's on-chip bootrom itself.

The design goal for entire SDK is to be simple but powerful.

Additional libraries/APIs that are not yet ready for inclusion in the SDK can be found inpico-extras.

Documentation

SeeGetting Started with the Raspberry Pi Pico-Series for information on how to setup yourhardware, IDE/environment and how to build and debug software for the Raspberry Pi Pico and other RP-series microcontroller based devices.

SeeConnecting to the Internet with Raspberry Pi Pico W to learn more about writingapplications for your Raspberry Pi Pico W that connect to the internet.

SeeRaspberry Pi Pico-Series C/C++ SDK to learn more about programming using theSDK, to explore more advanced features, and for complete PDF-based API documentation.

SeeOnline Raspberry Pi Pico SDK API docs for HTML-based API documentation.

Example code

Seepico-examples for example code you can build.

Getting the latest SDK code

Themaster branch ofpico-sdk on GitHub contains thelatest stable release of the SDK. If you need or want to test upcoming features, you can try thedevelop branch instead.

Quick-start your own project

Using Visual Studio Code

You can install theRaspberry Pi Pico Visual Studio Code extension in VS Code.

Unix command line

These instructions are extremely terse, and Linux-based only. For detailed steps,instructions for other platforms, and just in general, we recommend you seeRaspberry Pi Pico-Series C/C++ SDK

  1. Install CMake (at least version 3.13), python 3, a native compiler, and a GCC cross compiler

    sudo apt install cmake python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
  2. Set up your project to point to use the Raspberry Pi Pico SDK

    • Either by cloning the SDK locally (most common) :

      1. git clone this Raspberry Pi Pico SDK repository

      2. Copypico_sdk_import.cmakefrom the SDK into your project directory

      3. SetPICO_SDK_PATH to the SDK location in your environment, or pass it (-DPICO_SDK_PATH=) to cmake later.

      4. Setup aCMakeLists.txt like:

        cmake_minimum_required(VERSION3.13...3.27)# initialize the SDK based on PICO_SDK_PATH# note: this must happen before project()include(pico_sdk_import.cmake)project(my_project)# initialize the Raspberry Pi Pico SDKpico_sdk_init()# rest of your project
    • Or with the Raspberry Pi Pico SDK as a submodule :

      1. Clone the SDK as a submodule calledpico-sdk

      2. Setup aCMakeLists.txt like:

        cmake_minimum_required(VERSION3.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 SDKpico_sdk_init()# rest of your project
    • Or with automatic download from GitHub :

      1. Copypico_sdk_import.cmakefrom the SDK into your project directory

      2. Setup aCMakeLists.txt like:

        cmake_minimum_required(VERSION3.13)# initialize pico-sdk from GIT# (note this can come from environment, CMake cache etc)set(PICO_SDK_FETCH_FROM_GITon)# pico_sdk_import.cmake is a single file copied from this SDK# note: this must happen before project()include(pico_sdk_import.cmake)project(my_project)# initialize the Raspberry Pi Pico SDKpico_sdk_init()# rest of your project
    • Or by cloning the SDK locally, but without copyingpico_sdk_import.cmake:

      1. git clone this Raspberry Pi Pico SDK repository

      2. Setup aCMakeLists.txt like:

        cmake_minimum_required(VERSION3.13)# initialize the SDK directlyinclude(/path/to/pico-sdk/pico_sdk_init.cmake)project(my_project)# initialize the Raspberry Pi Pico SDKpico_sdk_init()# rest of your project
  3. Write your code (seepico-examples or theRaspberry Pi Pico-Series C/C++ SDK documentation for more information)

    About the simplest you can do is a single source file (e.g. hello_world.c)

    #include<stdio.h>#include"pico/stdlib.h"intmain() {stdio_init_all();printf("Hello, world!\n");return0;}

    And add the following to yourCMakeLists.txt:

    add_executable(hello_worldhello_world.c)# Add pico_stdlib library which aggregates commonly used featurestarget_link_libraries(hello_worldpico_stdlib)# create map/bin/hex/uf2 file in addition to ELF.pico_add_extra_outputs(hello_world)

    Note this example uses the default UART forstdout;if you want to use the default USB see thehello-usb example.

  4. Setup a CMake build directory.For example, if not using an IDE:

    $ mkdir build$ cd build$ cmake ..

    When building for a board other than the Raspberry Pi Pico, you should pass-DPICO_BOARD=board_name to thecmake command above, e.g.cmake -DPICO_BOARD=pico2 .. orcmake -DPICO_BOARD=pico_w .. to configure the SDK and build options accordingly for that particular board.

    SpecifyingPICO_BOARD=<boardname> sets up various compiler defines (e.g. default pin numbers for UART and other hardware) and in certaincases also enables the use of additional libraries (e.g. wireless support when building forPICO_BOARD=pico_w) which cannotbe built without a board which provides the requisite hardware functionality.

    For a list of boards defined in the SDK itself, look inthis directory which has aheader for each named board.

  5. Make your target from the build directory you created.

    $ make hello_world
  6. You now havehello_world.elf to load via a debugger, orhello_world.uf2 that can be installed and run on your Raspberry Pi Pico-series device via drag and drop.

RISC-V support on RP2350

SeeRaspberry Pi Pico-series C/C++ SDK for information on setting up a build environment for RISC-V on RP2350.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp