Skip to content

Commit 4e3dc9e

Browse files
authored
Merge branch 'develop' into uart_pio_dma
2 parents 67e3171 + da4e50d commit 4e3dc9e

File tree

218 files changed

+27545
-947
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+27545
-947
lines changed

.github/workflows/windows.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ jobs:
3939

4040
- name: Build Project
4141
working-directory: ${{github.workspace}}/pico-examples
42-
# bash required otherwise this mysteriously (no error) fails at "Generating cyw43_bus_pio_spi.pio.h"
43-
shell: bash
42+
shell: pwsh
4443
run: |
4544
mkdir build
4645
cd build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
_deps
44
cmake-*
55
build
6+
build-*
67
.DS_Store
78
*.pdf

CMakeLists.txt

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,52 @@ cmake_minimum_required(VERSION 3.12)
22

33
# Pull in SDK (must be before project)
44
include(pico_sdk_import.cmake)
5-
65
include(pico_extras_import_optional.cmake)
76

87
project(pico_examples C CXX ASM)
8+
99
set(CMAKE_C_STANDARD 11)
1010
set(CMAKE_CXX_STANDARD 17)
1111

12-
if (PICO_SDK_VERSION_STRING VERSION_LESS "1.3.0")
13-
message(FATAL_ERROR "Raspberry Pi Pico SDK version 1.3.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}")
12+
if (PICO_SDK_VERSION_STRING VERSION_LESS "2.0.0")
13+
message(FATAL_ERROR "Raspberry Pi Pico SDK version 2.0.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}")
1414
endif()
1515

1616
set(PICO_EXAMPLES_PATH ${PROJECT_SOURCE_DIR})
1717

18+
# If you want debug output from USB (pass -DPICO_STDIO_USB=1) this ensures you don't lose any debug output while USB is set up
19+
if (NOT DEFINED PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS)
20+
set(PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS 3000)
21+
endif()
22+
1823
# Initialize the SDK
1924
pico_sdk_init()
2025

2126
include(example_auto_set_url.cmake)
27+
28+
function(add_subdirectory_exclude_platforms NAME)
29+
if (ARGN)
30+
if (PICO_PLATFORM IN_LIST ARGN)
31+
message("Skipping ${NAME} example which is unsupported on this platform")
32+
return()
33+
endif()
34+
foreach(PATTERN IN LISTS ARGN)
35+
string(REGEX MATCH "${PATTERN}" MATCHED "${PICO_PLATFORM}")
36+
if (MATCHED)
37+
message("Skipping ${NAME} example which is unsupported on this platform")
38+
return()
39+
endif()
40+
endforeach()
41+
endif()
42+
add_subdirectory(${NAME})
43+
endfunction()
44+
2245
# Add blink example
23-
add_subdirectory(blink)
46+
add_subdirectory_exclude_platforms(blink)
47+
add_subdirectory_exclude_platforms(blink_simple)
2448

2549
# Add hello world example
26-
add_subdirectory(hello_world)
50+
add_subdirectory_exclude_platforms(hello_world)
2751

