├── .github
└── workflows
│ ├── choco_packages.config
│ ├── cmake.yml
│ ├── macOS.yml
│ ├── multi-gcc.yml
│ └── windows.yml
├── .gitignore
├── CMakeLists.txt
├── CONTRIBUTING.md
├── LICENSE.TXT
├── README.md
├── adc
├── CMakeLists.txt
├── adc_console
│ ├── CMakeLists.txt
│ └── adc_console.c
├── dma_capture
│ ├── CMakeLists.txt
│ ├── dma_capture.c
│ └── resistor_dac.pio
├── hello_adc
│ ├── CMakeLists.txt
│ └── hello_adc.c
├── joystick_display
│ ├── CMakeLists.txt
│ └── joystick_display.c
├── microphone_adc
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── microphone_adc.c
│ ├── microphone_adc.fzz
│ ├── microphone_adc_bb.png
│ ├── microphone_adc_plotter.png
│ └── plotter.py
├── onboard_temperature
│ ├── CMakeLists.txt
│ └── onboard_temperature.c
└── read_vsys
│ ├── CMakeLists.txt
│ ├── power_status.c
│ ├── power_status.h
│ └── read_vsys.c
├── binary_info
├── CMakeLists.txt
├── README.md
├── blink_any
│ ├── CMakeLists.txt
│ └── blink_any.c
└── hello_anything
│ ├── CMakeLists.txt
│ └── hello_anything.c
├── blink
├── CMakeLists.txt
└── blink.c
├── blink_simple
├── CMakeLists.txt
└── blink_simple.c
├── bootloaders
├── CMakeLists.txt
└── encrypted
│ ├── CMakeLists.txt
│ ├── README.md
│ ├── aes.S
│ ├── config.h
│ ├── enc-pt.json
│ ├── enc_bootloader.c
│ ├── hello_serial.c
│ ├── otp.json
│ ├── private.pem
│ ├── privateaes.bin
│ └── update-key.cmake
├── clocks
├── CMakeLists.txt
├── detached_clk_peri
│ ├── CMakeLists.txt
│ └── detached_clk_peri.c
├── hello_48MHz
│ ├── CMakeLists.txt
│ └── hello_48MHz.c
├── hello_gpout
│ ├── CMakeLists.txt
│ └── hello_gpout.c
└── hello_resus
│ ├── CMakeLists.txt
│ └── hello_resus.c
├── cmake
├── CMakeLists.txt
└── build_variants
│ ├── CMakeLists.txt
│ ├── main.c
│ ├── other.c
│ └── other.h
├── dcp
├── CMakeLists.txt
└── hello_dcp
│ ├── CMakeLists.txt
│ ├── dcp_examples.S
│ └── hello_dcp.c
├── divider
├── CMakeLists.txt
└── hello_divider.c
├── dma
├── CMakeLists.txt
├── channel_irq
│ ├── CMakeLists.txt
│ ├── channel_irq.c
│ └── pio_serialiser.pio
├── control_blocks
│ ├── CMakeLists.txt
│ └── control_blocks.c
├── hello_dma
│ ├── CMakeLists.txt
│ └── hello_dma.c
└── sniff_crc
│ ├── CMakeLists.txt
│ └── sniff_crc.c
├── example_auto_set_url.cmake
├── flash
├── CMakeLists.txt
├── cache_perfctr
│ ├── CMakeLists.txt
│ └── flash_cache_perfctr.c
├── nuke
│ ├── CMakeLists.txt
│ └── nuke.c
├── program
│ ├── CMakeLists.txt
│ └── flash_program.c
├── runtime_flash_permissions
│ ├── CMakeLists.txt
│ ├── pt.json
│ └── runtime_flash_permissions.c
├── ssi_dma
│ ├── CMakeLists.txt
│ └── flash_ssi_dma.c
└── xip_stream
│ ├── CMakeLists.txt
│ ├── flash_xip_stream.c
│ └── random_test_data.h
├── freertos
├── CMakeLists.txt
├── FreeRTOSConfig.h
├── FreeRTOSConfig_examples_common.h
├── FreeRTOS_Kernel_import.cmake
└── hello_freertos
│ ├── CMakeLists.txt
│ └── hello_freertos.c
├── gpio
├── CMakeLists.txt
├── dht_sensor
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── dht.c
│ ├── pi-and-pico-uart-and-dht-sensor.fzz
│ ├── pi-and-pico-uart-and-dht-sensor.png
│ └── serial-output.png
├── hello_7segment
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── hello_7segment.c
│ ├── hello_7segment.fzz
│ └── hello_7segment_bb.png
└── hello_gpio_irq
│ ├── CMakeLists.txt
│ └── hello_gpio_irq.c
├── hello_world
├── CMakeLists.txt
├── serial
│ ├── CMakeLists.txt
│ └── hello_serial.c
└── usb
│ ├── CMakeLists.txt
│ └── hello_usb.c
├── hstx
├── CMakeLists.txt
├── dvi_out_hstx_encoder
│ ├── CMakeLists.txt
│ ├── dvi_out_hstx_encoder.c
│ └── images
│ │ └── mountains_640x480_rgb332.h
└── spi_lcd
│ ├── CMakeLists.txt
│ └── hstx_spi_lcd.c
├── i2c
├── CMakeLists.txt
├── bmp280_i2c
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── bmp280_i2c.c
│ ├── bmp280_i2c.fzz
│ └── bmp280_i2c_bb.png
├── bus_scan
│ ├── CMakeLists.txt
│ └── bus_scan.c
├── ht16k33_i2c
│ ├── CMakeLists.txt
│ ├── README.adoc
│ └── ht16k33_i2c.c
├── lcd_1602_i2c
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── lcd_1602_i2c.c
│ ├── lcd_1602_i2c.fzz
│ └── lcd_1602_i2c_bb.png
├── lis3dh_i2c
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── lis3dh_i2c.c
│ ├── lis3dh_i2c.fzz
│ └── lis3dh_i2c.png
├── mcp9808_i2c
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── mcp9808_i2c.c
│ ├── mcp9808_i2c.fzz
│ └── mcp9808_i2c.png
├── mma8451_i2c
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── mma8451_i2c.c
│ ├── mma8451_i2c.fzz
│ └── mma8451_i2c.png
├── mpl3115a2_i2c
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── mpl3115a2_i2c.c
│ ├── mpl3115a2_i2c.fzz
│ └── mpl3115a2_i2c_bb.png
├── mpu6050_i2c
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── mpu6050_i2c.c
│ ├── mpu6050_i2c.fzz
│ └── mpu6050_i2c_bb.png
├── pa1010d_i2c
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── pa1010d_i2c.c
│ ├── pa1010d_i2c.fzz
│ └── pa1010d_i2c.png
├── pcf8523_i2c
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── pc8523_i2c.fzz
│ ├── pc8523_i2c.png
│ └── pcf8523_i2c.c
├── slave_mem_i2c
│ ├── CMakeLists.txt
│ ├── slave_mem_i2c.c
│ └── slave_mem_i2c_burst.c
└── ssd1306_i2c
│ ├── 1306_i2c.fzz
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── img_to_array.py
│ ├── raspberry26x32.bmp
│ ├── raspberry26x32.h
│ ├── ssd1306_font.h
│ ├── ssd1306_i2c.c
│ └── ssd1306_i2c_bb.png
├── ide
└── vscode
│ ├── README.md
│ ├── launch-probe-swd.json
│ ├── launch-raspberrypi-swd.json
│ ├── launch-remote-openocd.json
│ └── settings.json
├── interp
├── CMakeLists.txt
└── hello_interp
│ ├── CMakeLists.txt
│ └── hello_interp.c
├── multicore
├── CMakeLists.txt
├── hello_multicore
│ ├── CMakeLists.txt
│ └── multicore.c
├── multicore_doorbell
│ ├── CMakeLists.txt
│ └── multicore_doorbell.c
├── multicore_fifo_irqs
│ ├── CMakeLists.txt
│ └── multicore_fifo_irqs.c
├── multicore_runner
│ ├── CMakeLists.txt
│ └── multicore_runner.c
└── multicore_runner_queue
│ ├── CMakeLists.txt
│ └── multicore_runner_queue.c
├── otp
├── CMakeLists.txt
└── hello_otp
│ ├── CMakeLists.txt
│ └── hello_otp.c
├── pico_extras_import_optional.cmake
├── pico_sdk_import.cmake
├── pico_w
├── CMakeLists.txt
├── bt
│ ├── CMakeLists.txt
│ ├── FreeRTOS_Kernel_import.cmake
│ ├── README.md
│ ├── a2dp_sink_demo
│ │ └── CMakeLists.txt
│ ├── a2dp_source_demo
│ │ └── CMakeLists.txt
│ ├── ancs_client_demo
│ │ └── CMakeLists.txt
│ ├── att_delayed_response
│ │ └── CMakeLists.txt
│ ├── avrcp_browsing_client
│ │ └── CMakeLists.txt
│ ├── btstack_audio_pico.c
│ ├── config
│ │ ├── FreeRTOSConfig.h
│ │ ├── btstack_config.h
│ │ └── lwipopts.h
│ ├── dut_mode_classic
│ │ └── CMakeLists.txt
│ ├── gap_dedicated_bonding
│ │ └── CMakeLists.txt
│ ├── gap_inquiry
│ │ └── CMakeLists.txt
│ ├── gap_le_advertisements
│ │ └── CMakeLists.txt
│ ├── gap_link_keys
│ │ └── CMakeLists.txt
│ ├── gatt_battery_query
│ │ └── CMakeLists.txt
│ ├── gatt_browser
│ │ └── CMakeLists.txt
│ ├── gatt_counter
│ │ └── CMakeLists.txt
│ ├── gatt_counter_with_wifi
│ │ └── CMakeLists.txt
│ ├── gatt_device_information_query
│ │ └── CMakeLists.txt
│ ├── gatt_heart_rate_client
│ │ └── CMakeLists.txt
│ ├── gatt_streamer_server
│ │ └── CMakeLists.txt
│ ├── gatt_streamer_server_with_wifi
│ │ └── CMakeLists.txt
│ ├── hfp_ag_demo
│ │ └── CMakeLists.txt
│ ├── hfp_hf_demo
│ │ └── CMakeLists.txt
│ ├── hid_host_demo
│ │ └── CMakeLists.txt
│ ├── hid_keyboard_demo
│ │ └── CMakeLists.txt
│ ├── hid_mouse_demo
│ │ └── CMakeLists.txt
│ ├── hog_boot_host_demo
│ │ └── CMakeLists.txt
│ ├── hog_host_demo
│ │ └── CMakeLists.txt
│ ├── hog_keyboard_demo
│ │ └── CMakeLists.txt
│ ├── hog_mouse_demo
│ │ └── CMakeLists.txt
│ ├── hsp_ag_demo
│ │ └── CMakeLists.txt
│ ├── hsp_hs_demo
│ │ └── CMakeLists.txt
│ ├── le_credit_based_flow_control_mode_client
│ │ └── CMakeLists.txt
│ ├── le_credit_based_flow_control_mode_server
│ │ └── CMakeLists.txt
│ ├── le_mitm
│ │ └── CMakeLists.txt
│ ├── le_streamer_client
│ │ └── CMakeLists.txt
│ ├── led_counter
│ │ └── CMakeLists.txt
│ ├── mod_player
│ │ └── CMakeLists.txt
│ ├── nordic_spp_le_counter
│ │ └── CMakeLists.txt
│ ├── nordic_spp_le_streamer
│ │ └── CMakeLists.txt
│ ├── pan_lwip_http_server
│ │ └── CMakeLists.txt
│ ├── pbap_client_demo
│ │ └── CMakeLists.txt
│ ├── picow_bt_example_background.c
│ ├── picow_bt_example_common.c
│ ├── picow_bt_example_common.h
│ ├── picow_bt_example_freertos.c
│ ├── picow_bt_example_poll.c
│ ├── sdp_bnep_query
│ │ └── CMakeLists.txt
│ ├── sdp_general_query
│ │ └── CMakeLists.txt
│ ├── sdp_rfcomm_query
│ │ └── CMakeLists.txt
│ ├── sine_player
│ │ └── CMakeLists.txt
│ ├── sm_pairing_central
│ │ └── CMakeLists.txt
│ ├── sm_pairing_peripheral
│ │ └── CMakeLists.txt
│ ├── spp_and_gatt_counter
│ │ └── CMakeLists.txt
│ ├── spp_and_gatt_streamer
│ │ └── CMakeLists.txt
│ ├── spp_counter
│ │ └── CMakeLists.txt
│ ├── spp_flowcontrol
│ │ └── CMakeLists.txt
│ ├── spp_streamer
│ │ └── CMakeLists.txt
│ ├── spp_streamer_client
│ │ └── CMakeLists.txt
│ ├── spp_streamer_with_wifi
│ │ └── CMakeLists.txt
│ ├── standalone
│ │ ├── CMakeLists.txt
│ │ ├── btstack_config.h
│ │ ├── client.c
│ │ ├── lwipopts.h
│ │ ├── server.c
│ │ ├── server_common.c
│ │ ├── server_common.h
│ │ ├── server_with_wifi.c
│ │ └── temp_sensor.gatt
│ └── ublox_spp_le_counter
│ │ └── CMakeLists.txt
└── wifi
│ ├── CMakeLists.txt
│ ├── access_point
│ ├── CMakeLists.txt
│ ├── dhcpserver
│ │ ├── LICENSE
│ │ ├── dhcpserver.c
│ │ └── dhcpserver.h
│ ├── dnsserver
│ │ ├── dnsserver.c
│ │ └── dnsserver.h
│ ├── lwipopts.h
│ └── picow_access_point.c
│ ├── blink
│ ├── CMakeLists.txt
│ ├── picow_blink.c
│ ├── picow_blink_fast_clock.c
│ └── picow_blink_slow_clock.c
│ ├── freertos
│ ├── CMakeLists.txt
│ ├── FreeRTOSConfig_examples_common.h
│ ├── FreeRTOS_Kernel_import.cmake
│ ├── http_client
│ │ ├── CMakeLists.txt
│ │ ├── FreeRTOSConfig.h
│ │ ├── lwipopts.h
│ │ ├── mbedtls_config.h
│ │ └── picow_freertos_http_client.c
│ ├── httpd
│ │ ├── CMakeLists.txt
│ │ ├── FreeRTOSConfig.h
│ │ ├── content
│ │ │ ├── 404.html
│ │ │ ├── index.shtml
│ │ │ └── test.shtml
│ │ ├── lwipopts.h
│ │ └── pico_freertos_httpd.c
│ ├── iperf
│ │ ├── CMakeLists.txt
│ │ ├── FreeRTOSConfig.h
│ │ ├── lwipopts.h
│ │ └── picow_freertos_iperf.c
│ ├── ntp_client_socket
│ │ ├── CMakeLists.txt
│ │ ├── FreeRTOSConfig.h
│ │ ├── lwipopts.h
│ │ └── picow_freertos_ntp_client_socket.c
│ └── ping
│ │ ├── CMakeLists.txt
│ │ ├── FreeRTOSConfig.h
│ │ ├── lwipopts.h
│ │ └── picow_freertos_ping.c
│ ├── http_client
│ ├── CMakeLists.txt
│ ├── example_http_client_util.c
│ ├── example_http_client_util.h
│ ├── lwipopts.h
│ ├── mbedtls_config.h
│ ├── picow_http_client.c
│ └── picow_http_verify.c
│ ├── httpd
│ ├── CMakeLists.txt
│ ├── content
│ │ ├── 404.html
│ │ ├── img
│ │ │ └── rpi.png
│ │ ├── index.shtml
│ │ ├── ledfail.shtml
│ │ ├── ledpass.shtml
│ │ └── test.shtml
│ ├── lwipopts.h
│ └── pico_httpd.c
│ ├── iperf
│ ├── CMakeLists.txt
│ ├── lwipopts.h
│ └── picow_iperf.c
│ ├── lwipopts_examples_common.h
│ ├── mbedtls_config_examples_common.h
│ ├── mqtt
│ ├── CMakeLists.txt
│ ├── README
│ ├── certs
│ │ ├── .gitignore
│ │ ├── makecerts.sh
│ │ ├── pub.sh
│ │ └── sub.sh
│ ├── lwipopts.h
│ ├── mbedtls_config.h
│ └── mqtt_client.c
│ ├── ntp_client
│ ├── CMakeLists.txt
│ ├── lwipopts.h
│ └── picow_ntp_client.c
│ ├── python_test_tcp
│ ├── micropython_test_tcp_client.py
│ ├── micropython_test_tcp_server.py
│ ├── python_test_tcp_client.py
│ └── python_test_tcp_server.py
│ ├── tcp_client
│ ├── CMakeLists.txt
│ ├── lwipopts.h
│ └── picow_tcp_client.c
│ ├── tcp_server
│ ├── CMakeLists.txt
│ ├── lwipopts.h
│ └── picow_tcp_server.c
│ ├── tls_client
│ ├── CMakeLists.txt
│ ├── lwipopts.h
│ ├── mbedtls_config.h
│ ├── picow_tls_client.c
│ ├── tls_common.c
│ └── tls_verify.c
│ ├── udp_beacon
│ ├── CMakeLists.txt
│ ├── lwipopts.h
│ └── picow_udp_beacon.c
│ └── wifi_scan
│ ├── CMakeLists.txt
│ ├── lwipopts.h
│ └── picow_wifi_scan.c
├── picoboard
├── CMakeLists.txt
├── blinky
│ ├── CMakeLists.txt
│ └── blinky.c
└── button
│ ├── CMakeLists.txt
│ └── button.c
├── pio
├── CMakeLists.txt
├── addition
│ ├── CMakeLists.txt
│ ├── addition.c
│ └── addition.pio
├── apa102
│ ├── CMakeLists.txt
│ ├── apa102.c
│ └── apa102.pio
├── clocked_input
│ ├── CMakeLists.txt
│ ├── clocked_input.c
│ └── clocked_input.pio
├── differential_manchester
│ ├── CMakeLists.txt
│ ├── differential_manchester.c
│ └── differential_manchester.pio
├── hello_pio
│ ├── CMakeLists.txt
│ ├── hello.c
│ └── hello.pio
├── hub75
│ ├── CMakeLists.txt
│ ├── Readme.md
│ ├── hub75.c
│ ├── hub75.pio
│ ├── mountains_128x64.png
│ └── mountains_128x64_rgb565.h
├── i2c
│ ├── CMakeLists.txt
│ ├── i2c.pio
│ ├── i2c_bus_scan.c
│ ├── pio_i2c.c
│ └── pio_i2c.h
├── ir_nec
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── ir_loopback
│ │ ├── CMakeLists.txt
│ │ └── ir_loopback.c
│ ├── nec_receive_library
│ │ ├── CMakeLists.txt
│ │ ├── nec_receive.c
│ │ ├── nec_receive.h
│ │ └── nec_receive.pio
│ ├── nec_transmit_library
│ │ ├── CMakeLists.txt
│ │ ├── nec_carrier_burst.pio
│ │ ├── nec_carrier_control.pio
│ │ ├── nec_transmit.c
│ │ └── nec_transmit.h
│ ├── pio_ir_loopback.fzz
│ └── pio_ir_loopback.png
├── logic_analyser
│ ├── CMakeLists.txt
│ └── logic_analyser.c
├── manchester_encoding
│ ├── CMakeLists.txt
│ ├── manchester_encoding.c
│ └── manchester_encoding.pio
├── onewire
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── ds18b20.h
│ ├── onewire.c
│ ├── onewire_library
│ │ ├── CMakeLists.txt
│ │ ├── onewire_library.c
│ │ ├── onewire_library.h
│ │ └── onewire_library.pio
│ ├── ow_rom.h
│ ├── pio_onewire.fzz
│ └── pio_onewire.png
├── pio_blink
│ ├── CMakeLists.txt
│ ├── blink.c
│ └── blink.pio
├── pwm
│ ├── CMakeLists.txt
│ ├── pwm.c
│ └── pwm.pio
├── quadrature_encoder
│ ├── CMakeLists.txt
│ ├── quadrature_encoder.c
│ └── quadrature_encoder.pio
├── quadrature_encoder_substep
│ ├── CMakeLists.txt
│ ├── README.md
│ ├── images
│ │ ├── chart.svg
│ │ └── steps.svg
│ ├── quadrature_encoder_substep.c
│ └── quadrature_encoder_substep.pio
├── spi
│ ├── CMakeLists.txt
│ ├── pio_spi.c
│ ├── pio_spi.h
│ ├── spi.pio
│ ├── spi_flash.c
│ └── spi_loopback.c
├── squarewave
│ ├── CMakeLists.txt
│ ├── generated
│ │ ├── squarewave.hex
│ │ ├── squarewave.pio.h
│ │ └── squarewave_wrap.pio.h
│ ├── squarewave.c
│ ├── squarewave.pio
│ ├── squarewave_div_sync.c
│ ├── squarewave_fast.pio
│ └── squarewave_wrap.pio
├── st7789_lcd
│ ├── CMakeLists.txt
│ ├── raspberry_256x256.png
│ ├── raspberry_256x256_rgb565.h
│ ├── st7789_lcd.c
│ └── st7789_lcd.pio
├── uart_pio_dma
│ ├── CMakeLists.txt
│ └── uart_pio_dma.c
├── uart_rx
│ ├── CMakeLists.txt
│ ├── uart_rx.c
│ ├── uart_rx.pio
│ └── uart_rx_intr.c
├── uart_tx
│ ├── CMakeLists.txt
│ ├── uart_tx.c
│ └── uart_tx.pio
└── ws2812
│ ├── CMakeLists.txt
│ ├── generated
│ ├── ws2812.pio.h
│ └── ws2812.py
│ ├── ws2812.c
│ ├── ws2812.pio
│ └── ws2812_parallel.c
├── pwm
├── CMakeLists.txt
├── hello_pwm
│ ├── CMakeLists.txt
│ └── hello_pwm.c
├── led_fade
│ ├── CMakeLists.txt
│ └── pwm_led_fade.c
└── measure_duty_cycle
│ ├── CMakeLists.txt
│ └── measure_duty_cycle.c
├── reset
├── CMakeLists.txt
└── hello_reset
│ ├── CMakeLists.txt
│ └── hello_reset.c
├── rtc
├── CMakeLists.txt
├── hello_rtc
│ ├── CMakeLists.txt
│ └── hello_rtc.c
├── rtc_alarm
│ ├── CMakeLists.txt
│ └── rtc_alarm.c
└── rtc_alarm_repeat
│ ├── CMakeLists.txt
│ └── rtc_alarm_repeat.c
├── sha
├── CMakeLists.txt
├── mbedtls_sha256
│ ├── CMakeLists.txt
│ ├── mbedtls_config.h
│ └── mbedtls_sha256.c
└── sha256
│ ├── CMakeLists.txt
│ ├── hello_sha256.c
│ └── sample.txt
├── spi
├── CMakeLists.txt
├── bme280_spi
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── bme280_spi.c
│ ├── bme280_spi.fzz
│ └── bme280_spi_bb.png
├── max7219_32x8_spi
│ ├── CMakeLists.txt
│ ├── README.adoc
│ └── max7219_32x8_spi.c
├── max7219_8x7seg_spi
│ ├── CMakeLists.txt
│ ├── README.adoc
│ └── max7219_8x7seg_spi.c
├── mpu9250_spi
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── mpu9250_spi.c
│ ├── mpu9250_spi.fzz
│ └── mpu9250_spi_bb.png
├── spi_dma
│ ├── CMakeLists.txt
│ └── spi_dma.c
├── spi_flash
│ ├── CMakeLists.txt
│ └── spi_flash.c
└── spi_master_slave
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── spi_master
│ ├── CMakeLists.txt
│ └── spi_master.c
│ ├── spi_master_slave.csv
│ ├── spi_master_slave.fzz
│ ├── spi_master_slave_bb.png
│ ├── spi_master_slave_logic.png
│ └── spi_slave
│ ├── CMakeLists.txt
│ └── spi_slave.c
├── system
├── CMakeLists.txt
├── boot_info
│ ├── CMakeLists.txt
│ └── boot_info.c
├── hello_double_tap
│ ├── CMakeLists.txt
│ └── hello_double_tap.c
├── narrow_io_write
│ ├── CMakeLists.txt
│ └── narrow_io_write.c
├── rand
│ ├── CMakeLists.txt
│ └── rand.c
└── unique_board_id
│ ├── CMakeLists.txt
│ └── unique_board_id.c
├── timer
├── CMakeLists.txt
├── hello_timer
│ ├── CMakeLists.txt
│ └── hello_timer.c
├── periodic_sampler
│ ├── CMakeLists.txt
│ └── periodic_sampler.c
└── timer_lowlevel
│ ├── CMakeLists.txt
│ └── timer_lowlevel.c
├── uart
├── CMakeLists.txt
├── hello_uart
│ ├── CMakeLists.txt
│ └── hello_uart.c
├── lcd_uart
│ ├── CMakeLists.txt
│ ├── README.adoc
│ ├── lcd_uart.c
│ ├── lcd_uart.fzz
│ └── lcd_uart_bb.png
└── uart_advanced
│ ├── CMakeLists.txt
│ └── uart_advanced.c
├── universal
├── CMakeLists.txt
├── hello_universal
│ ├── CMakeLists.txt
│ └── hello_universal.c
└── wrapper
│ └── CMakeLists.txt
├── usb
├── CMakeLists.txt
├── README.md
├── device
│ ├── CMakeLists.txt
│ ├── dev_hid_composite
│ │ ├── CMakeLists.txt
│ │ ├── LICENSE.TXT
│ │ ├── README.md
│ │ ├── main.c
│ │ ├── tusb_config.h
│ │ ├── usb_descriptors.c
│ │ └── usb_descriptors.h
│ ├── dev_lowlevel
│ │ ├── CMakeLists.txt
│ │ ├── dev_lowlevel.c
│ │ ├── dev_lowlevel.h
│ │ ├── dev_lowlevel_loopback.py
│ │ └── usb_common.h
│ └── dev_multi_cdc
│ │ ├── CMakeLists.txt
│ │ ├── main.c
│ │ ├── tusb_config.h
│ │ └── usb_descriptors.c
├── dual
│ └── CMakeLists.txt
└── host
│ ├── CMakeLists.txt
│ └── host_cdc_msc_hid
│ ├── CMakeLists.txt
│ ├── LICENSE.TXT
│ ├── cdc_app.c
│ ├── hid_app.c
│ ├── main.c
│ ├── msc_app.c
│ └── tusb_config.h
└── watchdog
├── CMakeLists.txt
└── hello_watchdog
├── CMakeLists.txt
└── hello_watchdog.c
/.github/workflows/choco_packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | .vscode
3 | _deps
4 | cmake-*
5 | build
6 | build-*
7 | build_*
8 | .DS_Store
9 | *.pdf
10 |
--------------------------------------------------------------------------------
/adc/CMakeLists.txt:
--------------------------------------------------------------------------------
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/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(adc_console
2 | adc_console.c
3 | )
4 |
5 | target_link_libraries(adc_console pico_stdlib hardware_adc)
6 |
7 | # create map/bin/hex file etc.
8 | pico_add_extra_outputs(adc_console)
9 |
10 | # add url via pico_set_program_url
11 | example_auto_set_url(adc_console)
12 |
13 |
--------------------------------------------------------------------------------
/adc/dma_capture/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(adc_dma_capture
2 | dma_capture.c
3 | )
4 |
5 | pico_generate_pio_header(adc_dma_capture ${CMAKE_CURRENT_LIST_DIR}/resistor_dac.pio)
6 |
7 | target_link_libraries(adc_dma_capture
8 | pico_stdlib
9 | hardware_adc
10 | hardware_dma
11 | # For the dummy output:
12 | hardware_pio
13 | pico_multicore
14 | )
15 |
16 | # create map/bin/hex file etc.
17 | pico_add_extra_outputs(adc_dma_capture)
18 |
19 | # add url via pico_set_program_url
20 | example_auto_set_url(adc_dma_capture)
21 |
--------------------------------------------------------------------------------
/adc/dma_capture/resistor_dac.pio:
--------------------------------------------------------------------------------
1 | ;
2 | ; Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
3 | ;
4 | ; SPDX-License-Identifier: BSD-3-Clause
5 | ;
6 |
7 | .program resistor_dac_5bit
8 |
9 | ; Drive one of the 5-bit resistor DACs on the VGA reference board. (this isn't
10 | ; a good way to do VGA -- just want a nice sawtooth for the ADC example!)
11 |
12 | out pins, 5
13 |
14 |
15 |
16 | % c-sdk {
17 | #include "hardware/clocks.h"
18 | static inline void resistor_dac_5bit_program_init(PIO pio, uint sm, uint offset,
19 | uint sample_rate_hz, uint pin_base) {
20 |
21 | pio_sm_set_pins_with_mask(pio, sm, 0, 0x1fu << pin_base);
22 | pio_sm_set_pindirs_with_mask(pio, sm, ~0u, 0x1fu << pin_base);
23 | for (int i = 0; i < 5; ++i)
24 | pio_gpio_init(pio, pin_base + i);
25 |
26 | pio_sm_config c = resistor_dac_5bit_program_get_default_config(offset);
27 | sm_config_set_out_pins(&c, pin_base, 5);
28 | // Shift to right, autopull threshold 5
29 | sm_config_set_out_shift(&c, true, true, 5);
30 | // Deeper FIFO as we're not doing any RX
31 | sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX);
32 | float div = (float)clock_get_hz(clk_sys) / sample_rate_hz;
33 | sm_config_set_clkdiv(&c, div);
34 |
35 | pio_sm_init(pio, sm, offset, &c);
36 | pio_sm_set_enabled(pio, sm, true);
37 | }
38 | %}
39 |
--------------------------------------------------------------------------------
/adc/hello_adc/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_adc
2 | hello_adc.c
3 | )
4 |
5 | target_link_libraries(hello_adc pico_stdlib hardware_adc)
6 |
7 | # create map/bin/hex file etc.
8 | pico_add_extra_outputs(hello_adc)
9 |
10 | # add url via pico_set_program_url
11 | example_auto_set_url(hello_adc)
12 |
--------------------------------------------------------------------------------
/adc/hello_adc/hello_adc.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 | #include "pico/stdlib.h"
9 | #include "hardware/gpio.h"
10 | #include "hardware/adc.h"
11 |
12 | int main() {
13 | stdio_init_all();
14 | printf("ADC Example, measuring GPIO26\n");
15 |
16 | adc_init();
17 |
18 | // Make sure GPIO is high-impedance, no pullups etc
19 | adc_gpio_init(26);
20 | // Select ADC input 0 (GPIO26)
21 | adc_select_input(0);
22 |
23 | while (1) {
24 | // 12-bit conversion, assume max value == ADC_VREF == 3.3 V
25 | const float conversion_factor = 3.3f / (1 << 12);
26 | uint16_t result = adc_read();
27 | printf("Raw value: 0x%03x, voltage: %f V\n", result, result * conversion_factor);
28 | sleep_ms(500);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/adc/joystick_display/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(joystick_display
2 | joystick_display.c
3 | )
4 |
5 | target_link_libraries(joystick_display pico_stdlib hardware_adc)
6 |
7 | # create map/bin/hex file etc.
8 | pico_add_extra_outputs(joystick_display)
9 |
10 | # add url via pico_set_program_url
11 | example_auto_set_url(joystick_display)
12 |
--------------------------------------------------------------------------------
/adc/joystick_display/joystick_display.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 | #include "pico/stdlib.h"
9 | #include "hardware/adc.h"
10 |
11 | int main() {
12 | stdio_init_all();
13 | adc_init();
14 | // Make sure GPIO is high-impedance, no pullups etc
15 | adc_gpio_init(26);
16 | adc_gpio_init(27);
17 |
18 | while (1) {
19 | adc_select_input(0);
20 | uint adc_x_raw = adc_read();
21 | adc_select_input(1);
22 | uint adc_y_raw = adc_read();
23 |
24 | // Display the joystick position something like this:
25 | // X: [ o ] Y: [ o ]
26 | const uint bar_width = 40;
27 | const uint adc_max = (1 << 12) - 1;
28 | uint bar_x_pos = adc_x_raw * bar_width / adc_max;
29 | uint bar_y_pos = adc_y_raw * bar_width / adc_max;
30 | printf("\rX: [");
31 | for (uint i = 0; i < bar_width; ++i)
32 | putchar( i == bar_x_pos ? 'o' : ' ');
33 | printf("] Y: [");
34 | for (uint i = 0; i < bar_width; ++i)
35 | putchar( i == bar_y_pos ? 'o' : ' ');
36 | printf("]");
37 | sleep_ms(50);
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/adc/microphone_adc/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(microphone_adc
2 | microphone_adc.c
3 | )
4 |
5 | # pull in common dependencies and adc hardware support
6 | target_link_libraries(microphone_adc pico_stdlib hardware_adc)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(microphone_adc)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(microphone_adc)
13 |
--------------------------------------------------------------------------------
/adc/microphone_adc/microphone_adc.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/adc/microphone_adc/microphone_adc.fzz
--------------------------------------------------------------------------------
/adc/microphone_adc/microphone_adc_bb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/adc/microphone_adc/microphone_adc_bb.png
--------------------------------------------------------------------------------
/adc/microphone_adc/microphone_adc_plotter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/adc/microphone_adc/microphone_adc_plotter.png
--------------------------------------------------------------------------------
/adc/onboard_temperature/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(onboard_temperature onboard_temperature.c)
2 |
3 | target_link_libraries(onboard_temperature pico_stdlib hardware_adc)
4 |
5 | # enable uart output, disable usb output
6 | pico_enable_stdio_uart(onboard_temperature 1)
7 | pico_enable_stdio_usb(onboard_temperature 0)
8 |
9 | # create map/bin/hex file etc.
10 | pico_add_extra_outputs(onboard_temperature)
11 |
12 | # add url via pico_set_program_url
13 | example_auto_set_url(onboard_temperature)
14 |
15 |
--------------------------------------------------------------------------------
/adc/read_vsys/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(power_status_adc INTERFACE)
2 | target_sources(power_status_adc INTERFACE
3 | ${CMAKE_CURRENT_LIST_DIR}/power_status.c
4 | )
5 | target_include_directories(power_status_adc INTERFACE
6 | ${CMAKE_CURRENT_LIST_DIR}
7 | )
8 | target_link_libraries(power_status_adc INTERFACE
9 | hardware_adc
10 | hardware_gpio
11 | )
12 |
13 | add_executable(read_vsys
14 | read_vsys.c
15 | )
16 | target_include_directories(read_vsys PRIVATE
17 | ${CMAKE_CURRENT_LIST_DIR}
18 | )
19 | target_link_libraries(read_vsys
20 | pico_stdlib
21 | power_status_adc
22 | )
23 | if (PICO_CYW43_SUPPORTED)
24 | target_link_libraries(read_vsys
25 | pico_cyw43_arch_none
26 | )
27 | endif()
28 |
29 | pico_add_extra_outputs(read_vsys)
30 | example_auto_set_url(read_vsys)
31 |
--------------------------------------------------------------------------------
/adc/read_vsys/power_status.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2023 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #ifndef POWER_STATUS_H
8 | #define POWER_STATUS_H
9 |
10 | /*!
11 | * \brief Get power source
12 | *
13 | * Returns whether battery powered
14 | * \note On boards that support Wi-Fi you must have called cyw43_arch_init first
15 | *
16 | * \param battery_powered True if powered by battery, False if powered by USB or another means
17 | * \return Zero if the battery status can be determined, an error code otherwise \see pico_error_codes
18 | */
19 |
20 | int power_source(bool *battery_powered);
21 |
22 | /*!
23 | * \brief Get system voltage
24 | *
25 | * Returns the system voltage
26 | * \note Must have called adc_init
27 | *
28 | * \param voltage Calculated voltage
29 | * \return Zero if the voltage can be determined, an error code otherwise \see pico_error_codes
30 | */
31 | int power_voltage(float *voltage);
32 |
33 | #endif
--------------------------------------------------------------------------------
/binary_info/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory_exclude_platforms(blink_any host)
2 | add_subdirectory_exclude_platforms(hello_anything host)
3 |
--------------------------------------------------------------------------------
/binary_info/blink_any/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (NOT PICO_CYW43_SUPPORTED)
2 | message("Only building blink_any for non W boards as PICO_CYW43_SUPPORTED is not set")
3 | endif()
4 |
5 | add_executable(blink_any
6 | blink_any.c
7 | )
8 |
9 | # pull in common dependencies
10 | target_link_libraries(blink_any pico_stdlib)
11 |
12 | if (PICO_CYW43_SUPPORTED)
13 | target_link_libraries(blink_any pico_cyw43_arch_none)
14 | endif()
15 |
16 | # create map/bin/hex file etc.
17 | pico_add_extra_outputs(blink_any)
18 |
19 | # add url via pico_set_program_url
20 | example_auto_set_url(blink_any)
21 |
--------------------------------------------------------------------------------
/binary_info/hello_anything/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET tinyusb_device)
2 | add_executable(hello_anything
3 | hello_anything.c
4 | )
5 |
6 | # pull in common dependencies
7 | target_link_libraries(hello_anything pico_stdlib)
8 |
9 | # enable usb and uart output
10 | pico_enable_stdio_usb(hello_anything 1)
11 | pico_enable_stdio_uart(hello_anything 1)
12 |
13 | # create map/bin/hex/uf2 file etc.
14 | pico_add_extra_outputs(hello_anything)
15 |
16 | # add url via pico_set_program_url
17 | example_auto_set_url(hello_anything)
18 | elseif(PICO_ON_DEVICE)
19 | message("Skipping hello_anything because TinyUSB submodule is not initialized in the SDK")
20 | endif()
21 |
--------------------------------------------------------------------------------
/binary_info/hello_anything/hello_anything.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 | #include "pico/stdlib.h"
9 | #include "pico/binary_info.h"
10 | #include "hardware/uart.h"
11 |
12 | int main() {
13 | // create feature groups to group configuration settings
14 | // these will also show up in picotool info, not just picotool config
15 | bi_decl(bi_program_feature_group(0x1111, 0, "UART Configuration"));
16 | bi_decl(bi_program_feature_group(0x1111, 1, "Enabled Interfaces"));
17 | // stdio_uart configuration and initialisation
18 | bi_decl(bi_ptr_int32(0x1111, 1, use_uart, 1));
19 | bi_decl(bi_ptr_int32(0x1111, 0, uart_num, 0));
20 | bi_decl(bi_ptr_int32(0x1111, 0, uart_tx, 0));
21 | bi_decl(bi_ptr_int32(0x1111, 0, uart_rx, 1));
22 | bi_decl(bi_ptr_int32(0x1111, 0, uart_baud, 115200));
23 | if (use_uart) {
24 | stdio_uart_init_full(UART_INSTANCE(uart_num), uart_baud, uart_tx, uart_rx);
25 | }
26 |
27 | // stdio_usb initialisation
28 | bi_decl(bi_ptr_int32(0x1111, 1, use_usb, 1));
29 | if (use_usb) {
30 | stdio_usb_init();
31 | }
32 |
33 | // default printed string
34 | bi_decl(bi_ptr_string(0, 0, text, "Hello, world!", 256));
35 |
36 | while (true) {
37 | printf("%s\n", text);
38 | sleep_ms(1000);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/blink/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(blink
2 | blink.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(blink pico_stdlib)
7 |
8 | if (PICO_CYW43_SUPPORTED)
9 | target_link_libraries(blink pico_cyw43_arch_none)
10 | endif()
11 |
12 | # create map/bin/hex file etc.
13 | pico_add_extra_outputs(blink)
14 |
15 | # add url via pico_set_program_url
16 | example_auto_set_url(blink)
17 |
--------------------------------------------------------------------------------
/blink_simple/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(blink_simple
2 | blink_simple.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(blink_simple pico_stdlib)
7 |
8 | # create map/bin/hex/uf2 file etc.
9 | pico_add_extra_outputs(blink_simple)
10 |
11 | # call pico_set_program_url to set path to example on github, so users can find the source for an example via picotool
12 | example_auto_set_url(blink_simple)
13 |
--------------------------------------------------------------------------------
/blink_simple/blink_simple.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include "pico/stdlib.h"
8 |
9 | #ifndef LED_DELAY_MS
10 | #define LED_DELAY_MS 250
11 | #endif
12 |
13 | #ifndef PICO_DEFAULT_LED_PIN
14 | #warning blink_simple example requires a board with a regular LED
15 | #endif
16 |
17 | // Initialize the GPIO for the LED
18 | void pico_led_init(void) {
19 | #ifdef PICO_DEFAULT_LED_PIN
20 | // A device like Pico that uses a GPIO for the LED will define PICO_DEFAULT_LED_PIN
21 | // so we can use normal GPIO functionality to turn the led on and off
22 | gpio_init(PICO_DEFAULT_LED_PIN);
23 | gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
24 | #endif
25 | }
26 |
27 | // Turn the LED on or off
28 | void pico_set_led(bool led_on) {
29 | #if defined(PICO_DEFAULT_LED_PIN)
30 | // Just set the GPIO on or off
31 | gpio_put(PICO_DEFAULT_LED_PIN, led_on);
32 | #endif
33 | }
34 |
35 | int main() {
36 | pico_led_init();
37 | while (true) {
38 | pico_set_led(true);
39 | sleep_ms(LED_DELAY_MS);
40 | pico_set_led(false);
41 | sleep_ms(LED_DELAY_MS);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/bootloaders/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET pico_mbedtls)
2 | # older clang seem to have a segment overlap issue that confuses picotool
3 | if (PICO_C_COMPILER_IS_CLANG AND CMAKE_C_COMPILER_VERSION VERSION_LESS "17.0.0")
4 | message("Skipping encrypted bootloader example on LLVM/Clang version < 17; please use GCC or newer LLVM/Clang")
5 | else()
6 | add_subdirectory_exclude_platforms(encrypted host rp2040 rp2350-riscv)
7 | endif()
8 | else()
9 | # Assume picotool has no signing support, if no pico_mbedtls available
10 | message("Skipping encrypted bootloader example as pico_mbedtls unavailable")
11 | endif ()
12 |
--------------------------------------------------------------------------------
/bootloaders/encrypted/README.md:
--------------------------------------------------------------------------------
1 | Replace private.pem and privateaes.bin with your own keys - your signing key must be for the _secp256k1_ curve, in PEM format. You can create a .PEM file with:
2 |
3 | ```bash
4 | openssl ecparam -name secp256k1 -genkey -out private.pem
5 | ```
6 |
7 | The AES key is just be a 32 byte binary file - you can create one with
8 |
9 | ```bash
10 | dd if=/dev/urandom of=privateaes.bin bs=1 count=32
11 | ```
12 |
13 | Then either drag & drop the UF2 files to the device in order (enc_bootloader first, then hello_serial_enc) waiting for a reboot in-between, or run
14 | ```bash
15 | picotool load enc_bootloader.uf2
16 | picotool reboot -u
17 | picotool load -x hello_serial_enc.uf2
18 | ```
19 |
--------------------------------------------------------------------------------
/bootloaders/encrypted/enc-pt.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": [1, 0],
3 | "unpartitioned": {
4 | "families": ["absolute"],
5 | "permissions": {
6 | "secure": "rw",
7 | "nonsecure": "rw",
8 | "bootloader": "rw"
9 | }
10 | },
11 | "partitions": [
12 | {
13 | "name": "A",
14 | "id": 0,
15 | "start": "64K",
16 | "size": "448K",
17 | "families": ["rp2350-arm-s"],
18 | "permissions": {
19 | "secure": "rw",
20 | "nonsecure": "rw",
21 | "bootloader": "rw"
22 | }
23 | },
24 | {
25 | "name": "B",
26 | "id": 1,
27 | "size": "448K",
28 | "families": ["rp2350-arm-s"],
29 | "permissions": {
30 | "secure": "rw",
31 | "nonsecure": "rw",
32 | "bootloader": "rw"
33 | },
34 | "link": ["a", 0]
35 | }
36 | ]
37 | }
--------------------------------------------------------------------------------
/bootloaders/encrypted/hello_serial.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 | #include "pico/stdlib.h"
9 |
10 | int main() {
11 | stdio_init_all();
12 | while (true) {
13 | printf("Hello, world!\n");
14 | printf("I'm an encrypted binary\n");
15 | sleep_ms(1000);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/bootloaders/encrypted/otp.json:
--------------------------------------------------------------------------------
1 | {
2 | "30:0" :
3 | {
4 | "ecc" : true,
5 | "value" :
6 | [
7 | "0x00",
8 | "0x01",
9 | "0x02",
10 | "0x03",
11 | "0x04",
12 | "0x05",
13 | "0x06",
14 | "0x07",
15 | "0x08",
16 | "0x09",
17 | "0x0a",
18 | "0x0b",
19 | "0x0c",
20 | "0x0d",
21 | "0x0e",
22 | "0x0f",
23 | "0x00",
24 | "0x10",
25 | "0x20",
26 | "0x30",
27 | "0x40",
28 | "0x50",
29 | "0x60",
30 | "0x70",
31 | "0x80",
32 | "0x90",
33 | "0xa0",
34 | "0xb0",
35 | "0xc0",
36 | "0xd0",
37 | "0xe0",
38 | "0xf0"
39 | ]
40 | },
41 | "OTP_DATA_KEY1" : [ 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 ],
42 | "OTP_DATA_KEY1_VALID" : "0x010101",
43 | "OTP_DATA_KEY2" : [ 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0 ],
44 | "OTP_DATA_KEY2_VALID" : "0x010101",
45 | "PAGE30_LOCK0" : "0x4a4a4a"
46 | }
--------------------------------------------------------------------------------
/bootloaders/encrypted/private.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN EC PARAMETERS-----
2 | BgUrgQQACg==
3 | -----END EC PARAMETERS-----
4 | -----BEGIN EC PRIVATE KEY-----
5 | MHQCAQEEIAXAdiilH8wT07TESUzWPt+BY9+NcchvYU3xbnpK+CBNoAcGBSuBBAAK
6 | oUQDQgAEYYJtMQFGW4AB94tU3u/Qir5sRcYjBYMqCa+8gxsYd9OwMS3dqWKsnVBz
7 | dyy7bFWdJzXDMb9o20xRRd57Q9xSYw==
8 | -----END EC PRIVATE KEY-----
9 |
--------------------------------------------------------------------------------
/bootloaders/encrypted/privateaes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/bootloaders/encrypted/privateaes.bin
--------------------------------------------------------------------------------
/bootloaders/encrypted/update-key.cmake:
--------------------------------------------------------------------------------
1 | if (CMAKE_VERSION VERSION_LESS 3.19)
2 | # Check if keyfile is not the default, and print warning
3 | file(READ ${CMAKE_CURRENT_LIST_DIR}/privateaes.bin key_file HEX)
4 | if (NOT ${key_file} STREQUAL "000102030405060708090a0b0c0d0e0f00102030405060708090a0b0c0d0e0f0")
5 | message(WARNING
6 | "Encrypted bootloader AES key not updated in otp.json file, as CMake version is < 3.19"
7 | " - you will need to change the key in otp.json manually and re-run the build"
8 | )
9 | endif()
10 | else()
11 | # Read the JSON file.
12 | file(READ ${CMAKE_CURRENT_LIST_DIR}/otp.json json_string)
13 | # Read the key file
14 | file(READ ${CMAKE_CURRENT_LIST_DIR}/privateaes.bin key_file HEX)
15 |
16 | # adds '0x' prefix, comma suffix, and quotes for every byte
17 | string(REGEX REPLACE "([0-9a-f][0-9a-f])" "\"0x\\1\", " key_file ${key_file})
18 | set(key_file_json "[${key_file}]")
19 |
20 | string(JSON json_string SET ${json_string} "30:0" "value" ${key_file_json})
21 |
22 | file(WRITE ${CMAKE_CURRENT_LIST_DIR}/otp.json ${json_string})
23 | endif()
24 |
--------------------------------------------------------------------------------
/clocks/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET hardware_clocks)
2 | add_subdirectory_exclude_platforms(detached_clk_peri)
3 | add_subdirectory_exclude_platforms(hello_48MHz)
4 | add_subdirectory_exclude_platforms(hello_gpout)
5 | add_subdirectory_exclude_platforms(hello_resus)
6 | else()
7 | message("Skipping clocks examples as hardware_clocks is unavailable on this platform")
8 | endif()
--------------------------------------------------------------------------------
/clocks/detached_clk_peri/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(clocks_detached_clk_peri
2 | detached_clk_peri.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(clocks_detached_clk_peri pico_stdlib)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(clocks_detached_clk_peri)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(clocks_detached_clk_peri)
13 |
--------------------------------------------------------------------------------
/clocks/hello_48MHz/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_48MHz
2 | hello_48MHz.c
3 | )
4 |
5 | # pull in common dependencies and additional clocks hardware support
6 | target_link_libraries(hello_48MHz pico_stdlib hardware_clocks)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(hello_48MHz)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(hello_48MHz)
13 |
--------------------------------------------------------------------------------
/clocks/hello_gpout/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_gpout
2 | hello_gpout.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(hello_gpout pico_stdlib)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(hello_gpout)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(hello_gpout)
13 |
--------------------------------------------------------------------------------
/clocks/hello_gpout/hello_gpout.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 | #include "pico/stdlib.h"
9 | #include "hardware/clocks.h"
10 |
11 |
12 | int main() {
13 | stdio_init_all();
14 | printf("Hello gpout\n");
15 |
16 | // Output clk_sys / 10 to gpio 21, etc...
17 | clock_gpio_init(21, CLOCKS_CLK_GPOUT0_CTRL_AUXSRC_VALUE_CLK_SYS, 10);
18 | clock_gpio_init(23, CLOCKS_CLK_GPOUT1_CTRL_AUXSRC_VALUE_CLK_USB, 10);
19 | clock_gpio_init(24, CLOCKS_CLK_GPOUT2_CTRL_AUXSRC_VALUE_CLK_ADC, 10);
20 | #if PICO_RP2040
21 | clock_gpio_init(25, CLOCKS_CLK_GPOUT3_CTRL_AUXSRC_VALUE_CLK_RTC, 10);
22 | #else
23 | clock_gpio_init(25, CLOCKS_CLK_GPOUT3_CTRL_AUXSRC_VALUE_CLK_PERI, 10);
24 | #endif
25 |
26 | return 0;
27 | }
28 |
--------------------------------------------------------------------------------
/clocks/hello_resus/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_resus
2 | hello_resus.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(hello_resus pico_stdlib)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(hello_resus)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(hello_resus)
13 |
--------------------------------------------------------------------------------
/clocks/hello_resus/hello_resus.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 | #include "pico/stdlib.h"
9 | #include "hardware/clocks.h"
10 | #include "hardware/pll.h"
11 |
12 | volatile bool seen_resus;
13 |
14 | void resus_callback(void) {
15 | // Reconfigure PLL sys back to the default state of 1500 / 6 / 2 = 125MHz
16 | pll_init(pll_sys, 1, 1500 * MHZ, 6, 2);
17 |
18 | // CLK SYS = PLL SYS (125MHz) / 1 = 125MHz
19 | clock_configure(clk_sys,
20 | CLOCKS_CLK_SYS_CTRL_SRC_VALUE_CLKSRC_CLK_SYS_AUX,
21 | CLOCKS_CLK_SYS_CTRL_AUXSRC_VALUE_CLKSRC_PLL_SYS,
22 | 125 * MHZ,
23 | 125 * MHZ);
24 |
25 | // Reconfigure uart as clocks have changed
26 | stdio_init_all();
27 | printf("Resus event fired\n");
28 |
29 | // Wait for uart output to finish
30 | uart_default_tx_wait_blocking();
31 |
32 | seen_resus = true;
33 | }
34 |
35 | int main() {
36 | stdio_init_all();
37 | printf("Hello resus\n");
38 |
39 | seen_resus = false;
40 |
41 | clocks_enable_resus(&resus_callback);
42 | // Break PLL sys
43 | pll_deinit(pll_sys);
44 |
45 | while(!seen_resus);
46 |
47 | return 0;
48 | }
49 |
--------------------------------------------------------------------------------
/cmake/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory_exclude_platforms(build_variants)
--------------------------------------------------------------------------------
/cmake/build_variants/main.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 | #include "pico/stdlib.h"
9 | #include "other.h"
10 |
11 | int main() {
12 | stdio_init_all();
13 | do_other();
14 | #ifdef DO_EXTRA
15 | printf("A little extra\n");
16 | #endif
17 | return 0;
18 | }
--------------------------------------------------------------------------------
/cmake/build_variants/other.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 | #include "other.h"
9 |
10 | void do_other() {
11 | printf("The common thing is %d\n",
12 | A_DEFINE_THAT_IS_SHARED);
13 | printf("The binary local thing is %d\n",
14 | A_DEFINE_THAT_IS_NOT_SHARED);
15 | }
--------------------------------------------------------------------------------
/cmake/build_variants/other.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | void do_other();
--------------------------------------------------------------------------------
/dcp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory_exclude_platforms(hello_dcp host rp2040 rp2350-riscv)
--------------------------------------------------------------------------------
/dcp/hello_dcp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_dcp
2 | hello_dcp.c
3 | dcp_examples.S
4 | )
5 |
6 | # pull in common dependencies
7 | target_link_libraries(hello_dcp pico_stdlib)
8 |
9 | # we need a high-precision printf to demonstrate dotx properly
10 | pico_set_printf_implementation(hello_dcp compiler)
11 |
12 | # create map/bin/hex file etc.
13 | pico_add_extra_outputs(hello_dcp)
14 |
15 | # add url via pico_set_program_url
16 | example_auto_set_url(hello_dcp)
--------------------------------------------------------------------------------
/divider/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET hardware_divider)
2 | add_executable(hello_divider
3 | hello_divider.c
4 | )
5 |
6 | # pull in common dependencies
7 | target_link_libraries(hello_divider pico_stdlib)
8 |
9 | # create map/bin/hex file etc.
10 | pico_add_extra_outputs(hello_divider)
11 |
12 | # add url via pico_set_program_url
13 | example_auto_set_url(hello_divider)
14 | else()
15 | message("Skipping divider examples as hardware_divider is unavailable on this platform")
16 | endif()
17 |
--------------------------------------------------------------------------------
/dma/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET hardware_dma)
2 | add_subdirectory_exclude_platforms(channel_irq)
3 | add_subdirectory_exclude_platforms(control_blocks)
4 | add_subdirectory_exclude_platforms(hello_dma)
5 | add_subdirectory_exclude_platforms(sniff_crc)
6 | else()
7 | message("Skipping DMA examples as hardware_dma is unavailable on this platform")
8 | endif()
9 |
10 |
--------------------------------------------------------------------------------
/dma/channel_irq/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(dma_channel_irq
2 | channel_irq.c
3 | )
4 |
5 | pico_generate_pio_header(dma_channel_irq ${CMAKE_CURRENT_LIST_DIR}/pio_serialiser.pio)
6 |
7 | target_link_libraries(dma_channel_irq
8 | pico_stdlib
9 | hardware_dma
10 | hardware_irq
11 | hardware_pio
12 | )
13 |
14 | # create map/bin/hex file etc.
15 | pico_add_extra_outputs(dma_channel_irq)
16 |
17 | # add url via pico_set_program_url
18 | example_auto_set_url(dma_channel_irq)
19 |
--------------------------------------------------------------------------------
/dma/channel_irq/pio_serialiser.pio:
--------------------------------------------------------------------------------
1 | ;
2 | ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | ;
4 | ; SPDX-License-Identifier: BSD-3-Clause
5 | ;
6 |
7 | .program pio_serialiser
8 |
9 | ; Just serialise a stream of bits. Take 32 bits from each FIFO record. LSB-first.
10 |
11 | .wrap_target
12 | out pins, 1
13 | .wrap
14 |
15 | % c-sdk {
16 | static inline void pio_serialiser_program_init(PIO pio, uint sm, uint offset, uint data_pin, float clk_div) {
17 | pio_gpio_init(pio, data_pin);
18 | pio_sm_set_consecutive_pindirs(pio, sm, data_pin, 1, true);
19 | pio_sm_config c = pio_serialiser_program_get_default_config(offset);
20 | sm_config_set_out_pins(&c, data_pin, 1);
21 | sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX);
22 | sm_config_set_clkdiv(&c, clk_div);
23 | sm_config_set_out_shift(&c, true, true, 32);
24 | pio_sm_init(pio, sm, offset, &c);
25 | pio_sm_set_enabled(pio, sm, true);
26 | }
27 | %}
28 |
--------------------------------------------------------------------------------
/dma/control_blocks/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(dma_control_blocks
2 | control_blocks.c
3 | )
4 |
5 | target_link_libraries(dma_control_blocks pico_stdlib hardware_dma)
6 |
7 | # create map/bin/hex file etc.
8 | pico_add_extra_outputs(dma_control_blocks)
9 |
10 | # add url via pico_set_program_url
11 | example_auto_set_url(dma_control_blocks)
12 |
--------------------------------------------------------------------------------
/dma/hello_dma/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_dma
2 | hello_dma.c
3 | )
4 |
5 | target_link_libraries(hello_dma pico_stdlib hardware_dma)
6 |
7 | # create map/bin/hex file etc.
8 | pico_add_extra_outputs(hello_dma)
9 |
10 | # add url via pico_set_program_url
11 | example_auto_set_url(hello_dma)
12 |
--------------------------------------------------------------------------------
/dma/sniff_crc/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(sniff_crc
2 | sniff_crc.c
3 | )
4 |
5 | target_link_libraries(sniff_crc pico_stdlib hardware_dma)
6 |
7 | # create map/bin/hex file etc.
8 | pico_add_extra_outputs(sniff_crc)
9 |
10 | # add url via pico_set_program_url
11 | example_auto_set_url(sniff_crc)
12 |
--------------------------------------------------------------------------------
/example_auto_set_url.cmake:
--------------------------------------------------------------------------------
1 | set(PICO_EXAMPLE_URL_BASE "https://github.com/raspberrypi/pico-examples/tree/HEAD")
2 | macro(example_auto_set_url TARGET)
3 | file(RELATIVE_PATH URL_REL_PATH "${PICO_EXAMPLES_PATH}" "${CMAKE_CURRENT_LIST_DIR}")
4 | pico_set_program_url(${TARGET} "${PICO_EXAMPLE_URL_BASE}/${URL_REL_PATH}")
5 | endmacro()
--------------------------------------------------------------------------------
/flash/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET hardware_flash)
2 | add_subdirectory_exclude_platforms(cache_perfctr "rp2350.*")
3 | add_subdirectory_exclude_platforms(nuke)
4 | add_subdirectory_exclude_platforms(program)
5 | add_subdirectory_exclude_platforms(ssi_dma "rp2350.*")
6 | add_subdirectory_exclude_platforms(xip_stream)
7 | add_subdirectory_exclude_platforms(runtime_flash_permissions rp2040)
8 | else()
9 | message("Skipping flash examples as hardware_flash is unavailable on this platform")
10 | endif()
--------------------------------------------------------------------------------
/flash/cache_perfctr/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(flash_cache_perfctr
2 | flash_cache_perfctr.c
3 | )
4 |
5 | target_link_libraries(flash_cache_perfctr
6 | pico_stdlib
7 | )
8 |
9 | # create map/bin/hex file etc.
10 | pico_add_extra_outputs(flash_cache_perfctr)
11 |
12 | # add url via pico_set_program_url
13 | example_auto_set_url(flash_cache_perfctr)
14 |
--------------------------------------------------------------------------------
/flash/nuke/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(flash_nuke
2 | nuke.c
3 | )
4 |
5 | target_link_libraries(flash_nuke
6 | pico_stdlib
7 | hardware_flash
8 | )
9 |
10 | # It doesn't make sense to run this program from flash. Always build a
11 | # RAM-only binary.
12 | pico_set_binary_type(flash_nuke no_flash)
13 |
14 | pico_add_extra_outputs(flash_nuke)
15 |
16 | # add url via pico_set_program_url
17 | example_auto_set_url(flash_nuke)
18 |
19 |
--------------------------------------------------------------------------------
/flash/program/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(flash_program
2 | flash_program.c
3 | )
4 |
5 | target_link_libraries(flash_program
6 | pico_stdlib
7 | hardware_flash
8 | )
9 |
10 | # create map/bin/hex file etc.
11 | pico_add_extra_outputs(flash_program)
12 |
13 | # add url via pico_set_program_url
14 | example_auto_set_url(flash_program)
15 |
--------------------------------------------------------------------------------
/flash/runtime_flash_permissions/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(runtime_flash_permissions
2 | runtime_flash_permissions.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(runtime_flash_permissions pico_stdlib)
7 |
8 | # not necessary for the example functionality, but shows you how you would add a partition table
9 | pico_embed_pt_in_binary(runtime_flash_permissions ${CMAKE_CURRENT_LIST_DIR}/pt.json)
10 |
11 | # create map/bin/hex/uf2 file etc.
12 | pico_add_extra_outputs(runtime_flash_permissions)
13 |
14 | # add url via pico_set_program_url
15 | example_auto_set_url(runtime_flash_permissions)
16 |
--------------------------------------------------------------------------------
/flash/runtime_flash_permissions/pt.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": [1, 0],
3 | "unpartitioned": {
4 | "families": ["absolute"],
5 | "permissions": {
6 | "bootloader": "rw"
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/flash/ssi_dma/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(flash_ssi_dma
2 | flash_ssi_dma.c
3 | )
4 |
5 | target_link_libraries(flash_ssi_dma
6 | pico_stdlib
7 | hardware_dma
8 | hardware_sync
9 | )
10 |
11 | # create map/bin/hex file etc.
12 | pico_add_extra_outputs(flash_ssi_dma)
13 |
14 | # add url via pico_set_program_url
15 | example_auto_set_url(flash_ssi_dma)
--------------------------------------------------------------------------------
/flash/xip_stream/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(flash_xip_stream
2 | flash_xip_stream.c
3 | )
4 |
5 | target_link_libraries(flash_xip_stream
6 | pico_stdlib
7 | hardware_dma
8 | )
9 |
10 | # create map/bin/hex file etc.
11 | pico_add_extra_outputs(flash_xip_stream)
12 |
13 | # add url via pico_set_program_url
14 | example_auto_set_url(flash_xip_stream)
15 |
--------------------------------------------------------------------------------
/freertos/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (NOT FREERTOS_KERNEL_PATH AND NOT DEFINED ENV{FREERTOS_KERNEL_PATH})
2 | message("Skipping FreeRTOS examples as FREERTOS_KERNEL_PATH not defined")
3 | return()
4 | endif()
5 |
6 | include(FreeRTOS_Kernel_import.cmake)
7 |
8 | add_subdirectory(hello_freertos)
9 |
--------------------------------------------------------------------------------
/freertos/FreeRTOSConfig.h:
--------------------------------------------------------------------------------
1 | #ifndef FREERTOS_CONFIG_H
2 | #define FREERTOS_CONFIG_H
3 |
4 | // This example uses a common include to avoid repetition
5 | #include "FreeRTOSConfig_examples_common.h"
6 |
7 | #endif
8 |
--------------------------------------------------------------------------------
/freertos/hello_freertos/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(TARGET_NAME hello_freertos1)
2 | add_executable(${TARGET_NAME}
3 | hello_freertos.c
4 | )
5 | target_include_directories(${TARGET_NAME} PRIVATE
6 | ${CMAKE_CURRENT_LIST_DIR}/..
7 | )
8 | target_link_libraries(${TARGET_NAME} PRIVATE
9 | pico_async_context_freertos
10 | FreeRTOS-Kernel-Heap4
11 | pico_stdlib
12 | )
13 | if(PICO_CYW43_SUPPORTED)
14 | # For led support on pico_w
15 | target_link_libraries(${TARGET_NAME} PRIVATE
16 | pico_cyw43_arch_none
17 | )
18 | endif()
19 | target_compile_definitions(${TARGET_NAME} PRIVATE
20 | configNUMBER_OF_CORES=1
21 | )
22 | pico_add_extra_outputs(${TARGET_NAME})
23 |
24 | set(TARGET_NAME hello_freertos2)
25 | add_executable(${TARGET_NAME}
26 | hello_freertos.c
27 | )
28 | target_include_directories(${TARGET_NAME} PRIVATE
29 | ${CMAKE_CURRENT_LIST_DIR}/..
30 | )
31 | target_link_libraries(${TARGET_NAME} PRIVATE
32 | pico_async_context_freertos
33 | FreeRTOS-Kernel-Heap4
34 | pico_stdlib
35 | )
36 | if(PICO_CYW43_SUPPORTED)
37 | # For led support on pico_w
38 | target_link_libraries(${TARGET_NAME} PRIVATE
39 | pico_cyw43_arch_none
40 | )
41 | endif()
42 | pico_add_extra_outputs(${TARGET_NAME})
43 |
--------------------------------------------------------------------------------
/gpio/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory_exclude_platforms(dht_sensor host)
2 | add_subdirectory_exclude_platforms(hello_7segment host)
3 | add_subdirectory_exclude_platforms(hello_gpio_irq host)
4 |
--------------------------------------------------------------------------------
/gpio/dht_sensor/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(dht
2 | dht.c
3 | )
4 |
5 | target_link_libraries(dht pico_stdlib)
6 |
7 | pico_add_extra_outputs(dht)
8 |
9 | # add url via pico_set_program_url
10 | example_auto_set_url(dht)
11 |
12 |
--------------------------------------------------------------------------------
/gpio/dht_sensor/pi-and-pico-uart-and-dht-sensor.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/gpio/dht_sensor/pi-and-pico-uart-and-dht-sensor.fzz
--------------------------------------------------------------------------------
/gpio/dht_sensor/pi-and-pico-uart-and-dht-sensor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/gpio/dht_sensor/pi-and-pico-uart-and-dht-sensor.png
--------------------------------------------------------------------------------
/gpio/dht_sensor/serial-output.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/gpio/dht_sensor/serial-output.png
--------------------------------------------------------------------------------
/gpio/hello_7segment/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_7segment
2 | hello_7segment.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(hello_7segment pico_stdlib)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(hello_7segment)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(hello_7segment)
13 |
--------------------------------------------------------------------------------
/gpio/hello_7segment/hello_7segment.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/gpio/hello_7segment/hello_7segment.fzz
--------------------------------------------------------------------------------
/gpio/hello_7segment/hello_7segment_bb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/gpio/hello_7segment/hello_7segment_bb.png
--------------------------------------------------------------------------------
/gpio/hello_gpio_irq/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_gpio_irq
2 | hello_gpio_irq.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(hello_gpio_irq pico_stdlib)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(hello_gpio_irq)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(hello_gpio_irq)
13 |
--------------------------------------------------------------------------------
/hello_world/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory_exclude_platforms(serial)
2 | add_subdirectory_exclude_platforms(usb)
3 |
--------------------------------------------------------------------------------
/hello_world/serial/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_serial
2 | hello_serial.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(hello_serial pico_stdlib)
7 |
8 | # create map/bin/hex/uf2 file etc.
9 | pico_add_extra_outputs(hello_serial)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(hello_serial)
13 |
--------------------------------------------------------------------------------
/hello_world/serial/hello_serial.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 | #include "pico/stdlib.h"
9 |
10 | int main() {
11 | stdio_init_all();
12 | while (true) {
13 | printf("Hello, world!\n");
14 | sleep_ms(1000);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/hello_world/usb/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET tinyusb_device)
2 | add_executable(hello_usb
3 | hello_usb.c
4 | )
5 |
6 | # pull in common dependencies
7 | target_link_libraries(hello_usb pico_stdlib)
8 |
9 | # enable usb output, disable uart output
10 | pico_enable_stdio_usb(hello_usb 1)
11 | pico_enable_stdio_uart(hello_usb 0)
12 |
13 | # create map/bin/hex/uf2 file etc.
14 | pico_add_extra_outputs(hello_usb)
15 |
16 | # add url via pico_set_program_url
17 | example_auto_set_url(hello_usb)
18 | elseif(PICO_ON_DEVICE)
19 | message("Skipping hello_usb because TinyUSB submodule is not initialized in the SDK")
20 | endif()
21 |
--------------------------------------------------------------------------------
/hello_world/usb/hello_usb.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 | #include "pico/stdlib.h"
9 |
10 | int main() {
11 | stdio_init_all();
12 | while (true) {
13 | printf("Hello, world!\n");
14 | sleep_ms(1000);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/hstx/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory_exclude_platforms(dvi_out_hstx_encoder host rp2040)
2 | add_subdirectory_exclude_platforms(spi_lcd host rp2040)
3 |
--------------------------------------------------------------------------------
/hstx/dvi_out_hstx_encoder/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(dvi_out_hstx_encoder
2 | dvi_out_hstx_encoder.c
3 | )
4 |
5 | target_include_directories(dvi_out_hstx_encoder PRIVATE
6 | ${CMAKE_CURRENT_LIST_DIR}/images
7 | )
8 |
9 | # pull in common dependencies
10 | target_link_libraries(dvi_out_hstx_encoder
11 | pico_stdlib
12 | pico_multicore
13 | hardware_dma
14 | pico_sync
15 | )
16 |
17 | # create map/bin/hex/uf2 file etc.
18 | pico_add_extra_outputs(dvi_out_hstx_encoder)
19 |
--------------------------------------------------------------------------------
/hstx/spi_lcd/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hstx_spi_lcd
2 | hstx_spi_lcd.c
3 | )
4 |
5 | target_include_directories(hstx_spi_lcd PRIVATE
6 | ${CMAKE_CURRENT_LIST_DIR}/images
7 | )
8 |
9 | # pull in common dependencies
10 | target_link_libraries(hstx_spi_lcd
11 | pico_stdlib
12 | pico_sync
13 | )
14 |
15 | # create map/bin/hex/uf2 file etc.
16 | pico_add_extra_outputs(hstx_spi_lcd)
17 |
--------------------------------------------------------------------------------
/i2c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET hardware_i2c)
2 | add_subdirectory_exclude_platforms(bmp280_i2c)
3 | add_subdirectory_exclude_platforms(bus_scan)
4 | add_subdirectory_exclude_platforms(lcd_1602_i2c)
5 | add_subdirectory_exclude_platforms(lis3dh_i2c)
6 | add_subdirectory_exclude_platforms(mcp9808_i2c)
7 | add_subdirectory_exclude_platforms(mma8451_i2c)
8 | add_subdirectory_exclude_platforms(mpl3115a2_i2c)
9 | add_subdirectory_exclude_platforms(mpu6050_i2c)
10 | add_subdirectory_exclude_platforms(ssd1306_i2c)
11 | add_subdirectory_exclude_platforms(pa1010d_i2c)
12 | add_subdirectory_exclude_platforms(pcf8523_i2c)
13 | add_subdirectory_exclude_platforms(ht16k33_i2c)
14 | add_subdirectory_exclude_platforms(slave_mem_i2c)
15 | else()
16 | message("Skipping I2C examples as hardware_i2c is unavailable on this platform")
17 | endif()
18 |
--------------------------------------------------------------------------------
/i2c/bmp280_i2c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(bmp280_i2c
2 | bmp280_i2c.c
3 | )
4 |
5 | # pull in common dependencies and additional i2c hardware support
6 | target_link_libraries(bmp280_i2c pico_stdlib hardware_i2c)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(bmp280_i2c)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(bmp280_i2c)
13 |
--------------------------------------------------------------------------------
/i2c/bmp280_i2c/bmp280_i2c.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/bmp280_i2c/bmp280_i2c.fzz
--------------------------------------------------------------------------------
/i2c/bmp280_i2c/bmp280_i2c_bb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/bmp280_i2c/bmp280_i2c_bb.png
--------------------------------------------------------------------------------
/i2c/bus_scan/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(i2c_bus_scan
2 | bus_scan.c
3 | )
4 |
5 | # pull in common dependencies and additional i2c hardware support
6 | target_link_libraries(i2c_bus_scan pico_stdlib hardware_i2c)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(i2c_bus_scan)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(i2c_bus_scan)
13 |
--------------------------------------------------------------------------------
/i2c/ht16k33_i2c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(ht16k33_i2c
2 | ht16k33_i2c.c
3 | )
4 |
5 | # pull in common dependencies and additional i2c hardware support
6 | target_link_libraries(ht16k33_i2c pico_stdlib hardware_i2c)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(ht16k33_i2c)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(ht16k33_i2c)
13 |
--------------------------------------------------------------------------------
/i2c/lcd_1602_i2c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(lcd_1602_i2c
2 | lcd_1602_i2c.c
3 | )
4 |
5 | # pull in common dependencies and additional i2c hardware support
6 | target_link_libraries(lcd_1602_i2c pico_stdlib hardware_i2c)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(lcd_1602_i2c)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(lcd_1602_i2c)
13 |
--------------------------------------------------------------------------------
/i2c/lcd_1602_i2c/lcd_1602_i2c.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/lcd_1602_i2c/lcd_1602_i2c.fzz
--------------------------------------------------------------------------------
/i2c/lcd_1602_i2c/lcd_1602_i2c_bb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/lcd_1602_i2c/lcd_1602_i2c_bb.png
--------------------------------------------------------------------------------
/i2c/lis3dh_i2c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(lis3dh_i2c
2 | lis3dh_i2c.c
3 | )
4 |
5 | # pull in common dependencies and additional i2c hardware support
6 | target_link_libraries(lis3dh_i2c pico_stdlib hardware_i2c)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(lis3dh_i2c)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(lis3dh_i2c)
13 |
--------------------------------------------------------------------------------
/i2c/lis3dh_i2c/lis3dh_i2c.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/lis3dh_i2c/lis3dh_i2c.fzz
--------------------------------------------------------------------------------
/i2c/lis3dh_i2c/lis3dh_i2c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/lis3dh_i2c/lis3dh_i2c.png
--------------------------------------------------------------------------------
/i2c/mcp9808_i2c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(mcp9808_i2c
2 | mcp9808_i2c.c
3 | )
4 |
5 | # pull in common dependencies and additional i2c hardware support
6 | target_link_libraries(mcp9808_i2c pico_stdlib hardware_i2c)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(mcp9808_i2c)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(mcp9808_i2c)
--------------------------------------------------------------------------------
/i2c/mcp9808_i2c/README.adoc:
--------------------------------------------------------------------------------
1 | = Attaching a MCP9808 digital temperature sensor via I2C
2 |
3 | This example code shows how to interface the Raspberry Pi Pico to the MCP9808 digital temperature sensor board.
4 |
5 | This example reads the ambient temperature value each second from the sensor and sets upper, lower and critical limits for the temperature and checks if alerts need to be raised. The CONFIG register can also be used to check for an alert if the critical temperature is surpassed.
6 |
7 | == Wiring information
8 |
9 | Wiring up the device requires 4 jumpers, to connect VDD, GND, SDA and SCL. The example here uses I2C port 0, which is assigned to GPIO 4 (SDA) and 5 (SCL) in software. Power is supplied from the VSYS pin.
10 |
11 | [[mcp9808_i2c_wiring]]
12 | [pdfwidth=75%]
13 | .Wiring Diagram for MCP9808.
14 | image::mcp9808_i2c.png[]
15 |
16 | == List of Files
17 |
18 | CMakeLists.txt:: CMake file to incorporate the example in to the examples build tree.
19 | mcp9808_i2c.c:: The example code.
20 |
21 | == Bill of Materials
22 |
23 | .A list of materials required for the example
24 | [[mcp9808-bom-table]]
25 | [cols=3]
26 | |===
27 | | *Item* | *Quantity* | Details
28 | | Breadboard | 1 | generic part
29 | | Raspberry Pi Pico | 1 | https://www.raspberrypi.com/products/raspberry-pi-pico/
30 | | MCP9808 board| 1 | https://www.adafruit.com/product/1782
31 | | M/M Jumper wires | 4 | generic part
32 | |===
33 |
34 |
35 |
--------------------------------------------------------------------------------
/i2c/mcp9808_i2c/mcp9808_i2c.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/mcp9808_i2c/mcp9808_i2c.fzz
--------------------------------------------------------------------------------
/i2c/mcp9808_i2c/mcp9808_i2c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/mcp9808_i2c/mcp9808_i2c.png
--------------------------------------------------------------------------------
/i2c/mma8451_i2c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(mma8451_i2c
2 | mma8451_i2c.c
3 | )
4 | # pull in common dependencies and additional i2c hardware support
5 | target_link_libraries(mma8451_i2c pico_stdlib hardware_i2c)
6 |
7 | # create map/bin/hex file etc.
8 | pico_add_extra_outputs(mma8451_i2c)
9 |
10 | # add url via pico_set_program_url
11 | example_auto_set_url(mma8451_i2c)
12 |
--------------------------------------------------------------------------------
/i2c/mma8451_i2c/mma8451_i2c.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/mma8451_i2c/mma8451_i2c.fzz
--------------------------------------------------------------------------------
/i2c/mma8451_i2c/mma8451_i2c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/mma8451_i2c/mma8451_i2c.png
--------------------------------------------------------------------------------
/i2c/mpl3115a2_i2c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(mpl3115a2_i2c
2 | mpl3115a2_i2c.c
3 | )
4 |
5 | # pull in common dependencies and additional i2c hardware support
6 | target_link_libraries(mpl3115a2_i2c pico_stdlib hardware_i2c)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(mpl3115a2_i2c)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(mpl3115a2_i2c)
13 |
--------------------------------------------------------------------------------
/i2c/mpl3115a2_i2c/mpl3115a2_i2c.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/mpl3115a2_i2c/mpl3115a2_i2c.fzz
--------------------------------------------------------------------------------
/i2c/mpl3115a2_i2c/mpl3115a2_i2c_bb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/mpl3115a2_i2c/mpl3115a2_i2c_bb.png
--------------------------------------------------------------------------------
/i2c/mpu6050_i2c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(mpu6050_i2c
2 | mpu6050_i2c.c
3 | )
4 |
5 | # pull in common dependencies and additional i2c hardware support
6 | target_link_libraries(mpu6050_i2c pico_stdlib hardware_i2c)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(mpu6050_i2c)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(mpu6050_i2c)
13 |
--------------------------------------------------------------------------------
/i2c/mpu6050_i2c/mpu6050_i2c.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/mpu6050_i2c/mpu6050_i2c.fzz
--------------------------------------------------------------------------------
/i2c/mpu6050_i2c/mpu6050_i2c_bb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/mpu6050_i2c/mpu6050_i2c_bb.png
--------------------------------------------------------------------------------
/i2c/pa1010d_i2c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pa1010d_i2c
2 | pa1010d_i2c.c
3 | )
4 |
5 | # pull in common dependencies and additional i2c hardware support
6 | target_link_libraries(pa1010d_i2c pico_stdlib hardware_i2c)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(pa1010d_i2c)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(pa1010d_i2c)
13 |
--------------------------------------------------------------------------------
/i2c/pa1010d_i2c/pa1010d_i2c.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/pa1010d_i2c/pa1010d_i2c.fzz
--------------------------------------------------------------------------------
/i2c/pa1010d_i2c/pa1010d_i2c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/pa1010d_i2c/pa1010d_i2c.png
--------------------------------------------------------------------------------
/i2c/pcf8523_i2c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pcf8523_i2c
2 | pcf8523_i2c.c
3 | )
4 |
5 | # pull in common dependencies and additional i2c hardware support
6 | target_link_libraries(pcf8523_i2c pico_stdlib hardware_i2c)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(pcf8523_i2c)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(pcf8523_i2c)
13 |
--------------------------------------------------------------------------------
/i2c/pcf8523_i2c/README.adoc:
--------------------------------------------------------------------------------
1 | = Attaching a PCF8523 Real Time Clock via I2C
2 |
3 | This example code shows how to interface the Raspberry Pi Pico to the PCF8523 Real Time Clock
4 |
5 | This example allows you to initialise the current time and date and then displays it every half-second. Additionally it lets you set an alarm for a particular time and date and raises an alert accordingly. More information about the module is available at https://learn.adafruit.com/adafruit-pcf8523-real-time-clock.
6 |
7 | == Wiring information
8 |
9 | Wiring up the device requires 4 jumpers, to connect VDD, GND, SDA and SCL. The example here uses I2C port 0, which is assigned to GPIO 4 (SDA) and 5 (SCL) in software. Power is supplied from the 5V pin.
10 |
11 | [[pcf8523_i2c_wiring]]
12 | [pdfwidth=75%]
13 | .Wiring Diagram for PCF8523.
14 | image::pc8523_i2c.png[]
15 |
16 | == List of Files
17 |
18 | CMakeLists.txt:: CMake file to incorporate the example in to the examples build tree.
19 | pcf8523_i2c.c:: The example code.
20 |
21 | == Bill of Materials
22 |
23 | .A list of materials required for the example
24 | [[pcf8523-bom-table]]
25 | [cols=3]
26 | |===
27 | | *Item* | *Quantity* | Details
28 | | Breadboard | 1 | generic part
29 | | Raspberry Pi Pico | 1 | https://www.raspberrypi.com/products/raspberry-pi-pico/
30 | | PCF8523 board| 1 | https://www.adafruit.com/product/3295
31 | | M/M Jumper wires | 4 | generic part
32 | |===
33 |
34 |
--------------------------------------------------------------------------------
/i2c/pcf8523_i2c/pc8523_i2c.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/pcf8523_i2c/pc8523_i2c.fzz
--------------------------------------------------------------------------------
/i2c/pcf8523_i2c/pc8523_i2c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/pcf8523_i2c/pc8523_i2c.png
--------------------------------------------------------------------------------
/i2c/slave_mem_i2c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(slave_mem_i2c
2 | slave_mem_i2c.c
3 | )
4 | target_link_libraries(slave_mem_i2c
5 | pico_i2c_slave
6 | hardware_i2c
7 | pico_stdlib
8 | )
9 | pico_add_extra_outputs(slave_mem_i2c)
10 | example_auto_set_url(slave_mem_i2c)
11 |
12 | add_executable(slave_mem_i2c_burst
13 | slave_mem_i2c_burst.c
14 | )
15 | target_link_libraries(slave_mem_i2c_burst
16 | pico_i2c_slave
17 | hardware_i2c
18 | pico_stdlib
19 | )
20 | pico_add_extra_outputs(slave_mem_i2c_burst)
21 | example_auto_set_url(slave_mem_i2c_burst)
22 |
--------------------------------------------------------------------------------
/i2c/ssd1306_i2c/1306_i2c.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/ssd1306_i2c/1306_i2c.fzz
--------------------------------------------------------------------------------
/i2c/ssd1306_i2c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(ssd1306_i2c
2 | ssd1306_i2c.c
3 | )
4 |
5 | # pull in common dependencies and additional i2c hardware support
6 | target_link_libraries(ssd1306_i2c pico_stdlib hardware_i2c)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(ssd1306_i2c)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(ssd1306_i2c)
13 |
--------------------------------------------------------------------------------
/i2c/ssd1306_i2c/raspberry26x32.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/ssd1306_i2c/raspberry26x32.bmp
--------------------------------------------------------------------------------
/i2c/ssd1306_i2c/raspberry26x32.h:
--------------------------------------------------------------------------------
1 | #define IMG_WIDTH 26
2 | #define IMG_HEIGHT 32
3 |
4 | static uint8_t raspberry26x32[] = { 0x0, 0x0, 0xe, 0x7e, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xf8, 0xfc, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7e, 0x1e, 0x0, 0x0, 0x0, 0x80, 0xe0, 0xf8, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xf8, 0xe0, 0x80, 0x0, 0x0, 0x1e, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1e, 0x0, 0x0, 0x0, 0x3, 0x7, 0xf, 0x1f, 0x1f, 0x3f, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x3f, 0x3f, 0x1f, 0x1f, 0xf, 0x7, 0x3, 0x0, 0x0};
5 |
--------------------------------------------------------------------------------
/i2c/ssd1306_i2c/ssd1306_i2c_bb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/i2c/ssd1306_i2c/ssd1306_i2c_bb.png
--------------------------------------------------------------------------------
/ide/vscode/launch-probe-swd.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "Pico Debug",
6 | "cwd": "${workspaceRoot}",
7 | "executable": "${command:cmake.launchTargetPath}",
8 | "request": "launch",
9 | "type": "cortex-debug",
10 | "servertype": "openocd",
11 | // This may need to be "arm-none-eabi-gdb" for some previous builds
12 | "gdbPath" : "gdb-multiarch",
13 | "device": "RP2040",
14 | "configFiles": [
15 | // This may need to be "interface/picoprobe.cfg" for some previous builds
16 | "interface/cmsis-dap.cfg",
17 | "target/rp2040.cfg"
18 | ],
19 | "svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",
20 | "runToEntryPoint": "main",
21 | // Work around for stopping at main on restart
22 | "postRestartCommands": [
23 | "break main",
24 | "continue"
25 | ]
26 | }
27 | ]
28 | }
29 |
--------------------------------------------------------------------------------
/ide/vscode/launch-raspberrypi-swd.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "Pico Debug",
6 | "cwd": "${workspaceRoot}",
7 | "executable": "${command:cmake.launchTargetPath}",
8 | "request": "launch",
9 | "type": "cortex-debug",
10 | "servertype": "openocd",
11 | // This may need to be "arm-none-eabi-gdb" for some previous builds
12 | "gdbPath" : "gdb-multiarch",
13 | "device": "RP2040",
14 | "configFiles": [
15 | "interface/raspberrypi-swd.cfg",
16 | "target/rp2040.cfg"
17 | ],
18 | "svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",
19 | "runToEntryPoint": "main",
20 | // Work around for stopping at main on restart
21 | "postRestartCommands": [
22 | "break main",
23 | "continue"
24 | ]
25 | }
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/ide/vscode/launch-remote-openocd.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "Pico Debug",
6 | "type":"cortex-debug",
7 | "cwd": "${workspaceRoot}",
8 | "executable": "${command:cmake.launchTargetPath}",
9 | "request": "launch",
10 | "servertype": "external",
11 | // This may need to be "arm-none-eabi-gdb" for older builds
12 | "gdbPath" : "gdb-multiarch",
13 | // Connect to an already running OpenOCD instance
14 | "gdbTarget": "your-openocd:3333",
15 | "svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",
16 | "runToEntryPoint": "main",
17 | // Work around for stopping at main on restart
18 | "postRestartCommands": [
19 | "break main",
20 | "continue"
21 | ]
22 | }
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/ide/vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | // These settings tweaks to the cmake plugin will ensure
3 | // that you debug using cortex-debug instead of trying to launch
4 | // a Pico binary on the host
5 | "cmake.statusbar.advanced": {
6 | "debug": {
7 | "visibility": "hidden"
8 | },
9 | "launch": {
10 | "visibility": "hidden"
11 | },
12 | "build": {
13 | "visibility": "hidden"
14 | },
15 | "buildTarget": {
16 | "visibility": "hidden"
17 | }
18 | },
19 | "cmake.buildBeforeRun": true,
20 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
21 | }
--------------------------------------------------------------------------------
/interp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET hardware_interp)
2 | add_subdirectory_exclude_platforms(hello_interp)
3 | else()
4 | message("Skipping interp examples as hardware_interp is unavailable on this platform")
5 | endif()
6 |
--------------------------------------------------------------------------------
/interp/hello_interp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET hardware_interp)
2 | add_executable(hello_interp
3 | hello_interp.c
4 | )
5 |
6 | # pull in common dependencies and additional interpolator hardware support
7 | target_link_libraries(hello_interp pico_stdlib hardware_interp)
8 |
9 | # create map/bin/hex file etc.
10 | pico_add_extra_outputs(hello_interp)
11 |
12 | # add url via pico_set_program_url
13 | example_auto_set_url(hello_interp)
14 | endif ()
15 |
--------------------------------------------------------------------------------
/multicore/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET pico_multicore)
2 | add_subdirectory_exclude_platforms(hello_multicore host)
3 | # currently broken on RP2350 due to both cores sharing IRQ
4 | add_subdirectory_exclude_platforms(multicore_fifo_irqs host "rp2350.*")
5 | add_subdirectory_exclude_platforms(multicore_runner host)
6 | add_subdirectory_exclude_platforms(multicore_runner_queue host)
7 | add_subdirectory_exclude_platforms(multicore_doorbell host rp2040)
8 | else()
9 | message("Skipping multicore examples as pico_multicore is unavailable on this platform")
10 | endif()
11 |
--------------------------------------------------------------------------------
/multicore/hello_multicore/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_multicore
2 | multicore.c
3 | )
4 |
5 | # Add pico_multicore which is required for multicore functionality
6 | target_link_libraries(hello_multicore
7 | pico_stdlib
8 | pico_multicore)
9 |
10 | # create map/bin/hex file etc.
11 | pico_add_extra_outputs(hello_multicore)
12 |
13 | # add url via pico_set_program_url
14 | example_auto_set_url(hello_multicore)
--------------------------------------------------------------------------------
/multicore/hello_multicore/multicore.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 | #include "pico/stdlib.h"
9 | #include "pico/multicore.h"
10 |
11 | #define FLAG_VALUE 123
12 |
13 | void core1_entry() {
14 |
15 | multicore_fifo_push_blocking(FLAG_VALUE);
16 |
17 | uint32_t g = multicore_fifo_pop_blocking();
18 |
19 | if (g != FLAG_VALUE)
20 | printf("Hmm, that's not right on core 1!\n");
21 | else
22 | printf("Its all gone well on core 1!");
23 |
24 | while (1)
25 | tight_loop_contents();
26 | }
27 |
28 | int main() {
29 | stdio_init_all();
30 | printf("Hello, multicore!\n");
31 |
32 | /// \tag::setup_multicore[]
33 |
34 | multicore_launch_core1(core1_entry);
35 |
36 | // Wait for it to start up
37 |
38 | uint32_t g = multicore_fifo_pop_blocking();
39 |
40 | if (g != FLAG_VALUE)
41 | printf("Hmm, that's not right on core 0!\n");
42 | else {
43 | multicore_fifo_push_blocking(FLAG_VALUE);
44 | printf("It's all gone well on core 0!");
45 | }
46 |
47 | /// \end::setup_multicore[]
48 | }
49 |
--------------------------------------------------------------------------------
/multicore/multicore_doorbell/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(multicore_doorbell
2 | multicore_doorbell.c
3 | )
4 | target_link_libraries(multicore_doorbell
5 | pico_stdlib
6 | pico_multicore)
7 | pico_add_extra_outputs(multicore_doorbell)
8 | example_auto_set_url(multicore_doorbell)
9 |
--------------------------------------------------------------------------------
/multicore/multicore_fifo_irqs/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(multicore_fifo_irqs
2 | multicore_fifo_irqs.c
3 | )
4 |
5 | target_link_libraries(multicore_fifo_irqs
6 | pico_multicore
7 | pico_stdlib)
8 |
9 | # create map/bin/hex file etc.
10 | pico_add_extra_outputs(multicore_fifo_irqs)
11 |
12 | # add url via pico_set_program_url
13 | example_auto_set_url(multicore_fifo_irqs)
--------------------------------------------------------------------------------
/multicore/multicore_runner/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(multicore_runner
2 | multicore_runner.c
3 | )
4 |
5 | target_link_libraries(multicore_runner
6 | pico_multicore
7 | pico_stdlib)
8 |
9 | # create map/bin/hex file etc.
10 | pico_add_extra_outputs(multicore_runner)
11 |
12 | # add url via pico_set_program_url
13 | example_auto_set_url(multicore_runner)
--------------------------------------------------------------------------------
/multicore/multicore_runner_queue/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(multicore_runner_queue
2 | multicore_runner_queue.c
3 | )
4 |
5 | target_link_libraries(multicore_runner_queue
6 | pico_multicore
7 | pico_stdlib)
8 |
9 | # create map/bin/hex file etc.
10 | pico_add_extra_outputs(multicore_runner_queue)
11 |
12 | # add url via pico_set_program_url
13 | example_auto_set_url(multicore_runner_queue)
--------------------------------------------------------------------------------
/otp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory_exclude_platforms(hello_otp host rp2040)
2 |
--------------------------------------------------------------------------------
/otp/hello_otp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_otp
2 | hello_otp.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(hello_otp pico_stdlib)
7 |
8 | # create map/bin/hex/uf2 file etc.
9 | pico_add_extra_outputs(hello_otp)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(hello_otp)
13 |
--------------------------------------------------------------------------------
/pico_w/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.12)
2 |
3 | if (PICO_CYW43_SUPPORTED) # set by PICO_BOARD=pico_w
4 | if (NOT TARGET pico_cyw43_arch)
5 | message("Skipping Pico W examples as support is not available")
6 | else()
7 |
8 | if (DEFINED ENV{WIFI_SSID} AND (NOT WIFI_SSID))
9 | set(WIFI_SSID $ENV{WIFI_SSID})
10 | message("Using WIFI_SSID from environment ('${WIFI_SSID}')")
11 | endif()
12 |
13 | if (DEFINED ENV{WIFI_PASSWORD} AND (NOT WIFI_PASSWORD))
14 | set(WIFI_PASSWORD $ENV{WIFI_PASSWORD})
15 | message("Using WIFI_PASSWORD from environment")
16 | endif()
17 |
18 | set(WIFI_SSID "${WIFI_SSID}" CACHE INTERNAL "WiFi SSID for examples")
19 | set(WIFI_PASSWORD "${WIFI_PASSWORD}" CACHE INTERNAL "WiFi password for examples")
20 |
21 | add_subdirectory(wifi)
22 | if (NOT TARGET pico_btstack_base)
23 | message("Skipping Pico W Bluetooth examples as support is not available")
24 | else()
25 | add_subdirectory(bt)
26 | endif()
27 | endif()
28 | endif()
29 |
--------------------------------------------------------------------------------
/pico_w/bt/README.md:
--------------------------------------------------------------------------------
1 | # Pico Bluetooth Examples
2 |
3 | The source for most of the Bluetooth examples is stored in `pico-sdk/lib/btstack/example`.
4 | There's a standalone example in `pico-examples/pico_w/bt/standalone`.
5 |
6 | ## Debugging
7 |
8 | To debug Bluetooth issues you can enable [btstack](https://github.com/bluekitchen/btstack) debug output which also enables packet logging.
9 | Define `WANT_HCI_DUMP=1` in your CMakeLists.txt file. Uncomment this line to enable debug in the btstack examples.
10 |
11 | target_compile_definitions(picow_bt_example_common INTERFACE
12 | #WANT_HCI_DUMP=1 # This enables btstack debug
13 | )
14 |
15 | ## Packet logging
16 |
17 | To view packet logs, save the output from the debug port (e.g. the uart) to a file and afterwards run `pico-sdk/lib/btstack/tool/create_packet_log.py `.
18 | This will generate a file with the same name except for a `pklg` extension. This can be opened in the [Wireshark](https://www.wireshark.org) application to analyze communications activity.
19 |
20 | ## Link keys
21 |
22 | By default, the last two sectors of flash are used to store Bluetooth link keys and this relies on the Bluetooth address. Old pre-release versions of the SDK had issues with some devices using a default Bluetooth address. If you experience issues with pairing try Resetting flash memory, see https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html#resetting-flash-memory
23 |
--------------------------------------------------------------------------------
/pico_w/bt/a2dp_sink_demo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(a2dp_sink_demo_pins INTERFACE)
2 | target_compile_definitions(a2dp_sink_demo_pins INTERFACE
3 | PICO_AUDIO_I2S_DATA_PIN=9
4 | PICO_AUDIO_I2S_CLOCK_PIN_BASE=10
5 | )
6 |
7 | picow_bt_example(a2dp_sink_demo pico_btstack_sbc_decoder a2dp_sink_demo_pins)
8 |
--------------------------------------------------------------------------------
/pico_w/bt/a2dp_source_demo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(a2dp_source_demo pico_btstack_hxcmod_player pico_btstack_sbc_encoder)
--------------------------------------------------------------------------------
/pico_w/bt/ancs_client_demo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(ancs_client_demo)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/att_delayed_response/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(att_delayed_response)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/avrcp_browsing_client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(avrcp_browsing_client)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/config/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Generally you would define your own explicit list of lwIP options
5 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6 | //
7 | // This example uses a common include to avoid repetition
8 | #include "lwipopts_examples_common.h"
9 |
10 | #if !NO_SYS
11 | #define TCPIP_THREAD_STACKSIZE 1024
12 | #define DEFAULT_THREAD_STACKSIZE 1024
13 | #define DEFAULT_RAW_RECVMBOX_SIZE 8
14 | #define TCPIP_MBOX_SIZE 8
15 | #define LWIP_TIMEVAL_PRIVATE 0
16 |
17 | // not necessary, can be done either way
18 | #define LWIP_TCPIP_CORE_LOCKING_INPUT 1
19 | #endif
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/pico_w/bt/dut_mode_classic/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(dut_mode_classic)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/gap_dedicated_bonding/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(gap_dedicated_bonding)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/gap_inquiry/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(gap_inquiry)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/gap_le_advertisements/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(gap_le_advertisements)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/gap_link_keys/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(gap_link_keys)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/gatt_battery_query/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(gatt_battery_query)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/gatt_browser/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(gatt_browser)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/gatt_counter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(gatt_counter)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/gatt_counter_with_wifi/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(NAME gatt_counter)
2 | picow_bt_example_target_name(${NAME}_with_wifi TARGET_NAME)
3 |
4 | picow_bt_example_poll(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_poll pico_btstack_ble)
5 | picow_bt_example_background(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_background pico_btstack_ble)
6 | picow_bt_example_freertos(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_freertos pico_btstack_ble)
7 |
--------------------------------------------------------------------------------
/pico_w/bt/gatt_device_information_query/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(gatt_device_information_query)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/gatt_heart_rate_client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(gatt_heart_rate_client)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/gatt_streamer_server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(gatt_streamer_server)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/gatt_streamer_server_with_wifi/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(NAME gatt_streamer_server)
2 | picow_bt_example_target_name(${NAME}_with_wifi TARGET_NAME)
3 |
4 | picow_bt_example_poll(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_poll pico_btstack_ble)
5 | picow_bt_example_background(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_background pico_btstack_ble)
6 | picow_bt_example_freertos(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_freertos pico_btstack_ble)
7 |
--------------------------------------------------------------------------------
/pico_w/bt/hfp_ag_demo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(hfp_ag_demo pico_btstack_sco_demo_util pico_btstack_sbc_encoder)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/hfp_hf_demo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(hfp_hf_demo_pins INTERFACE)
2 | target_compile_definitions(hfp_hf_demo_pins INTERFACE
3 | PICO_AUDIO_I2S_DATA_PIN=9
4 | PICO_AUDIO_I2S_CLOCK_PIN_BASE=10
5 | )
6 | picow_bt_example(hfp_hf_demo pico_btstack_sco_demo_util pico_btstack_sbc_encoder hfp_hf_demo_pins)
7 |
--------------------------------------------------------------------------------
/pico_w/bt/hid_host_demo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(hid_host_demo)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/hid_keyboard_demo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(hid_keyboard_demo)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/hid_mouse_demo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(hid_mouse_demo)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/hog_boot_host_demo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(hog_boot_host_demo)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/hog_host_demo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(hog_host_demo)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/hog_keyboard_demo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(hog_keyboard_demo)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/hog_mouse_demo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(hog_mouse_demo)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/hsp_ag_demo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(hsp_ag_demo pico_btstack_sco_demo_util pico_btstack_sbc_encoder)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/hsp_hs_demo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(hsp_hs_demo pico_btstack_sco_demo_util pico_btstack_sbc_encoder)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/le_credit_based_flow_control_mode_client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(le_credit_based_flow_control_mode_client)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/le_credit_based_flow_control_mode_server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(le_credit_based_flow_control_mode_server)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/le_mitm/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(le_mitm)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/le_streamer_client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(le_streamer_client)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/led_counter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(led_counter)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/mod_player/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(mod_player_pins INTERFACE)
2 | target_compile_definitions(mod_player_pins INTERFACE
3 | PICO_AUDIO_I2S_DATA_PIN=9
4 | PICO_AUDIO_I2S_CLOCK_PIN_BASE=10
5 | )
6 | picow_bt_example(mod_player pico_btstack_hxcmod_player mod_player_pins)
7 |
--------------------------------------------------------------------------------
/pico_w/bt/nordic_spp_le_counter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(nordic_spp_le_counter)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/nordic_spp_le_streamer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(nordic_spp_le_streamer)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/pan_lwip_http_server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(pan_lwip_dhserver INTERFACE)
2 | target_sources(pan_lwip_dhserver INTERFACE
3 | ${BTSTACK_3RD_PARTY_PATH}/lwip/dhcp-server/dhserver.c
4 | )
5 | target_include_directories(pan_lwip_dhserver INTERFACE
6 | ${BTSTACK_3RD_PARTY_PATH}/lwip/dhcp-server
7 | )
8 |
9 | picow_bt_example_target_name(pan_lwip_http_server TARGET_NAME)
10 |
11 | picow_bt_example_poll(pan_lwip_http_server ${TARGET_NAME} picow_bt_example_btstack_lwip_poll pan_lwip_dhserver pico_lwip_http pico_btstack_classic)
12 | picow_bt_example_background(pan_lwip_http_server ${TARGET_NAME} picow_bt_example_btstack_lwip_background pan_lwip_dhserver pico_lwip_http pico_btstack_classic)
13 | picow_bt_example_freertos(pan_lwip_http_server ${TARGET_NAME} picow_bt_example_btstack_lwip_freertos pan_lwip_dhserver pico_lwip_http pico_btstack_classic)
14 |
--------------------------------------------------------------------------------
/pico_w/bt/pbap_client_demo/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(pbap_client_demo)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/picow_bt_example_background.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include "btstack_run_loop.h"
8 | #include "pico/stdlib.h"
9 | #include "picow_bt_example_common.h"
10 |
11 | int main() {
12 | stdio_init_all();
13 |
14 | int res = picow_bt_example_init();
15 | if (res){
16 | return -1;
17 | }
18 |
19 | picow_bt_example_main();
20 | btstack_run_loop_execute();
21 | }
22 |
--------------------------------------------------------------------------------
/pico_w/bt/picow_bt_example_common.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | /*
8 | * \brief Initialise BTstack example with cyw43
9 | *
10 | * \return 0 if ok
11 | */
12 | int picow_bt_example_init(void);
13 |
14 | /*
15 | * \brief Run the BTstack example
16 | *
17 | */
18 | void picow_bt_example_main(void);
19 |
--------------------------------------------------------------------------------
/pico_w/bt/picow_bt_example_poll.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include "btstack_run_loop.h"
8 | #include "pico/stdlib.h"
9 | #include "picow_bt_example_common.h"
10 |
11 | int main() {
12 | stdio_init_all();
13 |
14 | int res = picow_bt_example_init();
15 | if (res){
16 | return -1;
17 | }
18 |
19 | picow_bt_example_main();
20 | btstack_run_loop_execute();
21 | }
22 |
--------------------------------------------------------------------------------
/pico_w/bt/sdp_bnep_query/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(sdp_bnep_query)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/sdp_general_query/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(sdp_general_query)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/sdp_rfcomm_query/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(sdp_rfcomm_query)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/sine_player/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(sine_player_pins INTERFACE)
2 | target_compile_definitions(sine_player_pins INTERFACE
3 | PICO_AUDIO_I2S_DATA_PIN=9
4 | PICO_AUDIO_I2S_CLOCK_PIN_BASE=10
5 | )
6 | picow_bt_example(sine_player sine_player_pins)
7 |
--------------------------------------------------------------------------------
/pico_w/bt/sm_pairing_central/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(sm_pairing_central)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/sm_pairing_peripheral/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(sm_pairing_peripheral)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/spp_and_gatt_counter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(spp_and_gatt_counter)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/spp_and_gatt_streamer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(spp_and_gatt_streamer)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/spp_counter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(spp_counter)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/spp_flowcontrol/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(spp_flowcontrol)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/spp_streamer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(spp_streamer)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/spp_streamer_client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(spp_streamer_client)
2 |
--------------------------------------------------------------------------------
/pico_w/bt/spp_streamer_with_wifi/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(NAME spp_streamer)
2 | picow_bt_example_target_name(${NAME}_with_wifi TARGET_NAME)
3 |
4 | picow_bt_example_poll(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_poll pico_btstack_classic)
5 | picow_bt_example_background(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_background pico_btstack_classic)
6 | picow_bt_example_freertos(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_freertos pico_btstack_classic)
7 |
--------------------------------------------------------------------------------
/pico_w/bt/standalone/server_common.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2023 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #ifndef SERVER_COMMON_H_
8 | #define SERVER_COMMON_H_
9 |
10 | #define ADC_CHANNEL_TEMPSENSOR 4
11 |
12 | extern int le_notification_enabled;
13 | extern hci_con_handle_t con_handle;
14 | extern uint16_t current_temp;
15 | extern uint8_t const profile_data[];
16 |
17 | void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
18 | uint16_t att_read_callback(hci_con_handle_t connection_handle, uint16_t att_handle, uint16_t offset, uint8_t * buffer, uint16_t buffer_size);
19 | int att_write_callback(hci_con_handle_t connection_handle, uint16_t att_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size);
20 | void poll_temp(void);
21 |
22 | #endif
23 |
--------------------------------------------------------------------------------
/pico_w/bt/standalone/temp_sensor.gatt:
--------------------------------------------------------------------------------
1 | PRIMARY_SERVICE, GAP_SERVICE
2 | CHARACTERISTIC, GAP_DEVICE_NAME, READ, "picow_temp"
3 |
4 | PRIMARY_SERVICE, GATT_SERVICE
5 | CHARACTERISTIC, GATT_DATABASE_HASH, READ,
6 |
7 | PRIMARY_SERVICE, ORG_BLUETOOTH_SERVICE_ENVIRONMENTAL_SENSING
8 | CHARACTERISTIC, ORG_BLUETOOTH_CHARACTERISTIC_TEMPERATURE, READ | NOTIFY | INDICATE | DYNAMIC,
9 |
--------------------------------------------------------------------------------
/pico_w/bt/ublox_spp_le_counter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | picow_bt_example(ublox_spp_le_counter)
2 |
--------------------------------------------------------------------------------
/pico_w/wifi/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(WIFI_SSID "${WIFI_SSID}" CACHE INTERNAL "WiFi SSID for examples")
2 | set(WIFI_PASSWORD "${WIFI_PASSWORD}" CACHE INTERNAL "WiFi password for examples")
3 |
4 | add_subdirectory_exclude_platforms(blink)
5 | add_subdirectory_exclude_platforms(wifi_scan)
6 | add_subdirectory_exclude_platforms(access_point)
7 |
8 | if ("${WIFI_SSID}" STREQUAL "")
9 | message("Skipping some Pico W examples as WIFI_SSID is not defined")
10 | elseif ("${WIFI_PASSWORD}" STREQUAL "")
11 | message("Skipping some Pico W examples as WIFI_PASSWORD is not defined")
12 | else()
13 | add_subdirectory_exclude_platforms(freertos)
14 | add_subdirectory_exclude_platforms(httpd)
15 | add_subdirectory_exclude_platforms(iperf)
16 | add_subdirectory_exclude_platforms(ntp_client)
17 | add_subdirectory_exclude_platforms(tcp_client)
18 | add_subdirectory_exclude_platforms(tcp_server)
19 | add_subdirectory_exclude_platforms(udp_beacon)
20 | add_subdirectory_exclude_platforms(http_client)
21 | add_subdirectory_exclude_platforms(mqtt)
22 |
23 | if (NOT PICO_MBEDTLS_PATH)
24 | message("Skipping tls examples as PICO_MBEDTLS_PATH is not defined")
25 | else()
26 | add_subdirectory_exclude_platforms(tls_client)
27 | endif()
28 | endif()
29 |
--------------------------------------------------------------------------------
/pico_w/wifi/access_point/dhcpserver/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013-2022 Damien P. George
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/pico_w/wifi/access_point/dnsserver/dnsserver.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #ifndef _DNSSERVER_H_
8 | #define _DNSSERVER_H_
9 |
10 | #include "lwip/ip_addr.h"
11 |
12 | typedef struct dns_server_t_ {
13 | struct udp_pcb *udp;
14 | ip_addr_t ip;
15 | } dns_server_t;
16 |
17 | void dns_server_init(dns_server_t *d, ip_addr_t *ip);
18 | void dns_server_deinit(dns_server_t *d);
19 |
20 | #endif
21 |
--------------------------------------------------------------------------------
/pico_w/wifi/access_point/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Generally you would define your own explicit list of lwIP options
5 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6 | //
7 | // This example uses a common include to avoid repetition
8 | #include "lwipopts_examples_common.h"
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/pico_w/wifi/blink/picow_blink.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include "pico/stdlib.h"
8 | #include "pico/cyw43_arch.h"
9 |
10 | int main() {
11 | stdio_init_all();
12 | if (cyw43_arch_init()) {
13 | printf("Wi-Fi init failed");
14 | return -1;
15 | }
16 | while (true) {
17 | cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);
18 | sleep_ms(250);
19 | cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);
20 | sleep_ms(250);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/pico_w/wifi/blink/picow_blink_fast_clock.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2024 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include "pico/stdlib.h"
8 | #include "pico/cyw43_arch.h"
9 | #include "pico/cyw43_driver.h"
10 | #include "hardware/clocks.h"
11 |
12 | int main() {
13 | // Increase sys clock. We have slowed down the cyw43 pio to compensate using CYW43_PIO_CLOCK_DIV_INT=4 CYW43_PIO_CLOCK_DIV_FRAC=0 in the cmake file
14 | // By default the pio used to communicate with cyw43 runs with a clock divisor of 2
15 | // if you modify the clock you will have to compensate for this
16 | // As an alternative you could specify CYW43_PIO_CLOCK_DIV_DYNAMIC=1 in your cmake file and call cyw43_set_pio_clock_divisor(4, 0)
17 | set_sys_clock_khz(266000, true);
18 |
19 | stdio_init_all();
20 | if (cyw43_arch_init()) {
21 | printf("Wi-Fi init failed");
22 | return -1;
23 | }
24 | while (true) {
25 | cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);
26 | sleep_ms(250);
27 | cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);
28 | sleep_ms(250);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/pico_w/wifi/blink/picow_blink_slow_clock.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2024 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include "pico/stdlib.h"
8 | #include "pico/cyw43_arch.h"
9 | #include "pico/cyw43_driver.h"
10 | #include "hardware/clocks.h"
11 |
12 | int main() {
13 | // Slow the sys clock down and speed up the cyw43 pio to compensate
14 | // By default the pio used to communicate with cyw43 runs with a clock divisor of 2
15 | // if you modify the clock you will have to compensate for this
16 | // As an alternative you could specify CYW43_PIO_CLOCK_DIV_INT=x CYW43_PIO_CLOCK_DIV_FRAC=y in your cmake file
17 | // To call cyw43_set_pio_clock_divisor you have to add CYW43_PIO_CLOCK_DIV_DYNAMIC=1 to your cmake file
18 | set_sys_clock_khz(18000, true);
19 | cyw43_set_pio_clock_divisor(1, 0);
20 |
21 | stdio_init_all();
22 | if (cyw43_arch_init()) {
23 | printf("Wi-Fi init failed");
24 | return -1;
25 | }
26 | while (true) {
27 | cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);
28 | sleep_ms(250);
29 | cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);
30 | sleep_ms(250);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/pico_w/wifi/freertos/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (NOT FREERTOS_KERNEL_PATH AND NOT DEFINED ENV{FREERTOS_KERNEL_PATH})
2 | message("Skipping Pico W FreeRTOS examples as FREERTOS_KERNEL_PATH not defined")
3 | else()
4 | include(FreeRTOS_Kernel_import.cmake)
5 |
6 | add_subdirectory_exclude_platforms(httpd)
7 | add_subdirectory_exclude_platforms(iperf)
8 | add_subdirectory_exclude_platforms(ntp_client_socket)
9 | add_subdirectory_exclude_platforms(ping)
10 | add_subdirectory_exclude_platforms(http_client)
11 | endif()
12 |
--------------------------------------------------------------------------------
/pico_w/wifi/freertos/http_client/FreeRTOSConfig.h:
--------------------------------------------------------------------------------
1 | #ifndef FREERTOS_CONFIG_H
2 | #define FREERTOS_CONFIG_H
3 |
4 | // This example uses a common include to avoid repetition
5 | #include "FreeRTOSConfig_examples_common.h"
6 |
7 | #endif
8 |
--------------------------------------------------------------------------------
/pico_w/wifi/freertos/http_client/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Generally you would define your own explicit list of lwIP options
5 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6 | //
7 | // This example uses a common include to avoid repetition
8 | #include "lwipopts_examples_common.h"
9 |
10 | #if !NO_SYS
11 | #define TCPIP_THREAD_STACKSIZE 1024
12 | #define DEFAULT_THREAD_STACKSIZE 1024
13 | #define DEFAULT_RAW_RECVMBOX_SIZE 8
14 | #define TCPIP_MBOX_SIZE 8
15 | #define LWIP_TIMEVAL_PRIVATE 0
16 |
17 | // not necessary, can be done either way
18 | #define LWIP_TCPIP_CORE_LOCKING_INPUT 1
19 |
20 | // ping_thread sets socket receive timeout, so enable this feature
21 | #define LWIP_SO_RCVTIMEO 1
22 | #endif
23 |
24 | #define LWIP_ALTCP 1
25 |
26 | // If you don't want to use TLS (just a http request) you can avoid linking to mbedtls and remove the following
27 | #define LWIP_ALTCP_TLS 1
28 | #define LWIP_ALTCP_TLS_MBEDTLS 1
29 |
30 | // Note bug in lwip with LWIP_ALTCP and LWIP_DEBUG
31 | // https://savannah.nongnu.org/bugs/index.php?62159
32 | //#define LWIP_DEBUG 1
33 | #undef LWIP_DEBUG
34 | #define ALTCP_MBEDTLS_DEBUG LWIP_DBG_ON
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/pico_w/wifi/freertos/http_client/mbedtls_config.h:
--------------------------------------------------------------------------------
1 | #ifndef MBEDTLS_CONFIG_TLS_CLIENT_H
2 | #define MBEDTLS_CONFIG_TLS_CLIENT_H
3 |
4 | #include "mbedtls_config_examples_common.h"
5 |
6 | #endif
--------------------------------------------------------------------------------
/pico_w/wifi/freertos/httpd/FreeRTOSConfig.h:
--------------------------------------------------------------------------------
1 | #ifndef FREERTOS_CONFIG_H
2 | #define FREERTOS_CONFIG_H
3 |
4 | // This example uses a common include to avoid repetition
5 | #include "FreeRTOSConfig_examples_common.h"
6 |
7 | #endif
8 |
--------------------------------------------------------------------------------
/pico_w/wifi/freertos/httpd/content/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Pico httpd example
4 |
5 |
6 | Pico httpd example
7 | 404 - Page not found
8 | Sorry, the page you are requesting was not found on this server.
9 |
10 |
11 |
--------------------------------------------------------------------------------
/pico_w/wifi/freertos/httpd/content/index.shtml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Pico httpd example
4 |
5 |
6 | Pico httpd example
7 |
8 | Uptime is seconds
9 | CGI test
10 | Led is click here to toggle the led
11 |
12 |
13 |
--------------------------------------------------------------------------------
/pico_w/wifi/freertos/httpd/content/test.shtml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Pico cgi test
4 |
5 |
6 | Pico cgi test
7 |
8 | Test result:
9 | Go back
10 |
11 |
12 |
--------------------------------------------------------------------------------
/pico_w/wifi/freertos/httpd/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Generally you would define your own explicit list of lwIP options
5 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6 | //
7 | // This example uses a common include to avoid repetition
8 | #include "lwipopts_examples_common.h"
9 |
10 | // The following is needed to test mDns
11 | #define LWIP_MDNS_RESPONDER 1
12 | #define LWIP_IGMP 1
13 | #define LWIP_NUM_NETIF_CLIENT_DATA 1
14 | #define MDNS_RESP_USENETIF_EXTCALLBACK 1
15 | #define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 3)
16 | #define MEMP_NUM_TCP_PCB 12
17 |
18 | // Enable cgi and ssi
19 | #define LWIP_HTTPD_CGI 1
20 | #define LWIP_HTTPD_SSI 1
21 | #define LWIP_HTTPD_SSI_MULTIPART 1
22 |
23 | #if !NO_SYS
24 | #define TCPIP_THREAD_STACKSIZE 2048 // mDNS needs more stack
25 | #define DEFAULT_THREAD_STACKSIZE 1024
26 | #define DEFAULT_RAW_RECVMBOX_SIZE 8
27 | #define TCPIP_MBOX_SIZE 8
28 | #define LWIP_TIMEVAL_PRIVATE 0
29 |
30 | // not necessary, can be done either way
31 | #define LWIP_TCPIP_CORE_LOCKING_INPUT 1
32 | #endif
33 |
34 | #define HTTPD_FSDATA_FILE "pico_fsdata.inc"
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/pico_w/wifi/freertos/iperf/FreeRTOSConfig.h:
--------------------------------------------------------------------------------
1 | #ifndef FREERTOS_CONFIG_H
2 | #define FREERTOS_CONFIG_H
3 |
4 | // This example uses a common include to avoid repetition
5 | #include "FreeRTOSConfig_examples_common.h"
6 |
7 | #endif
8 |
--------------------------------------------------------------------------------
/pico_w/wifi/freertos/iperf/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Generally you would define your own explicit list of lwIP options
5 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6 | //
7 | // This example uses a common include to avoid repetition
8 | #include "lwipopts_examples_common.h"
9 |
10 | #if !NO_SYS
11 | #define TCPIP_THREAD_STACKSIZE 1024
12 | #define DEFAULT_THREAD_STACKSIZE 1024
13 | #define DEFAULT_RAW_RECVMBOX_SIZE 8
14 | #define TCPIP_MBOX_SIZE 8
15 | #define LWIP_TIMEVAL_PRIVATE 0
16 |
17 | // not necessary, can be done either way
18 | #define LWIP_TCPIP_CORE_LOCKING_INPUT 1
19 |
20 | // ping_thread sets socket receive timeout, so enable this feature
21 | #define LWIP_SO_RCVTIMEO 1
22 | #endif
23 |
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/pico_w/wifi/freertos/ntp_client_socket/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(picow_freertos_ntp_client_socket
2 | picow_freertos_ntp_client_socket.c
3 | )
4 | target_compile_definitions(picow_freertos_ntp_client_socket PRIVATE
5 | WIFI_SSID=\"${WIFI_SSID}\"
6 | WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
7 | NO_SYS=0 # don't want NO_SYS (generally this would be in your lwipopts.h)
8 | LWIP_SOCKET=1 # we need the socket API (generally this would be in your lwipopts.h)
9 | )
10 | target_include_directories(picow_freertos_ntp_client_socket PRIVATE
11 | ${CMAKE_CURRENT_LIST_DIR}
12 | ${CMAKE_CURRENT_LIST_DIR}/.. # for our common FreeRTOSConfig
13 | ${CMAKE_CURRENT_LIST_DIR}/../.. # for our common lwipopts
14 | )
15 | target_link_libraries(picow_freertos_ntp_client_socket
16 | pico_cyw43_arch_lwip_sys_freertos
17 | pico_stdlib
18 | FreeRTOS-Kernel-Heap4 # FreeRTOS kernel and dynamic heap
19 | )
20 | pico_add_extra_outputs(picow_freertos_ntp_client_socket)
21 |
--------------------------------------------------------------------------------
/pico_w/wifi/freertos/ntp_client_socket/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Generally you would define your own explicit list of lwIP options
5 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6 | //
7 | // This example uses a common include to avoid repetition
8 | #include "lwipopts_examples_common.h"
9 |
10 | #if !NO_SYS
11 | #define TCPIP_THREAD_STACKSIZE 1024
12 | #define DEFAULT_THREAD_STACKSIZE 1024
13 | #define DEFAULT_RAW_RECVMBOX_SIZE 8
14 | #define DEFAULT_UDP_RECVMBOX_SIZE 8
15 | #define DEFAULT_TCP_RECVMBOX_SIZE 8
16 | #define TCPIP_MBOX_SIZE 8
17 | #define LWIP_TIMEVAL_PRIVATE 0
18 |
19 | // not necessary, can be done either way
20 | #define LWIP_TCPIP_CORE_LOCKING_INPUT 1
21 |
22 | #define LWIP_SO_RCVTIMEO 1
23 | #endif
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/pico_w/wifi/freertos/ping/FreeRTOSConfig.h:
--------------------------------------------------------------------------------
1 | #ifndef FREERTOS_CONFIG_H
2 | #define FREERTOS_CONFIG_H
3 |
4 | // This example uses a common include to avoid repetition
5 | #include "FreeRTOSConfig_examples_common.h"
6 |
7 | #endif
8 |
--------------------------------------------------------------------------------
/pico_w/wifi/freertos/ping/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Generally you would define your own explicit list of lwIP options
5 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6 | //
7 | // This example uses a common include to avoid repetition
8 | #include "lwipopts_examples_common.h"
9 |
10 | #if !NO_SYS
11 | #define TCPIP_THREAD_STACKSIZE 1024
12 | #define DEFAULT_THREAD_STACKSIZE 2048
13 | #define DEFAULT_RAW_RECVMBOX_SIZE 8
14 | #define TCPIP_MBOX_SIZE 8
15 | #define LWIP_TIMEVAL_PRIVATE 0
16 |
17 | // not necessary, can be done either way
18 | #define LWIP_TCPIP_CORE_LOCKING_INPUT 1
19 |
20 | // ping_thread sets socket receive timeout, so enable this feature
21 | #define LWIP_SO_RCVTIMEO 1
22 | #endif
23 |
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/pico_w/wifi/http_client/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Generally you would define your own explicit list of lwIP options
5 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6 | //
7 | // This example uses a common include to avoid repetition
8 | #include "lwipopts_examples_common.h"
9 |
10 | /* TCP WND must be at least 16 kb to match TLS record size
11 | or you will get a warning "altcp_tls: TCP_WND is smaller than the RX decrypion buffer, connection RX might stall!" */
12 | #undef TCP_WND
13 | #define TCP_WND 16384
14 |
15 | #define LWIP_ALTCP 1
16 |
17 | // If you don't want to use TLS (just a http request) you can avoid linking to mbedtls and remove the following
18 | #define LWIP_ALTCP_TLS 1
19 | #define LWIP_ALTCP_TLS_MBEDTLS 1
20 |
21 | // Note bug in lwip with LWIP_ALTCP and LWIP_DEBUG
22 | // https://savannah.nongnu.org/bugs/index.php?62159
23 | //#define LWIP_DEBUG 1
24 | #undef LWIP_DEBUG
25 | #define ALTCP_MBEDTLS_DEBUG LWIP_DBG_ON
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/pico_w/wifi/http_client/mbedtls_config.h:
--------------------------------------------------------------------------------
1 | #ifndef MBEDTLS_CONFIG_TLS_CLIENT_H
2 | #define MBEDTLS_CONFIG_TLS_CLIENT_H
3 |
4 | #include "mbedtls_config_examples_common.h"
5 |
6 | #endif
--------------------------------------------------------------------------------
/pico_w/wifi/httpd/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR})
2 |
3 | add_executable(picow_httpd_background
4 | pico_httpd.c
5 | )
6 | target_compile_definitions(picow_httpd_background PRIVATE
7 | WIFI_SSID=\"${WIFI_SSID}\"
8 | WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
9 | )
10 | target_include_directories(picow_httpd_background PRIVATE
11 | ${CMAKE_CURRENT_LIST_DIR}
12 | ${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
13 | ${PICO_LWIP_CONTRIB_PATH}/apps/httpd
14 | )
15 | target_link_libraries(picow_httpd_background PRIVATE
16 | pico_cyw43_arch_lwip_threadsafe_background
17 | pico_lwip_http
18 | pico_lwip_mdns
19 | pico_httpd_content
20 | pico_stdlib
21 | )
22 | pico_add_extra_outputs(picow_httpd_background)
23 |
24 | pico_add_library(pico_httpd_content NOFLAG)
25 | pico_set_lwip_httpd_content(pico_httpd_content INTERFACE
26 | ${CMAKE_CURRENT_LIST_DIR}/content/404.html
27 | ${CMAKE_CURRENT_LIST_DIR}/content/index.shtml
28 | ${CMAKE_CURRENT_LIST_DIR}/content/test.shtml
29 | ${CMAKE_CURRENT_LIST_DIR}/content/ledpass.shtml
30 | ${CMAKE_CURRENT_LIST_DIR}/content/ledfail.shtml
31 | ${CMAKE_CURRENT_LIST_DIR}/content/img/rpi.png
32 | )
33 |
--------------------------------------------------------------------------------
/pico_w/wifi/httpd/content/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | 404 - Page not found
4 |
5 |
6 | 404 - Page not found
7 | Sorry, the page you are requesting was not found on this server.
8 |
9 |
10 |
--------------------------------------------------------------------------------
/pico_w/wifi/httpd/content/img/rpi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/pico_w/wifi/httpd/content/img/rpi.png
--------------------------------------------------------------------------------
/pico_w/wifi/httpd/content/index.shtml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Pico httpd example
4 |
5 |
6 | Pico httpd example
7 | 
8 |
9 | Uptime is seconds
10 | CGI handler test
11 |
12 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/pico_w/wifi/httpd/content/ledfail.shtml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Pico post test
4 |
5 |
6 | Pico post test
7 | Failed to update led
8 | Go back
9 |
10 |
11 |
--------------------------------------------------------------------------------
/pico_w/wifi/httpd/content/ledpass.shtml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Pico post test
4 |
5 |
6 | Pico post test
7 | Success. Led is now
8 | Go back
9 |
10 |
11 |
--------------------------------------------------------------------------------
/pico_w/wifi/httpd/content/test.shtml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Pico cgi handler test
4 |
5 |
6 | Pico cgi handler test
7 |
8 | Test result:
9 | Go back
10 |
11 |
12 |
--------------------------------------------------------------------------------
/pico_w/wifi/httpd/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Generally you would define your own explicit list of lwIP options
5 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6 | //
7 | // This example uses a common include to avoid repetition
8 | #include "lwipopts_examples_common.h"
9 |
10 | // The following is needed to test mDns
11 | #define LWIP_MDNS_RESPONDER 1
12 | #define LWIP_IGMP 1
13 | #define LWIP_NUM_NETIF_CLIENT_DATA 1
14 | #define MDNS_RESP_USENETIF_EXTCALLBACK 1
15 | #define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 3)
16 | #define MEMP_NUM_TCP_PCB 12
17 |
18 | // Enable some httpd features
19 | #define LWIP_HTTPD_CGI 1
20 | #define LWIP_HTTPD_SSI 1
21 | #define LWIP_HTTPD_SSI_MULTIPART 1
22 | #define LWIP_HTTPD_SUPPORT_POST 1
23 | #define LWIP_HTTPD_SSI_INCLUDE_TAG 0
24 |
25 | // Generated file containing html data
26 | #define HTTPD_FSDATA_FILE "pico_fsdata.inc"
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/pico_w/wifi/iperf/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(picow_iperf_server_background
2 | picow_iperf.c
3 | )
4 | target_compile_definitions(picow_iperf_server_background PRIVATE
5 | WIFI_SSID=\"${WIFI_SSID}\"
6 | WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
7 | )
8 | target_include_directories(picow_iperf_server_background PRIVATE
9 | ${CMAKE_CURRENT_LIST_DIR}
10 | ${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
11 | )
12 | target_link_libraries(picow_iperf_server_background
13 | pico_cyw43_arch_lwip_threadsafe_background
14 | pico_stdlib
15 | pico_lwip_iperf
16 | )
17 | pico_add_extra_outputs(picow_iperf_server_background)
18 |
19 | add_executable(picow_iperf_server_poll
20 | picow_iperf.c
21 | )
22 | target_compile_definitions(picow_iperf_server_poll PRIVATE
23 | WIFI_SSID=\"${WIFI_SSID}\"
24 | WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
25 | )
26 | target_include_directories(picow_iperf_server_poll PRIVATE
27 | ${CMAKE_CURRENT_LIST_DIR}
28 | ${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
29 | )
30 | target_link_libraries(picow_iperf_server_poll
31 | pico_cyw43_arch_lwip_poll
32 | pico_stdlib
33 | pico_lwip_iperf
34 | )
35 | pico_add_extra_outputs(picow_iperf_server_poll)
36 |
37 |
--------------------------------------------------------------------------------
/pico_w/wifi/iperf/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Generally you would define your own explicit list of lwIP options
5 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6 | //
7 | // This example uses a common include to avoid repetition
8 | #include "lwipopts_examples_common.h"
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/pico_w/wifi/mqtt/certs/.gitignore:
--------------------------------------------------------------------------------
1 | */
2 |
3 |
--------------------------------------------------------------------------------
/pico_w/wifi/mqtt/certs/pub.sh:
--------------------------------------------------------------------------------
1 | #/usr/bin/bash
2 |
3 | if [ -z "$MQTT_SERVER" ]; then
4 | echo Define MQTT_SERVER
5 | exit 1
6 | fi
7 |
8 | mosquitto_pub -h $MQTT_SERVER --cafile $MQTT_SERVER/ca.crt --key $MQTT_SERVER/client.key --cert $MQTT_SERVER/client.crt -t "$1" -m "$2"
9 |
10 |
--------------------------------------------------------------------------------
/pico_w/wifi/mqtt/certs/sub.sh:
--------------------------------------------------------------------------------
1 | #/usr/bin/bash
2 |
3 | if [ -z "$MQTT_SERVER" ]; then
4 | echo Define MQTT_SERVER
5 | exit 1
6 | fi
7 |
8 | mosquitto_sub -h $MQTT_SERVER --cafile $MQTT_SERVER/ca.crt --key $MQTT_SERVER/client.key --cert $MQTT_SERVER/client.crt -t "$1"
9 |
10 |
--------------------------------------------------------------------------------
/pico_w/wifi/mqtt/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Need more memory for TLS
5 | #ifdef MQTT_CERT_INC
6 | #define MEM_SIZE 8000
7 | #endif
8 |
9 | // Generally you would define your own explicit list of lwIP options
10 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
11 | //
12 | // This example uses a common include to avoid repetition
13 | #include "lwipopts_examples_common.h"
14 |
15 | #define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL+1)
16 |
17 | #ifdef MQTT_CERT_INC
18 | #define LWIP_ALTCP 1
19 | #define LWIP_ALTCP_TLS 1
20 | #define LWIP_ALTCP_TLS_MBEDTLS 1
21 | #ifndef NDEBUG
22 | #define ALTCP_MBEDTLS_DEBUG LWIP_DBG_ON
23 | #endif
24 | /* TCP WND must be at least 16 kb to match TLS record size
25 | or you will get a warning "altcp_tls: TCP_WND is smaller than the RX decrypion buffer, connection RX might stall!" */
26 | #undef TCP_WND
27 | #define TCP_WND 16384
28 | #endif // MQTT_CERT_INC
29 |
30 | // This defaults to 4
31 | #define MQTT_REQ_MAX_IN_FLIGHT 5
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/pico_w/wifi/mqtt/mbedtls_config.h:
--------------------------------------------------------------------------------
1 | #ifndef MBEDTLS_CONFIG_TLS_CLIENT_H
2 | #define MBEDTLS_CONFIG_TLS_CLIENT_H
3 |
4 | #include "mbedtls_config_examples_common.h"
5 |
6 | #endif
--------------------------------------------------------------------------------
/pico_w/wifi/ntp_client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(picow_ntp_client_background
2 | picow_ntp_client.c
3 | )
4 | target_compile_definitions(picow_ntp_client_background PRIVATE
5 | WIFI_SSID=\"${WIFI_SSID}\"
6 | WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
7 | )
8 | target_include_directories(picow_ntp_client_background PRIVATE
9 | ${CMAKE_CURRENT_LIST_DIR}
10 | ${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
11 | )
12 | target_link_libraries(picow_ntp_client_background
13 | pico_cyw43_arch_lwip_threadsafe_background
14 | pico_stdlib
15 | )
16 |
17 | pico_add_extra_outputs(picow_ntp_client_background)
18 |
19 | add_executable(picow_ntp_client_poll
20 | picow_ntp_client.c
21 | )
22 | target_compile_definitions(picow_ntp_client_poll PRIVATE
23 | WIFI_SSID=\"${WIFI_SSID}\"
24 | WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
25 | )
26 | target_include_directories(picow_ntp_client_poll PRIVATE
27 | ${CMAKE_CURRENT_LIST_DIR}
28 | ${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
29 | )
30 | target_link_libraries(picow_ntp_client_poll
31 | pico_cyw43_arch_lwip_poll
32 | pico_stdlib
33 | )
34 | pico_add_extra_outputs(picow_ntp_client_poll)
35 |
36 |
--------------------------------------------------------------------------------
/pico_w/wifi/ntp_client/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Generally you would define your own explicit list of lwIP options
5 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6 | //
7 | // This example uses a common include to avoid repetition
8 | #include "lwipopts_examples_common.h"
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/pico_w/wifi/python_test_tcp/python_test_tcp_client.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | import socket
4 | import sys
5 |
6 | # Check server ip address set
7 | if len(sys.argv) < 2:
8 | raise RuntimeError('pass IP address of the server')
9 |
10 | # Set the server address here like 1.2.3.4
11 | SERVER_ADDR = sys.argv[1]
12 |
13 | # These constants should match the server
14 | BUF_SIZE = 2048
15 | SERVER_PORT = 4242
16 | TEST_ITERATIONS = 10
17 |
18 | # Open socket to the server
19 | sock = socket.socket()
20 | addr = (SERVER_ADDR, SERVER_PORT)
21 | sock.connect(addr)
22 |
23 | # Repeat test for a number of iterations
24 | for test_iteration in range(TEST_ITERATIONS):
25 |
26 | # Read BUF_SIZE bytes from the server
27 | total_size = BUF_SIZE
28 | read_buf = b''
29 | while total_size > 0:
30 | buf = sock.recv(BUF_SIZE)
31 | print('read %d bytes from server' % len(buf))
32 | total_size -= len(buf)
33 | read_buf += buf
34 |
35 | # Check size of data received
36 | if len(read_buf) != BUF_SIZE:
37 | raise RuntimeError('wrong amount of data read %d', len(read_buf))
38 |
39 | # Send the data back to the server
40 | write_len = sock.send(read_buf)
41 | print('written %d bytes to server' % write_len)
42 | if write_len != BUF_SIZE:
43 | raise RuntimeError('wrong amount of data written')
44 |
45 | # All done
46 | sock.close()
47 | print("test completed")
48 |
--------------------------------------------------------------------------------
/pico_w/wifi/tcp_client/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Generally you would define your own explicit list of lwIP options
5 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6 | //
7 | // This example uses a common include to avoid repetition
8 | #include "lwipopts_examples_common.h"
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/pico_w/wifi/tcp_server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(picow_tcpip_server_background
2 | picow_tcp_server.c
3 | )
4 | target_compile_definitions(picow_tcpip_server_background PRIVATE
5 | WIFI_SSID=\"${WIFI_SSID}\"
6 | WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
7 | )
8 | target_include_directories(picow_tcpip_server_background PRIVATE
9 | ${CMAKE_CURRENT_LIST_DIR}
10 | ${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
11 | )
12 | target_link_libraries(picow_tcpip_server_background
13 | pico_cyw43_arch_lwip_threadsafe_background
14 | pico_stdlib
15 | )
16 |
17 | pico_add_extra_outputs(picow_tcpip_server_background)
18 |
19 | add_executable(picow_tcpip_server_poll
20 | picow_tcp_server.c
21 | )
22 | target_compile_definitions(picow_tcpip_server_poll PRIVATE
23 | WIFI_SSID=\"${WIFI_SSID}\"
24 | WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
25 | )
26 | target_include_directories(picow_tcpip_server_poll PRIVATE
27 | ${CMAKE_CURRENT_LIST_DIR}
28 | ${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
29 | )
30 | target_link_libraries(picow_tcpip_server_poll
31 | pico_cyw43_arch_lwip_poll
32 | pico_stdlib
33 | )
34 | pico_add_extra_outputs(picow_tcpip_server_poll)
35 |
--------------------------------------------------------------------------------
/pico_w/wifi/tcp_server/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Generally you would define your own explicit list of lwIP options
5 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6 | //
7 | // This example uses a common include to avoid repetition
8 | #include "lwipopts_examples_common.h"
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/pico_w/wifi/tls_client/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | #include "lwipopts_examples_common.h"
5 |
6 | /* TCP WND must be at least 16 kb to match TLS record size
7 | or you will get a warning "altcp_tls: TCP_WND is smaller than the RX decrypion buffer, connection RX might stall!" */
8 | #undef TCP_WND
9 | #define TCP_WND 16384
10 |
11 | #define LWIP_ALTCP 1
12 | #define LWIP_ALTCP_TLS 1
13 | #define LWIP_ALTCP_TLS_MBEDTLS 1
14 |
15 | #define LWIP_DEBUG 1
16 | #define ALTCP_MBEDTLS_DEBUG LWIP_DBG_ON
17 |
18 | #endif
19 |
20 |
--------------------------------------------------------------------------------
/pico_w/wifi/tls_client/mbedtls_config.h:
--------------------------------------------------------------------------------
1 | #ifndef MBEDTLS_CONFIG_TLS_CLIENT_H
2 | #define MBEDTLS_CONFIG_TLS_CLIENT_H
3 |
4 | #include "mbedtls_config_examples_common.h"
5 |
6 | #endif
--------------------------------------------------------------------------------
/pico_w/wifi/udp_beacon/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(picow_udp_beacon_background
2 | picow_udp_beacon.c
3 | )
4 | target_compile_definitions(picow_udp_beacon_background PRIVATE
5 | WIFI_SSID=\"${WIFI_SSID}\"
6 | WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
7 | )
8 | target_include_directories(picow_udp_beacon_background PRIVATE
9 | ${CMAKE_CURRENT_LIST_DIR}
10 | ${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
11 | )
12 | target_link_libraries(picow_udp_beacon_background
13 | pico_cyw43_arch_lwip_threadsafe_background
14 | pico_stdlib
15 | )
16 |
17 | pico_add_extra_outputs(picow_udp_beacon_background)
18 |
19 | add_executable(picow_udp_beacon_poll
20 | picow_udp_beacon.c
21 | )
22 | target_compile_definitions(picow_udp_beacon_poll PRIVATE
23 | WIFI_SSID=\"${WIFI_SSID}\"
24 | WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
25 | )
26 | target_include_directories(picow_udp_beacon_poll PRIVATE
27 | ${CMAKE_CURRENT_LIST_DIR}
28 | ${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
29 | )
30 | target_link_libraries(picow_udp_beacon_poll
31 | pico_cyw43_arch_lwip_poll
32 | pico_stdlib
33 | )
34 | pico_add_extra_outputs(picow_udp_beacon_poll)
35 |
--------------------------------------------------------------------------------
/pico_w/wifi/udp_beacon/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Generally you would define your own explicit list of lwIP options
5 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6 | //
7 | // This example uses a common include to avoid repetition
8 | #include "lwipopts_examples_common.h"
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/pico_w/wifi/wifi_scan/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(picow_wifi_scan_background
2 | picow_wifi_scan.c
3 | )
4 | target_include_directories(picow_wifi_scan_background PRIVATE
5 | ${CMAKE_CURRENT_LIST_DIR}
6 | ${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
7 | )
8 | target_link_libraries(picow_wifi_scan_background
9 | pico_cyw43_arch_lwip_threadsafe_background
10 | pico_stdlib
11 | )
12 |
13 | pico_add_extra_outputs(picow_wifi_scan_background)
14 |
15 | add_executable(picow_wifi_scan_poll
16 | picow_wifi_scan.c
17 | )
18 | target_include_directories(picow_wifi_scan_poll PRIVATE
19 | ${CMAKE_CURRENT_LIST_DIR}
20 | ${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
21 | )
22 | target_link_libraries(picow_wifi_scan_poll
23 | pico_cyw43_arch_lwip_poll
24 | pico_stdlib
25 | )
26 | pico_add_extra_outputs(picow_wifi_scan_poll)
27 |
28 |
--------------------------------------------------------------------------------
/pico_w/wifi/wifi_scan/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef _LWIPOPTS_H
2 | #define _LWIPOPTS_H
3 |
4 | // Generally you would define your own explicit list of lwIP options
5 | // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6 | //
7 | // This example uses a common include to avoid repetition
8 | #include "lwipopts_examples_common.h"
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/picoboard/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory_exclude_platforms(blinky host)
2 | add_subdirectory_exclude_platforms(button host)
--------------------------------------------------------------------------------
/picoboard/blinky/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(picoboard_blinky
2 | blinky.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(picoboard_blinky pico_stdlib)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(picoboard_blinky)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(picoboard_blinky)
13 |
--------------------------------------------------------------------------------
/picoboard/button/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(picoboard_button
2 | button.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(picoboard_button pico_stdlib)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(picoboard_button)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(picoboard_button)
13 |
--------------------------------------------------------------------------------
/pio/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET hardware_pio)
2 | add_subdirectory_exclude_platforms(addition)
3 | add_subdirectory_exclude_platforms(apa102)
4 | add_subdirectory_exclude_platforms(clocked_input)
5 | add_subdirectory_exclude_platforms(differential_manchester)
6 | add_subdirectory_exclude_platforms(hello_pio)
7 | add_subdirectory_exclude_platforms(hub75)
8 | add_subdirectory_exclude_platforms(i2c)
9 | add_subdirectory_exclude_platforms(ir_nec)
10 | add_subdirectory_exclude_platforms(logic_analyser)
11 | add_subdirectory_exclude_platforms(manchester_encoding)
12 | add_subdirectory_exclude_platforms(onewire)
13 | add_subdirectory_exclude_platforms(pio_blink)
14 | add_subdirectory_exclude_platforms(pwm)
15 | add_subdirectory_exclude_platforms(quadrature_encoder)
16 | add_subdirectory_exclude_platforms(quadrature_encoder_substep)
17 | add_subdirectory_exclude_platforms(spi)
18 | add_subdirectory_exclude_platforms(squarewave)
19 | add_subdirectory_exclude_platforms(st7789_lcd)
20 | add_subdirectory_exclude_platforms(uart_rx)
21 | add_subdirectory_exclude_platforms(uart_tx)
22 | add_subdirectory_exclude_platforms(ws2812)
23 | add_subdirectory_exclude_platforms(uart_pio_dma)
24 | else()
25 | message("Skipping PIO examples as hardware_pio is unavailable on this platform")
26 | endif()
27 |
--------------------------------------------------------------------------------
/pio/addition/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_addition)
2 |
3 | pico_generate_pio_header(pio_addition ${CMAKE_CURRENT_LIST_DIR}/addition.pio)
4 |
5 | target_sources(pio_addition PRIVATE addition.c)
6 |
7 | target_link_libraries(pio_addition PRIVATE pico_stdlib hardware_pio)
8 | pico_add_extra_outputs(pio_addition)
9 |
10 | # add url via pico_set_program_url
11 | example_auto_set_url(pio_addition)
12 |
--------------------------------------------------------------------------------
/pio/addition/addition.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 | #include
9 |
10 | #include "pico/stdlib.h"
11 | #include "hardware/pio.h"
12 | #include "addition.pio.h"
13 |
14 | // Pop quiz: how many additions does the processor do when calling this function
15 | uint32_t do_addition(PIO pio, uint sm, uint32_t a, uint32_t b) {
16 | pio_sm_put_blocking(pio, sm, a);
17 | pio_sm_put_blocking(pio, sm, b);
18 | return pio_sm_get_blocking(pio, sm);
19 | }
20 |
21 | int main() {
22 | stdio_init_all();
23 |
24 | PIO pio = pio0;
25 | uint sm = 0;
26 | uint offset = pio_add_program(pio, &addition_program);
27 | addition_program_init(pio, sm, offset);
28 |
29 | printf("Doing some random additions:\n");
30 | for (int i = 0; i < 10; ++i) {
31 | uint a = rand() % 100;
32 | uint b = rand() % 100;
33 | printf("%u + %u = %u\n", a, b, do_addition(pio, sm, a, b));
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/pio/addition/addition.pio:
--------------------------------------------------------------------------------
1 | ;
2 | ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | ;
4 | ; SPDX-License-Identifier: BSD-3-Clause
5 | ;
6 | .pio_version 0 // only requires PIO version 0
7 | .program addition
8 |
9 | ; Pop two 32 bit integers from the TX FIFO, add them together, and push the
10 | ; result to the TX FIFO. Autopush/pull should be disabled as we're using
11 | ; explicit push and pull instructions.
12 | ;
13 | ; This program uses the two's complement identity x + y == ~(~x - y)
14 |
15 | pull
16 | mov x, ~osr
17 | pull
18 | mov y, osr
19 | jmp test ; this loop is equivalent to the following C code:
20 | incr: ; while (y--)
21 | jmp x-- test ; x--;
22 | test: ; This has the effect of subtracting y from x, eventually.
23 | jmp y-- incr
24 | mov isr, ~x
25 | push
26 |
27 | % c-sdk {
28 | static inline void addition_program_init(PIO pio, uint sm, uint offset) {
29 | pio_sm_config c = addition_program_get_default_config(offset);
30 | pio_sm_init(pio, sm, offset, &c);
31 | pio_sm_set_enabled(pio, sm, true);
32 | }
33 | %}
34 |
--------------------------------------------------------------------------------
/pio/apa102/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_apa102)
2 |
3 | pico_generate_pio_header(pio_apa102 ${CMAKE_CURRENT_LIST_DIR}/apa102.pio)
4 |
5 | target_sources(pio_apa102 PRIVATE apa102.c)
6 |
7 | target_link_libraries(pio_apa102 PRIVATE
8 | pico_stdlib
9 | hardware_pio
10 | )
11 |
12 | pico_add_extra_outputs(pio_apa102)
13 |
14 | # add url via pico_set_program_url
15 | example_auto_set_url(pio_apa102)
16 |
--------------------------------------------------------------------------------
/pio/clocked_input/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_clocked_input)
2 |
3 | pico_generate_pio_header(pio_clocked_input ${CMAKE_CURRENT_LIST_DIR}/clocked_input.pio)
4 |
5 | target_sources(pio_clocked_input PRIVATE clocked_input.c)
6 |
7 | target_link_libraries(pio_clocked_input PRIVATE
8 | pico_stdlib
9 | hardware_pio
10 | hardware_spi
11 | )
12 |
13 | pico_add_extra_outputs(pio_clocked_input)
14 |
15 | # add url via pico_set_program_url
16 | example_auto_set_url(pio_clocked_input)
17 |
--------------------------------------------------------------------------------
/pio/differential_manchester/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_differential_manchester)
2 |
3 | pico_generate_pio_header(pio_differential_manchester ${CMAKE_CURRENT_LIST_DIR}/differential_manchester.pio)
4 |
5 | target_sources(pio_differential_manchester PRIVATE differential_manchester.c)
6 |
7 | target_link_libraries(pio_differential_manchester PRIVATE pico_stdlib hardware_pio)
8 | pico_add_extra_outputs(pio_differential_manchester)
9 |
10 | # add url via pico_set_program_url
11 | example_auto_set_url(pio_differential_manchester)
--------------------------------------------------------------------------------
/pio/hello_pio/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_pio)
2 |
3 | pico_generate_pio_header(hello_pio ${CMAKE_CURRENT_LIST_DIR}/hello.pio)
4 |
5 | target_sources(hello_pio PRIVATE hello.c)
6 |
7 | target_link_libraries(hello_pio PRIVATE
8 | pico_stdlib
9 | hardware_pio
10 | )
11 |
12 | # Pass cmake -DHELLO_PIO_LED_PIN=x, where x is the pin you want to use
13 | if(HELLO_PIO_LED_PIN)
14 | target_compile_definitions(hello_pio PRIVATE
15 | HELLO_PIO_LED_PIN=${HELLO_PIO_LED_PIN}
16 | )
17 | endif()
18 |
19 | pico_add_extra_outputs(hello_pio)
20 |
21 | # add url via pico_set_program_url
22 | example_auto_set_url(hello_pio)
23 |
--------------------------------------------------------------------------------
/pio/hello_pio/hello.pio:
--------------------------------------------------------------------------------
1 | ;
2 | ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | ;
4 | ; SPDX-License-Identifier: BSD-3-Clause
5 | ;
6 | .pio_version 0 // only requires PIO version 0
7 |
8 | .program hello
9 |
10 | ; Repeatedly get one word of data from the TX FIFO, stalling when the FIFO is
11 | ; empty. Write the least significant bit to the OUT pin group.
12 |
13 | loop:
14 | pull
15 | out pins, 1
16 | jmp loop
17 |
18 | % c-sdk {
19 | static inline void hello_program_init(PIO pio, uint sm, uint offset, uint pin) {
20 | pio_sm_config c = hello_program_get_default_config(offset);
21 |
22 | // Map the state machine's OUT pin group to one pin, namely the `pin`
23 | // parameter to this function.
24 | sm_config_set_out_pins(&c, pin, 1);
25 | // Set this pin's GPIO function (connect PIO to the pad)
26 | pio_gpio_init(pio, pin);
27 | // Set the pin direction to output at the PIO
28 | pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
29 |
30 | // Load our configuration, and jump to the start of the program
31 | pio_sm_init(pio, sm, offset, &c);
32 | // Set the state machine running
33 | pio_sm_set_enabled(pio, sm, true);
34 | }
35 | %}
36 |
--------------------------------------------------------------------------------
/pio/hub75/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_hub75)
2 |
3 | pico_generate_pio_header(pio_hub75 ${CMAKE_CURRENT_LIST_DIR}/hub75.pio)
4 |
5 | target_sources(pio_hub75 PRIVATE hub75.c)
6 |
7 | target_compile_definitions(pio_hub75 PRIVATE
8 | PICO_DEFAULT_UART_TX_PIN=28
9 | PICO_DEFAULT_UART_RX_PIN=29
10 | )
11 |
12 | target_link_libraries(pio_hub75 PRIVATE pico_stdlib hardware_pio)
13 | pico_add_extra_outputs(pio_hub75)
14 |
15 | # add url via pico_set_program_url
16 | example_auto_set_url(pio_hub75)
17 |
--------------------------------------------------------------------------------
/pio/hub75/Readme.md:
--------------------------------------------------------------------------------
1 | HUB75E Pinout:
2 |
3 | ```
4 | /-----\
5 | R0 | o o | G0
6 | B0 | o o | GND
7 | R1 | o o | G1
8 | B1 \ o o | E
9 | A / o o | B
10 | C | o o | D
11 | CLK | o o | STB
12 | OEn | o o | GND
13 | \-----/
14 | ```
15 |
16 | Wiring:
17 |
18 | ```
19 | Must be contiguous, in order:
20 | R0 - GPIO0
21 | G0 - GPIO1
22 | B0 - GPIO2
23 | R1 - GPIO3
24 | G1 - GPIO4
25 | B1 - GPIO5
26 |
27 | Must be contiguous, somewhat ok to change order:
28 | A - GPIO6
29 | B - GPIO7
30 | C - GPIO8
31 | D - GPIO9
32 | E - GPIO10
33 |
34 | Can be anywhere:
35 | CLK - GPIO11
36 |
37 | Must be contiguous, in order:
38 | STB - GPIO12
39 | OEn - GPIO13
40 | ```
41 |
42 | This is a 1/32nd scan panel. The inputs A, B, C, D, E select one of 32 rows, starting at the top and working down (assuming the first pixel to be shifted is the one on the left of the screen, even though this is the "far end" of the shift register). R0, B0, G0 contain pixel data for the upper half of the screen. R1, G1, B1 contain pixel data for the lower half of the screen, which is scanned simultaneously with the upper half.
43 |
44 | Image credit for mountains_128x64.png: Paul Gilmore, found on [this wikimedia page](https://commons.wikimedia.org/wiki/File:Mountain_lake_dam.jpg)
45 |
46 |
--------------------------------------------------------------------------------
/pio/hub75/mountains_128x64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/pio/hub75/mountains_128x64.png
--------------------------------------------------------------------------------
/pio/i2c/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_i2c_bus_scan)
2 |
3 | pico_generate_pio_header(pio_i2c_bus_scan ${CMAKE_CURRENT_LIST_DIR}/i2c.pio)
4 |
5 | target_sources(pio_i2c_bus_scan PRIVATE
6 | i2c_bus_scan.c
7 | pio_i2c.c
8 | pio_i2c.h
9 | )
10 |
11 | target_link_libraries(pio_i2c_bus_scan PRIVATE pico_stdlib hardware_pio)
12 | pico_add_extra_outputs(pio_i2c_bus_scan)
13 |
14 | # add url via pico_set_program_url
15 | example_auto_set_url(pio_i2c_bus_scan)
16 |
17 |
--------------------------------------------------------------------------------
/pio/i2c/i2c_bus_scan.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "pico/stdlib.h"
4 | #include "pio_i2c.h"
5 |
6 | #define PIN_SDA 2
7 | #define PIN_SCL 3
8 |
9 | bool reserved_addr(uint8_t addr) {
10 | return (addr & 0x78) == 0 || (addr & 0x78) == 0x78;
11 | }
12 |
13 | int main() {
14 | stdio_init_all();
15 |
16 | PIO pio = pio0;
17 | uint sm = 0;
18 | uint offset = pio_add_program(pio, &i2c_program);
19 | i2c_program_init(pio, sm, offset, PIN_SDA, PIN_SCL);
20 |
21 | printf("\nPIO I2C Bus Scan\n");
22 | printf(" 0 1 2 3 4 5 6 7 8 9 A B C D E F\n");
23 |
24 | for (int addr = 0; addr < (1 << 7); ++addr) {
25 | if (addr % 16 == 0) {
26 | printf("%02x ", addr);
27 | }
28 | // Perform a 0-byte read from the probe address. The read function
29 | // returns a negative result NAK'd any time other than the last data
30 | // byte. Skip over reserved addresses.
31 | int result;
32 | if (reserved_addr(addr))
33 | result = -1;
34 | else
35 | result = pio_i2c_read_blocking(pio, sm, addr, NULL, 0);
36 |
37 | printf(result < 0 ? "." : "@");
38 | printf(addr % 16 == 15 ? "\n" : " ");
39 | }
40 | printf("Done.\n");
41 | return 0;
42 | }
43 |
--------------------------------------------------------------------------------
/pio/i2c/pio_i2c.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 | #ifndef _PIO_I2C_H
7 | #define _PIO_I2C_H
8 |
9 | #include "i2c.pio.h"
10 |
11 | // ----------------------------------------------------------------------------
12 | // Low-level functions
13 |
14 | void pio_i2c_start(PIO pio, uint sm);
15 | void pio_i2c_stop(PIO pio, uint sm);
16 | void pio_i2c_repstart(PIO pio, uint sm);
17 |
18 | bool pio_i2c_check_error(PIO pio, uint sm);
19 | void pio_i2c_resume_after_error(PIO pio, uint sm);
20 |
21 | // If I2C is ok, block and push data. Otherwise fall straight through.
22 | void pio_i2c_put_or_err(PIO pio, uint sm, uint16_t data);
23 | uint8_t pio_i2c_get(PIO pio, uint sm);
24 |
25 | // ----------------------------------------------------------------------------
26 | // Transaction-level functions
27 |
28 | int pio_i2c_write_blocking(PIO pio, uint sm, uint8_t addr, uint8_t *txbuf, uint len);
29 | int pio_i2c_read_blocking(PIO pio, uint sm, uint8_t addr, uint8_t *rxbuf, uint len);
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/pio/ir_nec/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # build the transmit and receive libraries
2 | #
3 | add_subdirectory_exclude_platforms(nec_transmit_library)
4 | add_subdirectory_exclude_platforms(nec_receive_library)
5 |
6 | # build the example program
7 | #
8 | add_subdirectory_exclude_platforms(ir_loopback)
9 |
--------------------------------------------------------------------------------
/pio/ir_nec/ir_loopback/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable (pio_ir_loopback ir_loopback.c)
2 |
3 | # link the executable using the IR transmit and receive libraries
4 | #
5 | target_link_libraries(pio_ir_loopback LINK_PUBLIC
6 | pico_stdlib
7 | hardware_pio
8 | nec_transmit_library
9 | nec_receive_library
10 | )
11 |
12 | pico_add_extra_outputs(pio_ir_loopback)
13 |
14 | # add url via pico_set_program_url
15 | example_auto_set_url(pio_ir_loopback)
16 |
--------------------------------------------------------------------------------
/pio/ir_nec/nec_receive_library/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # build a normal library
2 | #
3 | add_library(nec_receive_library nec_receive.c)
4 |
5 | # invoke pio_asm to assemble the state machine program
6 | #
7 | pico_generate_pio_header(nec_receive_library ${CMAKE_CURRENT_LIST_DIR}/nec_receive.pio)
8 |
9 | target_link_libraries(nec_receive_library PRIVATE
10 | pico_stdlib
11 | hardware_pio
12 | )
13 |
14 | # add the `binary` directory so that the generated headers are included in the project
15 | #
16 | target_include_directories (nec_receive_library PUBLIC
17 | ${CMAKE_CURRENT_SOURCE_DIR}
18 | ${CMAKE_CURRENT_BINARY_DIR}
19 | )
20 |
--------------------------------------------------------------------------------
/pio/ir_nec/nec_receive_library/nec_receive.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2021 mjcross
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include "pico/stdlib.h"
8 | #include "hardware/pio.h"
9 |
10 | // public API
11 |
12 | int nec_rx_init(PIO pio, uint pin);
13 | bool nec_decode_frame(uint32_t sm, uint8_t *p_address, uint8_t *p_data);
14 |
--------------------------------------------------------------------------------
/pio/ir_nec/nec_transmit_library/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # build a normal library
2 | #
3 | add_library(nec_transmit_library nec_transmit.c)
4 |
5 | # invoke pio_asm to assemble the PIO state machine programs
6 | #
7 | pico_generate_pio_header(nec_transmit_library ${CMAKE_CURRENT_LIST_DIR}/nec_carrier_burst.pio)
8 | pico_generate_pio_header(nec_transmit_library ${CMAKE_CURRENT_LIST_DIR}/nec_carrier_control.pio)
9 |
10 | target_link_libraries(nec_transmit_library PRIVATE
11 | pico_stdlib
12 | hardware_pio
13 | )
14 |
15 | # add the `binary` directory so that the generated headers are included in the project
16 | #
17 | target_include_directories (nec_transmit_library PUBLIC
18 | ${CMAKE_CURRENT_SOURCE_DIR}
19 | ${CMAKE_CURRENT_BINARY_DIR}
20 | )
21 |
--------------------------------------------------------------------------------
/pio/ir_nec/nec_transmit_library/nec_transmit.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2021 mjcross
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include "pico/stdlib.h"
8 | #include "hardware/pio.h"
9 |
10 | // public API
11 |
12 | int nec_tx_init(PIO pio, uint pin);
13 | uint32_t nec_encode_frame(uint8_t address, uint8_t data);
14 |
--------------------------------------------------------------------------------
/pio/ir_nec/pio_ir_loopback.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/pio/ir_nec/pio_ir_loopback.fzz
--------------------------------------------------------------------------------
/pio/ir_nec/pio_ir_loopback.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/pio/ir_nec/pio_ir_loopback.png
--------------------------------------------------------------------------------
/pio/logic_analyser/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_logic_analyser)
2 |
3 | target_sources(pio_logic_analyser PRIVATE logic_analyser.c)
4 |
5 | target_link_libraries(pio_logic_analyser PRIVATE pico_stdlib hardware_pio hardware_dma)
6 | pico_add_extra_outputs(pio_logic_analyser)
7 |
8 | # add url via pico_set_program_url
9 | example_auto_set_url(pio_logic_analyser)
--------------------------------------------------------------------------------
/pio/manchester_encoding/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_manchester_encoding)
2 |
3 | pico_generate_pio_header(pio_manchester_encoding ${CMAKE_CURRENT_LIST_DIR}/manchester_encoding.pio)
4 |
5 | target_sources(pio_manchester_encoding PRIVATE manchester_encoding.c)
6 |
7 | target_link_libraries(pio_manchester_encoding PRIVATE pico_stdlib hardware_pio)
8 | pico_add_extra_outputs(pio_manchester_encoding)
9 |
10 | # add url via pico_set_program_url
11 | example_auto_set_url(pio_manchester_encoding)
--------------------------------------------------------------------------------
/pio/manchester_encoding/manchester_encoding.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 |
9 | #include "pico/stdlib.h"
10 | #include "hardware/pio.h"
11 | #include "manchester_encoding.pio.h"
12 |
13 | // Manchester serial transmit/receive example. This transmits and receives at
14 | // 10 Mbps if sysclk is 120 MHz.
15 |
16 | // Need to connect a wire from GPIO2 -> GPIO3
17 | const uint pin_tx = 2;
18 | const uint pin_rx = 3;
19 |
20 | int main() {
21 | stdio_init_all();
22 |
23 | PIO pio = pio0;
24 | uint sm_tx = 0;
25 | uint sm_rx = 1;
26 |
27 | uint offset_tx = pio_add_program(pio, &manchester_tx_program);
28 | uint offset_rx = pio_add_program(pio, &manchester_rx_program);
29 | printf("Transmit program loaded at %d\n", offset_tx);
30 | printf("Receive program loaded at %d\n", offset_rx);
31 |
32 | manchester_tx_program_init(pio, sm_tx, offset_tx, pin_tx, 1.f);
33 | manchester_rx_program_init(pio, sm_rx, offset_rx, pin_rx, 1.f);
34 |
35 | pio_sm_set_enabled(pio, sm_tx, false);
36 | pio_sm_put_blocking(pio, sm_tx, 0);
37 | pio_sm_put_blocking(pio, sm_tx, 0x0ff0a55a);
38 | pio_sm_put_blocking(pio, sm_tx, 0x12345678);
39 | pio_sm_set_enabled(pio, sm_tx, true);
40 |
41 | for (int i = 0; i < 3; ++i)
42 | printf("%08x\n", pio_sm_get_blocking(pio, sm_rx));
43 | }
44 |
--------------------------------------------------------------------------------
/pio/onewire/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_onewire)
2 |
3 | target_sources(pio_onewire PRIVATE onewire.c)
4 |
5 | add_subdirectory(onewire_library)
6 |
7 | target_link_libraries(pio_onewire PRIVATE
8 | pico_stdlib
9 | hardware_pio
10 | onewire_library)
11 |
12 | pico_add_extra_outputs(pio_onewire)
13 |
14 | # add url via pico_set_program_url
15 | example_auto_set_url(pio_onewire)
16 |
--------------------------------------------------------------------------------
/pio/onewire/ds18b20.h:
--------------------------------------------------------------------------------
1 | // Function commands for d218b20 1-Wire temperature sensor
2 | // https://www.analog.com/en/products/ds18b20.html
3 | //
4 | #define DS18B20_CONVERT_T 0x44
5 | #define DS18B20_WRITE_SCRATCHPAD 0x4e
6 | #define DS18B20_READ_SCRATCHPAD 0xbe
7 | #define DS18B20_COPY_SCRATCHPAD 0x48
8 | #define DS18B20_RECALL_EE 0xb8
9 | #define DS18B20_READ_POWER_SUPPLY 0xb4
--------------------------------------------------------------------------------
/pio/onewire/onewire_library/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(onewire_library INTERFACE)
2 | target_sources(onewire_library INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/onewire_library.c)
3 |
4 | # invoke pio_asm to assemble the state machine programs
5 | #
6 | pico_generate_pio_header(onewire_library ${CMAKE_CURRENT_LIST_DIR}/onewire_library.pio)
7 |
8 | target_link_libraries(onewire_library INTERFACE
9 | pico_stdlib
10 | hardware_pio
11 | )
12 |
13 | # add the `binary` directory so that the generated headers are included in the project
14 | #
15 | target_include_directories(onewire_library INTERFACE
16 | ${CMAKE_CURRENT_SOURCE_DIR}
17 | ${CMAKE_CURRENT_BINARY_DIR}
18 | )
19 |
--------------------------------------------------------------------------------
/pio/onewire/onewire_library/onewire_library.h:
--------------------------------------------------------------------------------
1 | #ifndef _ONEWIRE_LIBRARY_H
2 | #define _ONEWIRE_LIBRARY_H
3 |
4 | #include "hardware/pio.h"
5 | #include "hardware/clocks.h" // for clock_get_hz() in generated header
6 | #include "onewire_library.pio.h" // generated by pioasm
7 |
8 | typedef struct {
9 | PIO pio;
10 | uint sm;
11 | uint jmp_reset;
12 | int offset;
13 | int gpio;
14 | } OW;
15 |
16 | bool ow_init (OW *ow, PIO pio, uint offset, uint gpio);
17 | void ow_send (OW *ow, uint data);
18 | uint8_t ow_read (OW *ow);
19 | bool ow_reset (OW *ow);
20 | int ow_romsearch (OW *ow, uint64_t *romcodes, int maxdevs, uint command);
21 |
22 | #endif
23 |
--------------------------------------------------------------------------------
/pio/onewire/ow_rom.h:
--------------------------------------------------------------------------------
1 | // Generic ROM commands for 1-Wire devices
2 | // https://www.analog.com/en/technical-articles/guide-to-1wire-communication.html
3 | //
4 | #define OW_READ_ROM 0x33
5 | #define OW_MATCH_ROM 0x55
6 | #define OW_SKIP_ROM 0xCC
7 | #define OW_ALARM_SEARCH 0xEC
8 | #define OW_SEARCH_ROM 0xF0
--------------------------------------------------------------------------------
/pio/onewire/pio_onewire.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/pio/onewire/pio_onewire.fzz
--------------------------------------------------------------------------------
/pio/onewire/pio_onewire.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/pio/onewire/pio_onewire.png
--------------------------------------------------------------------------------
/pio/pio_blink/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_blink)
2 |
3 | # by default the header is generated into the build dir
4 | pico_generate_pio_header(pio_blink ${CMAKE_CURRENT_LIST_DIR}/blink.pio)
5 | # however, alternatively you can choose to generate it somewhere else (in this case in the source tree for check in)
6 | #pico_generate_pio_header(pio_blink ${CMAKE_CURRENT_LIST_DIR}/blink.pio OUTPUT_DIR ${CMAKE_CURRENT_LIST_DIR})
7 |
8 | target_sources(pio_blink PRIVATE blink.c)
9 |
10 | target_link_libraries(pio_blink PRIVATE pico_stdlib hardware_pio)
11 | pico_add_extra_outputs(pio_blink)
12 |
13 | # add url via pico_set_program_url
14 | example_auto_set_url(pio_blink)
--------------------------------------------------------------------------------
/pio/pio_blink/blink.pio:
--------------------------------------------------------------------------------
1 | ;
2 | ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | ;
4 | ; SPDX-License-Identifier: BSD-3-Clause
5 | ;
6 |
7 | ; SET pin 0 should be mapped to your LED GPIO
8 |
9 | .pio_version 0 // only requires PIO version 0
10 |
11 | .program blink
12 | pull block
13 | out y, 32
14 | .wrap_target
15 | mov x, y
16 | set pins, 1 ; Turn LED on
17 | lp1:
18 | jmp x-- lp1 ; Delay for (x + 1) cycles, x is a 32 bit number
19 | mov x, y
20 | set pins, 0 ; Turn LED off
21 | lp2:
22 | jmp x-- lp2 ; Delay for the same number of cycles again
23 | .wrap ; Blink forever!
24 |
25 |
26 | % c-sdk {
27 | // this is a raw helper function for use by the user which sets up the GPIO output, and configures the SM to output on a particular pin
28 |
29 | void blink_program_init(PIO pio, uint sm, uint offset, uint pin) {
30 | pio_gpio_init(pio, pin);
31 | pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
32 | pio_sm_config c = blink_program_get_default_config(offset);
33 | sm_config_set_set_pins(&c, pin, 1);
34 | pio_sm_init(pio, sm, offset, &c);
35 | }
36 | %}
37 |
--------------------------------------------------------------------------------
/pio/pwm/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_pwm)
2 |
3 | pico_generate_pio_header(pio_pwm ${CMAKE_CURRENT_LIST_DIR}/pwm.pio)
4 |
5 | target_sources(pio_pwm PRIVATE pwm.c)
6 |
7 | target_link_libraries(pio_pwm PRIVATE pico_stdlib hardware_pio)
8 | pico_add_extra_outputs(pio_pwm)
9 |
10 | # add url via pico_set_program_url
11 | example_auto_set_url(pio_pwm)
--------------------------------------------------------------------------------
/pio/pwm/pwm.pio:
--------------------------------------------------------------------------------
1 | ;
2 | ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | ;
4 | ; SPDX-License-Identifier: BSD-3-Clause
5 | ;
6 |
7 | ; Side-set pin 0 is used for PWM output
8 | .pio_version 0 // only requires PIO version 0
9 |
10 | .program pwm
11 | .side_set 1 opt
12 |
13 | pull noblock side 0 ; Pull from FIFO to OSR if available, else copy X to OSR.
14 | mov x, osr ; Copy most-recently-pulled value back to scratch X
15 | mov y, isr ; ISR contains PWM period. Y used as counter.
16 | countloop:
17 | jmp x!=y noset ; Set pin high if X == Y, keep the two paths length matched
18 | jmp skip side 1
19 | noset:
20 | nop ; Single dummy cycle to keep the two paths the same length
21 | skip:
22 | jmp y-- countloop ; Loop until Y hits 0, then pull a fresh PWM value from FIFO
23 |
24 | % c-sdk {
25 | static inline void pwm_program_init(PIO pio, uint sm, uint offset, uint pin) {
26 | pio_gpio_init(pio, pin);
27 | pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
28 | pio_sm_config c = pwm_program_get_default_config(offset);
29 | sm_config_set_sideset_pins(&c, pin);
30 | pio_sm_init(pio, sm, offset, &c);
31 | }
32 | %}
33 |
--------------------------------------------------------------------------------
/pio/quadrature_encoder/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_quadrature_encoder)
2 |
3 | pico_generate_pio_header(pio_quadrature_encoder ${CMAKE_CURRENT_LIST_DIR}/quadrature_encoder.pio)
4 |
5 | target_sources(pio_quadrature_encoder PRIVATE quadrature_encoder.c)
6 |
7 | target_link_libraries(pio_quadrature_encoder PRIVATE
8 | pico_stdlib
9 | pico_multicore
10 | hardware_pio
11 | )
12 |
13 | pico_enable_stdio_usb(pio_quadrature_encoder 1)
14 |
15 | pico_add_extra_outputs(pio_quadrature_encoder)
16 |
17 | # add url via pico_set_program_url
18 | example_auto_set_url(pio_quadrature_encoder)
19 |
--------------------------------------------------------------------------------
/pio/quadrature_encoder_substep/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_quadrature_encoder_substep)
2 |
3 | pico_generate_pio_header(pio_quadrature_encoder_substep ${CMAKE_CURRENT_LIST_DIR}/quadrature_encoder_substep.pio)
4 |
5 | target_sources(pio_quadrature_encoder_substep PRIVATE quadrature_encoder_substep.c)
6 |
7 | target_link_libraries(pio_quadrature_encoder_substep PRIVATE
8 | pico_stdlib
9 | pico_multicore
10 | hardware_pio
11 | hardware_pwm
12 | hardware_watchdog
13 | )
14 |
15 | target_compile_definitions(pio_quadrature_encoder_substep PRIVATE PICO_STDIO_USB_DEFAULT_CRLF=0)
16 | pico_enable_stdio_usb(pio_quadrature_encoder_substep 1)
17 |
18 | pico_add_extra_outputs(pio_quadrature_encoder_substep)
19 |
20 | # add url via pico_set_program_url
21 | example_auto_set_url(pio_quadrature_encoder_substep)
22 |
--------------------------------------------------------------------------------
/pio/spi/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_spi_flash)
2 |
3 | pico_generate_pio_header(pio_spi_flash ${CMAKE_CURRENT_LIST_DIR}/spi.pio)
4 |
5 | target_sources(pio_spi_flash PRIVATE
6 | spi_flash.c
7 | pio_spi.c
8 | pio_spi.h
9 | )
10 |
11 | target_link_libraries(pio_spi_flash PRIVATE pico_stdlib hardware_pio)
12 | pico_add_extra_outputs(pio_spi_flash)
13 |
14 | example_auto_set_url(pio_spi_flash)
15 |
16 | add_executable(pio_spi_loopback)
17 |
18 | pico_generate_pio_header(pio_spi_loopback ${CMAKE_CURRENT_LIST_DIR}/spi.pio)
19 |
20 | target_sources(pio_spi_loopback PRIVATE
21 | spi_loopback.c
22 | pio_spi.c
23 | pio_spi.h
24 | )
25 |
26 | target_link_libraries(pio_spi_loopback PRIVATE pico_stdlib hardware_pio)
27 | pico_add_extra_outputs(pio_spi_loopback)
28 |
29 | example_auto_set_url(pio_spi_loopback)
30 |
--------------------------------------------------------------------------------
/pio/spi/pio_spi.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 | #ifndef _PIO_SPI_H
7 | #define _PIO_SPI_H
8 |
9 | #include "hardware/pio.h"
10 | #include "spi.pio.h"
11 |
12 | typedef struct pio_spi_inst {
13 | PIO pio;
14 | uint sm;
15 | uint cs_pin;
16 | } pio_spi_inst_t;
17 |
18 | void pio_spi_write8_blocking(const pio_spi_inst_t *spi, const uint8_t *src, size_t len);
19 |
20 | void pio_spi_read8_blocking(const pio_spi_inst_t *spi, uint8_t *dst, size_t len);
21 |
22 | void pio_spi_write8_read8_blocking(const pio_spi_inst_t *spi, uint8_t *src, uint8_t *dst, size_t len);
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/pio/squarewave/generated/squarewave.hex:
--------------------------------------------------------------------------------
1 | e081
2 | e101
3 | e000
4 | 0001
5 |
--------------------------------------------------------------------------------
/pio/squarewave/generated/squarewave.pio.h:
--------------------------------------------------------------------------------
1 | // -------------------------------------------------- //
2 | // This file is autogenerated by pioasm; do not edit! //
3 | // -------------------------------------------------- //
4 |
5 | #pragma once
6 |
7 | #if !PICO_NO_HARDWARE
8 | #include "hardware/pio.h"
9 | #endif
10 |
11 | // ---------- //
12 | // squarewave //
13 | // ---------- //
14 |
15 | #define squarewave_wrap_target 0
16 | #define squarewave_wrap 3
17 | #define squarewave_pio_version 0
18 |
19 | static const uint16_t squarewave_program_instructions[] = {
20 | // .wrap_target
21 | 0xe081, // 0: set pindirs, 1
22 | 0xe101, // 1: set pins, 1 [1]
23 | 0xe000, // 2: set pins, 0
24 | 0x0001, // 3: jmp 1
25 | // .wrap
26 | };
27 |
28 | #if !PICO_NO_HARDWARE
29 | static const struct pio_program squarewave_program = {
30 | .instructions = squarewave_program_instructions,
31 | .length = 4,
32 | .origin = -1,
33 | .pio_version = squarewave_pio_version,
34 | #if PICO_PIO_VERSION > 0
35 | .used_gpio_ranges = 0x0
36 | #endif
37 | };
38 |
39 | static inline pio_sm_config squarewave_program_get_default_config(uint offset) {
40 | pio_sm_config c = pio_get_default_sm_config();
41 | sm_config_set_wrap(&c, offset + squarewave_wrap_target, offset + squarewave_wrap);
42 | return c;
43 | }
44 | #endif
45 |
46 |
--------------------------------------------------------------------------------
/pio/squarewave/generated/squarewave_wrap.pio.h:
--------------------------------------------------------------------------------
1 | // -------------------------------------------------- //
2 | // This file is autogenerated by pioasm; do not edit! //
3 | // -------------------------------------------------- //
4 |
5 | #pragma once
6 |
7 | #if !PICO_NO_HARDWARE
8 | #include "hardware/pio.h"
9 | #endif
10 |
11 | // --------------- //
12 | // squarewave_wrap //
13 | // --------------- //
14 |
15 | #define squarewave_wrap_wrap_target 1
16 | #define squarewave_wrap_wrap 2
17 | #define squarewave_wrap_pio_version 0
18 |
19 | static const uint16_t squarewave_wrap_program_instructions[] = {
20 | 0xe081, // 0: set pindirs, 1
21 | // .wrap_target
22 | 0xe101, // 1: set pins, 1 [1]
23 | 0xe100, // 2: set pins, 0 [1]
24 | // .wrap
25 | };
26 |
27 | #if !PICO_NO_HARDWARE
28 | static const struct pio_program squarewave_wrap_program = {
29 | .instructions = squarewave_wrap_program_instructions,
30 | .length = 3,
31 | .origin = -1,
32 | .pio_version = squarewave_wrap_pio_version,
33 | #if PICO_PIO_VERSION > 0
34 | .used_gpio_ranges = 0x0
35 | #endif
36 | };
37 |
38 | static inline pio_sm_config squarewave_wrap_program_get_default_config(uint offset) {
39 | pio_sm_config c = pio_get_default_sm_config();
40 | sm_config_set_wrap(&c, offset + squarewave_wrap_wrap_target, offset + squarewave_wrap_wrap);
41 | return c;
42 | }
43 | #endif
44 |
45 |
--------------------------------------------------------------------------------
/pio/squarewave/squarewave.pio:
--------------------------------------------------------------------------------
1 | ;
2 | ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | ;
4 | ; SPDX-License-Identifier: BSD-3-Clause
5 | ;
6 | .pio_version 0 // only requires PIO version 0
7 |
8 | .program squarewave
9 | set pindirs, 1 ; Set pin to output
10 | again:
11 | set pins, 1 [1] ; Drive pin high and then delay for one cycle
12 | set pins, 0 ; Drive pin low
13 | jmp again ; Set PC to label `again`
14 |
15 |
--------------------------------------------------------------------------------
/pio/squarewave/squarewave_fast.pio:
--------------------------------------------------------------------------------
1 | ;
2 | ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | ;
4 | ; SPDX-License-Identifier: BSD-3-Clause
5 | ;
6 |
7 | ; Note that if you modify squarewave.c to include this program, you'll also
8 | ; need to set the wrap registers yourself. This would be handled for you by
9 | ; squarewave_program_get_default_config().
10 | .pio_version 0 // only requires PIO version 0
11 |
12 | .program squarewave_fast
13 | ; Like squarewave_wrap, but remove the delay cycles so we can run twice as fast.
14 | set pindirs, 1 ; Set pin to output
15 | .wrap_target
16 | set pins, 1 ; Drive pin high
17 | set pins, 0 ; Drive pin low
18 | .wrap
19 |
20 |
--------------------------------------------------------------------------------
/pio/squarewave/squarewave_wrap.pio:
--------------------------------------------------------------------------------
1 | ;
2 | ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | ;
4 | ; SPDX-License-Identifier: BSD-3-Clause
5 | ;
6 |
7 | ; Note that if you modify squarewave.c to include this program, you'll also
8 | ; need to set the wrap registers yourself. This would be handled for you by
9 | ; squarewave_program_get_default_config().
10 | .pio_version 0 // only requires PIO version 0
11 |
12 | .program squarewave_wrap
13 | ; Like squarewave, but use the state machine's .wrap hardware instead of an
14 | ; explicit jmp. This is a free (0-cycle) unconditional jump.
15 |
16 | set pindirs, 1 ; Set pin to output
17 | .wrap_target
18 | set pins, 1 [1] ; Drive pin high and then delay for one cycle
19 | set pins, 0 [1] ; Drive pin low and then delay for one cycle
20 | .wrap
21 |
--------------------------------------------------------------------------------
/pio/st7789_lcd/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_st7789_lcd)
2 |
3 | pico_generate_pio_header(pio_st7789_lcd ${CMAKE_CURRENT_LIST_DIR}/st7789_lcd.pio)
4 |
5 | target_sources(pio_st7789_lcd PRIVATE st7789_lcd.c)
6 |
7 | target_link_libraries(pio_st7789_lcd PRIVATE pico_stdlib hardware_pio hardware_interp)
8 | pico_add_extra_outputs(pio_st7789_lcd)
9 |
10 | # add url via pico_set_program_url
11 | example_auto_set_url(pio_st7789_lcd)
12 |
--------------------------------------------------------------------------------
/pio/st7789_lcd/raspberry_256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/pio/st7789_lcd/raspberry_256x256.png
--------------------------------------------------------------------------------
/pio/uart_pio_dma/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(uart_pio_dma)
2 | pico_generate_pio_header(uart_pio_dma ${CMAKE_CURRENT_LIST_DIR}/../uart_rx/uart_rx.pio)
3 | pico_generate_pio_header(uart_pio_dma ${CMAKE_CURRENT_LIST_DIR}/../uart_tx/uart_tx.pio)
4 | target_sources(uart_pio_dma PRIVATE uart_pio_dma.c)
5 | target_link_libraries(uart_pio_dma PRIVATE
6 | pico_stdlib
7 | hardware_pio
8 | hardware_dma
9 | )
10 | pico_add_extra_outputs(uart_pio_dma)
11 | example_auto_set_url(uart_pio_dma)
12 |
--------------------------------------------------------------------------------
/pio/uart_rx/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_uart_rx)
2 |
3 | pico_generate_pio_header(pio_uart_rx ${CMAKE_CURRENT_LIST_DIR}/uart_rx.pio)
4 |
5 | target_sources(pio_uart_rx PRIVATE uart_rx.c)
6 |
7 | target_link_libraries(pio_uart_rx PRIVATE
8 | pico_stdlib
9 | pico_multicore
10 | hardware_pio
11 | )
12 |
13 | pico_add_extra_outputs(pio_uart_rx)
14 |
15 | # add url via pico_set_program_url
16 | example_auto_set_url(pio_uart_rx)
17 |
18 | # Similar to above but uses an interrupt for RX
19 | add_executable(pio_uart_rx_intr)
20 | pico_generate_pio_header(pio_uart_rx_intr ${CMAKE_CURRENT_LIST_DIR}/uart_rx.pio)
21 | target_sources(pio_uart_rx_intr PRIVATE uart_rx_intr.c)
22 | target_link_libraries(pio_uart_rx_intr PRIVATE
23 | pico_stdlib
24 | pico_multicore
25 | hardware_pio
26 | pico_async_context_threadsafe_background
27 | )
28 | pico_add_extra_outputs(pio_uart_rx_intr)
29 | example_auto_set_url(pio_uart_rx_intr)
30 |
--------------------------------------------------------------------------------
/pio/uart_tx/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pio_uart_tx)
2 |
3 | pico_generate_pio_header(pio_uart_tx ${CMAKE_CURRENT_LIST_DIR}/uart_tx.pio)
4 |
5 | target_sources(pio_uart_tx PRIVATE uart_tx.c)
6 |
7 | target_link_libraries(pio_uart_tx PRIVATE pico_stdlib hardware_pio)
8 | pico_add_extra_outputs(pio_uart_tx)
9 |
10 | # add url via pico_set_program_url
11 | example_auto_set_url(pio_uart_tx)
12 |
--------------------------------------------------------------------------------
/pio/ws2812/generated/ws2812.py:
--------------------------------------------------------------------------------
1 | # -------------------------------------------------- #
2 | # This file is autogenerated by pioasm; do not edit! #
3 | # -------------------------------------------------- #
4 |
5 | import rp2
6 | from machine import Pin
7 | # ------ #
8 | # ws2812 #
9 | # ------ #
10 |
11 | ws2812_T1 = 3
12 | ws2812_T2 = 3
13 | ws2812_T3 = 4
14 |
15 | @rp2.asm_pio(sideset_init=pico.PIO.OUT_HIGH, out_init=pico.PIO.OUT_HIGH, out_shiftdir=1)
16 | def ws2812():
17 | wrap_target()
18 | label("0")
19 | out(x, 1) .side(0) [3] # 0
20 | jmp(not_x, "3") .side(1) [2] # 1
21 | jmp("0") .side(1) [2] # 2
22 | label("3")
23 | nop() .side(0) [2] # 3
24 | wrap()
25 |
26 |
27 |
28 | # --------------- #
29 | # ws2812_parallel #
30 | # --------------- #
31 |
32 | ws2812_parallel_T1 = 3
33 | ws2812_parallel_T2 = 3
34 | ws2812_parallel_T3 = 4
35 |
36 | @rp2.asm_pio()
37 | def ws2812_parallel():
38 | wrap_target()
39 | out(x, 32) # 0
40 | mov(pins, invert(null)) [2] # 1
41 | mov(pins, x) [2] # 2
42 | mov(pins, null) [2] # 3
43 | wrap()
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/pwm/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET hardware_pwm)
2 | add_subdirectory_exclude_platforms(hello_pwm)
3 | add_subdirectory_exclude_platforms(led_fade)
4 | add_subdirectory_exclude_platforms(measure_duty_cycle)
5 | else()
6 | message("Skipping PWM examples as hardware_pwm is unavailable on this platform")
7 | endif()
8 |
--------------------------------------------------------------------------------
/pwm/hello_pwm/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_pwm
2 | hello_pwm.c
3 | )
4 |
5 | # pull in common dependencies and additional pwm hardware support
6 | target_link_libraries(hello_pwm pico_stdlib hardware_pwm)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(hello_pwm)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(hello_pwm)
13 |
--------------------------------------------------------------------------------
/pwm/hello_pwm/hello_pwm.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | // Output PWM signals on pins 0 and 1
8 |
9 | #include "pico/stdlib.h"
10 | #include "hardware/pwm.h"
11 |
12 | int main() {
13 | /// \tag::setup_pwm[]
14 |
15 | // Tell GPIO 0 and 1 they are allocated to the PWM
16 | gpio_set_function(0, GPIO_FUNC_PWM);
17 | gpio_set_function(1, GPIO_FUNC_PWM);
18 |
19 | // Find out which PWM slice is connected to GPIO 0 (it's slice 0)
20 | uint slice_num = pwm_gpio_to_slice_num(0);
21 |
22 | // Set period of 4 cycles (0 to 3 inclusive)
23 | pwm_set_wrap(slice_num, 3);
24 | // Set channel A output high for one cycle before dropping
25 | pwm_set_chan_level(slice_num, PWM_CHAN_A, 1);
26 | // Set initial B output high for three cycles before dropping
27 | pwm_set_chan_level(slice_num, PWM_CHAN_B, 3);
28 | // Set the PWM running
29 | pwm_set_enabled(slice_num, true);
30 | /// \end::setup_pwm[]
31 |
32 | // Note we could also use pwm_set_gpio_level(gpio, x) which looks up the
33 | // correct slice and channel for a given GPIO.
34 | }
35 |
--------------------------------------------------------------------------------
/pwm/led_fade/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pwm_led_fade
2 | pwm_led_fade.c
3 | )
4 |
5 | # pull in common dependencies and additional pwm hardware support
6 | target_link_libraries(pwm_led_fade pico_stdlib hardware_pwm)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(pwm_led_fade)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(pwm_led_fade)
13 |
--------------------------------------------------------------------------------
/pwm/measure_duty_cycle/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(pwm_measure_duty_cycle
2 | measure_duty_cycle.c
3 | )
4 |
5 | # pull in common dependencies and additional pwm hardware support
6 | target_link_libraries(pwm_measure_duty_cycle pico_stdlib hardware_pwm)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(pwm_measure_duty_cycle)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(pwm_measure_duty_cycle)
13 |
--------------------------------------------------------------------------------
/reset/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET hardware_resets)
2 | add_subdirectory_exclude_platforms(hello_reset)
3 | else()
4 | message("Skipping reset examples as hardware_resets is unavailable on this platform")
5 | endif()
6 |
--------------------------------------------------------------------------------
/reset/hello_reset/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET hardware_resets)
2 | add_executable(hello_reset
3 | hello_reset.c
4 | )
5 |
6 | # pull in common dependencies and additional reset hardware support
7 | target_link_libraries(hello_reset pico_stdlib hardware_resets)
8 |
9 | # create map/bin/hex file etc.
10 | pico_add_extra_outputs(hello_reset)
11 |
12 | # add url via pico_set_program_url
13 | example_auto_set_url(hello_reset)
14 | endif ()
15 |
--------------------------------------------------------------------------------
/reset/hello_reset/hello_reset.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 | #include "pico/stdlib.h"
9 | #include "hardware/resets.h"
10 |
11 | /// \tag::hello_reset[]
12 | int main() {
13 | stdio_init_all();
14 |
15 | printf("Hello, reset!\n");
16 |
17 | // Put the PWM block into reset
18 | reset_block_num(RESET_PWM);
19 |
20 | // And bring it out
21 | unreset_block_num_wait_blocking(RESET_PWM);
22 |
23 | // Put the PWM and ADC block into reset
24 | reset_block_mask((1u << RESET_PWM) | (1u << RESET_ADC));
25 |
26 | // Wait for both to come out of reset
27 | unreset_block_mask_wait_blocking((1u << RESET_PWM) | (1u << RESET_ADC));
28 |
29 | return 0;
30 | }
31 | /// \end::hello_reset[]
32 |
--------------------------------------------------------------------------------
/rtc/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET hardware_rtc)
2 | add_subdirectory_exclude_platforms(hello_rtc)
3 | add_subdirectory_exclude_platforms(rtc_alarm)
4 | add_subdirectory_exclude_platforms(rtc_alarm_repeat)
5 | else()
6 | message("Skipping RTC examples as hardware_rtc is unavailable on this platform")
7 | endif()
8 |
--------------------------------------------------------------------------------
/rtc/hello_rtc/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_rtc
2 | hello_rtc.c
3 | )
4 |
5 | # pull in common dependencies and additional rtc hardware support
6 | target_link_libraries(hello_rtc pico_stdlib hardware_rtc)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(hello_rtc)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(hello_rtc)
13 |
--------------------------------------------------------------------------------
/rtc/hello_rtc/hello_rtc.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 | #include "hardware/rtc.h"
9 | #include "pico/stdlib.h"
10 | #include "pico/util/datetime.h"
11 |
12 | /// \tag::hello_rtc_main[]
13 | int main() {
14 | stdio_init_all();
15 | printf("Hello RTC!\n");
16 |
17 | char datetime_buf[256];
18 | char *datetime_str = &datetime_buf[0];
19 |
20 | // Start on Friday 5th of June 2020 15:45:00
21 | datetime_t t = {
22 | .year = 2020,
23 | .month = 06,
24 | .day = 05,
25 | .dotw = 5, // 0 is Sunday, so 5 is Friday
26 | .hour = 15,
27 | .min = 45,
28 | .sec = 00
29 | };
30 |
31 | // Start the RTC
32 | rtc_init();
33 | rtc_set_datetime(&t);
34 |
35 | // clk_sys is >2000x faster than clk_rtc, so datetime is not updated immediately when rtc_get_datetime() is called.
36 | // The delay is up to 3 RTC clock cycles (which is 64us with the default clock settings)
37 | sleep_us(64);
38 |
39 | // Print the time
40 | while (true) {
41 | rtc_get_datetime(&t);
42 | datetime_to_str(datetime_str, sizeof(datetime_buf), &t);
43 | printf("\r%s ", datetime_str);
44 | sleep_ms(100);
45 | }
46 | }
47 | /// \end::hello_rtc_main[]
48 |
--------------------------------------------------------------------------------
/rtc/rtc_alarm/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(rtc_alarm
2 | rtc_alarm.c
3 | )
4 |
5 | # pull in common dependencies and additional rtc hardware support
6 | target_link_libraries(rtc_alarm pico_stdlib hardware_rtc)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(rtc_alarm)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(rtc_alarm)
13 |
--------------------------------------------------------------------------------
/rtc/rtc_alarm_repeat/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(rtc_alarm_repeat
2 | rtc_alarm_repeat.c
3 | )
4 |
5 | # pull in common dependencies and additional rtc hardware support
6 | target_link_libraries(rtc_alarm_repeat pico_stdlib hardware_rtc)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(rtc_alarm_repeat)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(rtc_alarm_repeat)
13 |
--------------------------------------------------------------------------------
/sha/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # todo peter fix mixture of sha256 and MBED
2 | if (TARGET pico_sha256 AND TARGET pico_mbedtls)
3 | add_subdirectory_exclude_platforms(sha256)
4 | add_subdirectory_exclude_platforms(mbedtls_sha256)
5 | else()
6 | message("Skipping SHA256 examples as pico_sha256 or pico_mbedtls unavailable")
7 | endif ()
8 |
--------------------------------------------------------------------------------
/sha/mbedtls_sha256/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (NOT TARGET hardware_sha256)
2 | return()
3 | endif()
4 |
5 | # This example uses the mbedtls SHA-256 API
6 | # mbedtls_config.h defines MBEDTLS_SHA256_ALT enabling hardware acceleration if supported
7 | add_executable(mbedtls_sha256
8 | mbedtls_sha256.c
9 | )
10 | target_link_libraries(mbedtls_sha256
11 | pico_stdlib
12 | pico_mbedtls
13 | )
14 | target_include_directories(mbedtls_sha256 PRIVATE
15 | ${CMAKE_CURRENT_LIST_DIR}
16 | )
17 | pico_add_extra_outputs(mbedtls_sha256)
18 | example_auto_set_url(mbedtls_sha256)
19 |
--------------------------------------------------------------------------------
/sha/mbedtls_sha256/mbedtls_config.h:
--------------------------------------------------------------------------------
1 | #ifndef _MBEDTLS_CONFIG_H
2 | #define _MBEDTLS_CONFIG_H
3 |
4 | #if LIB_PICO_SHA256
5 | // Enable hardware acceleration
6 | #define MBEDTLS_SHA256_ALT
7 | #else
8 | #define MBEDTLS_SHA256_C
9 | #endif
10 |
11 | #endif
--------------------------------------------------------------------------------
/sha/sha256/sample.txt:
--------------------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
--------------------------------------------------------------------------------
/spi/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET hardware_spi)
2 | add_subdirectory_exclude_platforms(bme280_spi)
3 | add_subdirectory_exclude_platforms(mpu9250_spi)
4 | add_subdirectory_exclude_platforms(spi_dma)
5 | add_subdirectory_exclude_platforms(spi_master_slave)
6 | add_subdirectory_exclude_platforms(spi_flash)
7 | add_subdirectory_exclude_platforms(max7219_32x8_spi)
8 | add_subdirectory_exclude_platforms(max7219_8x7seg_spi)
9 | else()
10 | message("Skipping SPI examples as hardware_spi is unavailable on this platform")
11 | endif()
--------------------------------------------------------------------------------
/spi/bme280_spi/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(bme280_spi
2 | bme280_spi.c
3 | )
4 |
5 | # pull in common dependencies and additional spi hardware support
6 | target_link_libraries(bme280_spi pico_stdlib hardware_spi)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(bme280_spi)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(bme280_spi)
13 |
--------------------------------------------------------------------------------
/spi/bme280_spi/bme280_spi.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/spi/bme280_spi/bme280_spi.fzz
--------------------------------------------------------------------------------
/spi/bme280_spi/bme280_spi_bb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/spi/bme280_spi/bme280_spi_bb.png
--------------------------------------------------------------------------------
/spi/max7219_32x8_spi/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(max7219_32x8_spi
2 | max7219_32x8_spi.c
3 | )
4 |
5 | # pull in common dependencies and additional spi hardware support
6 | target_link_libraries(max7219_32x8_spi pico_stdlib hardware_spi)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(max7219_32x8_spi)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(max7219_32x8_spi)
13 |
--------------------------------------------------------------------------------
/spi/max7219_8x7seg_spi/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(max7219_8x7seg_spi
2 | max7219_8x7seg_spi.c
3 | )
4 |
5 | # pull in common dependencies and additional spi hardware support
6 | target_link_libraries(max7219_8x7seg_spi pico_stdlib hardware_spi)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(max7219_8x7seg_spi)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(max7219_8x7seg_spi)
13 |
--------------------------------------------------------------------------------
/spi/mpu9250_spi/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(mpu9250_spi
2 | mpu9250_spi.c
3 | )
4 |
5 | # pull in common dependencies and additional spi hardware support
6 | target_link_libraries(mpu9250_spi pico_stdlib hardware_spi)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(mpu9250_spi)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(mpu9250_spi)
13 |
--------------------------------------------------------------------------------
/spi/mpu9250_spi/mpu9250_spi.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/spi/mpu9250_spi/mpu9250_spi.fzz
--------------------------------------------------------------------------------
/spi/mpu9250_spi/mpu9250_spi_bb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/spi/mpu9250_spi/mpu9250_spi_bb.png
--------------------------------------------------------------------------------
/spi/spi_dma/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(spi_dma
2 | spi_dma.c
3 | )
4 |
5 | target_link_libraries(spi_dma pico_stdlib hardware_spi hardware_dma)
6 |
7 | # create map/bin/hex file etc.
8 | pico_add_extra_outputs(spi_dma)
9 |
10 | # add url via pico_set_program_url
11 | example_auto_set_url(spi_dma)
12 |
--------------------------------------------------------------------------------
/spi/spi_flash/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(spi_flash
2 | spi_flash.c
3 | )
4 |
5 | # pull in common dependencies and additional spi hardware support
6 | target_link_libraries(spi_flash pico_stdlib hardware_spi)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(spi_flash)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(spi_flash)
13 |
--------------------------------------------------------------------------------
/spi/spi_master_slave/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory_exclude_platforms(spi_master)
2 | add_subdirectory_exclude_platforms(spi_slave)
3 |
--------------------------------------------------------------------------------
/spi/spi_master_slave/spi_master/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(spi_master
2 | spi_master.c
3 | )
4 |
5 | # Pull in basic dependencies
6 | target_link_libraries(spi_master pico_stdlib hardware_spi)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(spi_master)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(spi_master)
13 |
--------------------------------------------------------------------------------
/spi/spi_master_slave/spi_master_slave.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/spi/spi_master_slave/spi_master_slave.fzz
--------------------------------------------------------------------------------
/spi/spi_master_slave/spi_master_slave_bb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/spi/spi_master_slave/spi_master_slave_bb.png
--------------------------------------------------------------------------------
/spi/spi_master_slave/spi_master_slave_logic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/spi/spi_master_slave/spi_master_slave_logic.png
--------------------------------------------------------------------------------
/spi/spi_master_slave/spi_slave/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(spi_slave
2 | spi_slave.c
3 | )
4 |
5 | # Pull in basic dependencies
6 | target_link_libraries(spi_slave pico_stdlib hardware_spi)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(spi_slave)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(spi_slave)
13 |
--------------------------------------------------------------------------------
/system/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory_exclude_platforms(boot_info host host rp2040)
2 | add_subdirectory_exclude_platforms(hello_double_tap host)
3 | add_subdirectory_exclude_platforms(narrow_io_write host)
4 | add_subdirectory_exclude_platforms(unique_board_id host)
5 | add_subdirectory_exclude_platforms(rand host)
6 |
--------------------------------------------------------------------------------
/system/boot_info/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(boot_info
2 | boot_info.c
3 | )
4 | target_link_libraries(boot_info
5 | pico_stdlib
6 | )
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(boot_info)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(boot_info)
13 |
--------------------------------------------------------------------------------
/system/hello_double_tap/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_double_tap
2 | hello_double_tap.c
3 | )
4 |
5 | # Double tap reset into bootrom is injected by linking with the
6 | # pico_bootsel_via_double_reset library
7 | target_link_libraries(hello_double_tap
8 | pico_stdlib
9 | pico_bootsel_via_double_reset
10 | )
11 |
12 | # Entering the bootloader in this way also lets us specify a GPIO to be used
13 | # as a bootloader activity LED:
14 | target_compile_definitions(hello_double_tap PRIVATE
15 | PICO_BOOTSEL_VIA_DOUBLE_RESET_ACTIVITY_LED=25
16 | )
17 |
18 | pico_add_extra_outputs(hello_double_tap)
19 |
20 | # add url via pico_set_program_url
21 | example_auto_set_url(hello_double_tap)
22 |
--------------------------------------------------------------------------------
/system/hello_double_tap/hello_double_tap.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include "pico/stdlib.h"
8 |
9 | // This is a regular old LED blinking example, however it is linked with the
10 | // `pico_bootsel_via_double_reset` library, so resetting the board twice
11 | // quickly will enter the USB bootloader. This is useful for boards which have
12 | // a reset button but no BOOTSEL, as long as you remember to always link the
13 | // `pico_bootsel_via_double_reset` library!
14 |
15 | int main() {
16 | #ifdef PICO_DEFAULT_LED_PIN
17 | const uint LED_PIN = PICO_DEFAULT_LED_PIN;
18 | gpio_init(LED_PIN);
19 | gpio_set_dir(LED_PIN, GPIO_OUT);
20 | while (true) {
21 | gpio_put(LED_PIN, 1);
22 | sleep_ms(250);
23 | gpio_put(LED_PIN, 0);
24 | sleep_ms(250);
25 | }
26 | #else
27 | while (true) {
28 | sleep_ms(250);
29 | }
30 | #endif
31 | }
32 |
--------------------------------------------------------------------------------
/system/narrow_io_write/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(narrow_io_write
2 | narrow_io_write.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(narrow_io_write pico_stdlib)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(narrow_io_write)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(narrow_io_write)
13 |
--------------------------------------------------------------------------------
/system/rand/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(rand
2 | rand.c
3 | )
4 | target_link_libraries(rand
5 | pico_stdlib
6 | pico_rand
7 | )
8 |
9 | # create map/bin/hex file etc.
10 | pico_add_extra_outputs(rand)
11 |
12 | # add url via pico_set_program_url
13 | example_auto_set_url(rand)
14 |
--------------------------------------------------------------------------------
/system/unique_board_id/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(unique_board_id
2 | unique_board_id.c
3 | )
4 |
5 | target_link_libraries(unique_board_id
6 | pico_stdlib
7 | pico_unique_id
8 | )
9 |
10 | # create map/bin/hex file etc.
11 | pico_add_extra_outputs(unique_board_id)
12 |
13 | # add url via pico_set_program_url
14 | example_auto_set_url(unique_board_id)
15 |
--------------------------------------------------------------------------------
/system/unique_board_id/unique_board_id.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 |
9 | #include "pico/stdlib.h"
10 | #include "pico/unique_id.h"
11 |
12 | // RP2040 does not have a unique on-board ID, but this is a standard feature
13 | // on the NOR flash it boots from. There is a 1:1 association between RP2040
14 | // and the flash, so this can be used to get a 64 bit globally unique board ID
15 | // for an RP2040-based board, including Pico.
16 | //
17 | // The pico_unique_id library retrieves this unique identifier during boot and
18 | // stores it in memory, where it can be accessed at any time without
19 | // disturbing the flash XIP hardware.
20 |
21 | int main() {
22 | stdio_init_all();
23 |
24 | pico_unique_board_id_t board_id;
25 | pico_get_unique_board_id(&board_id);
26 |
27 | printf("Unique identifier:");
28 | for (int i = 0; i < PICO_UNIQUE_BOARD_ID_SIZE_BYTES; ++i) {
29 | printf(" %02x", board_id.id[i]);
30 | }
31 | printf("\n");
32 | }
33 |
--------------------------------------------------------------------------------
/timer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory_exclude_platforms(hello_timer host)
2 | add_subdirectory_exclude_platforms(periodic_sampler)
3 | add_subdirectory_exclude_platforms(timer_lowlevel host)
4 |
--------------------------------------------------------------------------------
/timer/hello_timer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_timer
2 | hello_timer.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(hello_timer pico_stdlib)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(hello_timer)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(hello_timer)
13 |
--------------------------------------------------------------------------------
/timer/periodic_sampler/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (NOT PICO_TIME_NO_ALARM_SUPPORT)
2 | add_executable(periodic_sampler
3 | periodic_sampler.c
4 | )
5 |
6 | # pull in common dependencies
7 | target_link_libraries(periodic_sampler pico_stdlib)
8 |
9 | # create map/bin/hex file etc.
10 | pico_add_extra_outputs(periodic_sampler)
11 |
12 | # add url via pico_set_program_url
13 | example_auto_set_url(periodic_sampler)
14 | endif()
15 |
--------------------------------------------------------------------------------
/timer/timer_lowlevel/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (PICO_ON_DEVICE)
2 | add_executable(timer_lowlevel
3 | timer_lowlevel.c)
4 |
5 | # Disable SDK alarm support for this lowlevel example
6 | set(PICO_TIME_DEFAULT_ALARM_POOL_DISABLED 1)
7 |
8 | target_link_libraries(timer_lowlevel pico_stdlib)
9 |
10 | # create map/bin/hex file etc.
11 | pico_add_extra_outputs(timer_lowlevel)
12 |
13 | # add url via pico_set_program_url
14 | example_auto_set_url(timer_lowlevel)
15 | endif ()
--------------------------------------------------------------------------------
/uart/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET hardware_uart)
2 | add_subdirectory_exclude_platforms(hello_uart)
3 | add_subdirectory_exclude_platforms(lcd_uart host)
4 | add_subdirectory_exclude_platforms(uart_advanced host)
5 | else()
6 | message("Skipping UART examples as hardware_uart is unavailable on this platform")
7 | endif()
--------------------------------------------------------------------------------
/uart/hello_uart/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_uart
2 | hello_uart.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(hello_uart pico_stdlib)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(hello_uart)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(hello_uart)
13 |
--------------------------------------------------------------------------------
/uart/hello_uart/hello_uart.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 |
8 | #include
9 | #include "pico/stdlib.h"
10 | #include "hardware/uart.h"
11 |
12 | /// \tag::hello_uart[]
13 |
14 | #define UART_ID uart0
15 | #define BAUD_RATE 115200
16 |
17 | // We are using pins 0 and 1, but see the GPIO function select table in the
18 | // datasheet for information on which other pins can be used.
19 | #define UART_TX_PIN 0
20 | #define UART_RX_PIN 1
21 |
22 | int main() {
23 | // Set up our UART with the required speed.
24 | uart_init(UART_ID, BAUD_RATE);
25 |
26 | // Set the TX and RX pins by using the function select on the GPIO
27 | // Set datasheet for more information on function select
28 | gpio_set_function(UART_TX_PIN, UART_FUNCSEL_NUM(UART_ID, UART_TX_PIN));
29 | gpio_set_function(UART_RX_PIN, UART_FUNCSEL_NUM(UART_ID, UART_RX_PIN));
30 |
31 | // Use some the various UART functions to send out data
32 | // In a default system, printf will also output via the default UART
33 |
34 | // Send out a character without any conversions
35 | uart_putc_raw(UART_ID, 'A');
36 |
37 | // Send out a character but do CR/LF conversions
38 | uart_putc(UART_ID, 'B');
39 |
40 | // Send out a string, with CR/LF conversions
41 | uart_puts(UART_ID, " Hello, UART!\n");
42 | return 0;
43 | }
44 |
45 | /// \end::hello_uart[]
46 |
--------------------------------------------------------------------------------
/uart/lcd_uart/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(lcd_uart
2 | lcd_uart.c
3 | )
4 |
5 | # pull in common dependencies and additional uart hardware support
6 | target_link_libraries(lcd_uart pico_stdlib hardware_uart)
7 |
8 | # enable usb output and uart output
9 | # modify here as required
10 | pico_enable_stdio_usb(lcd_uart 1)
11 | pico_enable_stdio_uart(lcd_uart 1)
12 |
13 | # create map/bin/hex file etc.
14 | pico_add_extra_outputs(lcd_uart)
15 |
16 | # add url via pico_set_program_url
17 | example_auto_set_url(lcd_uart)
18 |
--------------------------------------------------------------------------------
/uart/lcd_uart/lcd_uart.fzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/uart/lcd_uart/lcd_uart.fzz
--------------------------------------------------------------------------------
/uart/lcd_uart/lcd_uart_bb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raspberrypi/pico-examples/84e8d489ca321a4be90ee49e36dc29e5c645da08/uart/lcd_uart/lcd_uart_bb.png
--------------------------------------------------------------------------------
/uart/uart_advanced/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(uart_advanced
2 | uart_advanced.c
3 | )
4 |
5 | # pull in common dependencies and additional uart hardware support
6 | target_link_libraries(uart_advanced pico_stdlib hardware_uart)
7 |
8 | # create map/bin/hex file etc.
9 | pico_add_extra_outputs(uart_advanced)
10 |
11 | # add url via pico_set_program_url
12 | example_auto_set_url(uart_advanced)
13 |
--------------------------------------------------------------------------------
/universal/hello_universal/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_universal
2 | hello_universal.c
3 | )
4 |
5 | # pull in common dependencies
6 | target_link_libraries(hello_universal pico_stdlib)
7 |
8 | # enable usb output and uart output
9 | pico_enable_stdio_uart(hello_universal 1)
10 | pico_enable_stdio_usb(hello_universal 1)
11 |
12 | # create map/bin/hex/uf2 file etc.
13 | pico_add_extra_outputs(hello_universal)
14 |
--------------------------------------------------------------------------------
/usb/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET tinyusb_device)
2 | add_subdirectory(device)
3 | else ()
4 | message("Skipping TinyUSB device examples as TinyUSB is unavailable")
5 | endif ()
6 | if (TARGET tinyusb_host)
7 | add_subdirectory(host)
8 | else ()
9 | message("Skipping TinyUSB host examples as TinyUSB is unavailable")
10 | endif ()
11 | if (TARGET tinyusb_pico_pio_usb)
12 | add_subdirectory(dual)
13 | else ()
14 | message("Skipping TinyUSB dual examples, as TinyUSB hw/mcu/raspberry_pi/Pico-PIO-USB submodule unavailable")
15 | endif ()
16 |
--------------------------------------------------------------------------------
/usb/README.md:
--------------------------------------------------------------------------------
1 | Note: most of these examples are copies of the tinyusb examples in pico-sdk/lib/tinyusb/examples
2 |
--------------------------------------------------------------------------------
/usb/device/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(FAMILY rp2040)
2 | set(BOARD pico_sdk)
3 | set(TINYUSB_FAMILY_PROJECT_NAME_PREFIX "tinyusb_dev_")
4 | # Provide an LWIP path for net_lwip_webserver in case the module does not exist in tinyusb
5 | set(TINYUSB_LWIP_PATH ${PICO_LWIP_PATH})
6 | # Some examples use this, and we need to set this here due to a bug in the TinyUSB CMake config
7 | set(TOP ${PICO_TINYUSB_PATH})
8 | add_subdirectory(${PICO_TINYUSB_PATH}/examples/device tinyusb_device_examples)
9 | add_subdirectory_exclude_platforms(dev_hid_composite)
10 | add_subdirectory_exclude_platforms(dev_lowlevel)
11 | add_subdirectory_exclude_platforms(dev_multi_cdc)
12 |
--------------------------------------------------------------------------------
/usb/device/dev_hid_composite/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.13)
2 |
3 | add_executable(dev_hid_composite)
4 |
5 | target_sources(dev_hid_composite PUBLIC
6 | ${CMAKE_CURRENT_LIST_DIR}/main.c
7 | ${CMAKE_CURRENT_LIST_DIR}/usb_descriptors.c
8 | )
9 |
10 | # Make sure TinyUSB can find tusb_config.h
11 | target_include_directories(dev_hid_composite PUBLIC
12 | ${CMAKE_CURRENT_LIST_DIR})
13 |
14 | # In addition to pico_stdlib required for common PicoSDK functionality, add dependency on tinyusb_device
15 | # for TinyUSB device support and tinyusb_board for the additional board support library used by the example
16 | target_link_libraries(dev_hid_composite PUBLIC pico_stdlib pico_unique_id tinyusb_device tinyusb_board)
17 |
18 | # Uncomment this line to enable fix for Errata RP2040-E5 (the fix requires use of GPIO 15)
19 | #target_compile_definitions(dev_hid_composite PUBLIC PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1)
20 |
21 | pico_add_extra_outputs(dev_hid_composite)
22 |
23 | # add url via pico_set_program_url
24 | example_auto_set_url(dev_hid_composite)
25 |
--------------------------------------------------------------------------------
/usb/device/dev_hid_composite/LICENSE.TXT:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2018, hathach (tinyusb.org)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/usb/device/dev_hid_composite/README.md:
--------------------------------------------------------------------------------
1 | This is a copy of the hid_composite example from TinyUSB (https://github.com/hathach/tinyusb/tree/master/examples/device/hid_composite)
2 | showing how to build with TinyUSB when using the Raspberry Pi Pico SDK
--------------------------------------------------------------------------------
/usb/device/dev_lowlevel/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(dev_lowlevel
2 | dev_lowlevel.c
3 | )
4 |
5 | target_link_libraries(dev_lowlevel PRIVATE pico_stdlib hardware_resets hardware_irq)
6 | pico_add_extra_outputs(dev_lowlevel)
7 |
8 | # add url via pico_set_program_url
9 | example_auto_set_url(dev_lowlevel)
10 |
--------------------------------------------------------------------------------
/usb/device/dev_lowlevel/dev_lowlevel_loopback.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | #
4 | # Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
5 | #
6 | # SPDX-License-Identifier: BSD-3-Clause
7 | #
8 |
9 | # sudo pip3 install pyusb
10 |
11 | import usb.core
12 | import usb.util
13 |
14 | # find our device
15 | dev = usb.core.find(idVendor=0x0000, idProduct=0x0001)
16 |
17 | # was it found?
18 | if dev is None:
19 | raise ValueError('Device not found')
20 |
21 | # get an endpoint instance
22 | cfg = dev.get_active_configuration()
23 | intf = cfg[(0, 0)]
24 |
25 | outep = usb.util.find_descriptor(
26 | intf,
27 | # match the first OUT endpoint
28 | custom_match= \
29 | lambda e: \
30 | usb.util.endpoint_direction(e.bEndpointAddress) == \
31 | usb.util.ENDPOINT_OUT)
32 |
33 | inep = usb.util.find_descriptor(
34 | intf,
35 | # match the first IN endpoint
36 | custom_match= \
37 | lambda e: \
38 | usb.util.endpoint_direction(e.bEndpointAddress) == \
39 | usb.util.ENDPOINT_IN)
40 |
41 | assert inep is not None
42 | assert outep is not None
43 |
44 | test_string = "Hello World!"
45 | outep.write(test_string)
46 | from_device = inep.read(len(test_string))
47 |
48 | print("Device Says: {}".format(''.join([chr(x) for x in from_device])))
49 |
--------------------------------------------------------------------------------
/usb/device/dev_multi_cdc/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.13)
2 |
3 | add_executable(dev_multi_cdc)
4 |
5 | target_sources(dev_multi_cdc PUBLIC
6 | ${CMAKE_CURRENT_LIST_DIR}/main.c
7 | ${CMAKE_CURRENT_LIST_DIR}/usb_descriptors.c
8 | )
9 |
10 | # Make sure TinyUSB can find tusb_config.h
11 | target_include_directories(dev_multi_cdc PUBLIC
12 | ${CMAKE_CURRENT_LIST_DIR})
13 |
14 | # In addition to pico_stdlib required for common PicoSDK functionality, add dependency on tinyusb_device
15 | # for TinyUSB device support and tinyusb_board for the additional board support library used by the example
16 | target_link_libraries(dev_multi_cdc PUBLIC pico_stdlib pico_unique_id tinyusb_device tinyusb_board)
17 |
18 | pico_enable_stdio_usb(dev_multi_cdc 1)
19 | pico_add_extra_outputs(dev_multi_cdc)
20 |
21 | # add url via pico_set_program_url
22 | example_auto_set_url(dev_multi_cdc)
23 |
--------------------------------------------------------------------------------
/usb/device/dev_multi_cdc/tusb_config.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2023 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #ifndef _TUSB_CONFIG_H_
8 | #define _TUSB_CONFIG_H_
9 |
10 | #ifdef __cplusplus
11 | extern "C" {
12 | #endif
13 |
14 | #define CFG_TUD_ENABLED (1)
15 |
16 | // Legacy RHPORT configuration
17 | #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_FULL_SPEED)
18 | #ifndef BOARD_TUD_RHPORT
19 | #define BOARD_TUD_RHPORT (0)
20 | #endif
21 | // end legacy RHPORT
22 |
23 | //------------------------
24 | // DEVICE CONFIGURATION //
25 | //------------------------
26 |
27 | // Enable 2 CDC classes
28 | #define CFG_TUD_CDC (2)
29 | // Set CDC FIFO buffer sizes
30 | #define CFG_TUD_CDC_RX_BUFSIZE (64)
31 | #define CFG_TUD_CDC_TX_BUFSIZE (64)
32 | #define CFG_TUD_CDC_EP_BUFSIZE (64)
33 |
34 | #ifndef CFG_TUD_ENDPOINT0_SIZE
35 | #define CFG_TUD_ENDPOINT0_SIZE (64)
36 | #endif
37 |
38 | #ifdef __cplusplus
39 | }
40 | #endif
41 |
42 | #endif /* _TUSB_CONFIG_H_ */
43 |
--------------------------------------------------------------------------------
/usb/dual/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(FAMILY rp2040)
2 | set(BOARD pico_sdk)
3 | set(TINYUSB_FAMILY_PROJECT_NAME_PREFIX "tinyusb_dual_")
4 | add_subdirectory(${PICO_TINYUSB_PATH}/examples/dual tinyusb_dual_examples)
--------------------------------------------------------------------------------
/usb/host/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(FAMILY rp2040)
2 | set(BOARD pico_sdk)
3 | set(TINYUSB_FAMILY_PROJECT_NAME_PREFIX "tinyusb_host_")
4 | # Hack as some host examples use $TOP in their path
5 | set(TOP ${PICO_TINYUSB_PATH})
6 | add_subdirectory(${PICO_TINYUSB_PATH}/examples/host tinyusb_host_examples)
7 |
8 | add_subdirectory_exclude_platforms(host_cdc_msc_hid)
--------------------------------------------------------------------------------
/usb/host/host_cdc_msc_hid/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.13)
2 |
3 | add_executable(host_cdc_msc_hid)
4 |
5 | # Example source
6 | target_sources(host_cdc_msc_hid PUBLIC
7 | ${CMAKE_CURRENT_LIST_DIR}/hid_app.c
8 | ${CMAKE_CURRENT_LIST_DIR}/main.c
9 | ${CMAKE_CURRENT_LIST_DIR}/msc_app.c
10 | ${CMAKE_CURRENT_LIST_DIR}/cdc_app.c
11 | )
12 |
13 | # Make sure TinyUSB can find tusb_config.h
14 | target_include_directories(host_cdc_msc_hid PUBLIC
15 | ${CMAKE_CURRENT_LIST_DIR})
16 |
17 | # In addition to pico_stdlib required for common PicoSDK functionality, add dependency on tinyusb_host
18 | # for TinyUSB device support and tinyusb_board for the additional board support library used by the example
19 | target_link_libraries(host_cdc_msc_hid PUBLIC pico_stdlib tinyusb_host tinyusb_board)
20 |
21 | pico_add_extra_outputs(host_cdc_msc_hid)
22 |
23 | # add url via pico_set_program_url
24 | example_auto_set_url(host_cdc_msc_hid)
25 |
--------------------------------------------------------------------------------
/usb/host/host_cdc_msc_hid/LICENSE.TXT:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2018, hathach (tinyusb.org)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/watchdog/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TARGET hardware_watchdog)
2 | add_subdirectory_exclude_platforms(hello_watchdog host)
3 | else()
4 | message("Skipping Watchdog examples as hardware_watchdog unavailable")
5 | endif()
--------------------------------------------------------------------------------
/watchdog/hello_watchdog/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(hello_watchdog
2 | hello_watchdog.c
3 | )
4 |
5 | target_link_libraries(hello_watchdog pico_stdlib)
6 |
7 | # create map/bin/hex file etc.
8 | pico_add_extra_outputs(hello_watchdog)
9 |
10 | # add url via pico_set_program_url
11 | example_auto_set_url(hello_watchdog)
12 |
--------------------------------------------------------------------------------
/watchdog/hello_watchdog/hello_watchdog.c:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 | *
4 | * SPDX-License-Identifier: BSD-3-Clause
5 | */
6 |
7 | #include
8 | #include "pico/stdlib.h"
9 | #include "hardware/watchdog.h"
10 |
11 | int main() {
12 | stdio_init_all();
13 |
14 | if (watchdog_enable_caused_reboot()) {
15 | printf("Rebooted by Watchdog!\n");
16 | return 0;
17 | } else {
18 | printf("Clean boot\n");
19 | }
20 |
21 | // Enable the watchdog, requiring the watchdog to be updated every 100ms or the chip will reboot
22 | // second arg is pause on debug which means the watchdog will pause when stepping through code
23 | watchdog_enable(100, 1);
24 |
25 | for (uint i = 0; i < 5; i++) {
26 | printf("Updating watchdog %d\n", i);
27 | watchdog_update();
28 | }
29 |
30 | // Wait in an infinite loop and don't update the watchdog so it reboots us
31 | printf("Waiting to be rebooted by watchdog\n");
32 | while(1);
33 | }
34 |
--------------------------------------------------------------------------------