No description
Find a file
Peter Harper af2f42613e
Changes for pico2_w (#1816)
* Add board file for pico2_w

This is a copy of pico2 with the definitions from pico_w added.
Set PICO_BOARD=pico2_w

* Simplify CYW43 PIO config

cyw43_spi_init contains code to find a free PIO and state machine. This
can all be replaced with pio_claim_free_sm_and_add_program_for_gpio_range

* Make CYW43 gpio pins configurable at build time

The CYW43 gpio pins are currently hardcoded. Give the defines better
names and make them overrideable at build time.

Note: CYW43_PIN_WL_REG_ON and CYW43_PIN_WL_HOST_WAKE are already used by
the driver via cyw43_hal_* functions

* Fix pio initialisation

Need to make sure the pio can work with all the gpios

* Add missing doxygen for cyw43_set_pio_clock_divisor

* Support dynamic configuration of cyw43 gpio pins

Add CYW43_PIN_WL_DYNAMIC that means cyw43 gpio pins can be changed at
runtime.

Then CYW43_PIN_WL_* calls cyw43_get_pin_wl to get the gpio out of
the array.

cyw43_set_pins_wl can be used to change the cyw43 gpio pins although
care is needed when calling this?

* Some fixes for cyw32 gpio > 32

* Allow CYW43 to be configured with cmake

* Add default config of CYW43_WL_GPIO_COUNT to cyw43_configport.h

* Fix some review comments

Add some PICO_CMAKE_CONFIG
Stop using gpio_*_mask64 functions
2024-09-18 14:16:41 -05:00
.github Fix Windows CI build (#1846) 2024-08-19 12:49:54 -05:00
bazel Enable building with Bazel on Raspberry PI OS machines (#1921) 2024-09-11 10:34:44 -05:00
cmake Update extract configs (#1845) 2024-08-27 11:11:42 -05:00
docs SDK 2.0.0 release 2024-08-08 08:54:38 -05:00
external set git tag for the SDK (#1630) 2024-06-04 20:04:21 -05:00
lib SDK 2.0.0 release 2024-08-08 08:54:38 -05:00
src Changes for pico2_w (#1816) 2024-09-18 14:16:41 -05:00
test Fix Bazel build breakages (#1908) 2024-09-10 18:44:55 -05:00
tools Fix Bazel build breakages (#1908) 2024-09-10 18:44:55 -05:00
.bazelignore SDK 2.0.0 release 2024-08-08 08:54:38 -05:00
.bazelrc SDK 2.0.0 release 2024-08-08 08:54:38 -05:00
.bazelversion SDK 2.0.0 release 2024-08-08 08:54:38 -05:00
.gitignore .gitignore: Add .cache (#1825) 2024-08-15 11:04:08 -05:00
.gitmodules Add Bluetooth support 2023-02-10 18:27:23 -06:00
BUILD.bazel Introduce initial Bazel build (#1705) 2024-06-04 18:50:32 -05:00
CMakeLists.txt SDK 2.0.0 release 2024-08-08 08:54:38 -05:00
CONTRIBUTING.md MarkDown syntax typo (#1366) 2023-05-07 10:34:33 -05:00
LICENSE.TXT Initial Release 2021-01-20 10:44:27 -06:00
MODULE.bazel Enable building with Bazel on Raspberry PI OS machines (#1921) 2024-09-11 10:34:44 -05:00
pico_sdk_init.cmake SDK 2.0.0 release 2024-08-08 08:54:38 -05:00
pico_sdk_version.cmake bump version for sdk 2.0.1-develop 2024-08-14 16:12:37 -05:00
README.md Add build-essential to README command line install (#1859) 2024-08-22 11:43:52 -05:00
WORKSPACE SDK 2.0.0 release 2024-08-08 08:54:38 -05:00

Raspberry Pi Pico SDK

The Raspberry Pi Pico SDK (henceforth the SDK) provides the headers, libraries and build system necessary to write programs for the RP-series microcontroller-based devices such as the Raspberry Pi Pico or Raspberry Pi Pico 2 in 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 conventional main() method. Standard C/C++ libraries are supported along with C-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 software such 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 in pico-extras.

Documentation

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

See Connecting to the Internet with Raspberry Pi Pico W to learn more about writing applications for your Raspberry Pi Pico W that connect to the internet.

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

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

Example code

See pico-examples for example code you can build.

Getting the latest SDK code

The master branch of pico-sdk on GitHub contains the latest stable release of the SDK. If you need or want to test upcoming features, you can try the develop branch instead.

Quick-start your own project

Using Visual Studio Code

You can install the Raspberry 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 see Raspberry 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. Copy pico_sdk_import.cmake from the SDK into your project directory

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

      4. Setup a CMakeLists.txt like:

        cmake_minimum_required(VERSION 3.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 SDK
        pico_sdk_init()
        
        # rest of your project
        
        
    • Or with the Raspberry Pi Pico SDK as a submodule :

      1. Clone the SDK as a submodule called pico-sdk

      2. Setup a CMakeLists.txt like:

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

      1. Copy pico_sdk_import.cmake from the SDK into your project directory

      2. Setup a CMakeLists.txt like:

        cmake_minimum_required(VERSION 3.13)
        
        # initialize pico-sdk from GIT
        # (note this can come from environment, CMake cache etc)
        set(PICO_SDK_FETCH_FROM_GIT on)
        
        # 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 SDK
        pico_sdk_init()
        
        # rest of your project
        
        
    • Or by cloning the SDK locally, but without copying pico_sdk_import.cmake:

      1. git clone this Raspberry Pi Pico SDK repository

      2. Setup a CMakeLists.txt like:

        cmake_minimum_required(VERSION 3.13)
        
        # initialize the SDK directly
        include(/path/to/pico-sdk/pico_sdk_init.cmake)
        
        project(my_project)
        
        # initialize the Raspberry Pi Pico SDK
        pico_sdk_init()
        
        # rest of your project
        
        
  3. Write your code (see pico-examples or the Raspberry 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"
    
    int main() {
        stdio_init_all();
        printf("Hello, world!\n");
        return 0;
    }
    

    And add the following to your CMakeLists.txt:

    add_executable(hello_world
        hello_world.c
    )
    
    # 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)
    

    Note this example uses the default UART for stdout; if you want to use the default USB see the hello-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 the cmake command above, e.g. cmake -DPICO_BOARD=pico2 .. or cmake -DPICO_BOARD=pico_w .. to configure the SDK and build options accordingly for that particular board.

    Specifying PICO_BOARD=<booardname> sets up various compiler defines (e.g. default pin numbers for UART and other hardware) and in certain cases also enables the use of additional libraries (e.g. wireless support when building for PICO_BOARD=pico_w) which cannot be built without a board which provides the requisite hardware functionality.

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

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

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

RISC-V support on RP2350

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