2852
add_compile_options(-Wall
2953
-Wno-format # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
@@ -35,15 +59,19 @@ endif()
3559

3660
# Hardware-specific examples in subdirectories:
3761
add_subdirectory(adc)
62+
add_subdirectory(bootloaders)
3863
add_subdirectory(clocks)
3964
add_subdirectory(cmake)
65+
add_subdirectory(dcp)
4066
add_subdirectory(divider)
4167
add_subdirectory(dma)
4268
add_subdirectory(flash)
4369
add_subdirectory(gpio)
70+
add_subdirectory(hstx)
4471
add_subdirectory(i2c)
4572
add_subdirectory(interp)
4673
add_subdirectory(multicore)
74+
add_subdirectory(otp)
4775
add_subdirectory(picoboard)
4876
add_subdirectory(pico_w)
4977
add_subdirectory(pio)
@@ -54,5 +82,8 @@ add_subdirectory(spi)
5482
add_subdirectory(system)
5583
add_subdirectory(timer)
5684
add_subdirectory(uart)
85+
add_subdirectory(universal)
5786
add_subdirectory(usb)
5887
add_subdirectory(watchdog)
88+
add_subdirectory(sha)
89+
add_subdirectory(freertos)

README.md

Lines changed: 85 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
1-
# Raspberry Pi Pico SDK Examples
1+
# Raspberry Pi RP2350 Pico SDK Examples - Early Access
2+
3+
## RP2350 Instructions
4+
5+
Everything below this section is from the stock pico-examples, so ignore URLs etc., but generally instructions are the same.
6+
7+
The Pico SDK default continues to be to build for RP2040 (PICO_PLATFORM=rp2040), so to build for RP2350, you need to pass
8+
`-DPICO_PLATFORM=rp2350` to CMake (or `-DPICO_PLATFORM=rp2350-riscv` for RISC-V).
9+
10+
Most, but not all examples, currently work on RP2350 however you should be able to do a full build with any of the above platforms (PICO_PLATFORM=host however currently fails on some examples)
11+
12+
For RISC-V compilation, you should take a compiler from here: https://www.embecosm.com/resources/tool-chain-downloads/#riscv-stable
13+
14+
# Original pico-examples docs
215

316
## Getting started
417

518
See [Getting Started with the Raspberry Pi Pico](https://rptl.io/pico-get-started) and the README in the [pico-sdk](https://github.com/raspberrypi/pico-sdk) for information
619
on getting up and running.
720

8-
### First Examples
21+
### First Examples
922

10-
App|Description | Link to prebuilt UF2
11-
---|---|---
12-
[hello_serial](hello_world/serial) | The obligatory Hello World program for Pico (Output over serial version) |
13-
[hello_usb](hello_world/usb) | The obligatory Hello World program for Pico (Output over USB version) | https://rptl.io/pico-hello-usb
14-
[blink](blink) | Blink an LED on and off. | https://rptl.io/pico-blink
23+
App| Description | Link to prebuilt UF2
24+
---|----------------------------------------------------------------------------|---
25+
[hello_serial](hello_world/serial) | The obligatory Hello World program for Pico (Output over serial version) |
26+
[hello_usb](hello_world/usb) | The obligatory Hello World program for Pico (Output over USB version) | https://rptl.io/pico-hello-usb
27+
[blink](blink) | Blink an LED on and off. Works on both boards with regular LEDs and Pico W | https://rptl.io/pico-blink
28+
[blink_simple](blink_simple) | Blink an LED on and off. Does not work on Pico W. | https://rptl.io/pico-blink
29+
[picow_blink](pico_w/wifi/blink) | Blinks the Pico W on-board LED (which is connected via the WiFi chip). | http://rptl.io/pico-w-blink
1530

1631
### ADC
1732

@@ -25,6 +40,11 @@ App|Description
2540
[dma_capture](adc/dma_capture) | Use the DMA to capture many samples from the ADC.
2641
[read_vsys](adc/read_vsys) | Demonstrates how to read VSYS to get the voltage of the power supply.
2742

43+
### Bootloaders (RP2350 Only)
44+
App|Description
45+
---|---
46+
[enc_bootloader](bootloaders/encrypted) | A bootloader which decrypts binaries from flash into SRAM. See the separate [README](bootloaders/encrypted/README.md) for more information
47+
2848
### Clocks
2949

3050
App|Description
@@ -40,6 +60,12 @@ App|Description
4060
---|---
4161
[build_variants](cmake/build_variants) | Builds two version of the same app with different configurations
4262

63+
### DCP
64+
65+
App|Description
66+
---|---
67+
[hello_dcp](dcp/hello_dcp) | Use the double-precision coprocessor directly in assembler.
68+
4369
### DMA
4470

4571
App|Description
@@ -49,6 +75,12 @@ App|Description
4975
[channel_irq](dma/channel_irq) | Use an IRQ handler to reconfigure a DMA channel, in order to continuously drive data through a PIO state machine.
5076
[sniff_crc](dma/sniff_crc) | Use the DMA engine's 'sniff' capability to calculate a CRC32 on a data buffer.
5177

78+
### HSTX
79+
80+
App|Description
81+
---|---
82+
[dvi_out_hstx_encoder](dvi_out_hstx_encoder) `RP2350`| Use the HSTX to output a DVI signal with 3:3:2 RGB
83+
5284
### Flash
5385

5486
App|Description
@@ -58,6 +90,15 @@ App|Description
5890
[program](flash/program) | Erase a flash sector, program one flash page, and read back the data.
5991
[xip_stream](flash/xip_stream) | Stream data using the XIP stream hardware, which allows data to be DMA'd in the background whilst executing code from flash.
6092
[ssi_dma](flash/ssi_dma) | DMA directly from the flash interface (continuous SCK clocking) for maximum bulk read performance.
93+
[runtime_flash_permissions](flash/runtime_flash_permissions) | Demonstrates adding partitions at runtime to change the flash permissions
94+
95+
### FreeRTOS
96+
97+
These examples require you to set the `FREERTOS_KERNEL_PATH` to point to the FreeRTOS Kernel. See https://github.com/FreeRTOS/FreeRTOS-Kernel
98+
99+
App|Description
100+
---|---
101+
[hello_freertos](freertos/hello_freertos) | Examples that demonstrate how run FreeRTOS and tasks on 1 or 2 cores.
61102

62103
### GPIO
63104

@@ -106,6 +147,13 @@ App|Description
106147
[hello_multicore](multicore/hello_multicore) | Launch a function on the second core, printf some messages on each core, and pass data back and forth through the mailbox FIFOs.
107148
[multicore_fifo_irqs](multicore/multicore_fifo_irqs) | On each core, register and interrupt handler for the mailbox FIFOs. Show how the interrupt fires when that core receives a message.
108149
[multicore_runner](multicore/multicore_runner) | Set up the second core to accept, and run, any function pointer pushed into its mailbox FIFO. Push in a few pieces of code and get answers back.
150+
[multicore_doorbell](multicore/multicore_doorbell) | Claims two doorbells for signaling between the cores. Counts how many doorbell IRQs occur on the second core and uses doorbells to coordinate exit.
151+
152+
### OTP
153+
154+
App|Description
155+
---|---
156+
[hello_otp](otp/hello_otp) | Demonstrate reading and writing from the OTP on RP2350, along with some of the features of OTP (error correction and page locking).
109157

110158
### Pico Board
111159

@@ -122,6 +170,7 @@ App|Description
122170
---|---
123171
[picow_access_point](pico_w/wifi/access_point) | Starts a WiFi access point, and fields DHCP requests.
124172
[picow_blink](pico_w/wifi/blink) | Blinks the on-board LED (which is connected via the WiFi chip).
173+
[picow_blink_slow_clock](pico_w/wifi/blink_slow_clock) | Blinks the on-board LED (which is connected via the WiFi chip) with a slower system clock to show how to reconfigure communication with the WiFi chip under those circumstances
125174
[picow_iperf_server](pico_w/wifi/iperf) | Runs an "iperf" server for WiFi speed testing.
126175
[picow_ntp_client](pico_w/wifi/ntp_client) | Connects to an NTP server to fetch and display the current time.
127176
[picow_tcp_client](pico_w/wifi/tcp_client) | A simple TCP client. You can run [python_test_tcp_server.py](pico_w/wifi/python_test_tcp/python_test_tcp_server.py) for it to connect to.
@@ -130,18 +179,22 @@ App|Description
130179
[picow_tls_verify](pico_w/wifi/tls_client) | Demonstrates how to make a HTTPS request using TLS with certificate verification.
131180
[picow_wifi_scan](pico_w/wifi/wifi_scan) | Scans for WiFi networks and prints the results.
132181
[picow_udp_beacon](pico_w/wifi/udp_beacon) | A simple UDP transmitter.
182+
[picow_httpd](pico_w/wifi/httpd) | Runs a LWIP HTTP server test app
133183

134184
#### FreeRTOS examples
135185

136186
These are examples of integrating Pico W networking under FreeRTOS, and require you to set the `FREERTOS_KERNEL_PATH`
137-
to point to the FreeRTOS Kernel.
187+
to point to the FreeRTOS Kernel. See https://github.com/FreeRTOS/FreeRTOS-Kernel
138188

139189
App|Description
140190
---|---
141191
[picow_freertos_iperf_server_nosys](pico_w/wifi/freertos/iperf) | Runs an "iperf" server for WiFi speed testing under FreeRTOS in NO_SYS=1 mode. The LED is blinked in another task
142192
[picow_freertos_iperf_server_sys](pico_w/wifi/freertos/iperf) | Runs an "iperf" server for WiFi speed testing under FreeRTOS in NO_SYS=0 (i.e. full FreeRTOS integration) mode. The LED is blinked in another task
143193
[picow_freertos_ping_nosys](pico_w/wifi/freertos/ping) | Runs the lwip-contrib/apps/ping test app under FreeRTOS in NO_SYS=1 mode.
144194
[picow_freertos_ping_sys](pico_w/wifi/freertos/ping) | Runs the lwip-contrib/apps/ping test app under FreeRTOS in NO_SYS=0 (i.e. full FreeRTOS integration) mode. The test app uses the lwIP _socket_ API in this case.
195+
[picow_freertos_ntp_client_socket](pico_w/wifi/freertos/ntp_client_socket) | Connects to an NTP server using the LwIP Socket API with FreeRTOS in NO_SYS=0 (i.e. full FreeRTOS integration) mode.
196+
[pico_freertos_httpd_nosys](pico_w/wifi/freertos/httpd) | Runs a LWIP HTTP server test app under FreeRTOS in NO_SYS=1 mode.
197+
[pico_freertos_httpd_sys](pico_w/wifi/freertos/httpd) | Runs a LWIP HTTP server test app under FreeRTOS in NO_SYS=0 (i.e. full FreeRTOS integration) mode.
145198

146199
### Pico W Bluetooth
147200

@@ -153,6 +206,8 @@ default being *background*. This can be changed by passing `-DBTSTACK_EXAMPLE_TY
153206
examples can be built (which may be slow) by passing `-DBTSTACK_EXAMPLE_TYPE=all`
154207
Freertos versions can only be built if `FREERTOS_KERNEL_PATH` is defined.
155208

209+
The Bluetooth examples that use audio require code in [pico-extras](https://github.com/raspberrypi/pico-extras). Pass `-DPICO_EXTRAS_PATH=${HOME}/pico-extras` on the cmake command line or define `PICO_EXTRAS_PATH=${HOME}/pico-extras` in your environment and re-run cmake to include them in the build.
210+
156211
App|Description
157212
---|---
158213
[picow_bt_example_a2dp_sink_demo](https://github.com/bluekitchen/btstack/tree/master/example/a2dp_sink_demo.c) | A2DP Sink - Receive Audio Stream and Control Playback.
@@ -230,8 +285,10 @@ App|Description
230285
[pwm](pio/pwm) | Pulse width modulation on PIO. Use it to gradually fade the brightness of an LED.
231286
[spi](pio/spi) | Use PIO to erase, program and read an external SPI flash chip. A second example runs a loopback test with all four CPHA/CPOL combinations.
232287
[squarewave](pio/squarewave) | Drive a fast square wave onto a GPIO. This example accesses low-level PIO registers directly, instead of using the SDK functions.
288+
[squarewave_div_sync](pio/squarewave) | Generates a square wave on three GPIOs and synchronises the divider on all the state machines
233289
[st7789_lcd](pio/st7789_lcd) | Set up PIO for 62.5 Mbps serial output, and use this to display a spinning image on a ST7789 serial LCD.
234290
[quadrature_encoder](pio/quadrature_encoder) | A quadrature encoder using PIO to maintain counts independent of the CPU.
291+
[quadrature_encoder_substep](pio/quadrature_encoder_substep) | High resolution speed measurement using a standard quadrature encoder
235292
[uart_rx](pio/uart_rx) | Implement the receive component of a UART serial port. Attach it to the spare Arm UART to see it receive characters.
236293
[uart_tx](pio/uart_tx) | Implement the transmit component of a UART serial port, and print hello world.
237294
[ws2812](pio/ws2812) | Examples of driving WS2812 addressable RGB LEDs.
@@ -260,6 +317,13 @@ App|Description
260317
[rtc_alarm](rtc/rtc_alarm) | Set an alarm on the RTC to trigger an interrupt at a date/time 5 seconds into the future.
261318
[rtc_alarm_repeat](rtc/rtc_alarm_repeat) | Trigger an RTC interrupt once per minute.
262319

320+
### SHA-256
321+
322+
App|Description
323+
---|---
324+
[hello_sha256](sha/sha256) | Demonstrates how to use the pico_sha256 library to calculate a checksum using the hardware in rp2350
325+
[mbedtls_sha256](sha/mbedtls_sha256) | Demonstrates using the SHA-256 hardware acceleration in mbedtls
326+
263327
### SPI
264328

265329
App|Description
@@ -276,7 +340,9 @@ App|Description
276340

277341
App|Description
278342
---|---
343+
[boot_info](system/boot_info) | Demonstrate how to read and interpret sys info boot info.
279344
[hello_double_tap](system/hello_double_tap) | An LED blink with the `pico_bootsel_via_double_reset` library linked. This enters the USB bootloader when it detects the system being reset twice in quick succession, which is useful for boards with a reset button but no BOOTSEL button.
345+
[rand](system/rand) | Demonstrate how to use the pico random number functions.
280346
[narrow_io_write](system/narrow_io_write) | Demonstrate the effects of 8-bit and 16-bit writes on a 32-bit IO register.
281347
[unique_board_id](system/unique_board_id) | Read the 64 bit unique ID from external flash, which serves as a unique identifier for the board.
282348

@@ -296,6 +362,17 @@ App|Description
296362
[lcd_uart](uart/lcd_uart) | Display text and symbols on a 16x02 RGB LCD display via UART
297363
[uart_advanced](uart/uart_advanced) | Use some other UART features like RX interrupts, hardware control flow, and data formats other than 8n1.
298364

365+
### Universal
366+
367+
These are examples of how to build universal binaries which run on RP2040, and RP2350 Arm & RISC-V.
368+
These require you to set `PICO_ARM_TOOLCHAIN_PATH` and `PICO_RISCV_TOOLCHAIN_PATH` to appropriate paths, to ensure you have compilers for both architectures.
369+
370+
App|Description
371+
---|---
372+
[blink](universal/CMakeLists.txt#L126) | Same as the [blink](blink) example, but universal.
373+
[hello_universal](universal/hello_universal) | The obligatory Hello World program for Pico (USB and serial output). On RP2350 it will reboot to the other architecture after every 10 prints.
374+
[nuke_universal](universal/CMakeLists.txt#L132) | Same as the [nuke](flash/nuke) example, but universal. On RP2350 runs as a packaged SRAM binary, so is written to flash and copied to SRAM by the bootloader
375+
299376
### USB Device
300377

301378
#### TinyUSB Examples

adc/CMakeLists.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
if (NOT PICO_NO_HARDWARE)
2-
add_subdirectory(adc_console)
3-
add_subdirectory(dma_capture)
4-
add_subdirectory(hello_adc)
5-
add_subdirectory(joystick_display)
6-
add_subdirectory(onboard_temperature)
7-
add_subdirectory(microphone_adc)
8-
add_subdirectory(read_vsys)
9-
endif ()
1+
if (TARGET hardware_adc)
2+
add_subdirectory_exclude_platforms(adc_console)
3+
add_subdirectory_exclude_platforms(dma_capture)
4+
add_subdirectory_exclude_platforms(hello_adc)
5+
add_subdirectory_exclude_platforms(joystick_display)
6+
add_subdirectory_exclude_platforms(onboard_temperature)
7+
add_subdirectory_exclude_platforms(microphone_adc)
8+
add_subdirectory_exclude_platforms(read_vsys)
9+
else()
10+
message("Skipping ADC examples as hardware_adc is unavailable on this platform")
11+
endif()

adc/adc_console/adc_console.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void printhelp() {
1717
void __not_in_flash_func(adc_capture)(uint16_t *buf, size_t count) {
1818
adc_fifo_setup(true, false, 0, false, false);
1919
adc_run(true);
20-
for (int i = 0; i < count; i = i + 1)
20+
for (size_t i = 0; i < count; i = i + 1)
2121
buf[i] = adc_fifo_get_blocking();
2222
adc_run(false);
2323
adc_fifo_drain();

adc/joystick_display/joystick_display.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ int main() {
2828
uint bar_x_pos = adc_x_raw * bar_width / adc_max;
2929
uint bar_y_pos = adc_y_raw * bar_width / adc_max;
3030
printf("\rX: [");
31-
for (int i = 0; i < bar_width; ++i)
31+
for (uint i = 0; i < bar_width; ++i)
3232
putchar( i == bar_x_pos ? 'o' : ' ');
3333
printf("] Y: [");
34-
for (int i = 0; i < bar_width; ++i)
34+
for (uint i = 0; i < bar_width; ++i)
3535
putchar( i == bar_y_pos ? 'o' : ' ');
3636
printf("]");
3737
sleep_ms(50);

adc/read_vsys/read_vsys.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ int main() {
2828
}
2929
#endif
3030

31-
bool old_battery_status;
32-
float old_voltage;
31+
bool old_battery_status = false;
3332
bool battery_status = true;
33+
float old_voltage = -1;
3434
char *power_str = "UNKNOWN";
3535

3636
while(true) {
@@ -50,7 +50,7 @@ int main() {
5050
if (battery_status && voltage_return == PICO_OK) {
5151
const float min_battery_volts = 3.0f;
5252
const float max_battery_volts = 4.2f;
53-
int percent_val = ((voltage - min_battery_volts) / (max_battery_volts - min_battery_volts)) * 100;
53+
int percent_val = (int) (((voltage - min_battery_volts) / (max_battery_volts - min_battery_volts)) * 100);
5454
snprintf(percent_buf, sizeof(percent_buf), " (%d%%)", percent_val);
5555
}
5656

blink/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
add_executable(blink
2-
blink.c
3-
)
2+
blink.c
3+
)
44

55
# pull in common dependencies
66
target_link_libraries(blink pico_stdlib)
77

8+
if (PICO_CYW43_SUPPORTED)
9+
target_link_libraries(blink pico_cyw43_arch_none)
10+
endif()
11+
812
# create map/bin/hex file etc.
913
pico_add_extra_outputs(blink)
1014

0 commit comments

Comments
 (0)