├── .bazelignore ├── .bazelrc ├── .bazelversion ├── .github ├── pull_request_template.md └── workflows │ ├── bazel_build.yml │ ├── choco_packages.config │ ├── cmake.yml │ ├── macOS.yml │ ├── multi-gcc.yml │ ├── scripts │ └── generate_multi_gcc_workflow.py │ └── windows.yml ├── .gitignore ├── .gitmodules ├── BUILD.bazel ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE.TXT ├── MODULE.bazel ├── README.md ├── WORKSPACE ├── bazel ├── BUILD.bazel ├── README.md ├── config │ └── BUILD.bazel ├── constraint │ └── BUILD.bazel ├── defs.bzl ├── generate_version_header.py ├── include │ └── pico │ │ └── config_autogen.h ├── pico_btstack_make_gatt_header.bzl ├── platform │ └── BUILD.bazel ├── toolchain │ ├── BUILD.bazel │ ├── clang.BUILD │ ├── configurable_feature.bzl │ ├── gcc_arm_none_eabi.BUILD │ └── objcopy.bzl └── util │ ├── BUILD.bazel │ ├── label_flag_matches.bzl │ ├── multiple_choice_flag.bzl │ ├── sdk_define.bzl │ └── transition.bzl ├── cmake ├── Platform │ └── PICO.cmake ├── generic_board.cmake ├── pico_pre_load_platform.cmake ├── pico_pre_load_toolchain.cmake ├── pico_utils.cmake └── preload │ ├── platforms │ ├── combined-docs.cmake │ ├── host.cmake │ ├── rp2040.cmake │ ├── rp2350-arm-s.cmake │ └── rp2350-riscv.cmake │ └── toolchains │ ├── pico_arm_clang_arm.cmake │ ├── pico_arm_cortex_m0plus_clang.cmake │ ├── pico_arm_cortex_m0plus_gcc.cmake │ ├── pico_arm_cortex_m23_gcc.cmake │ ├── pico_arm_cortex_m33_clang.cmake │ ├── pico_arm_cortex_m33_gcc.cmake │ ├── pico_riscv_gcc.cmake │ ├── pico_riscv_gcc_zcb_zcmp.cmake │ └── util │ ├── find_compiler.cmake │ ├── pico_arm_clang_common.cmake │ ├── pico_arm_gcc_common.cmake │ └── set_flags.cmake ├── docs ├── CMakeLists.txt ├── Doxyfile.in ├── DoxygenLayout.xml.in ├── examples.md ├── footer.html ├── header.html ├── index.h ├── logo-mobile.svg ├── logo.svg ├── main.css ├── main.js ├── mainpage.md ├── normalise.css ├── pico.jpg ├── rp2040.png ├── search.svg ├── styles.css └── weblinks_page.md ├── external └── pico_sdk_import.cmake ├── pico_sdk_init.cmake ├── pico_sdk_version.cmake ├── src ├── BUILD.bazel ├── CMakeLists.txt ├── boards │ ├── BUILD.bazel │ └── include │ │ └── boards │ │ ├── 0xcb_helios.h │ │ ├── adafruit_feather_rp2040.h │ │ ├── adafruit_feather_rp2040_usb_host.h │ │ ├── adafruit_feather_rp2350.h │ │ ├── adafruit_itsybitsy_rp2040.h │ │ ├── adafruit_kb2040.h │ │ ├── adafruit_macropad_rp2040.h │ │ ├── adafruit_qtpy_rp2040.h │ │ ├── adafruit_trinkey_qt2040.h │ │ ├── amethyst_fpga.h │ │ ├── archi.h │ │ ├── arduino_nano_rp2040_connect.h │ │ ├── cytron_maker_pi_rp2040.h │ │ ├── datanoisetv_rp2040_dsp.h │ │ ├── datanoisetv_rp2350_dsp.h │ │ ├── defcon32_badge.h │ │ ├── eetree_gamekit_rp2040.h │ │ ├── garatronic_pybstick26_rp2040.h │ │ ├── gen4_rp2350_24.h │ │ ├── gen4_rp2350_24ct.h │ │ ├── gen4_rp2350_24t.h │ │ ├── gen4_rp2350_28.h │ │ ├── gen4_rp2350_28ct.h │ │ ├── gen4_rp2350_28t.h │ │ ├── gen4_rp2350_32.h │ │ ├── gen4_rp2350_32ct.h │ │ ├── gen4_rp2350_32t.h │ │ ├── gen4_rp2350_35.h │ │ ├── gen4_rp2350_35ct.h │ │ ├── gen4_rp2350_35t.h │ │ ├── hellbender_0001.h │ │ ├── hellbender_2350A_devboard.h │ │ ├── ilabs_challenger_rp2350_bconnect.h │ │ ├── ilabs_challenger_rp2350_wifi_ble.h │ │ ├── ilabs_opendec02.h │ │ ├── machdyne_werkzeug.h │ │ ├── melopero_perpetuo_rp2350_lora.h │ │ ├── melopero_shake_rp2040.h │ │ ├── metrotech_xerxes_rp2040.h │ │ ├── net8086_usb_interposer.h │ │ ├── none.h │ │ ├── nullbits_bit_c_pro.h │ │ ├── phyx_rick_tny_rp2350.h │ │ ├── pi-plates_micropi.h │ │ ├── pico.h │ │ ├── pico2.h │ │ ├── pico2_w.h │ │ ├── pico_w.h │ │ ├── pimoroni_badger2040.h │ │ ├── pimoroni_interstate75.h │ │ ├── pimoroni_keybow2040.h │ │ ├── pimoroni_motor2040.h │ │ ├── pimoroni_pga2040.h │ │ ├── pimoroni_pga2350.h │ │ ├── pimoroni_pico_plus2_rp2350.h │ │ ├── pimoroni_pico_plus2_w_rp2350.h │ │ ├── pimoroni_picolipo_16mb.h │ │ ├── pimoroni_picolipo_4mb.h │ │ ├── pimoroni_picosystem.h │ │ ├── pimoroni_plasma2040.h │ │ ├── pimoroni_plasma2350.h │ │ ├── pimoroni_servo2040.h │ │ ├── pimoroni_tiny2040.h │ │ ├── pimoroni_tiny2040_2mb.h │ │ ├── pimoroni_tiny2350.h │ │ ├── pololu_3pi_2040_robot.h │ │ ├── pololu_zumo_2040_robot.h │ │ ├── seeed_xiao_rp2040.h │ │ ├── seeed_xiao_rp2350.h │ │ ├── solderparty_rp2040_stamp.h │ │ ├── solderparty_rp2040_stamp_carrier.h │ │ ├── solderparty_rp2040_stamp_round_carrier.h │ │ ├── solderparty_rp2350_stamp.h │ │ ├── solderparty_rp2350_stamp_xl.h │ │ ├── sparkfun_iotnode_lorawan_rp2350.h │ │ ├── sparkfun_micromod.h │ │ ├── sparkfun_promicro.h │ │ ├── sparkfun_promicro_rp2350.h │ │ ├── sparkfun_thingplus.h │ │ ├── sparkfun_thingplus_rp2350.h │ │ ├── switchscience_picossci2_conta_base.h │ │ ├── switchscience_picossci2_dev_board.h │ │ ├── switchscience_picossci2_micro.h │ │ ├── switchscience_picossci2_rp2350_breakout.h │ │ ├── switchscience_picossci2_tiny.h │ │ ├── tinycircuits_thumby_color_rp2350.h │ │ ├── vgaboard.h │ │ ├── waveshare_pico_cam_a.h │ │ ├── waveshare_rp2040_ble.h │ │ ├── waveshare_rp2040_eth.h │ │ ├── waveshare_rp2040_geek.h │ │ ├── waveshare_rp2040_lcd_0.96.h │ │ ├── waveshare_rp2040_lcd_1.28.h │ │ ├── waveshare_rp2040_matrix.h │ │ ├── waveshare_rp2040_one.h │ │ ├── waveshare_rp2040_pizero.h │ │ ├── waveshare_rp2040_plus_16mb.h │ │ ├── waveshare_rp2040_plus_4mb.h │ │ ├── waveshare_rp2040_power_management_hat_b.h │ │ ├── waveshare_rp2040_tiny.h │ │ ├── waveshare_rp2040_touch_lcd_1.28.h │ │ ├── waveshare_rp2040_zero.h │ │ ├── waveshare_rp2350_eth.h │ │ ├── waveshare_rp2350_geek.h │ │ ├── waveshare_rp2350_lcd_0.96.h │ │ ├── waveshare_rp2350_lcd_1.28.h │ │ ├── waveshare_rp2350_one.h │ │ ├── waveshare_rp2350_plus_16mb.h │ │ ├── waveshare_rp2350_plus_4mb.h │ │ ├── waveshare_rp2350_tiny.h │ │ ├── waveshare_rp2350_touch_lcd_1.28.h │ │ ├── waveshare_rp2350_zero.h │ │ ├── weact_studio_rp2040_16mb.h │ │ ├── weact_studio_rp2040_2mb.h │ │ ├── weact_studio_rp2040_4mb.h │ │ ├── weact_studio_rp2040_8mb.h │ │ └── wiznet_w5100s_evb_pico.h ├── cmake │ ├── no_hardware.cmake │ ├── on_device.cmake │ └── rp2_common.cmake ├── combined-docs.cmake ├── common │ ├── README.md │ ├── boot_picobin_headers │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── boot │ │ │ └── picobin.h │ ├── boot_picoboot_headers │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── boot │ │ │ ├── picoboot.h │ │ │ └── picoboot_constants.h │ ├── boot_uf2_headers │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── boot │ │ │ └── uf2.h │ ├── hardware_claim │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── claim.c │ │ └── include │ │ │ └── hardware │ │ │ └── claim.h │ ├── pico_base_headers │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── generate_config_header.cmake │ │ └── include │ │ │ ├── pico.h │ │ │ └── pico │ │ │ ├── assert.h │ │ │ ├── config.h │ │ │ ├── error.h │ │ │ ├── types.h │ │ │ └── version.h.in │ ├── pico_binary_info │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── binary_info.bzl │ │ └── include │ │ │ └── pico │ │ │ ├── binary_info.h │ │ │ └── binary_info │ │ │ ├── code.h │ │ │ ├── defs.h │ │ │ └── structure.h │ ├── pico_bit_ops_headers │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── pico │ │ │ └── bit_ops.h │ ├── pico_divider_headers │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── pico │ │ │ └── divider.h │ ├── pico_stdlib_headers │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── pico │ │ │ └── stdlib.h │ ├── pico_sync │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── critical_section.c │ │ ├── include │ │ │ └── pico │ │ │ │ ├── critical_section.h │ │ │ │ ├── lock_core.h │ │ │ │ ├── mutex.h │ │ │ │ ├── sem.h │ │ │ │ └── sync.h │ │ ├── lock_core.c │ │ ├── mutex.c │ │ └── sem.c │ ├── pico_time │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ ├── time.h │ │ │ │ └── timeout_helper.h │ │ ├── time.c │ │ └── timeout_helper.c │ ├── pico_usb_reset_interface_headers │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── pico │ │ │ └── usb_reset_interface.h │ └── pico_util │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── datetime.c │ │ ├── doc.h │ │ ├── include │ │ └── pico │ │ │ └── util │ │ │ ├── datetime.h │ │ │ ├── pheap.h │ │ │ └── queue.h │ │ ├── pheap.c │ │ └── queue.c ├── host.cmake ├── host │ ├── BUILD.bazel │ ├── README.md │ ├── boot_stage2.c │ ├── hardware_divider │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── divider.c │ │ └── include │ │ │ └── hardware │ │ │ └── divider.h │ ├── hardware_gpio │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── gpio.c │ │ └── include │ │ │ └── hardware │ │ │ └── gpio.h │ ├── hardware_irq │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ └── irq.h │ │ └── irq.c │ ├── hardware_sync │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ └── sync.h │ │ └── sync_core0_only.c │ ├── hardware_timer │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ └── timer.h │ │ └── timer.c │ ├── hardware_uart │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ └── uart.h │ │ └── uart.c │ ├── pico_bit_ops │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ └── bit_ops.c │ ├── pico_divider │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ └── divider.c │ ├── pico_multicore │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── pico │ │ │ └── multicore.h │ ├── pico_platform │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ ├── hardware │ │ │ │ └── platform_defs.h │ │ │ └── pico │ │ │ │ └── platform.h │ │ └── platform_base.c │ ├── pico_printf │ │ ├── BUILD.bazel │ │ └── CMakeLists.txt │ ├── pico_runtime │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ ├── runtime.h │ │ │ │ └── runtime_init.h │ │ └── runtime.c │ ├── pico_stdio │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ └── stdio.h │ │ └── stdio.c │ ├── pico_stdlib │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ └── stdlib.c │ └── pico_time_adapter │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── include │ │ └── pico │ │ │ └── time_adapter.h │ │ └── time_adapter.c ├── rp2040.cmake ├── rp2040 │ ├── README.md │ ├── boot_stage2 │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── asminclude │ │ │ └── boot2_helpers │ │ │ │ ├── exit_from_boot2.S │ │ │ │ ├── read_flash_sreg.S │ │ │ │ └── wait_ssi_ready.S │ │ ├── boot2_at25sf128a.S │ │ ├── boot2_generic_03h.S │ │ ├── boot2_is25lp080.S │ │ ├── boot2_usb_blinky.S │ │ ├── boot2_w25q080.S │ │ ├── boot2_w25x10cl.S │ │ ├── boot_stage2.ld │ │ ├── compile_time_choice.S │ │ ├── doc.h │ │ ├── include │ │ │ └── boot_stage2 │ │ │ │ └── config.h │ │ └── pad_checksum │ ├── hardware_regs │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── RP2040.svd │ │ └── include │ │ │ └── hardware │ │ │ ├── platform_defs.h │ │ │ └── regs │ │ │ ├── adc.h │ │ │ ├── addressmap.h │ │ │ ├── busctrl.h │ │ │ ├── clocks.h │ │ │ ├── dma.h │ │ │ ├── dreq.h │ │ │ ├── i2c.h │ │ │ ├── intctrl.h │ │ │ ├── io_bank0.h │ │ │ ├── io_qspi.h │ │ │ ├── m0plus.h │ │ │ ├── pads_bank0.h │ │ │ ├── pads_qspi.h │ │ │ ├── pio.h │ │ │ ├── pll.h │ │ │ ├── psm.h │ │ │ ├── pwm.h │ │ │ ├── resets.h │ │ │ ├── rosc.h │ │ │ ├── rtc.h │ │ │ ├── sio.h │ │ │ ├── spi.h │ │ │ ├── ssi.h │ │ │ ├── syscfg.h │ │ │ ├── sysinfo.h │ │ │ ├── tbman.h │ │ │ ├── timer.h │ │ │ ├── uart.h │ │ │ ├── usb.h │ │ │ ├── usb_device_dpram.h │ │ │ ├── vreg_and_chip_reset.h │ │ │ ├── watchdog.h │ │ │ ├── xip.h │ │ │ └── xosc.h │ ├── hardware_structs │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── hardware │ │ │ └── structs │ │ │ ├── adc.h │ │ │ ├── bus_ctrl.h │ │ │ ├── busctrl.h │ │ │ ├── clocks.h │ │ │ ├── dma.h │ │ │ ├── dma_debug.h │ │ │ ├── i2c.h │ │ │ ├── interp.h │ │ │ ├── io_bank0.h │ │ │ ├── io_qspi.h │ │ │ ├── iobank0.h │ │ │ ├── ioqspi.h │ │ │ ├── m0plus.h │ │ │ ├── mpu.h │ │ │ ├── nvic.h │ │ │ ├── pads_bank0.h │ │ │ ├── pads_qspi.h │ │ │ ├── padsbank0.h │ │ │ ├── pio.h │ │ │ ├── pll.h │ │ │ ├── psm.h │ │ │ ├── pwm.h │ │ │ ├── resets.h │ │ │ ├── rosc.h │ │ │ ├── rtc.h │ │ │ ├── scb.h │ │ │ ├── sio.h │ │ │ ├── spi.h │ │ │ ├── ssi.h │ │ │ ├── syscfg.h │ │ │ ├── sysinfo.h │ │ │ ├── systick.h │ │ │ ├── tbman.h │ │ │ ├── timer.h │ │ │ ├── uart.h │ │ │ ├── usb.h │ │ │ ├── usb_dpram.h │ │ │ ├── vreg_and_chip_reset.h │ │ │ ├── watchdog.h │ │ │ ├── xip.h │ │ │ ├── xip_ctrl.h │ │ │ └── xosc.h │ ├── pico_platform │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ ├── asm_helper.S │ │ │ │ ├── platform.h │ │ │ │ └── platform │ │ │ │ └── cpu_regs.h │ │ └── platform.c │ └── rp2040_interface_pins.json ├── rp2350-arm-s.cmake ├── rp2350-riscv.cmake ├── rp2350 │ ├── README.md │ ├── boot_stage2 │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── asminclude │ │ │ └── boot2_helpers │ │ │ │ ├── exit_from_boot2.S │ │ │ │ ├── read_flash_sreg.S │ │ │ │ └── wait_qmi_ready.S │ │ ├── boot2_at25sf128a.S │ │ ├── boot2_generic_03h.S │ │ ├── boot2_is25lp080.S │ │ ├── boot2_usb_blinky.S │ │ ├── boot2_w25q080.S │ │ ├── boot2_w25x10cl.S │ │ ├── boot_stage2.ld │ │ ├── compile_time_choice.S │ │ ├── doc.h │ │ ├── include │ │ │ └── boot_stage2 │ │ │ │ └── config.h │ │ └── pad_checksum │ ├── hardware_regs │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── RP2350.svd │ │ └── include │ │ │ └── hardware │ │ │ ├── platform_defs.h │ │ │ └── regs │ │ │ ├── accessctrl.h │ │ │ ├── adc.h │ │ │ ├── addressmap.h │ │ │ ├── bootram.h │ │ │ ├── busctrl.h │ │ │ ├── clocks.h │ │ │ ├── coresight_trace.h │ │ │ ├── dma.h │ │ │ ├── dreq.h │ │ │ ├── glitch_detector.h │ │ │ ├── hstx_ctrl.h │ │ │ ├── hstx_fifo.h │ │ │ ├── i2c.h │ │ │ ├── intctrl.h │ │ │ ├── io_bank0.h │ │ │ ├── io_qspi.h │ │ │ ├── m33.h │ │ │ ├── m33_eppb.h │ │ │ ├── otp.h │ │ │ ├── otp_data.h │ │ │ ├── pads_bank0.h │ │ │ ├── pads_qspi.h │ │ │ ├── pio.h │ │ │ ├── pll.h │ │ │ ├── powman.h │ │ │ ├── psm.h │ │ │ ├── pwm.h │ │ │ ├── qmi.h │ │ │ ├── resets.h │ │ │ ├── riscv_dm.h │ │ │ ├── rosc.h │ │ │ ├── rp_ap.h │ │ │ ├── rvcsr.h │ │ │ ├── sha256.h │ │ │ ├── sio.h │ │ │ ├── spi.h │ │ │ ├── syscfg.h │ │ │ ├── sysinfo.h │ │ │ ├── tbman.h │ │ │ ├── ticks.h │ │ │ ├── timer.h │ │ │ ├── trng.h │ │ │ ├── uart.h │ │ │ ├── usb.h │ │ │ ├── usb_device_dpram.h │ │ │ ├── watchdog.h │ │ │ ├── xip.h │ │ │ ├── xip_aux.h │ │ │ └── xosc.h │ ├── hardware_structs │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── hardware │ │ │ └── structs │ │ │ ├── accessctrl.h │ │ │ ├── adc.h │ │ │ ├── bootram.h │ │ │ ├── bus_ctrl.h │ │ │ ├── busctrl.h │ │ │ ├── clocks.h │ │ │ ├── coresight_trace.h │ │ │ ├── dma.h │ │ │ ├── dma_debug.h │ │ │ ├── glitch_detector.h │ │ │ ├── hstx_ctrl.h │ │ │ ├── hstx_fifo.h │ │ │ ├── i2c.h │ │ │ ├── interp.h │ │ │ ├── io_bank0.h │ │ │ ├── io_qspi.h │ │ │ ├── iobank0.h │ │ │ ├── ioqspi.h │ │ │ ├── m33.h │ │ │ ├── m33_eppb.h │ │ │ ├── mpu.h │ │ │ ├── nvic.h │ │ │ ├── otp.h │ │ │ ├── pads_bank0.h │ │ │ ├── pads_qspi.h │ │ │ ├── padsbank0.h │ │ │ ├── pio.h │ │ │ ├── pll.h │ │ │ ├── powman.h │ │ │ ├── psm.h │ │ │ ├── pwm.h │ │ │ ├── qmi.h │ │ │ ├── resets.h │ │ │ ├── rosc.h │ │ │ ├── sau.h │ │ │ ├── scb.h │ │ │ ├── sha256.h │ │ │ ├── sio.h │ │ │ ├── spi.h │ │ │ ├── syscfg.h │ │ │ ├── sysinfo.h │ │ │ ├── systick.h │ │ │ ├── tbman.h │ │ │ ├── ticks.h │ │ │ ├── timer.h │ │ │ ├── tmds_encode.h │ │ │ ├── trng.h │ │ │ ├── uart.h │ │ │ ├── usb.h │ │ │ ├── usb_dpram.h │ │ │ ├── watchdog.h │ │ │ ├── xip.h │ │ │ ├── xip_aux.h │ │ │ ├── xip_ctrl.h │ │ │ └── xosc.h │ ├── pico_platform │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ ├── asm_helper.S │ │ │ │ ├── platform.h │ │ │ │ └── platform │ │ │ │ └── cpu_regs.h │ │ └── platform.c │ ├── rp2350a_interface_pins.json │ └── rp2350b_interface_pins.json └── rp2_common │ ├── BUILD.bazel │ ├── README.md │ ├── boot_bootrom_headers │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── include │ │ └── boot │ │ └── bootrom_constants.h │ ├── cmsis │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── cmsis │ │ │ └── rename_exceptions.h │ └── stub │ │ └── CMSIS │ │ ├── Core │ │ └── Include │ │ │ ├── cmsis_armcc.h │ │ │ ├── cmsis_armclang.h │ │ │ ├── cmsis_armclang_ltm.h │ │ │ ├── cmsis_clang.h │ │ │ ├── cmsis_compiler.h │ │ │ ├── cmsis_gcc.h │ │ │ ├── cmsis_iccarm.h │ │ │ ├── cmsis_version.h │ │ │ ├── core_cm0plus.h │ │ │ ├── core_cm33.h │ │ │ ├── m-profile │ │ │ ├── armv7m_cachel1.h │ │ │ ├── armv7m_mpu.h │ │ │ ├── armv81m_pac.h │ │ │ ├── armv8m_mpu.h │ │ │ ├── armv8m_pmu.h │ │ │ ├── cmsis_armclang_m.h │ │ │ ├── cmsis_clang_m.h │ │ │ ├── cmsis_gcc_m.h │ │ │ ├── cmsis_iccarm_m.h │ │ │ └── cmsis_tiarmclang_m.h │ │ │ ├── mpu_armv7.h │ │ │ ├── mpu_armv8.h │ │ │ └── tz_context.h │ │ ├── Device │ │ ├── RP2040 │ │ │ ├── Include │ │ │ │ ├── RP2040.h │ │ │ │ └── system_RP2040.h │ │ │ └── Source │ │ │ │ └── system_RP2040.c │ │ └── RP2350 │ │ │ ├── Include │ │ │ ├── RP2350.h │ │ │ └── system_RP2350.h │ │ │ └── Source │ │ │ └── system_RP2350.c │ │ └── LICENSE.txt │ ├── hardware_adc │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── adc.c │ └── include │ │ └── hardware │ │ └── adc.h │ ├── hardware_base │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── include │ │ └── hardware │ │ └── address_mapped.h │ ├── hardware_boot_lock │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── boot_lock.c │ └── include │ │ └── hardware │ │ └── boot_lock.h │ ├── hardware_clocks │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── clocks.c │ ├── include │ │ └── hardware │ │ │ └── clocks.h │ └── scripts │ │ └── vcocalc.py │ ├── hardware_dcp │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── doc.h │ └── include │ │ └── hardware │ │ ├── dcp_canned.inc.S │ │ └── dcp_instr.inc.S │ ├── hardware_divider │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── divider.S │ ├── divider.c │ └── include │ │ └── hardware │ │ ├── divider.h │ │ └── divider_helper.S │ ├── hardware_dma │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── dma.c │ └── include │ │ └── hardware │ │ └── dma.h │ ├── hardware_exception │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── exception.c │ ├── exception_table_riscv.S │ └── include │ │ └── hardware │ │ └── exception.h │ ├── hardware_flash │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── flash.c │ └── include │ │ └── hardware │ │ └── flash.h │ ├── hardware_gpio │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── gpio.c │ └── include │ │ └── hardware │ │ ├── gpio.h │ │ └── gpio_coproc.h │ ├── hardware_hazard3 │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── include │ │ └── hardware │ │ ├── hazard3.h │ │ └── hazard3 │ │ ├── features.h │ │ └── instructions.h │ ├── hardware_i2c │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── i2c.c │ └── include │ │ └── hardware │ │ └── i2c.h │ ├── hardware_interp │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── interp.h │ └── interp.c │ ├── hardware_irq │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── irq.h │ ├── irq.c │ └── irq_handler_chain.S │ ├── hardware_pio │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ ├── pio.h │ │ │ └── pio_instructions.h │ └── pio.c │ ├── hardware_pll │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── pll.h │ └── pll.c │ ├── hardware_powman │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── powman.h │ └── powman.c │ ├── hardware_pwm │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── include │ │ └── hardware │ │ └── pwm.h │ ├── hardware_rcp │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── include │ │ └── hardware │ │ └── rcp.h │ ├── hardware_resets │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── include │ │ └── hardware │ │ └── resets.h │ ├── hardware_riscv │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── include │ │ └── hardware │ │ └── riscv.h │ ├── hardware_riscv_platform_timer │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── include │ │ └── hardware │ │ └── riscv_platform_timer.h │ ├── hardware_rtc │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── rtc.h │ └── rtc.c │ ├── hardware_sha256 │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── sha256.h │ └── sha256.c │ ├── hardware_spi │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── spi.h │ └── spi.c │ ├── hardware_sync │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── sync.h │ └── sync.c │ ├── hardware_sync_spin_lock │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── sync │ │ │ └── spin_lock.h │ └── sync_spin_lock.c │ ├── hardware_ticks │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── ticks.h │ └── ticks.c │ ├── hardware_timer │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── timer.h │ └── timer.c │ ├── hardware_uart │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── uart.h │ └── uart.c │ ├── hardware_vreg │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── vreg.h │ └── vreg.c │ ├── hardware_watchdog │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── watchdog.h │ └── watchdog.c │ ├── hardware_xip_cache │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── xip_cache.h │ └── xip_cache.c │ ├── hardware_xosc │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── hardware │ │ │ └── xosc.h │ └── xosc.c │ ├── pico_aon_timer │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── aon_timer.c │ └── include │ │ └── pico │ │ └── aon_timer.h │ ├── pico_async_context │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── async_context_base.c │ ├── async_context_freertos.c │ ├── async_context_poll.c │ ├── async_context_threadsafe_background.c │ └── include │ │ └── pico │ │ ├── async_context.h │ │ ├── async_context_base.h │ │ ├── async_context_freertos.h │ │ ├── async_context_poll.h │ │ └── async_context_threadsafe_background.h │ ├── pico_atomic │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── atomic.c │ └── include │ │ └── stdatomic.h │ ├── pico_bit_ops │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── bit_ops_aeabi.S │ ├── pico_bootrom │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── bootrom.c │ ├── bootrom_lock.c │ └── include │ │ └── pico │ │ ├── bootrom.h │ │ ├── bootrom │ │ ├── lock.h │ │ └── sf_table.h │ │ └── bootrom_constants.h │ ├── pico_bootsel_via_double_reset │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── pico_bootsel_via_double_reset.c │ ├── pico_btstack │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── LICENSE.RP │ ├── btstack.BUILD │ ├── btstack_flash_bank.c │ ├── btstack_run_loop_async_context.c │ ├── btstack_stdin_pico.c │ ├── doc.h │ └── include │ │ └── pico │ │ ├── btstack_flash_bank.h │ │ └── btstack_run_loop_async_context.h │ ├── pico_clib_interface │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── doc.h │ ├── include │ │ └── llvm_libc │ │ │ ├── sys │ │ │ ├── cdefs.h │ │ │ ├── stat.h │ │ │ ├── time.h │ │ │ ├── times.h │ │ │ └── types.h │ │ │ ├── time.h │ │ │ └── unistd.h │ ├── llvm_libc_interface.c │ ├── newlib_interface.c │ └── picolibc_interface.c │ ├── pico_crt0 │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── crt0.S │ ├── crt0_riscv.S │ ├── doc.h │ ├── embedded_end_block.inc.S │ ├── embedded_start_block.inc.S │ ├── rp2040 │ │ ├── BUILD.bazel │ │ ├── memmap_blocked_ram.ld │ │ ├── memmap_copy_to_ram.ld │ │ ├── memmap_default.ld │ │ └── memmap_no_flash.ld │ └── rp2350 │ │ ├── BUILD.bazel │ │ ├── memmap_copy_to_ram.ld │ │ ├── memmap_default.ld │ │ └── memmap_no_flash.ld │ ├── pico_cxx_options │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── doc.h │ └── new_delete.cpp │ ├── pico_cyw43_arch │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── cyw43_arch.c │ ├── cyw43_arch_freertos.c │ ├── cyw43_arch_poll.c │ ├── cyw43_arch_threadsafe_background.c │ └── include │ │ └── pico │ │ ├── cyw43_arch.h │ │ └── cyw43_arch │ │ ├── arch_freertos.h │ │ ├── arch_poll.h │ │ └── arch_threadsafe_background.h │ ├── pico_cyw43_driver │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── btstack_chipset_cyw43.c │ ├── btstack_cyw43.c │ ├── btstack_hci_transport_cyw43.c │ ├── cybt_shared_bus │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── cybt_shared_bus.c │ │ ├── cybt_shared_bus_driver.c │ │ └── cybt_shared_bus_driver.h │ ├── cyw43-driver.BUILD │ ├── cyw43_bus_pio_spi.c │ ├── cyw43_bus_pio_spi.pio │ ├── cyw43_driver.c │ └── include │ │ ├── cyw43_configport.h │ │ └── pico │ │ ├── btstack_chipset_cyw43.h │ │ ├── btstack_cyw43.h │ │ ├── btstack_hci_transport_cyw43.h │ │ └── cyw43_driver.h │ ├── pico_divider │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── divider_compiler.c │ └── divider_hardware.S │ ├── pico_double │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── double_aeabi_dcp.S │ ├── double_aeabi_rp2040.S │ ├── double_conv_m33.S │ ├── double_fma_dcp.S │ ├── double_init_rom_rp2040.c │ ├── double_math.c │ ├── double_none.S │ ├── double_sci_m33.S │ ├── double_v1_rom_shim_rp2040.S │ └── include │ │ └── pico │ │ └── double.h │ ├── pico_fix │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── rp2040_usb_device_enumeration │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── include │ │ └── pico │ │ │ └── fix │ │ │ └── rp2040_usb_device_enumeration.h │ │ └── rp2040_usb_device_enumeration.c │ ├── pico_flash │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── flash.c │ └── include │ │ └── pico │ │ └── flash.h │ ├── pico_float │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── float_aeabi_dcp.S │ ├── float_aeabi_rp2040.S │ ├── float_common_m33.S │ ├── float_conv32_vfp.S │ ├── float_init_rom_rp2040.c │ ├── float_math.c │ ├── float_none.S │ ├── float_sci_m33.S │ ├── float_sci_m33_vfp.S │ ├── float_single_hazard3.S │ ├── float_v1_rom_shim_rp2040.S │ └── include │ │ └── pico │ │ └── float.h │ ├── pico_i2c_slave │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── i2c_slave.c │ └── include │ │ └── pico │ │ └── i2c_slave.h │ ├── pico_int64_ops │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── pico │ │ │ └── int64_ops.h │ └── pico_int64_ops_aeabi.S │ ├── pico_lwip │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── doc.h │ ├── include │ │ ├── arch │ │ │ └── cc.h │ │ └── pico │ │ │ ├── lwip_freertos.h │ │ │ └── lwip_nosys.h │ ├── lwip.BUILD │ ├── lwip_freertos.c │ ├── lwip_nosys.c │ └── tools │ │ ├── CMakeLists.txt │ │ └── makefsdata.py │ ├── pico_malloc │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── pico │ │ │ └── malloc.h │ └── malloc.c │ ├── pico_mbedtls │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── sha256_alt.h │ └── pico_mbedtls.c │ ├── pico_mem_ops │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── pico │ │ │ └── mem_ops.h │ ├── mem_ops.c │ └── mem_ops_aeabi.S │ ├── pico_multicore │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── pico │ │ │ └── multicore.h │ └── multicore.c │ ├── pico_platform_compiler │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── include │ │ └── pico │ │ └── platform │ │ └── compiler.h │ ├── pico_platform_panic │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── pico │ │ │ └── platform │ │ │ └── panic.h │ └── panic.c │ ├── pico_platform_sections │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── include │ │ └── pico │ │ └── platform │ │ └── sections.h │ ├── pico_printf │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── LICENSE │ ├── include │ │ └── pico │ │ │ └── printf.h │ ├── printf.c │ └── printf_none.S │ ├── pico_rand │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── pico │ │ │ └── rand.h │ └── rand.c │ ├── pico_runtime │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── pico │ │ │ └── runtime.h │ └── runtime.c │ ├── pico_runtime_init │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── pico │ │ │ └── runtime_init.h │ ├── runtime_init.c │ ├── runtime_init_clocks.c │ └── runtime_init_stack_guard.c │ ├── pico_sha256 │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── pico │ │ │ └── sha256.h │ └── sha256.c │ ├── pico_standard_binary_info │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── doc.h │ └── standard_binary_info.c │ ├── pico_standard_link │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── doc.h │ ├── pico_flash_region.bzl │ └── pico_flash_region.template.ld │ ├── pico_stdio │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── pico │ │ │ ├── stdio.h │ │ │ └── stdio │ │ │ └── driver.h │ └── stdio.c │ ├── pico_stdio_rtt │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── SEGGER │ │ ├── Config │ │ │ └── SEGGER_RTT_Conf.h │ │ └── RTT │ │ │ ├── SEGGER_RTT.c │ │ │ └── SEGGER_RTT.h │ ├── include │ │ └── pico │ │ │ └── stdio_rtt.h │ └── stdio_rtt.c │ ├── pico_stdio_semihosting │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── pico │ │ │ └── stdio_semihosting.h │ └── stdio_semihosting.c │ ├── pico_stdio_uart │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── pico │ │ │ └── stdio_uart.h │ └── stdio_uart.c │ ├── pico_stdio_usb │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ ├── pico │ │ │ ├── stdio_usb.h │ │ │ └── stdio_usb │ │ │ │ └── reset_interface.h │ │ └── tusb_config.h │ ├── reset_interface.c │ ├── stdio_usb.c │ └── stdio_usb_descriptors.c │ ├── pico_stdlib │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── stdlib.c │ ├── pico_time_adapter │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── include │ │ └── pico │ │ └── time_adapter.h │ ├── pico_unique_id │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── include │ │ └── pico │ │ │ └── unique_id.h │ └── unique_id.c │ └── tinyusb │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── doc.h │ ├── include │ └── bsp │ │ └── board.h │ └── tinyusb.BUILD ├── test ├── CMakeLists.txt ├── cmsis_test │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── cmsis_test.c ├── hardware_irq_test │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── hardware_irq_test.c ├── hardware_pwm_test │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── hardware_pwm_test.c ├── hardware_sync_spin_lock_test │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── hardware_sync_spin_lock_test.c ├── kitchen_sink │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── btstack_config.h │ ├── kitchen_sink.c │ ├── kitchen_sink_cpp.cpp │ ├── lwipopts.h │ └── mbedtls_config.h ├── pico_divider_test │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── pico_divider_nesting_test.c │ └── pico_divider_test.c ├── pico_float_test │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── custom_double_funcs_test.c │ ├── custom_float_funcs_test.c │ ├── hazard3_test_gen.c │ ├── llvm │ │ ├── LICENSE.TXT │ │ ├── call_apsr.S │ │ └── call_apsr.h │ ├── m33.c │ ├── pico_double_test.c │ ├── pico_float_test.c │ ├── pico_float_test_hazard3.c │ └── vectors │ │ ├── hazard3_addsf.inc │ │ └── hazard3_mulsf.inc ├── pico_sem_test │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── pico_sem_test.c ├── pico_sha256_test │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── pico_sha256_test.c ├── pico_stdio_test │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── pico_stdio_test.c ├── pico_stdlib_test │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── pico_stdlib_test.c ├── pico_test │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── include │ │ └── pico │ │ ├── test.h │ │ └── test │ │ └── xrand.h └── pico_time_test │ ├── BUILD.bazel │ ├── CMakeLists.txt │ └── pico_time_test.c └── tools ├── BUILD.bazel ├── CMakeLists.txt ├── Findpicotool.cmake ├── Findpioasm.cmake ├── bazel_build.py ├── bazel_common.py ├── build_all_headers.py ├── check_all_board_headers.sh ├── check_board_header.py ├── check_configs.sh ├── check_doxygen_groups.py ├── check_source_files_in_bazel_build.py ├── compare_build_systems.py ├── copro_dis.py ├── extract_build_defines.py ├── extract_cmake_configs.py ├── extract_configs.py ├── pioasm ├── BUILD.bazel ├── CMakeLists.txt ├── ada_output.cpp ├── c_sdk_output.cpp ├── cmake │ └── pioasmConfig.cmake ├── gen │ ├── lexer.cpp │ ├── location.h │ ├── parser.cpp │ └── parser.hpp ├── go_output.cpp ├── hex_output.cpp ├── json_output.cpp ├── lexer.ll ├── main.cpp ├── output_format.h ├── parser.yy ├── pio_assembler.cpp ├── pio_assembler.h ├── pio_disassembler.cpp ├── pio_disassembler.h ├── pio_enums.h ├── pio_types.h ├── python_output.cpp └── test │ └── amethyst.pio ├── run_all_bazel_checks.py └── uf2_aspect.bzl /.bazelignore: -------------------------------------------------------------------------------- 1 | # Don't accidentally pick up external CMake deps with Bazel build files. 2 | build 3 | # Don't treat submodules as part of this project. 4 | lib 5 | -------------------------------------------------------------------------------- /.bazelrc: -------------------------------------------------------------------------------- 1 | # Silence all C/C++ warnings in external code. 2 | common --per_file_copt=external/.*@-w 3 | common --host_per_file_copt=external/.*@-w 4 | 5 | # Produce useful output when the build fails. 6 | common --verbose_failures 7 | -------------------------------------------------------------------------------- /.bazelversion: -------------------------------------------------------------------------------- 1 | 7.2.1 2 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | _Instructions: (please delete)_ 2 | - _please do not submit against `master`, use `develop` instead_ 3 | - _please make sure there is an associated issue for your PR, and reference it via "Fixes #num" in the description_ 4 | - _please enter a detailed description_ 5 | -------------------------------------------------------------------------------- /.github/workflows/choco_packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | name: Build on Windows 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: 6 | - 'develop' 7 | - 'master' 8 | - 'test_workflow' 9 | 10 | jobs: 11 | build: 12 | runs-on: windows-2022 13 | steps: 14 | - name: Clean workspace 15 | shell: bash 16 | run: | 17 | echo "Cleaning up previous run" 18 | rm -rf "${{ github.workspace }}/pico-sdk" 19 | - name: Checkout repo 20 | uses: actions/checkout@v4 21 | - name: Checkout submodules 22 | run: git submodule update --init 23 | - name: Install dependencies 24 | run: choco install .github/workflows/choco_packages.config 25 | 26 | - name: Build Project 27 | shell: pwsh 28 | run: | 29 | mkdir build 30 | cd build 31 | cmake .. -G Ninja -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_BOARD=pico_w 32 | cmake --build . 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | cmake-* 4 | .cache 5 | .DS_Store 6 | build 7 | build-* 8 | 9 | bazel-* 10 | 11 | # Ignore until https://github.com/bazelbuild/bazel/issues/20369 is fixed. 12 | MODULE.bazel.lock 13 | __pycache__/ 14 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tinyusb"] 2 | path = lib/tinyusb 3 | url = https://github.com/hathach/tinyusb.git 4 | [submodule "lib/cyw43-driver"] 5 | path = lib/cyw43-driver 6 | url = https://github.com/georgerobotics/cyw43-driver.git 7 | [submodule "lib/lwip"] 8 | path = lib/lwip 9 | url = https://github.com/lwip-tcpip/lwip.git 10 | [submodule "lib/mbedtls"] 11 | path = lib/mbedtls 12 | url = https://github.com/Mbed-TLS/mbedtls.git 13 | [submodule "lib/btstack"] 14 | path = lib/btstack 15 | url = https://github.com/bluekitchen/btstack.git 16 | -------------------------------------------------------------------------------- /BUILD.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypi/pico-sdk/ee68c78d0afae2b69c03ae1a72bf5cc267a2d94c/BUILD.bazel -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypi/pico-sdk/ee68c78d0afae2b69c03ae1a72bf5cc267a2d94c/WORKSPACE -------------------------------------------------------------------------------- /bazel/include/pico/config_autogen.h: -------------------------------------------------------------------------------- 1 | // Rather than auto-generating as part of the build, this header 2 | // is checked in directly. 3 | // 4 | // You can change what is included by configuring these `label_flag`s: 5 | // --@pico-sdk//bazel/config:PICO_CONFIG_EXTRA_HEADER=//my_proj:my_custom_headers 6 | // --@pico-sdk//bazel/config:PICO_CONFIG_PLATFORM_HEADER=//my_proj:my_custom_headers 7 | 8 | // This header must be provided by //bazel/config:PICO_CONFIG_EXTRA_HEADER: 9 | #include "pico_config_extra_headers.h" 10 | 11 | // This header must be provided by //bazel/config:PICO_CONFIG_PLATFORM_HEADER: 12 | #include "pico_config_platform_headers.h" 13 | -------------------------------------------------------------------------------- /bazel/platform/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | platform( 4 | name = "rp2040", 5 | constraint_values = [ 6 | "@pico-sdk//bazel/constraint:rp2040", 7 | "@platforms//cpu:armv6-m", 8 | ], 9 | ) 10 | 11 | platform( 12 | name = "rp2350", 13 | constraint_values = [ 14 | "@pico-sdk//bazel/constraint:rp2350", 15 | "@platforms//cpu:armv8-m", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /bazel/util/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | -------------------------------------------------------------------------------- /bazel/util/label_flag_matches.bzl: -------------------------------------------------------------------------------- 1 | """A wrapper that enables a `config_setting` matcher for label_flag flags.""" 2 | 3 | load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") 4 | load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain") 5 | 6 | def _match_label_flag_impl(ctx): 7 | matches = str(ctx.attr.expected_value.label) == str(ctx.attr.flag.label) 8 | return [ 9 | config_common.FeatureFlagInfo(value = str(matches)), 10 | BuildSettingInfo(value = matches), 11 | ] 12 | 13 | _match_label_flag = rule( 14 | implementation = _match_label_flag_impl, 15 | attrs = { 16 | "expected_value": attr.label( 17 | mandatory = True, 18 | doc = "The expected flag value", 19 | ), 20 | "flag": attr.label( 21 | mandatory = True, 22 | doc = "The flag to extract a value from", 23 | ), 24 | }, 25 | ) 26 | 27 | def label_flag_matches(*, name, flag, value): 28 | _match_label_flag( 29 | name = name + "._impl", 30 | expected_value = native.package_relative_label(value), 31 | flag = flag, 32 | ) 33 | 34 | native.config_setting( 35 | name = name, 36 | flag_values = {":{}".format(name + "._impl"): "True"}, 37 | ) 38 | -------------------------------------------------------------------------------- /cmake/Platform/PICO.cmake: -------------------------------------------------------------------------------- 1 | # this is included because toolchain file sets SYSTEM_NAME=PICO 2 | 3 | set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) 4 | set(CMAKE_EXECUTABLE_SUFFIX .elf) 5 | 6 | # include paths to find installed tools 7 | if(CMAKE_HOST_WIN32) 8 | include(Platform/WindowsPaths) 9 | else() 10 | include(Platform/UnixPaths) 11 | endif() 12 | -------------------------------------------------------------------------------- /cmake/pico_utils.cmake: -------------------------------------------------------------------------------- 1 | function(pico_message param) 2 | if (${ARGC} EQUAL 1) 3 | message("${param}") 4 | return() 5 | endif () 6 | 7 | if (NOT ${ARGC} EQUAL 2) 8 | message(FATAL_ERROR "Expect at most 2 arguments") 9 | endif () 10 | message("${param}" "${ARGV1}") 11 | endfunction() 12 | 13 | macro(assert VAR MSG) 14 | if (NOT ${VAR}) 15 | message(FATAL_ERROR "${MSG}") 16 | endif () 17 | endmacro() 18 | 19 | function(pico_find_in_paths OUT PATHS NAME) 20 | foreach(PATH IN LISTS ${PATHS}) 21 | if (EXISTS ${PATH}/${NAME}) 22 | get_filename_component(FULLNAME ${PATH}/${NAME} ABSOLUTE) 23 | set(${OUT} ${FULLNAME} PARENT_SCOPE) 24 | return() 25 | endif() 26 | endforeach() 27 | set(${OUT} "" PARENT_SCOPE) 28 | endfunction() -------------------------------------------------------------------------------- /cmake/preload/platforms/combined-docs.cmake: -------------------------------------------------------------------------------- 1 | set(PICO_DEFAULT_COMPILER "pico_arm_cortex_m33_gcc") 2 | set(PICO_CHIP rp2350) 3 | 4 | -------------------------------------------------------------------------------- /cmake/preload/platforms/host.cmake: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypi/pico-sdk/ee68c78d0afae2b69c03ae1a72bf5cc267a2d94c/cmake/preload/platforms/host.cmake -------------------------------------------------------------------------------- /cmake/preload/platforms/rp2040.cmake: -------------------------------------------------------------------------------- 1 | set(PICO_DEFAULT_COMPILER "pico_arm_cortex_m0plus_gcc") 2 | set(PICO_CHIP rp2040) 3 | -------------------------------------------------------------------------------- /cmake/preload/platforms/rp2350-arm-s.cmake: -------------------------------------------------------------------------------- 1 | set(PICO_DEFAULT_COMPILER "pico_arm_cortex_m33_gcc") 2 | set(PICO_CHIP rp2350) 3 | 4 | -------------------------------------------------------------------------------- /cmake/preload/platforms/rp2350-riscv.cmake: -------------------------------------------------------------------------------- 1 | set(PICO_DEFAULT_COMPILER "pico_riscv_gcc") 2 | set(PICO_CHIP rp2350) 3 | 4 | -------------------------------------------------------------------------------- /cmake/preload/toolchains/pico_arm_cortex_m0plus_clang.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus) 2 | 3 | # these are all the directories under LLVM embedded toolchain for ARM (newlib or pibolibc) and under llvm_libc 4 | set(PICO_CLANG_RUNTIMES armv6m_soft_nofp armv6m-unknown-none-eabi) 5 | 6 | set(PICO_COMMON_LANG_FLAGS "--target=armv6m-none-eabi -mfloat-abi=soft -march=armv6m") 7 | 8 | include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_clang_common.cmake) 9 | -------------------------------------------------------------------------------- /cmake/preload/toolchains/pico_arm_cortex_m0plus_gcc.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus) 2 | 3 | set(PICO_DEFAULT_GCC_TRIPLE arm-none-eabi) 4 | # on ARM -mcpu should not be mixed with -march 5 | set(PICO_COMMON_LANG_FLAGS " -mcpu=cortex-m0plus -mthumb") 6 | 7 | include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_gcc_common.cmake) -------------------------------------------------------------------------------- /cmake/preload/toolchains/pico_arm_cortex_m23_gcc.cmake: -------------------------------------------------------------------------------- 1 | # todo there is probably a more "cmake" way of doing this going thru the standard path with our "PICO" platform 2 | # i.e. CMakeInformation and whatnot 3 | 4 | set(CMAKE_SYSTEM_PROCESSOR cortex-m23) 5 | set(PICO_DEFAULT_GCC_TRIPLE arm-none-eabi) 6 | 7 | # todo amy should this be -mfloat-abi=hard? 8 | set(PICO_COMMON_LANG_FLAGS " -mcpu=cortex-m23 -mthumb -march=armv8-m.base") 9 | # todo probably need a setting here, also do we want `softfp`? 10 | set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -mfloat-abi=softfp") 11 | if (NOT PICO_NO_CMSE) 12 | set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -mcmse") 13 | endif() 14 | 15 | include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_gcc_common.cmake) -------------------------------------------------------------------------------- /cmake/preload/toolchains/pico_arm_cortex_m33_clang.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_PROCESSOR cortex-m33) 2 | 3 | # these are all the directories under LLVM embedded toolchain for ARM (newlib or pibolibc) and under llvm_libc 4 | set(PICO_CLANG_RUNTIMES armv8m.main_soft_nofp armv8m.main-unknown-none-eabi) 5 | 6 | set(PICO_COMMON_LANG_FLAGS "-mcpu=cortex-m33 --target=armv8m.main-none-eabi -mfloat-abi=softfp -march=armv8m.main+fp+dsp") 7 | set(PICO_DISASM_OBJDUMP_ARGS --mcpu=cortex-m33 --arch=armv8m.main+fp+dsp) 8 | include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_clang_common.cmake) 9 | -------------------------------------------------------------------------------- /cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_PROCESSOR cortex-m33) 2 | set(PICO_DEFAULT_GCC_TRIPLE arm-none-eabi) 3 | 4 | set(PICO_COMMON_LANG_FLAGS " -mcpu=cortex-m33 -mthumb -march=armv8-m.main+fp+dsp") 5 | set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -mfloat-abi=softfp") 6 | if (NOT PICO_NO_CMSE) 7 | set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -mcmse") 8 | endif() 9 | 10 | include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_gcc_common.cmake) -------------------------------------------------------------------------------- /cmake/preload/toolchains/pico_riscv_gcc.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_PROCESSOR hazard3) 2 | 3 | set(PICO_DEFAULT_GCC_TRIPLE riscv32-unknown-elf riscv32-corev-elf) 4 | 5 | set(PICO_COMMON_LANG_FLAGS " -march=rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb -mabi=ilp32") 6 | 7 | include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_gcc_common.cmake) 8 | -------------------------------------------------------------------------------- /cmake/preload/toolchains/pico_riscv_gcc_zcb_zcmp.cmake: -------------------------------------------------------------------------------- 1 | # todo there is probably a more "cmake" way of doing this going thru the standard path with our "PICO" platform 2 | # i.e. CMakeInformation and whatnot 3 | 4 | set(CMAKE_SYSTEM_PROCESSOR hazard3) 5 | 6 | set(PICO_DEFAULT_GCC_TRIPLE riscv32-unknown-elf riscv32-corev-elf) 7 | 8 | set(PICO_COMMON_LANG_FLAGS " -march=rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb_zcmp -mabi=ilp32") 9 | 10 | include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_gcc_common.cmake) 11 | -------------------------------------------------------------------------------- /cmake/preload/toolchains/util/set_flags.cmake: -------------------------------------------------------------------------------- 1 | option(PICO_DEOPTIMIZED_DEBUG "Build debug builds with -O0" 0) 2 | option(PICO_DEBUG_INFO_IN_RELEASE "Include debug info in release builds" 1) 3 | 4 | get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE) 5 | foreach(LANG IN ITEMS C CXX ASM) 6 | set(CMAKE_${LANG}_FLAGS_INIT "${PICO_COMMON_LANG_FLAGS}") 7 | unset(CMAKE_${LANG}_FLAGS_DEBUG CACHE) 8 | if (PICO_DEOPTIMIZED_DEBUG) 9 | set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-O0") 10 | else() 11 | set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-Og") 12 | endif() 13 | if (PICO_DEBUG_INFO_IN_RELEASE) 14 | set(CMAKE_${LANG}_FLAGS_RELEASE_INIT "-g") 15 | set(CMAKE_${LANG}_FLAGS_MINSIZEREL_INIT "-g") 16 | endif() 17 | set(CMAKE_${LANG}_LINK_FLAGS "-Wl,--build-id=none") 18 | 19 | # try_compile is where the feature testing is done, and at that point, 20 | # pico_standard_link is not ready to be linked in to provide essential 21 | # functions like _exit. So pass -nostdlib so it doesn't link in an exit() 22 | # function at all. 23 | if(IS_IN_TRY_COMPILE) 24 | set(CMAKE_${LANG}_LINK_FLAGS "${CMAKE_${LANG}_LINK_FLAGS} -nostdlib") 25 | endif() 26 | endforeach() 27 | -------------------------------------------------------------------------------- /docs/examples.md: -------------------------------------------------------------------------------- 1 | ## Examples Index {#examples_page} 2 | 3 | This page links to the various example code fragments in this documentation. For more complete examples, please see the [pico-examples](https://github.com/raspberrypi/pico-examples) repository, which contains complete buildable projects. 4 | 5 | - [RTC example](@ref rtc_example) 6 | - [UART example](@ref uart_example) 7 | - [ADC example](@ref adc_example) 8 | - [I2C example](@ref i2c_example) 9 | - [Clock example](@ref clock_example) 10 | - [Timer example](@ref timer_example) 11 | - [Flash programming example](@ref flash_example) 12 | - [Watchdog example](@ref watchdog_example) 13 | - [Divider example](@ref divider_example) 14 | - [PWM example](@ref pwm_example) 15 | - [Multicore example](@ref multicore_example) 16 | - [Reset example](@ref reset_example) 17 | 18 | 19 | All examples are "Copyright (c) 2020 Raspberry Pi (Trading) Ltd", and are released under a 3-Clause BSD licence. Briefly, this means you are free to use the example code 20 | as long as you retain the copyright notice. Full details on the licence can be found [here](https://opensource.org/licenses/BSD-3-Clause). 21 | 22 | -------------------------------------------------------------------------------- /docs/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /docs/main.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function() { 2 | 3 | // Trigger the mobile navigation 4 | $(document).on('click', '.navigation-toggle', function (event) { 5 | event.preventDefault(); 6 | $(this).toggleClass('clicked'); 7 | $('#top').toggleClass('open'); 8 | }); 9 | 10 | // Add a class to all
  • 's with children 11 | $('#main-nav ul li > ul').parent().addClass('hasChildren'); 12 | $('#main-nav .has-submenu').removeClass('has-submenu'); 13 | $('#main-nav .sm').removeClass('sm'); 14 | $('#main-nav .sm-dox').removeClass('sm-dox'); 15 | $('#main-nav #main-menu').removeAttr('data-smartmenus-id'); 16 | $('#main-nav #main-menu').removeAttr('id'); 17 | }); 18 | -------------------------------------------------------------------------------- /docs/pico.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypi/pico-sdk/ee68c78d0afae2b69c03ae1a72bf5cc267a2d94c/docs/pico.jpg -------------------------------------------------------------------------------- /docs/rp2040.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raspberrypi/pico-sdk/ee68c78d0afae2b69c03ae1a72bf5cc267a2d94c/docs/rp2040.png -------------------------------------------------------------------------------- /src/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | # This shim exists as a way to break internal header dependency cycles 4 | # that occur within the dependency chain of the pico_platform target below. 5 | alias( 6 | name = "pico_platform_internal", 7 | actual = select({ 8 | "//bazel/constraint:host": "//src/host/pico_platform:pico_platform_internal", 9 | "//conditions:default": "//src/rp2_common:pico_platform_internal", 10 | }), 11 | visibility = [ 12 | "//src/common/boot_picobin_headers:__pkg__", 13 | "//src/common/boot_picoboot_headers:__pkg__", 14 | "//src/common/hardware_claim:__pkg__", 15 | "//src/common/pico_base_headers:__pkg__", 16 | "//src/common/pico_binary_info:__pkg__", 17 | # These libraries sometimes need the host version even though they live 18 | # in rp2_common. 19 | "//src/rp2_common/boot_bootrom_headers:__pkg__", 20 | "//src/rp2_common/hardware_boot_lock:__pkg__", 21 | "//src/rp2_common/pico_flash:__pkg__", 22 | ], 23 | ) 24 | 25 | alias( 26 | name = "pico_platform", 27 | actual = select({ 28 | "//bazel/constraint:host": "//src/host/pico_platform", 29 | "//conditions:default": "//src/rp2_common:pico_platform", 30 | }), 31 | ) 32 | -------------------------------------------------------------------------------- /src/boards/include/boards/none.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // ----------------------------------------------------- 8 | // NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO 9 | // SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES 10 | // ----------------------------------------------------- 11 | 12 | #ifndef _BOARDS_NONE_H 13 | #define _BOARDS_NONE_H 14 | 15 | #endif -------------------------------------------------------------------------------- /src/boards/include/boards/pololu_3pi_2040_robot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // ----------------------------------------------------- 8 | // NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO 9 | // SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES 10 | // ----------------------------------------------------- 11 | 12 | // pico_cmake_set PICO_PLATFORM=rp2040 13 | 14 | #ifndef _BOARDS_POLOLU_3PI_2040_ROBOT_H 15 | #define _BOARDS_POLOLU_3PI_2040_ROBOT_H 16 | 17 | // For board detection 18 | #define POLOLU_3PI_2040_ROBOT 19 | 20 | #define PICO_DEFAULT_LED_PIN 25 21 | #define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 22 | #define PICO_FLASH_SPI_CLKDIV 2 23 | // pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024) 24 | #define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024) 25 | 26 | // All boards have at least the B1 revision 27 | #define PICO_RP2040_B0_SUPPORTED 0 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/boards/include/boards/pololu_zumo_2040_robot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // ----------------------------------------------------- 8 | // NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO 9 | // SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES 10 | // ----------------------------------------------------- 11 | 12 | // pico_cmake_set PICO_PLATFORM=rp2040 13 | 14 | #ifndef _BOARDS_POLOLU_ZUMO_2040_ROBOT_H 15 | #define _BOARDS_POLOLU_ZUMO_2040_ROBOT_H 16 | 17 | // For board detection 18 | #define POLOLU_ZUMO_2040_ROBOT 19 | 20 | #define PICO_DEFAULT_LED_PIN 25 21 | #define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 22 | #define PICO_FLASH_SPI_CLKDIV 2 23 | // pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024) 24 | #define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024) 25 | 26 | // All boards have at least the B1 revision 27 | #define PICO_RP2040_B0_SUPPORTED 0 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/boards/include/boards/solderparty_rp2040_stamp_carrier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // ----------------------------------------------------- 8 | // NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO 9 | // SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES 10 | // ----------------------------------------------------- 11 | // 12 | //------------------------------------------------------------------------------------------ 13 | // Board definition for the Solder Party RP2040 Stamp Carrier 14 | // 15 | // This header may be included by other board headers as "boards/solderparty_rp2040_stamp_carrier.h" 16 | 17 | // pico_cmake_set PICO_PLATFORM=rp2040 18 | 19 | #ifndef _BOARDS_SOLDERPARTY_RP2040_STAMP_CARRIER_H 20 | #define _BOARDS_SOLDERPARTY_RP2040_STAMP_CARRIER_H 21 | 22 | // For board detection 23 | #define SOLDERPARTY_RP2040_STAMP_CARRIER 24 | 25 | #ifndef PICO_DEFAULT_LED_PIN 26 | #define PICO_DEFAULT_LED_PIN 20 27 | #endif 28 | 29 | #include "solderparty_rp2040_stamp.h" 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/cmake/no_hardware.cmake: -------------------------------------------------------------------------------- 1 | macro(pico_set_float_implementation TARGET IMPL) 2 | # ignore 3 | endmacro() 4 | 5 | macro(pico_set_double_implementation TARGET IMPL) 6 | # ignore 7 | endmacro() 8 | 9 | macro(pico_set_binary_type TARGET IMPL) 10 | # ignore 11 | endmacro() 12 | 13 | macro(pico_set_boot_stage2 TARGET IMPL) 14 | # ignore 15 | endmacro() 16 | 17 | set(PICO_HOST_DIR "${CMAKE_CURRENT_LIST_DIR}/host" CACHE INTERNAL "") 18 | function(pico_define_boot_stage2 NAME) 19 | add_executable(${NAME} ${PICO_HOST_DIR}/boot_stage2.c) 20 | endfunction() 21 | 22 | function(pico_add_extra_outputs TARGET) 23 | endfunction() 24 | 25 | set(PICO_NO_HARDWARE "1" CACHE INTERNAL "") 26 | set(PICO_ON_DEVICE "0" CACHE INTERNAL "") -------------------------------------------------------------------------------- /src/common/README.md: -------------------------------------------------------------------------------- 1 | This directory code that is common to all builds regardless of `PICO_PLATFORM`. It is a mix 2 | of common header files, or high level functionality built entirely using `hardware_` or `pico_` libraries provided 3 | by the actual target `PICO_PLATFORM` 4 | -------------------------------------------------------------------------------- /src/common/boot_picobin_headers/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "boot_picobin_headers", 5 | hdrs = ["include/boot/picobin.h"], 6 | includes = ["include"], 7 | deps = [ 8 | "//src:pico_platform_internal", 9 | ], 10 | ) 11 | -------------------------------------------------------------------------------- /src/common/boot_picobin_headers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(boot_picobin_headers INTERFACE) 2 | target_include_directories(boot_picobin_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 3 | -------------------------------------------------------------------------------- /src/common/boot_picoboot_headers/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | # This needs to remain compatible with the host build since it's used by 4 | # Picotool. 5 | cc_library( 6 | name = "boot_picoboot_headers", 7 | hdrs = [ 8 | "include/boot/picoboot.h", 9 | "include/boot/picoboot_constants.h", 10 | ], 11 | includes = ["include"], 12 | deps = ["//src:pico_platform_internal"], 13 | ) 14 | -------------------------------------------------------------------------------- /src/common/boot_picoboot_headers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(boot_picoboot_headers INTERFACE) 2 | target_include_directories(boot_picoboot_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 3 | -------------------------------------------------------------------------------- /src/common/boot_uf2_headers/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "boot_uf2_headers", 5 | hdrs = ["include/boot/uf2.h"], 6 | includes = ["include"], 7 | ) 8 | -------------------------------------------------------------------------------- /src/common/boot_uf2_headers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(boot_uf2_headers INTERFACE) 2 | target_include_directories(boot_uf2_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 3 | -------------------------------------------------------------------------------- /src/common/hardware_claim/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "hardware_claim", 5 | srcs = ["claim.c"], 6 | hdrs = ["include/hardware/claim.h"], 7 | includes = ["include"], 8 | deps = [ 9 | ] + select({ 10 | "//bazel/constraint:host": [ 11 | "//src/host/hardware_sync", 12 | ], 13 | "//conditions:default": [ 14 | "//src:pico_platform_internal", 15 | "//src/rp2_common/hardware_sync:hardware_sync_headers", 16 | "//src/rp2_common/hardware_sync_spin_lock", 17 | ], 18 | }), 19 | ) 20 | -------------------------------------------------------------------------------- /src/common/hardware_claim/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(claim) 2 | 3 | pico_mirrored_target_link_libraries(hardware_claim INTERFACE hardware_sync) -------------------------------------------------------------------------------- /src/common/pico_base_headers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_base_headers) 2 | pico_add_library(pico_base NOFLAG) 3 | target_include_directories(pico_base_headers SYSTEM INTERFACE include ${CMAKE_BINARY_DIR}/generated/pico_base) 4 | 5 | # PICO_BUILD_DEFINE: PICO_BOARD, Name of board, type=string, default=CMake PICO_BOARD variable, group=pico_base 6 | target_compile_definitions(pico_base_headers INTERFACE 7 | PICO_BOARD="${PICO_BOARD}") 8 | 9 | foreach(override ${PICO_BOARD_CMAKE_OVERRIDES}) 10 | target_compile_definitions(pico_base_headers INTERFACE 11 | ${override}=${${override}}) 12 | endforeach() 13 | 14 | target_link_libraries(pico_base_headers INTERFACE pico_platform_headers) 15 | 16 | list(APPEND PICO_SDK_POST_LIST_FILES ${CMAKE_CURRENT_LIST_DIR}/generate_config_header.cmake) 17 | pico_promote_common_scope_vars() 18 | endif() -------------------------------------------------------------------------------- /src/common/pico_base_headers/include/pico.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_H 8 | #define _PICO_H 9 | 10 | /** \file pico.h 11 | * \defgroup pico_base pico_base 12 | * 13 | * \brief Core types and macros for the Raspberry Pi Pico SDK. 14 | * 15 | * This header is intended to be included by all source code 16 | * as it includes configuration headers and overrides in the correct order 17 | * 18 | * This header may be included by assembly code 19 | */ 20 | 21 | // We may be included by assembly which can't include 22 | #define __PICO_STRING(x) #x 23 | #define __PICO_XSTRING(x) __PICO_STRING(x) 24 | #define __PICO_CONCAT1(x, y) x ## y 25 | 26 | #include "pico/types.h" 27 | #include "pico/version.h" 28 | 29 | // PICO_CONFIG: PICO_CONFIG_HEADER, Unquoted path to header include in place of the default pico/config.h which may be desirable for build systems which can't easily generate the config_autogen header, group=pico_base 30 | #ifdef PICO_CONFIG_HEADER 31 | #include __PICO_XSTRING(PICO_CONFIG_HEADER) 32 | #else 33 | #include "pico/config.h" 34 | #endif 35 | #include "pico/platform.h" 36 | #include "pico/error.h" 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/common/pico_base_headers/include/pico/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_CONFIG_H 8 | #define _PICO_CONFIG_H 9 | 10 | // ----------------------------------------------------- 11 | // NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLY CODE SO 12 | // SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES 13 | // OR USE #ifndef __ASSEMBLER__ guards 14 | // ------------- 15 | 16 | // PICO_CONFIG_HEADER_FILES and then PICO_SDK__CONFIG_INCLUDE_FILES 17 | // entries are dumped in order at build time into this generated header 18 | 19 | #include "pico/config_autogen.h" 20 | 21 | // PICO_CONFIG: PICO_CONFIG_RTOS_ADAPTER_HEADER, Unquoted path to header include in the default pico/config.h for RTOS integration defines that must be included in all sources, group=pico_base 22 | #ifdef PICO_CONFIG_RTOS_ADAPTER_HEADER 23 | #include __PICO_XSTRING(PICO_CONFIG_RTOS_ADAPTER_HEADER) 24 | #endif 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/common/pico_base_headers/include/pico/version.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // --------------------------------------- 8 | // THIS FILE IS AUTOGENERATED; DO NOT EDIT 9 | // --------------------------------------- 10 | 11 | #ifndef _PICO_VERSION_H 12 | #define _PICO_VERSION_H 13 | 14 | #define PICO_SDK_VERSION_MAJOR ${PICO_SDK_VERSION_MAJOR} 15 | #define PICO_SDK_VERSION_MINOR ${PICO_SDK_VERSION_MINOR} 16 | #define PICO_SDK_VERSION_REVISION ${PICO_SDK_VERSION_REVISION} 17 | #define PICO_SDK_VERSION_STRING "${PICO_SDK_VERSION_STRING}" 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/common/pico_binary_info/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel/util:sdk_define.bzl", "pico_sdk_define") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | pico_sdk_define( 6 | name = "LIB_PICO_BINARY_INFO", 7 | define_name = "LIB_PICO_BINARY_INFO", 8 | from_flag = "//bazel/config:PICO_BINARY_INFO_ENABLED", 9 | ) 10 | 11 | # The actual sources and defines for pico_binary_info are provided 12 | # in the //src/rp2_common/pico_standard_link package. 13 | 14 | cc_library( 15 | name = "pico_binary_info", 16 | hdrs = [ 17 | "include/pico/binary_info.h", 18 | "include/pico/binary_info/code.h", 19 | "include/pico/binary_info/defs.h", 20 | "include/pico/binary_info/structure.h", 21 | ], 22 | includes = ["include"], 23 | deps = [ 24 | ":LIB_PICO_BINARY_INFO", 25 | "//src:pico_platform_internal", 26 | "//src/common/pico_base_headers", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /src/common/pico_binary_info/include/pico/binary_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_BINARY_INFO_H 8 | #define _PICO_BINARY_INFO_H 9 | 10 | /** \file binary_info.h 11 | * \defgroup pico_binary_info pico_binary_info 12 | * 13 | * \brief Binary info is intended for embedding machine readable information with the binary in FLASH 14 | * 15 | * Example uses include: 16 | * 17 | * - Program identification / information 18 | * - Pin layouts 19 | * - Included features 20 | * - Identifying flash regions used as block devices/storage 21 | */ 22 | 23 | #include "pico/binary_info/defs.h" 24 | #include "pico/binary_info/structure.h" 25 | 26 | // PICO_CONFIG: PICO_NO_BINARY_INFO, Don't include "binary info" in the output binary, type=bool, default=0 except for `PICO_PLATFORM` `host`, group=pico_runtime_init 27 | #if !PICO_ON_DEVICE && !defined(PICO_NO_BINARY_INFO) 28 | #define PICO_NO_BINARY_INFO 1 29 | #endif 30 | #include "pico/binary_info/code.h" 31 | #endif 32 | -------------------------------------------------------------------------------- /src/common/pico_bit_ops_headers/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | # This exists to break dependency cycles between 4 | # this library and the bit ops implementations. 5 | # Application code should always use :pico_bit_ops instead. 6 | cc_library( 7 | name = "pico_bit_ops_interface", 8 | hdrs = ["include/pico/bit_ops.h"], 9 | includes = ["include"], 10 | visibility = [ 11 | "//src/host/pico_bit_ops:__pkg__", 12 | "//src/rp2_common/pico_bit_ops:__pkg__", 13 | ], 14 | deps = [ 15 | "//src/common/pico_base_headers", 16 | ], 17 | ) 18 | 19 | cc_library( 20 | name = "pico_bit_ops_headers", 21 | hdrs = ["include/pico/bit_ops.h"], 22 | includes = ["include"], 23 | deps = [ 24 | "//src/common/pico_base_headers", 25 | ] + select({ 26 | "//bazel/constraint:host": ["//src/host/pico_bit_ops"], 27 | "//conditions:default": ["//src/rp2_common/pico_bit_ops"], 28 | }), 29 | ) 30 | -------------------------------------------------------------------------------- /src/common/pico_bit_ops_headers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_bit_ops_headers) 2 | add_library(pico_bit_ops_headers INTERFACE) 3 | target_include_directories(pico_bit_ops_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 4 | target_link_libraries(pico_bit_ops_headers INTERFACE pico_base_headers) 5 | endif() -------------------------------------------------------------------------------- /src/common/pico_bit_ops_headers/include/pico/bit_ops.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_BIT_OPS_H 8 | #define _PICO_BIT_OPS_H 9 | 10 | #include "pico.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /** \file bit_ops.h 17 | * \defgroup pico_bit_ops pico_bit_ops 18 | * 19 | * \brief Optimized bit manipulation functions 20 | * 21 | * Additionally provides replacement implementations of the compiler built-ins __builtin_popcount, __builtin_clz 22 | * and __bulitin_ctz 23 | */ 24 | 25 | /*! \brief Reverse the bits in a 32 bit word 26 | * \ingroup pico_bit_ops 27 | * 28 | * \param bits 32 bit input 29 | * \return the 32 input bits reversed 30 | */ 31 | uint32_t __rev(uint32_t bits); 32 | 33 | /*! \brief Reverse the bits in a 64 bit double word 34 | * \ingroup pico_bit_ops 35 | * 36 | * \param bits 64 bit input 37 | * \return the 64 input bits reversed 38 | */ 39 | uint64_t __revll(uint64_t bits); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/common/pico_divider_headers/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "pico_divider_headers", 5 | hdrs = ["include/pico/divider.h"], 6 | includes = ["include"], 7 | deps = [ 8 | "//src/common/pico_base_headers", 9 | ], 10 | ) 11 | -------------------------------------------------------------------------------- /src/common/pico_divider_headers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_divider_headers) 2 | add_library(pico_divider_headers INTERFACE) 3 | target_include_directories(pico_divider_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 4 | target_link_libraries(pico_divider_headers INTERFACE pico_base_headers hardware_divider_headers) 5 | endif() -------------------------------------------------------------------------------- /src/common/pico_stdlib_headers/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | # Use //host/pico_stdlib or //rp2_common/pico_stdlib to get the 4 | # implementation of this header, along with other critical defines headers. 5 | cc_library( 6 | name = "pico_stdlib_headers", 7 | hdrs = ["include/pico/stdlib.h"], 8 | includes = ["include"], 9 | visibility = [ 10 | "//src/host/pico_stdio:__pkg__", 11 | "//src/host/pico_stdlib:__pkg__", 12 | "//src/rp2_common/pico_stdio:__pkg__", 13 | "//src/rp2_common/pico_stdlib:__pkg__", 14 | "//src/rp2_common/tinyusb:__pkg__", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /src/common/pico_stdlib_headers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_stdlib_headers) 2 | add_library(pico_stdlib_headers INTERFACE) 3 | target_include_directories(pico_stdlib_headers SYSTEM INTERFACE include) 4 | # dependencies handled in implementation CMakeLists.txt 5 | endif() 6 | -------------------------------------------------------------------------------- /src/common/pico_sync/critical_section.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico/critical_section.h" 8 | 9 | #if PICO_32BIT 10 | static_assert(sizeof(critical_section_t) == 8, ""); 11 | #endif 12 | 13 | void critical_section_init(critical_section_t *crit_sec) { 14 | critical_section_init_with_lock_num(crit_sec, (uint)spin_lock_claim_unused(true)); 15 | } 16 | 17 | void critical_section_init_with_lock_num(critical_section_t *crit_sec, uint lock_num) { 18 | crit_sec->spin_lock = spin_lock_instance(lock_num); 19 | __mem_fence_release(); 20 | } 21 | 22 | void critical_section_deinit(critical_section_t *crit_sec) { 23 | spin_lock_unclaim(spin_lock_get_num(crit_sec->spin_lock)); 24 | crit_sec->spin_lock = NULL; 25 | } -------------------------------------------------------------------------------- /src/common/pico_sync/include/pico/sync.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_SYNC_H 8 | #define _PICO_SYNC_H 9 | 10 | /** \file pico/sync.h 11 | * \defgroup pico_sync pico_sync 12 | * \brief Synchronization primitives and mutual exclusion 13 | */ 14 | 15 | #include "pico/sem.h" 16 | #include "pico/mutex.h" 17 | #include "pico/critical_section.h" 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/common/pico_sync/lock_core.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico/lock_core.h" 8 | 9 | void lock_init(lock_core_t *core, uint lock_num) { 10 | valid_params_if(LOCK_CORE, lock_num < NUM_SPIN_LOCKS); 11 | core->spin_lock = spin_lock_instance(lock_num); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/common/pico_time/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_time_headers) 2 | add_library(pico_time_headers INTERFACE) 3 | target_include_directories(pico_time_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 4 | target_link_libraries(pico_time_headers INTERFACE hardware_timer_headers pico_sync_headers pico_util_headers) 5 | endif() 6 | 7 | if (NOT TARGET pico_time) 8 | pico_add_impl_library(pico_time) 9 | 10 | target_sources(pico_time INTERFACE 11 | ${CMAKE_CURRENT_LIST_DIR}/time.c 12 | ${CMAKE_CURRENT_LIST_DIR}/timeout_helper.c) 13 | target_link_libraries(pico_time INTERFACE hardware_timer pico_sync pico_util) 14 | endif() 15 | -------------------------------------------------------------------------------- /src/common/pico_time/include/pico/timeout_helper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_TIMEOUT_HELPER_H 8 | #define _PICO_TIMEOUT_HELPER_H 9 | 10 | #include "pico/time.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | typedef struct timeout_state { 17 | absolute_time_t next_timeout; 18 | uint64_t param; 19 | } timeout_state_t; 20 | 21 | typedef bool (*check_timeout_fn)(timeout_state_t *ts, bool reset); 22 | 23 | check_timeout_fn init_single_timeout_until(timeout_state_t *ts, absolute_time_t target); 24 | check_timeout_fn init_per_iteration_timeout_us(timeout_state_t *ts, uint64_t per_iteration_timeout_us); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif -------------------------------------------------------------------------------- /src/common/pico_time/timeout_helper.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico/timeout_helper.h" 8 | 9 | static bool check_single_timeout_us(timeout_state_t *ts, __unused bool reset) { 10 | return time_reached(ts->next_timeout); 11 | } 12 | 13 | check_timeout_fn init_single_timeout_until(timeout_state_t *ts, absolute_time_t target) { 14 | ts->next_timeout = target; 15 | return check_single_timeout_us; 16 | } 17 | 18 | static bool check_per_iteration_timeout_us(timeout_state_t *ts, bool reset) { 19 | if (reset) { 20 | ts->next_timeout = make_timeout_time_us(ts->param); 21 | } 22 | if (time_reached(ts->next_timeout)) { 23 | return true; 24 | } 25 | return false; 26 | } 27 | 28 | check_timeout_fn init_per_iteration_timeout_us(timeout_state_t *ts, uint64_t per_iteration_timeout_us) { 29 | ts->next_timeout = make_timeout_time_us(per_iteration_timeout_us); 30 | ts->param = per_iteration_timeout_us; 31 | return check_per_iteration_timeout_us; 32 | } -------------------------------------------------------------------------------- /src/common/pico_usb_reset_interface_headers/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "pico_usb_reset_interface_headers", 5 | hdrs = ["include/pico/usb_reset_interface.h"], 6 | includes = ["include"], 7 | ) 8 | -------------------------------------------------------------------------------- /src/common/pico_usb_reset_interface_headers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # don't use pico_add_library here as picotool includes it directly 2 | add_library(pico_usb_reset_interface_headers INTERFACE) 3 | add_library(pico_usb_reset_interface INTERFACE) 4 | target_link_libraries(pico_usb_reset_interface INTERFACE pico_usb_reset_interface_headers) 5 | 6 | target_include_directories(pico_usb_reset_interface_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 7 | -------------------------------------------------------------------------------- /src/common/pico_usb_reset_interface_headers/include/pico/usb_reset_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_USB_RESET_INTERFACE_H 8 | #define _PICO_USB_RESET_INTERFACE_H 9 | 10 | /** \file usb_reset_interface.h 11 | * \defgroup pico_usb_reset_interface_headers pico_usb_reset_interface_headers 12 | * 13 | * \brief Definition for the reset interface that may be exposed by the pico_stdio_usb library 14 | */ 15 | 16 | // VENDOR sub-class for the reset interface 17 | #define RESET_INTERFACE_SUBCLASS 0x00 18 | // VENDOR protocol for the reset interface 19 | #define RESET_INTERFACE_PROTOCOL 0x01 20 | 21 | // CONTROL requests: 22 | 23 | // reset to BOOTSEL 24 | #define RESET_REQUEST_BOOTSEL 0x01 25 | // regular flash boot 26 | #define RESET_REQUEST_FLASH 0x02 27 | 28 | #endif -------------------------------------------------------------------------------- /src/common/pico_util/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@pico-sdk//bazel:defs.bzl", "incompatible_with_config") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_util", 7 | srcs = [ 8 | "datetime.c", 9 | "pheap.c", 10 | "queue.c", 11 | ], 12 | hdrs = [ 13 | "include/pico/util/datetime.h", 14 | "include/pico/util/pheap.h", 15 | "include/pico/util/queue.h", 16 | ], 17 | includes = ["include"], 18 | # invalid_params_if() uses Statement Expressions, which aren't supported in MSVC. 19 | target_compatible_with = incompatible_with_config("@rules_cc//cc/compiler:msvc-cl"), 20 | deps = [ 21 | "//src/common/pico_base_headers", 22 | "//src/common/pico_sync", 23 | ] + select({ 24 | "//bazel/constraint:host": [ 25 | "//src/host/hardware_sync", 26 | ], 27 | "//conditions:default": [ 28 | "//src/rp2_common/hardware_sync", 29 | ], 30 | }), 31 | ) 32 | -------------------------------------------------------------------------------- /src/common/pico_util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_util_headers) 2 | add_library(pico_util_headers INTERFACE) 3 | target_include_directories(pico_util_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 4 | target_link_libraries(pico_util_headers INTERFACE pico_base_headers hardware_sync_headers) 5 | endif() 6 | 7 | if (NOT TARGET pico_util) 8 | pico_add_impl_library(pico_util) 9 | target_sources(pico_util INTERFACE 10 | ${CMAKE_CURRENT_LIST_DIR}/datetime.c 11 | ${CMAKE_CURRENT_LIST_DIR}/pheap.c 12 | ${CMAKE_CURRENT_LIST_DIR}/queue.c 13 | ) 14 | pico_mirrored_target_link_libraries(pico_util INTERFACE pico_sync) 15 | endif() 16 | -------------------------------------------------------------------------------- /src/common/pico_util/doc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup pico_util pico_util 3 | * \brief Useful data structures and utility functions 4 | */ 5 | -------------------------------------------------------------------------------- /src/host/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | # This is currently unused in Bazel. 4 | cc_binary( 5 | name = "boot_stage2", 6 | srcs = ["boot_stage2.c"], 7 | target_compatible_with = ["//bazel/constraint:host"], 8 | ) 9 | -------------------------------------------------------------------------------- /src/host/README.md: -------------------------------------------------------------------------------- 1 | This is a basic set of replacement library implementations sufficient to get simple applications 2 | running on your computer (Raspberry Pi OS, Linux, macOS or Windows using Cygwin or Windows Subsystem for Linux). 3 | It is selected by `PICO_PLATFORM=host` in your CMake build 4 | 5 | This can be extremely useful for testing and debugging higher level application code, or porting code which is not yet small enough 6 | to run on the RP2040 or RP2350 device itself. 7 | 8 | This base level host library provides a minimal environment to compile programs, but is likely sufficient for programs 9 | that don't access hardware directly. 10 | 11 | It is possible however to inject additional SDK library implementations/simulations to provide 12 | more complete functionality. For an example of this see the [pico-host-sdl](https://github.com/raspberrypi/pico-host-sdl) 13 | which uses the SDL2 library to add additional library support for pico_multicore, timers/alarms in pico-time and 14 | pico-audio/pico-scanvideo from [pico-extras](https://github.com/raspberrypi/pico-extras) 15 | -------------------------------------------------------------------------------- /src/host/boot_stage2.c: -------------------------------------------------------------------------------- 1 | int main() { 2 | 3 | } -------------------------------------------------------------------------------- /src/host/hardware_divider/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "hardware_divider", 5 | srcs = ["divider.c"], 6 | hdrs = ["include/hardware/divider.h"], 7 | includes = ["include"], 8 | target_compatible_with = ["//bazel/constraint:host"], 9 | deps = ["//src/host/pico_platform"], 10 | ) 11 | -------------------------------------------------------------------------------- /src/host/hardware_divider/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(divider) -------------------------------------------------------------------------------- /src/host/hardware_divider/divider.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "hardware/divider.h" 8 | 9 | __thread uint64_t hw_divider_result_threadlocal; 10 | -------------------------------------------------------------------------------- /src/host/hardware_gpio/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "hardware_gpio", 5 | srcs = ["gpio.c"], 6 | hdrs = ["include/hardware/gpio.h"], 7 | includes = ["include"], 8 | target_compatible_with = ["//bazel/constraint:host"], 9 | deps = [ 10 | "//src/common/pico_binary_info:LIB_PICO_BINARY_INFO", 11 | "//src/host/pico_platform", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /src/host/hardware_gpio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(gpio) -------------------------------------------------------------------------------- /src/host/hardware_irq/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "hardware_irq", 5 | srcs = ["irq.c"], 6 | hdrs = ["include/hardware/irq.h"], 7 | includes = ["include"], 8 | tags = ["manual"], # TODO: No hardware/regs/intctrl.h for host yet. 9 | target_compatible_with = ["//bazel/constraint:host"], 10 | deps = [ 11 | "//src/host/hardware_claim", 12 | "//src/host/pico_platform", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /src/host/hardware_irq/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(irq) -------------------------------------------------------------------------------- /src/host/hardware_sync/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "hardware_sync_headers", 5 | srcs = ["sync_core0_only.c"], 6 | hdrs = ["include/hardware/sync.h"], 7 | implementation_deps = ["//src/host/pico_platform:platform_defs"], 8 | includes = ["include"], 9 | target_compatible_with = ["//bazel/constraint:host"], 10 | deps = ["//src/common/pico_base_headers"], 11 | ) 12 | 13 | cc_library( 14 | name = "hardware_sync", 15 | srcs = ["sync_core0_only.c"], 16 | hdrs = ["include/hardware/sync.h"], 17 | implementation_deps = ["//src/host/pico_platform:platform_defs"], 18 | includes = ["include"], 19 | target_compatible_with = ["//bazel/constraint:host"], 20 | deps = ["//src/host/pico_platform"], 21 | ) 22 | -------------------------------------------------------------------------------- /src/host/hardware_sync/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_headers_target(sync) 2 | 3 | if (NOT TARGET hardware_sync) 4 | add_library(hardware_sync INTERFACE) 5 | 6 | target_sources(hardware_sync INTERFACE 7 | ${CMAKE_CURRENT_LIST_DIR}/sync_core0_only.c 8 | ) 9 | 10 | pico_mirrored_target_link_libraries(hardware_sync INTERFACE pico_platform) 11 | endif() 12 | 13 | -------------------------------------------------------------------------------- /src/host/hardware_timer/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | _DEFINES = [ 4 | "PICO_HARDWARE_TIMER_RESOLUTION_US=1000", 5 | # TODO: This seems to be the default, make configurable eventually. 6 | "PICO_TIME_DEFAULT_ALARM_POOL_DISABLED=1", 7 | ] 8 | 9 | # This exists to break a dependency cycle between 10 | # this library and //src/common/pico_time. 11 | # Application code should always use :hardware_timer instead. 12 | cc_library( 13 | name = "hardware_timer_headers", 14 | hdrs = ["include/hardware/timer.h"], 15 | defines = _DEFINES, 16 | includes = ["include"], 17 | target_compatible_with = ["//bazel/constraint:host"], 18 | visibility = [ 19 | "//src/common/pico_time:__pkg__", 20 | "//src/host/pico_platform:__pkg__", 21 | ], 22 | deps = ["//src/common/pico_base_headers"], 23 | ) 24 | 25 | cc_library( 26 | name = "hardware_timer", 27 | srcs = ["timer.c"], 28 | hdrs = ["include/hardware/timer.h"], 29 | defines = _DEFINES, 30 | includes = ["include"], 31 | target_compatible_with = ["//bazel/constraint:host"], 32 | deps = ["//src/host/pico_platform"], 33 | ) 34 | -------------------------------------------------------------------------------- /src/host/hardware_timer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(timer) 2 | 3 | target_compile_definitions(hardware_timer_headers INTERFACE 4 | PICO_HARDWARE_TIMER_RESOLUTION_US=1000 # to loosen tests a little 5 | ) 6 | 7 | if (NOT DEFINED PICO_TIME_NO_ALARM_SUPPORT) 8 | # we don't have alarm pools in the basic host support, though pico_host_sdl adds it 9 | set(PICO_TIME_NO_ALARM_SUPPORT "1" CACHE INTERNAL "") 10 | endif() 11 | 12 | if (PICO_TIME_NO_ALARM_SUPPORT) 13 | target_compile_definitions(hardware_timer INTERFACE 14 | PICO_TIME_DEFAULT_ALARM_POOL_DISABLED=1 15 | ) 16 | endif() -------------------------------------------------------------------------------- /src/host/hardware_uart/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "hardware_uart", 5 | srcs = ["uart.c"], 6 | hdrs = ["include/hardware/uart.h"], 7 | includes = ["include"], 8 | target_compatible_with = ["//bazel/constraint:host"], 9 | deps = ["//src/host/pico_platform"], 10 | ) 11 | -------------------------------------------------------------------------------- /src/host/hardware_uart/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(uart) -------------------------------------------------------------------------------- /src/host/pico_bit_ops/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "pico_bit_ops", 5 | srcs = ["bit_ops.c"], 6 | target_compatible_with = ["//bazel/constraint:host"], 7 | deps = ["//src/common/pico_bit_ops_headers:pico_bit_ops_interface"], 8 | ) 9 | -------------------------------------------------------------------------------- /src/host/pico_bit_ops/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_impl_library(pico_bit_ops) 2 | 3 | target_sources(pico_bit_ops INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/bit_ops.c) 5 | 6 | target_link_libraries(pico_bit_ops INTERFACE pico_bit_ops_headers) 7 | 8 | macro(pico_set_bit_ops_implementation TARGET IMPL) 9 | endmacro() -------------------------------------------------------------------------------- /src/host/pico_bit_ops/bit_ops.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico/bit_ops.h" 8 | 9 | uint32_t __rev(uint32_t v) { 10 | v = ((v & 0x55555555u) << 1u) | ((v >> 1u) & 0x55555555u); 11 | v = ((v & 0x33333333u) << 2u) | ((v >> 2u) & 0x33333333u); 12 | v = ((v & 0x0f0f0f0fu) << 4u) | ((v >> 4u) & 0x0f0f0f0fu); 13 | return (v << 24u) | ((v & 0xff00u) << 8u) | ((v >> 8u) & 0xff00u) | (v >> 24u); 14 | } 15 | 16 | uint64_t __revll(uint64_t v) { 17 | v = ((v & 0x5555555555555555u) << 1u) | ((v >> 1u) & 0x5555555555555555u); 18 | v = ((v & 0x3333333333333333u) << 2u) | ((v >> 2u) & 0x3333333333333333u); 19 | v = ((v & 0x0f0f0f0f0f0f0f0fu) << 4u) | ((v >> 4u) & 0x0f0f0f0f0f0f0f0fu); 20 | v = ((v & 0x00ff00ff00ff00ffu) << 8u) | ((v >> 8u) & 0x00ff00ff00ff00ffu); 21 | return (v << 48u) | ((v & 0xffff0000u) << 16u) | ((v >> 16u) & 0xffff0000u) | (v >> 48u); 22 | } 23 | -------------------------------------------------------------------------------- /src/host/pico_divider/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "pico_divider", 5 | srcs = ["divider.c"], 6 | target_compatible_with = ["//bazel/constraint:host"], 7 | deps = [ 8 | "//src/common/pico_divider_headers", 9 | "//src/host/hardware_divider", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /src/host/pico_divider/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_impl_library(pico_divider) 2 | 3 | target_sources(pico_divider INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/divider.c) 5 | 6 | pico_mirrored_target_link_libraries(pico_divider INTERFACE hardware_divider) 7 | 8 | macro(pico_set_divider_implementation TARGET IMPL) 9 | endmacro() -------------------------------------------------------------------------------- /src/host/pico_multicore/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "pico_multicore", 5 | hdrs = ["include/pico/multicore.h"], 6 | includes = ["include"], 7 | target_compatible_with = ["//bazel/constraint:host"], 8 | deps = ["//src/host/pico_platform"], 9 | ) 10 | -------------------------------------------------------------------------------- /src/host/pico_multicore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_multicore) 2 | pico_add_library(pico_multicore) 3 | 4 | target_include_directories(pico_multicore_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 5 | 6 | pico_mirrored_target_link_libraries(pico_multicore INTERFACE pico_base) 7 | endif() 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/host/pico_platform/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "platform_defs", 5 | hdrs = [ 6 | "include/hardware/platform_defs.h", 7 | ], 8 | includes = ["include"], 9 | target_compatible_with = ["//bazel/constraint:host"], 10 | ) 11 | 12 | # Resolves circular dependencies. 13 | cc_library( 14 | name = "pico_platform_internal", 15 | hdrs = [ 16 | "include/pico/platform.h", 17 | ], 18 | includes = ["include"], 19 | visibility = ["//src:__pkg__"], 20 | deps = [ 21 | ":platform_defs", 22 | ], 23 | ) 24 | 25 | cc_library( 26 | name = "pico_platform", 27 | srcs = ["platform_base.c"], 28 | target_compatible_with = ["//bazel/constraint:host"], 29 | deps = [ 30 | ":pico_platform_internal", 31 | ":platform_defs", 32 | "//src/common/pico_base_headers", 33 | "//src/host/hardware_timer:hardware_timer_headers", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /src/host/pico_platform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file may be included directly by a build to get common SDK macros and types 2 | 3 | if (NOT TARGET pico_platform_headers) 4 | add_library(pico_platform_headers INTERFACE) 5 | 6 | target_compile_definitions(pico_platform_headers INTERFACE 7 | PICO_NO_HARDWARE=1 8 | PICO_ON_DEVICE=0 9 | PICO_BUILD=1 10 | ) 11 | 12 | target_include_directories(pico_platform_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 13 | endif() 14 | 15 | if (NOT TARGET pico_platform) 16 | if (COMMAND pico_add_platform_library) 17 | pico_add_platform_library(pico_platform) 18 | else() 19 | add_library(pico_platform INTERFACE) 20 | endif() 21 | 22 | target_sources(pico_platform INTERFACE 23 | ${CMAKE_CURRENT_LIST_DIR}/platform_base.c 24 | ) 25 | 26 | target_link_libraries(pico_platform INTERFACE pico_platform_headers pico_bit_ops ${PICO_PLATFORM_EXTRA_LIBRARIES}) 27 | endif() 28 | 29 | function(pico_add_platform_library TARGET) 30 | target_link_libraries(pico_platform INTERFACE ${TARGET}) 31 | endfunction() 32 | -------------------------------------------------------------------------------- /src/host/pico_platform/include/hardware/platform_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _HARDWARE_PLATFORM_DEFS_H 8 | #define _HARDWARE_PLATFORM_DEFS_H 9 | 10 | #define NUM_CORES 2u 11 | 12 | #define NUM_DMA_CHANNELS 12u 13 | 14 | #define NUM_GENERIC_TIMERS 1u 15 | #define NUM_ALARMS 4u 16 | 17 | #define NUM_IRQS 32u 18 | 19 | #define NUM_SPIN_LOCKS 32u 20 | 21 | #define XOSC_HZ 12000000u 22 | 23 | #define NUM_SPIN_LOCKS 32u 24 | 25 | #define NUM_BANK0_GPIOS 30 26 | 27 | #ifndef _u 28 | #define _u(x) x ## u 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/host/pico_platform/platform_base.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | #include 7 | #include 8 | 9 | #include "pico.h" 10 | #include "hardware/timer.h" 11 | 12 | PICO_WEAK_FUNCTION_DEF(tight_loop_contents) 13 | void PICO_WEAK_FUNCTION_IMPL_NAME(tight_loop_contents)() { 14 | 15 | } 16 | 17 | 18 | PICO_WEAK_FUNCTION_DEF(get_core_num) 19 | uint PICO_WEAK_FUNCTION_IMPL_NAME(get_core_num)() { 20 | return 0; 21 | } 22 | 23 | void __noreturn panic_unsupported() { 24 | panic("not supported"); 25 | } 26 | 27 | void panic(const char *fmt, ...) { 28 | va_list args; 29 | 30 | puts("*** PANIC ***\n"); 31 | if (fmt) { 32 | va_start(args, fmt); 33 | vprintf(fmt, args); 34 | va_end(args); 35 | } 36 | 37 | puts("\n"); 38 | 39 | __breakpoint(); 40 | } 41 | 42 | void __breakpoint() { 43 | #ifdef _MSC_VER 44 | __debugbreak(); 45 | #else 46 | __builtin_trap(); 47 | #endif 48 | } 49 | 50 | PICO_WEAK_FUNCTION_DEF(busy_wait_at_least_cycles) 51 | void PICO_WEAK_FUNCTION_IMPL_NAME(busy_wait_at_least_cycles)(uint32_t cycles) { 52 | // fairly arbitrary; we'll use 125Mhz as a reference 53 | busy_wait_us((cycles + 124)/125); 54 | } 55 | -------------------------------------------------------------------------------- /src/host/pico_printf/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "pico_printf", 5 | target_compatible_with = ["//bazel/constraint:host"], 6 | ) 7 | -------------------------------------------------------------------------------- /src/host/pico_printf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_printf) 2 | pico_add_library(pico_printf) 3 | function(pico_set_printf_implementation) 4 | endfunction() 5 | endif() 6 | 7 | -------------------------------------------------------------------------------- /src/host/pico_runtime/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "pico_runtime", 5 | srcs = ["runtime.c"], 6 | hdrs = [ 7 | "include/pico/runtime.h", 8 | "include/pico/runtime_init.h", 9 | ], 10 | copts = select({ 11 | "@platforms//os:windows": [], # TODO: MSVC flags. 12 | "//conditions:default": ["-Wno-ignored-attributes"], 13 | }), 14 | includes = ["include"], 15 | target_compatible_with = ["//bazel/constraint:host"], 16 | deps = ["//src/host/pico_platform"], 17 | ) 18 | -------------------------------------------------------------------------------- /src/host/pico_runtime/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_runtime) 2 | 3 | target_include_directories(pico_runtime_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 4 | 5 | pico_mirrored_target_link_libraries(pico_runtime INTERFACE 6 | pico_base 7 | ) 8 | 9 | function(pico_minimize_runtime TARGET) 10 | endfunction() -------------------------------------------------------------------------------- /src/host/pico_runtime/runtime.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico/runtime.h" 8 | 9 | void __weak hard_assertion_failure(void) { 10 | panic("Hard assert"); 11 | } 12 | -------------------------------------------------------------------------------- /src/host/pico_stdio/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "pico_stdio_headers", 5 | hdrs = ["include/pico/stdio.h"], 6 | defines = ["LIB_PICO_STDIO=1"], 7 | includes = ["include"], 8 | target_compatible_with = ["//bazel/constraint:host"], 9 | visibility = [ 10 | "//src/host/pico_stdlib:__pkg__", 11 | ], 12 | ) 13 | 14 | cc_library( 15 | name = "pico_stdio", 16 | srcs = ["stdio.c"], 17 | implementation_deps = [ 18 | "//src/host/hardware_uart", 19 | ], 20 | target_compatible_with = ["//bazel/constraint:host"], 21 | deps = [ 22 | ":pico_stdio_headers", 23 | "//src/common/pico_stdlib_headers", 24 | "//src/common/pico_time", 25 | "//src/host/hardware_gpio", 26 | "//src/host/hardware_uart", 27 | "//src/host/pico_platform", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /src/host/pico_stdio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_stdio) 2 | pico_add_library(pico_stdio) 3 | 4 | target_include_directories(pico_stdio_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 5 | 6 | target_sources(pico_stdio INTERFACE 7 | ${CMAKE_CURRENT_LIST_DIR}/stdio.c 8 | ) 9 | pico_add_library(pico_stdio_usb) 10 | pico_add_library(pico_stdio_uart) 11 | pico_add_library(pico_stdio_semihosting) 12 | 13 | function(pico_enable_stdio_uart) 14 | endfunction() 15 | function(pico_enable_stdio_usb) 16 | endfunction() 17 | function(pico_enable_stdio_semihosting) 18 | endfunction() 19 | function(pico_enable_stdio_rtt) 20 | endfunction() 21 | endif() 22 | 23 | -------------------------------------------------------------------------------- /src/host/pico_stdio/include/pico/stdio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | #ifndef _PICO_STDIO_H 7 | #define _PICO_STDIO_H 8 | 9 | typedef struct stdio_driver stdio_driver_t; 10 | 11 | #define STDIO_ERROR -1 12 | #define STDIO_NO_INPUT -2 13 | 14 | static inline void stdio_usb_init() {} 15 | void stdio_uart_init(); 16 | static inline void stdio_init_all() { stdio_uart_init(); } 17 | static inline void stdio_filter_driver(stdio_driver_t *driver) {} 18 | static inline void stdio_set_translate_crlf(stdio_driver_t *driver, bool enabled) {} 19 | static inline bool stdio_usb_connected(void) { return true; } 20 | int getchar_timeout_us(uint32_t timeout_us); 21 | #define puts_raw puts 22 | #define putchar_raw putchar 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/host/pico_stdio/stdio.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 | #include "hardware/uart.h" 9 | 10 | int getchar_timeout_us(uint32_t timeout_us) { 11 | absolute_time_t t = make_timeout_time_us(timeout_us); 12 | while (!uart_is_readable(uart_default)) { 13 | if (absolute_time_diff_us(t, get_absolute_time()) > 0) { 14 | return STDIO_NO_INPUT; 15 | } 16 | sleep_ms(1); 17 | } 18 | return uart_getc(uart_default); 19 | } 20 | 21 | void stdio_uart_init() { 22 | uart_init(uart_default, 0); 23 | } -------------------------------------------------------------------------------- /src/host/pico_stdlib/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "pico_stdlib", 5 | srcs = ["stdlib.c"], 6 | target_compatible_with = ["//bazel/constraint:host"], 7 | deps = [ 8 | "//src/common/pico_time", 9 | "//src/host/hardware_gpio", 10 | "//src/host/hardware_uart", 11 | "//src/host/pico_platform", 12 | "//src/host/pico_stdio", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /src/host/pico_stdlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_stdlib) 2 | pico_add_impl_library(pico_stdlib) 3 | 4 | target_sources(pico_stdlib INTERFACE 5 | ${CMAKE_CURRENT_LIST_DIR}/stdlib.c 6 | ) 7 | 8 | target_link_libraries(pico_stdlib INTERFACE 9 | pico_stdlib_headers 10 | pico_platform 11 | pico_time 12 | pico_divider 13 | pico_binary_info 14 | pico_printf 15 | pico_runtime 16 | pico_stdio 17 | hardware_gpio 18 | hardware_uart 19 | ) 20 | endif() 21 | 22 | -------------------------------------------------------------------------------- /src/host/pico_stdlib/stdlib.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 | void setup_default_uart() { 10 | 11 | } 12 | 13 | void set_sys_clock_48mhz() { 14 | 15 | } 16 | 17 | bool check_sys_clock_khz(uint32_t freq_khz, uint *vco_out, uint *postdiv1_out, uint *postdiv2_out) { 18 | *vco_out = 1000000; 19 | *postdiv1_out = 0; 20 | *postdiv2_out = 0; 21 | return true; 22 | } 23 | 24 | void set_sys_clock_pll(__unused uint32_t vco_freq, __unused uint post_div1, __unused uint post_div2) { 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /src/host/pico_time_adapter/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "pico_time_adapter", 5 | srcs = ["time_adapter.c"], 6 | hdrs = ["include/pico/time_adapter.h"], 7 | includes = ["include"], 8 | target_compatible_with = ["//bazel/constraint:host"], 9 | deps = [ 10 | "//src/common/pico_time:pico_time_headers", 11 | "//src/host/pico_platform", 12 | ], 13 | alwayslink = True, 14 | ) 15 | -------------------------------------------------------------------------------- /src/host/pico_time_adapter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_time_adapter) 2 | 3 | target_sources(pico_time_adapter INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/time_adapter.c 5 | ) 6 | 7 | target_include_directories(pico_time_adapter_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 8 | 9 | pico_mirrored_target_link_libraries(pico_time INTERFACE pico_time_adapter) -------------------------------------------------------------------------------- /src/rp2040.cmake: -------------------------------------------------------------------------------- 1 | # include everything needed to build against rp2040 2 | 3 | set(RP2_VARIANT_DIR ${CMAKE_CURRENT_LIST_DIR}/rp2040) 4 | set(PICO_RP2040 "1" CACHE INTERNAL "") 5 | set(PICO_RP2350 "0" CACHE INTERNAL "") 6 | set(PICO_32BIT "1" CACHE INTERNAL "") 7 | set(PICO_RISCV "0" CACHE INTERNAL "") 8 | set(PICO_ARM "1" CACHE INTERNAL "") 9 | set(PICO_CMSIS_DEVICE "RP2040" CACHE INTERNAL "") 10 | set(PICO_DEFAULT_FLASH_SIZE_BYTES "2 * 1024 * 1024") 11 | 12 | pico_add_doxygen_pre_define("PICO_RP2040=1") 13 | pico_add_doxygen_pre_define("PICO_RP2350=0") 14 | #pico_add_doxygen_pre_define("NUM_DOORBELLS=0") # we have functions that are gated by this 15 | pico_add_doxygen_enabled_section(rp2040_specific) 16 | 17 | include(cmake/rp2_common.cmake) 18 | 19 | -------------------------------------------------------------------------------- /src/rp2040/README.md: -------------------------------------------------------------------------------- 1 | This directory contains files specific to the RP2040 hardware. It is only used when building for the RP2040 platforms i.e. `PICO_PLATFORM=rp2040` 2 | 3 | `hardware_regs` contains low level hardware register #defines autogenerated from the RP2040 chip definition itself. 4 | 5 | `hardware_structs` contains C structures for accessing memory mapped registers 6 | 7 | -------------------------------------------------------------------------------- /src/rp2040/boot_stage2/asminclude/boot2_helpers/exit_from_boot2.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _BOOT2_HELPER_EXIT_FROM_BOOT2 8 | #define _BOOT2_HELPER_EXIT_FROM_BOOT2 9 | 10 | #include "hardware/regs/m0plus.h" 11 | 12 | // If entered from the bootrom, lr (which we earlier pushed) will be 0, 13 | // and we vector through the table at the start of the main flash image. 14 | // Any regular function call will have a nonzero value for lr. 15 | check_return: 16 | pop {r0} 17 | cmp r0, #0 18 | beq vector_into_flash 19 | bx r0 20 | vector_into_flash: 21 | ldr r0, =(XIP_BASE + 0x100) 22 | ldr r1, =(PPB_BASE + M0PLUS_VTOR_OFFSET) 23 | str r0, [r1] 24 | ldmia r0, {r0, r1} 25 | msr msp, r0 26 | bx r1 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/rp2040/boot_stage2/asminclude/boot2_helpers/read_flash_sreg.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _BOOT2_HELPER_READ_FLASH_SREG 8 | #define _BOOT2_HELPER_READ_FLASH_SREG 9 | 10 | #include "boot2_helpers/wait_ssi_ready.S" 11 | 12 | // Pass status read cmd into r0. 13 | // Returns status value in r0. 14 | .global read_flash_sreg 15 | .type read_flash_sreg,%function 16 | .thumb_func 17 | read_flash_sreg: 18 | push {r1, lr} 19 | str r0, [r3, #SSI_DR0_OFFSET] 20 | // Dummy byte: 21 | str r0, [r3, #SSI_DR0_OFFSET] 22 | 23 | bl wait_ssi_ready 24 | // Discard first byte and combine the next two 25 | ldr r0, [r3, #SSI_DR0_OFFSET] 26 | ldr r0, [r3, #SSI_DR0_OFFSET] 27 | 28 | pop {r1, pc} 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/rp2040/boot_stage2/asminclude/boot2_helpers/wait_ssi_ready.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _BOOT2_HELPER_WAIT_SSI_READY 8 | #define _BOOT2_HELPER_WAIT_SSI_READY 9 | 10 | wait_ssi_ready: 11 | push {r0, r1, lr} 12 | 13 | // Command is complete when there is nothing left to send 14 | // (TX FIFO empty) and SSI is no longer busy (CSn deasserted) 15 | 1: 16 | ldr r1, [r3, #SSI_SR_OFFSET] 17 | movs r0, #SSI_SR_TFE_BITS 18 | tst r1, r0 19 | beq 1b 20 | movs r0, #SSI_SR_BUSY_BITS 21 | tst r1, r0 22 | bne 1b 23 | 24 | pop {r0, r1, pc} 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/rp2040/boot_stage2/boot_stage2.ld: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | /* We are loaded to the top 256 bytes of SRAM, which is above the bootrom 3 | stack. Note 4 bytes occupied by checksum. */ 4 | SRAM(rx) : ORIGIN = 0x20041f00, LENGTH = 252 5 | } 6 | 7 | SECTIONS { 8 | . = ORIGIN(SRAM); 9 | .text : { 10 | _start = .; /* make LLVM happy */ 11 | *(.entry) 12 | *(.text) 13 | } >SRAM 14 | } 15 | -------------------------------------------------------------------------------- /src/rp2040/boot_stage2/compile_time_choice.S: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // Second stage boot code 3 | // Copyright (c) 2019-2021 Raspberry Pi (Trading) Ltd. 4 | // SPDX-License-Identifier: BSD-3-Clause 5 | // ---------------------------------------------------------------------------- 6 | // 7 | // This implementation uses the PICO_BOOT_STAGE2_CHOOSE_ preprocessor defines to pick 8 | // amongst a menu of known boot stage 2 implementations, allowing the board 9 | // configuration header to be able to specify the boot stage 2 10 | 11 | #include "boot_stage2/config.h" 12 | 13 | #ifdef PICO_BUILD_BOOT_STAGE2_NAME 14 | // boot stage 2 is configured by cmake, so use the name specified there 15 | #error PICO_BUILD_BOOT_STAGE2_NAME should not be defined for compile_time_choice builds 16 | #else 17 | // boot stage 2 is selected by board config header, and PICO_BOOT_STAGE2_ASM is set in boot_stage2/config.h 18 | #include PICO_BOOT_STAGE2_ASM 19 | #endif 20 | -------------------------------------------------------------------------------- /src/rp2040/boot_stage2/doc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup boot_stage2 boot_stage2 3 | * \brief Second stage boot loaders responsible for setting up external flash 4 | */ 5 | -------------------------------------------------------------------------------- /src/rp2040/hardware_regs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(hardware_regs INTERFACE) 2 | add_library(hardware_regs_headers INTERFACE) 3 | target_include_directories(hardware_regs_headers SYSTEM INTERFACE include) 4 | pico_mirrored_target_link_libraries(hardware_regs INTERFACE hardware_base) 5 | -------------------------------------------------------------------------------- /src/rp2040/hardware_structs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(hardware_structs INTERFACE) 2 | add_library(hardware_structs_headers INTERFACE) 3 | target_include_directories(hardware_structs_headers SYSTEM INTERFACE include) 4 | pico_mirrored_target_link_libraries(hardware_structs INTERFACE hardware_regs) 5 | -------------------------------------------------------------------------------- /src/rp2040/hardware_structs/include/hardware/structs/bus_ctrl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024 Raspberry Pi Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // Support old header for compatibility (and if included, support old variable name) 8 | #include "hardware/structs/busctrl.h" 9 | #define bus_ctrl_hw busctrl_hw -------------------------------------------------------------------------------- /src/rp2040/hardware_structs/include/hardware/structs/iobank0.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024 Raspberry Pi Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // Support old header for compatibility (and if included, support old variable name) 8 | #include "hardware/structs/io_bank0.h" 9 | #define iobank0_hw io_bank0_hw -------------------------------------------------------------------------------- /src/rp2040/hardware_structs/include/hardware/structs/ioqspi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024 Raspberry Pi Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // Support old header for compatibility (and if included, support old variable name) 8 | #include "hardware/structs/io_qspi.h" 9 | #define ioqspi_hw io_qspi_hw -------------------------------------------------------------------------------- /src/rp2040/hardware_structs/include/hardware/structs/padsbank0.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024 Raspberry Pi Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // Support old header for compatibility (and if included, support old variable name) 8 | #include "hardware/structs/pads_bank0.h" 9 | #define padsbank0_hw pads_bank0_hw -------------------------------------------------------------------------------- /src/rp2040/hardware_structs/include/hardware/structs/xip_ctrl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // Support old header for compatibility (and if included, support old variable name) 8 | #include "hardware/structs/xip.h" 9 | #define XIP_STAT_FIFO_FULL XIP_STAT_FIFO_FULL_BITS 10 | #define XIP_STAT_FIFO_EMPTY XIP_STAT_FIFO_EMPTY_BITS 11 | #define XIP_STAT_FLUSH_RDY XIP_STAT_FLUSH_READY_BITS 12 | -------------------------------------------------------------------------------- /src/rp2040/pico_platform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_platform) 2 | pico_add_library(pico_platform) 3 | 4 | target_sources(pico_platform INTERFACE 5 | ${CMAKE_CURRENT_LIST_DIR}/platform.c 6 | ) 7 | 8 | target_compile_definitions(pico_platform_headers INTERFACE 9 | PICO_NO_HARDWARE=0 10 | PICO_ON_DEVICE=1 11 | PICO_BUILD=1 12 | PICO_RP2040=1 13 | PICO_32BIT=1 14 | ) 15 | 16 | target_include_directories(pico_platform_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 17 | 18 | target_link_libraries(pico_platform_headers INTERFACE hardware_regs) 19 | pico_mirrored_target_link_libraries(pico_platform INTERFACE 20 | pico_platform_compiler 21 | pico_platform_panic 22 | pico_platform_sections 23 | ) 24 | endif() 25 | 26 | function(pico_add_platform_library TARGET) 27 | target_link_libraries(pico_platform INTERFACE ${TARGET}) 28 | endfunction() -------------------------------------------------------------------------------- /src/rp2040/pico_platform/include/pico/platform/cpu_regs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | /** \file platform.h 8 | * \defgroup pico_platform pico_platform 9 | * 10 | * \brief Macros and definitions for accessing the CPU registers 11 | * 12 | * This header may be included by assembly code 13 | */ 14 | 15 | #ifndef _PICO_PLATFORM_CPU_REGS_H 16 | #define _PICO_PLATFORM_CPU_REGS_H 17 | 18 | #include "hardware/regs/m0plus.h" 19 | #define ARM_CPU_PREFIXED(x) M0PLUS_ ## x 20 | 21 | #ifndef __ASSEMBLER__ 22 | #include "hardware/structs/m0plus.h" 23 | #define arm_cpu_hw m0plus_hw 24 | #include "hardware/structs/nvic.h" 25 | #include "hardware/structs/scb.h" 26 | #endif 27 | 28 | #endif -------------------------------------------------------------------------------- /src/rp2350-arm-s.cmake: -------------------------------------------------------------------------------- 1 | # include everything needed to build against rp2350 2 | 3 | set(PICO_RP2040 "0" CACHE INTERNAL "") 4 | set(PICO_RP2350 "1" CACHE INTERNAL "") 5 | set(PICO_32BIT "1" CACHE INTERNAL "") 6 | set(PICO_RISCV "0" CACHE INTERNAL "") 7 | set(PICO_ARM "1" CACHE INTERNAL "") 8 | set(RP2_VARIANT_DIR ${CMAKE_CURRENT_LIST_DIR}/rp2350) 9 | set(PICO_PIO_VERSION "1" CACHE INTERNAL "") 10 | set(PICO_CMSIS_DEVICE "RP2350" CACHE INTERNAL "") 11 | set(PICO_DEFAULT_FLASH_SIZE_BYTES "4 * 1024 * 1024") 12 | 13 | pico_add_doxygen_pre_define("PICO_RP2040=0") 14 | pico_add_doxygen_pre_define("PICO_RP2350=1") 15 | pico_add_doxygen_pre_define("NUM_DOORBELLS=1") # we have functions that are gated by this 16 | pico_add_doxygen_enabled_section(rp2350_specific) 17 | 18 | # for now we are building RISC-V into RP2350 docs, so document these too 19 | pico_add_doxygen(rp2_common/hardware_riscv) 20 | pico_add_doxygen(rp2_common/hardware_hazard3) 21 | 22 | include(cmake/rp2_common.cmake) 23 | 24 | -------------------------------------------------------------------------------- /src/rp2350-riscv.cmake: -------------------------------------------------------------------------------- 1 | # include everything needed to build against rp2350-riscv 2 | 3 | set(PICO_RP2040 "0" CACHE INTERNAL "") 4 | set(PICO_RP2350 "1" CACHE INTERNAL "") 5 | set(PICO_32BIT "1" CACHE INTERNAL "") 6 | set(PICO_RISCV "1" CACHE INTERNAL "") 7 | set(PICO_ARM "0" CACHE INTERNAL "") 8 | set(RP2_VARIANT_DIR ${CMAKE_CURRENT_LIST_DIR}/rp2350) 9 | set(PICO_PIO_VERSION "1" CACHE INTERNAL "") 10 | set(PICO_DEFAULT_FLASH_SIZE_BYTES "4 * 1024 * 1024") 11 | # for TinyUSB 12 | set(NO_WARN_RWX_SEGMENTS_SUPPORTED "0" CACHE INTERNAL "") 13 | 14 | pico_add_doxygen_pre_define("PICO_RP2040=0") 15 | pico_add_doxygen_pre_define("PICO_RP2350=1") 16 | pico_add_doxygen_enabled_section(rp2350_specific) 17 | 18 | include(cmake/rp2_common.cmake) 19 | 20 | -------------------------------------------------------------------------------- /src/rp2350/README.md: -------------------------------------------------------------------------------- 1 | This directory contains files specific to the RP2350 hardware. It is only used when building for RP2350 platforms, i.e. 2 | `PICO_PLATFORM=rp2350-arm-s` or `PICO_PLATFORM=rp235-riscv` 3 | 4 | `hardware_regs` contains low level hardware register #defines autogenerated from the RP2350 chip definition itself. 5 | 6 | `hardware_structs` contains C structures for accessing memory mapped registers 7 | -------------------------------------------------------------------------------- /src/rp2350/boot_stage2/asminclude/boot2_helpers/exit_from_boot2.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _BOOT2_HELPER_EXIT_FROM_BOOT2 8 | #define _BOOT2_HELPER_EXIT_FROM_BOOT2 9 | 10 | // Always return through saved ra/lr. On RP2350, boot2 is not responsible for entering 11 | // the flash image. It's just a relocatable function that sets up QMI and flash 12 | // for the best possible XIP. 13 | 14 | #ifdef __riscv 15 | jr t0 16 | #else 17 | pop {pc} 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/rp2350/boot_stage2/asminclude/boot2_helpers/read_flash_sreg.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _BOOT2_HELPER_READ_FLASH_SREG 8 | #define _BOOT2_HELPER_READ_FLASH_SREG 9 | 10 | #include "boot2_helpers/wait_qmi_ready.S" 11 | 12 | // Pass status read cmd into r0/a0. 13 | // Returns status value in r0/a0. 14 | 15 | .global read_flash_sreg 16 | .type read_flash_sreg,%function 17 | #ifdef __riscv 18 | read_flash_sreg: 19 | // wait_qmi_ready does not clobber t1, so use this rather than stack. 20 | mv t1, ra 21 | sw a0, QMI_DIRECT_TX_OFFSET(a3) 22 | // Dummy byte: 23 | sw a0, QMI_DIRECT_TX_OFFSET(a3) 24 | 25 | jal wait_qmi_ready 26 | // Discard first byte, return second 27 | lw a0, QMI_DIRECT_RX_OFFSET(a3) 28 | lw a0, QMI_DIRECT_RX_OFFSET(a3) 29 | jr t1 30 | 31 | #else 32 | 33 | .thumb_func 34 | read_flash_sreg: 35 | push {lr} 36 | str r0, [r3, #QMI_DIRECT_TX_OFFSET] 37 | // Dummy byte: 38 | str r0, [r3, #QMI_DIRECT_TX_OFFSET] 39 | 40 | bl wait_qmi_ready 41 | // Discard first byte, return second 42 | ldr r0, [r3, #QMI_DIRECT_RX_OFFSET] 43 | ldr r0, [r3, #QMI_DIRECT_RX_OFFSET] 44 | 45 | pop {pc} 46 | 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/rp2350/boot_stage2/asminclude/boot2_helpers/wait_qmi_ready.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _BOOT2_HELPER_WAIT_SSI_READY 8 | #define _BOOT2_HELPER_WAIT_SSI_READY 9 | 10 | // Wait for QMI direct mode to go idle. Clobbers r0/a0 (Arm/RISC-V) 11 | 12 | #ifdef __riscv 13 | 14 | wait_qmi_ready: 15 | 1: 16 | lw a0, QMI_DIRECT_CSR_OFFSET(a3) 17 | andi a0, a0, QMI_DIRECT_CSR_BUSY_BITS 18 | bnez a0, 1b 19 | 20 | ret 21 | 22 | #else 23 | 24 | wait_qmi_ready: 25 | 1: 26 | ldr r0, [r3, #QMI_DIRECT_CSR_OFFSET] 27 | lsrs r0, r0, #QMI_DIRECT_CSR_BUSY_LSB + 1 28 | bcs 1b 29 | 30 | bx lr 31 | 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/rp2350/boot_stage2/boot_stage2.ld: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | /* We are loaded to the top 256 bytes of SRAM, which is above the bootrom 3 | stack. Note 4 bytes occupied by checksum. */ 4 | SRAM(rx) : ORIGIN = 0x20081f00, LENGTH = 252 5 | } 6 | 7 | SECTIONS { 8 | . = ORIGIN(SRAM); 9 | .text : { 10 | _start = .; /* make LLVM happy */ 11 | *(.entry) 12 | *(.text) 13 | } >SRAM 14 | } 15 | -------------------------------------------------------------------------------- /src/rp2350/boot_stage2/compile_time_choice.S: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // Second stage boot code 3 | // Copyright (c) 2019-2021 Raspberry Pi (Trading) Ltd. 4 | // SPDX-License-Identifier: BSD-3-Clause 5 | // ---------------------------------------------------------------------------- 6 | // 7 | // This implementation uses the PICO_BOOT_STAGE2_CHOOSE_ preprocessor defines to pick 8 | // amongst a menu of known boot stage 2 implementations, allowing the board 9 | // configuration header to be able to specify the boot stage 2 10 | 11 | #include "boot_stage2/config.h" 12 | 13 | #ifdef PICO_BUILD_BOOT_STAGE2_NAME 14 | // boot stage 2 is configured by cmake, so use the name specified there 15 | #error PICO_BUILD_BOOT_STAGE2_NAME should not be defined for compile_time_choice builds 16 | #else 17 | // boot stage 2 is selected by board config header, and PICO_BOOT_STAGE2_ASM is set in boot_stage2/config.h 18 | #include PICO_BOOT_STAGE2_ASM 19 | #endif 20 | -------------------------------------------------------------------------------- /src/rp2350/boot_stage2/doc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup boot_stage2 boot_stage2 3 | * \brief Second stage boot loaders responsible for setting up external flash 4 | */ 5 | -------------------------------------------------------------------------------- /src/rp2350/hardware_regs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(hardware_regs INTERFACE) 2 | add_library(hardware_regs_headers INTERFACE) 3 | target_include_directories(hardware_regs_headers SYSTEM INTERFACE include) 4 | pico_mirrored_target_link_libraries(hardware_regs INTERFACE hardware_base) 5 | -------------------------------------------------------------------------------- /src/rp2350/hardware_structs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(hardware_structs INTERFACE) 2 | add_library(hardware_structs_headers INTERFACE) 3 | target_include_directories(hardware_structs_headers SYSTEM INTERFACE include) 4 | pico_mirrored_target_link_libraries(hardware_structs INTERFACE hardware_regs) 5 | -------------------------------------------------------------------------------- /src/rp2350/hardware_structs/include/hardware/structs/bus_ctrl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024 Raspberry Pi Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // Support old header for compatibility (and if included, support old variable name) 8 | #include "hardware/structs/busctrl.h" 9 | #define bus_ctrl_hw busctrl_hw -------------------------------------------------------------------------------- /src/rp2350/hardware_structs/include/hardware/structs/iobank0.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024 Raspberry Pi Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // Support old header for compatibility (and if included, support old variable name) 8 | #include "hardware/structs/io_bank0.h" 9 | #define iobank0_hw io_bank0_hw -------------------------------------------------------------------------------- /src/rp2350/hardware_structs/include/hardware/structs/ioqspi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024 Raspberry Pi Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // Support old header for compatibility (and if included, support old variable name) 8 | #include "hardware/structs/io_qspi.h" 9 | #define ioqspi_hw io_qspi_hw -------------------------------------------------------------------------------- /src/rp2350/hardware_structs/include/hardware/structs/padsbank0.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024 Raspberry Pi Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // Support old header for compatibility (and if included, support old variable name) 8 | #include "hardware/structs/pads_bank0.h" 9 | #define padsbank0_hw pads_bank0_hw -------------------------------------------------------------------------------- /src/rp2350/hardware_structs/include/hardware/structs/xip_ctrl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // Support old header for compatibility (and if included, support old variable name) 8 | #include "hardware/structs/xip.h" 9 | #define XIP_STAT_FIFO_FULL XIP_STAT_FIFO_FULL_BITS 10 | #define XIP_STAT_FIFO_EMPTY XIP_STAT_FIFO_EMPTY_BITS 11 | #define XIP_STAT_FLUSH_RDY XIP_STAT_FLUSH_READY_BITS 12 | -------------------------------------------------------------------------------- /src/rp2350/pico_platform/include/pico/platform/cpu_regs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | /** \file platform.h 8 | * \defgroup pico_platform pico_platform 9 | * 10 | * \brief Macros and definitions for accessing the CPU registers 11 | * 12 | * This header may be included by assembly code 13 | */ 14 | 15 | #ifndef _PICO_PLATFORM_CPU_REGS_H 16 | #define _PICO_PLATFORM_CPU_REGS_H 17 | 18 | #if defined(__riscv) 19 | #include "hardware/hazard3.h" 20 | #else 21 | #include "hardware/regs/m33.h" 22 | #define ARM_CPU_PREFIXED(x) M33_ ## x 23 | #ifndef __ASSEMBLER__ 24 | #include "hardware/structs/m33.h" 25 | #define arm_cpu_hw m33_hw 26 | #include "hardware/structs/nvic.h" 27 | #include "hardware/structs/scb.h" 28 | #endif 29 | #endif 30 | #endif -------------------------------------------------------------------------------- /src/rp2_common/README.md: -------------------------------------------------------------------------------- 1 | This directory contains libraries specifically targeting the RP2040, RP2350 and possible future related devices. 2 | 3 | `hardware_` libraries exist for individual hardware components to provide a simple API 4 | providing a thin abstraction hiding the details of accessing the hardware registers directly. 5 | 6 | `pico_` provides higher level functionality you might generally find in say an OS kernel, as well 7 | as runtime support familiar to most C programmers. 8 | -------------------------------------------------------------------------------- /src/rp2_common/boot_bootrom_headers/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "boot_bootrom_headers", 5 | hdrs = ["include/boot/bootrom_constants.h"], 6 | includes = ["include"], 7 | deps = [ 8 | "//src:pico_platform_internal", 9 | ], 10 | ) 11 | -------------------------------------------------------------------------------- /src/rp2_common/boot_bootrom_headers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(boot_bootrom_headers INTERFACE) 2 | target_include_directories(boot_bootrom_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 3 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_adc/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_adc", 7 | srcs = ["adc.c"], 8 | hdrs = ["include/hardware/adc.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/rp2_common:hardware_structs", 13 | "//src/rp2_common:pico_platform", 14 | "//src/rp2_common/hardware_gpio", 15 | "//src/rp2_common/hardware_resets", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_adc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(adc) 2 | 3 | # additional library 4 | pico_mirrored_target_link_libraries(hardware_adc INTERFACE hardware_gpio hardware_resets) -------------------------------------------------------------------------------- /src/rp2_common/hardware_adc/adc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico.h" 8 | #include "hardware/adc.h" 9 | #include "hardware/resets.h" 10 | 11 | void adc_init(void) { 12 | // ADC is in an unknown state. We should start by resetting it 13 | reset_unreset_block_num_wait_blocking(RESET_ADC); 14 | 15 | // Now turn it back on. Staging of clock etc is handled internally 16 | adc_hw->cs = ADC_CS_EN_BITS; 17 | 18 | // Internal staging completes in a few cycles, but poll to be sure 19 | while (!(adc_hw->cs & ADC_CS_READY_BITS)) { 20 | tight_loop_contents(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_base/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_base", 7 | hdrs = ["include/hardware/address_mapped.h"], 8 | includes = ["include"], 9 | target_compatible_with = compatible_with_rp2(), 10 | deps = [ 11 | "//src/common/pico_base_headers", 12 | "//src/rp2_common:hardware_regs", 13 | "//src/rp2_common:hardware_structs", 14 | "//src/rp2_common:pico_platform_internal", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_base/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(hardware_base INTERFACE) 2 | add_library(hardware_base_headers INTERFACE) 3 | target_include_directories(hardware_base_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 4 | target_link_libraries(hardware_base_headers INTERFACE pico_base_headers) 5 | target_link_libraries(hardware_base INTERFACE hardware_base_headers) -------------------------------------------------------------------------------- /src/rp2_common/hardware_boot_lock/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | # Picotool needs this, so we can't strictly constrain compatibility. 6 | cc_library( 7 | name = "hardware_boot_lock_headers", 8 | hdrs = ["include/hardware/boot_lock.h"], 9 | includes = ["include"], 10 | tags = ["manual"], 11 | deps = ["//src:pico_platform_internal"], 12 | visibility = ["//src/rp2_common/pico_bootrom:__pkg__"], 13 | ) 14 | 15 | cc_library( 16 | name = "hardware_boot_lock", 17 | srcs = ["boot_lock.c"], 18 | hdrs = ["include/hardware/boot_lock.h"], 19 | includes = ["include"], 20 | target_compatible_with = compatible_with_rp2(), 21 | deps = [ 22 | "//src/common/pico_base_headers", 23 | "//src/common/pico_sync", 24 | "//src/rp2_common:hardware_structs", 25 | "//src/rp2_common/pico_runtime", 26 | "//src/rp2_common/pico_runtime_init", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_boot_lock/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(boot_lock) 2 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_boot_lock/boot_lock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | #include "hardware/boot_lock.h" 7 | #include "pico/runtime_init.h" 8 | 9 | #if NUM_BOOT_LOCKS > 0 10 | void boot_locks_reset(void) { 11 | GCC_Pragma("GCC unroll 1") // prevent GCC unrolling this loop which is 8 bytes per 12 | for (uint i = 0; i < NUM_BOOT_LOCKS; i++) { 13 | boot_unlock_unsafe(boot_lock_instance(i)); 14 | } 15 | } 16 | 17 | boot_lock_t *boot_lock_init(uint lock_num) { 18 | assert(lock_num < NUM_BOOT_LOCKS); 19 | boot_lock_t *lock = boot_lock_instance(lock_num); 20 | boot_unlock_unsafe(lock); 21 | return lock; 22 | } 23 | 24 | #if !PICO_RUNTIME_NO_INIT_BOOT_LOCKS_RESET 25 | #include "hardware/sync.h" 26 | void __weak runtime_init_boot_locks_reset(void) { 27 | boot_locks_reset(); 28 | } 29 | #endif 30 | 31 | #if !PICO_RUNTIME_SKIP_INIT_BOOT_LOCKS_RESET 32 | PICO_RUNTIME_INIT_FUNC_RUNTIME(runtime_init_boot_locks_reset, PICO_RUNTIME_INIT_BOOT_LOCKS_RESET); 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_clocks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(clocks) 2 | 3 | pico_mirrored_target_link_libraries(hardware_clocks INTERFACE 4 | hardware_gpio 5 | hardware_irq 6 | hardware_resets 7 | hardware_pll 8 | # not currently used by clocks.c, but sensibly bundled here 9 | # as changing frequencies may require upping voltage 10 | hardware_vreg 11 | hardware_watchdog 12 | hardware_xosc 13 | ) 14 | 15 | if (PICO_USE_FASTEST_SUPPORTED_CLOCK) 16 | target_compile_definitions(hardware_clocks INTERFACE PICO_USE_FASTEST_SUPPORTED_CLOCK=1) 17 | endif() -------------------------------------------------------------------------------- /src/rp2_common/hardware_dcp/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_dcp", 7 | hdrs = [ 8 | "include/hardware/dcp_canned.inc.S", 9 | "include/hardware/dcp_instr.inc.S", 10 | ], 11 | includes = ["include"], 12 | target_compatible_with = compatible_with_rp2(), 13 | ) 14 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_dcp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_headers_only_target(dcp) 2 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_dcp/doc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup hardware_dcp hardware_dcp 3 | * \brief Assembly macros for the Double Coprocessor 4 | */ 5 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_divider/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_divider", 7 | srcs = select({ 8 | "//bazel/constraint:rp2040": ["divider.S"], 9 | "//conditions:default": ["divider.c"], 10 | }), 11 | hdrs = [ 12 | "include/hardware/divider.h", 13 | "include/hardware/divider_helper.S", 14 | ], 15 | includes = ["include"], 16 | target_compatible_with = compatible_with_rp2(), 17 | deps = [ 18 | "//src/rp2_common:hardware_regs", 19 | "//src/rp2_common:hardware_structs", 20 | "//src/rp2_common:pico_platform", 21 | ], 22 | ) 23 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_divider/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_headers_only_target(divider) 2 | if (PICO_RP2040) 3 | target_sources(hardware_divider INTERFACE ${CMAKE_CURRENT_LIST_DIR}/divider.S) 4 | else() 5 | target_sources(hardware_divider INTERFACE ${CMAKE_CURRENT_LIST_DIR}/divider.c) 6 | endif() 7 | target_link_libraries(hardware_divider_headers INTERFACE hardware_structs) -------------------------------------------------------------------------------- /src/rp2_common/hardware_divider/divider.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "hardware/divider.h" 8 | 9 | #if PICO_EMULATE_DIVIDER 10 | divmod_result_t hw_divider_results[NUM_CORES]; 11 | #endif -------------------------------------------------------------------------------- /src/rp2_common/hardware_dma/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_dma", 7 | srcs = ["dma.c"], 8 | hdrs = ["include/hardware/dma.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/common/hardware_claim", 13 | "//src/rp2_common:hardware_regs", 14 | "//src/rp2_common:hardware_structs", 15 | "//src/rp2_common:pico_platform", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_dma/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(dma) 2 | pico_mirrored_target_link_libraries(hardware_dma INTERFACE hardware_claim) -------------------------------------------------------------------------------- /src/rp2_common/hardware_exception/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_exception", 7 | srcs = ["exception.c"], 8 | hdrs = ["include/hardware/exception.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/rp2_common:hardware_structs", 13 | "//src/rp2_common:pico_platform", 14 | "//src/rp2_common:platform_defs", 15 | "//src/rp2_common/hardware_base", 16 | "//src/rp2_common/hardware_sync", 17 | ], 18 | ) 19 | 20 | # TODO: RISC-V support. 21 | filegroup( 22 | name = "exception_table_riscv", 23 | srcs = ["exception_table_riscv.S"], 24 | ) 25 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_exception/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(exception) 2 | pico_mirrored_target_link_libraries(hardware_exception INTERFACE hardware_sync) 3 | 4 | if (PICO_RISCV) 5 | target_compile_definitions(hardware_exception INTERFACE PICO_CRT0_NO_ISR_RISCV_MACHINE_EXCEPTION=1) 6 | target_sources(hardware_exception INTERFACE 7 | exception_table_riscv.S 8 | ) 9 | endif() -------------------------------------------------------------------------------- /src/rp2_common/hardware_flash/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | # TODO: Needs LIB_FREERTOS_KERNEL defined. 6 | cc_library( 7 | name = "hardware_flash", 8 | srcs = ["flash.c"], 9 | hdrs = ["include/hardware/flash.h"], 10 | includes = ["include"], 11 | target_compatible_with = compatible_with_rp2(), 12 | deps = [ 13 | "//src/rp2_common:hardware_structs", 14 | "//src/rp2_common/hardware_xip_cache", 15 | "//src/rp2_common:pico_platform", 16 | "//src/rp2_common/pico_bootrom", 17 | "//src/rp2_common/pico_multicore", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_flash/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(flash) 2 | pico_mirrored_target_link_libraries(hardware_flash INTERFACE pico_bootrom) 3 | pico_mirrored_target_link_libraries(hardware_flash INTERFACE hardware_xip_cache) 4 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_gpio/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_gpio", 7 | srcs = ["gpio.c"], 8 | hdrs = [ 9 | "include/hardware/gpio.h", 10 | "include/hardware/gpio_coproc.h", 11 | ], 12 | includes = ["include"], 13 | target_compatible_with = compatible_with_rp2(), 14 | deps = [ 15 | "//src/common/pico_base_headers", 16 | "//src/common/pico_binary_info", 17 | "//src/rp2_common:hardware_structs", 18 | "//src/rp2_common/hardware_irq", 19 | "//src/rp2_common/hardware_sync", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_gpio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(gpio) 2 | pico_mirrored_target_link_libraries(hardware_gpio INTERFACE hardware_irq) -------------------------------------------------------------------------------- /src/rp2_common/hardware_hazard3/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_hazard3", 7 | hdrs = [ 8 | "include/hardware/hazard3.h", 9 | "include/hardware/hazard3/features.h", 10 | "include/hardware/hazard3/instructions.h", 11 | ], 12 | includes = ["include"], 13 | target_compatible_with = compatible_with_rp2() + ["@platforms//cpu:riscv32"], 14 | deps = [ 15 | "//src/rp2_common:hardware_regs", 16 | "//src/rp2_common:pico_platform", 17 | "//src/rp2_common/hardware_riscv", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_hazard3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_headers_only_target(hazard3) 2 | target_link_libraries(hardware_hazard3 INTERFACE hardware_riscv) 3 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_hazard3/include/hardware/hazard3/features.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Raspberry Pi Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _HARDWARE_HAZARD3_FEATURES_H 8 | #define _HARDWARE_HAZARD3_FEATURES_H 9 | 10 | #include "pico.h" 11 | 12 | /** \file hardware/hazard3/features.h 13 | * \addtogroup hardware_hazard3 14 | * 15 | * \brief Sets macros for supported Hazard3 custom extensions (features) based on PICO_PLATFORM macros 16 | * 17 | */ 18 | 19 | // Feature detection macros for Hazard3 custom extensions 20 | #if PICO_RP2350 21 | // Version 1.0 of these four extensions 22 | // (encoded as major * 100 + minor) 23 | #define __hazard3_extension_xh3power 100 24 | #define __hazard3_extension_xh3bextm 100 25 | #define __hazard3_extension_xh3irq 100 26 | #define __hazard3_extension_xh3pmpm 100 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_i2c/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_i2c", 7 | srcs = ["i2c.c"], 8 | hdrs = ["include/hardware/i2c.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/common/pico_time", 13 | "//src/rp2_common:hardware_regs", 14 | "//src/rp2_common:hardware_structs", 15 | "//src/rp2_common:pico_platform", 16 | "//src/rp2_common/hardware_clocks", 17 | "//src/rp2_common/hardware_resets", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_i2c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(i2c) 2 | pico_mirrored_target_link_libraries(hardware_i2c INTERFACE pico_time hardware_resets hardware_clocks) 3 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_interp/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_interp", 7 | srcs = ["interp.c"], 8 | hdrs = ["include/hardware/interp.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/common/hardware_claim", 13 | "//src/rp2_common:hardware_regs", 14 | "//src/rp2_common:hardware_structs", 15 | "//src/rp2_common:pico_platform", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_interp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(interp) -------------------------------------------------------------------------------- /src/rp2_common/hardware_irq/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_irq", 7 | srcs = [ 8 | "irq.c", 9 | "irq_handler_chain.S", 10 | ], 11 | hdrs = ["include/hardware/irq.h"], 12 | includes = ["include"], 13 | target_compatible_with = compatible_with_rp2(), 14 | deps = [ 15 | "//src/common/hardware_claim", 16 | "//src/common/pico_sync", 17 | "//src/rp2_common:hardware_regs", 18 | "//src/rp2_common:hardware_structs", 19 | "//src/rp2_common:pico_platform_internal", 20 | "//src/rp2_common:platform_defs", 21 | "//src/rp2_common/hardware_base", 22 | ], 23 | alwayslink = True, 24 | ) 25 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_irq/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(irq) 2 | 3 | # additional sources/libraries 4 | 5 | target_sources(hardware_irq INTERFACE ${CMAKE_CURRENT_LIST_DIR}/irq_handler_chain.S) 6 | 7 | # irq.c includes pico/runtime_init.h 8 | target_link_libraries(hardware_irq INTERFACE pico_sync pico_runtime_init_headers) # not mirrored as only implementation requires it 9 | if (PICO_RISCV) 10 | pico_mirrored_target_link_libraries(hardware_irq INTERFACE hardware_hazard3) 11 | endif() 12 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_pio/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_pio", 7 | srcs = ["pio.c"], 8 | hdrs = [ 9 | "include/hardware/pio.h", 10 | "include/hardware/pio_instructions.h", 11 | ], 12 | includes = ["include"], 13 | target_compatible_with = compatible_with_rp2(), 14 | deps = [ 15 | "//src/common/hardware_claim", 16 | "//src/rp2_common:hardware_regs", 17 | "//src/rp2_common:hardware_structs", 18 | "//src/rp2_common:pico_platform", 19 | "//src/rp2_common/hardware_base", 20 | "//src/rp2_common/hardware_gpio", 21 | ], 22 | ) 23 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_pio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(pio) 2 | 3 | # additional libraries 4 | pico_mirrored_target_link_libraries(hardware_pio INTERFACE 5 | hardware_gpio 6 | hardware_claim 7 | ) -------------------------------------------------------------------------------- /src/rp2_common/hardware_pll/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_pll", 7 | srcs = ["pll.c"], 8 | hdrs = ["include/hardware/pll.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/common/pico_base_headers", 13 | "//src/rp2_common:hardware_structs", 14 | "//src/rp2_common:pico_platform_internal", 15 | "//src/rp2_common/hardware_clocks:hardware_clocks_headers", 16 | "//src/rp2_common/hardware_resets", 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_pll/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(pll) 2 | 3 | pico_mirrored_target_link_libraries(hardware_pll INTERFACE hardware_clocks) -------------------------------------------------------------------------------- /src/rp2_common/hardware_powman/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "hardware_powman", 5 | srcs = ["powman.c"], 6 | hdrs = ["include/hardware/powman.h"], 7 | implementation_deps = ["//src/rp2_common/hardware_gpio"], 8 | includes = ["include"], 9 | 10 | # TODO: RP2350 only, but doesn't appear gated in CMake. 11 | target_compatible_with = ["//bazel/constraint:rp2350"], 12 | deps = [ 13 | "//src/rp2_common:hardware_structs", 14 | "//src/rp2_common:pico_platform", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_powman/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(powman) -------------------------------------------------------------------------------- /src/rp2_common/hardware_pwm/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_pwm", 7 | hdrs = ["include/hardware/pwm.h"], 8 | includes = ["include"], 9 | target_compatible_with = compatible_with_rp2(), 10 | deps = [ 11 | "//src/rp2_common:hardware_regs", 12 | "//src/rp2_common:hardware_structs", 13 | "//src/rp2_common:pico_platform", 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_pwm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_headers_only_target(pwm) 2 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_rcp/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_rcp", 7 | hdrs = ["include/hardware/rcp.h"], 8 | includes = ["include"], 9 | target_compatible_with = compatible_with_rp2(), 10 | deps = ["//src/rp2_common:pico_platform"], 11 | ) 12 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_rcp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_headers_only_target(rcp) 2 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_resets/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_resets", 7 | hdrs = ["include/hardware/resets.h"], 8 | includes = ["include"], 9 | target_compatible_with = compatible_with_rp2(), 10 | deps = [ 11 | "//src/common/pico_base_headers", 12 | "//src/rp2_common:hardware_structs", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_resets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_headers_only_target(resets) 2 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_riscv/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_riscv", 7 | hdrs = ["include/hardware/riscv.h"], 8 | includes = ["include"], 9 | target_compatible_with = compatible_with_rp2() + ["@platforms//cpu:riscv32"], 10 | deps = [ 11 | "//src/rp2_common:hardware_regs", 12 | "//src/rp2_common:pico_platform", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_riscv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_headers_only_target(riscv) 2 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_riscv_platform_timer/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_riscv_platform_timer", 7 | hdrs = ["include/hardware/riscv_platform_timer.h"], 8 | includes = ["include"], 9 | target_compatible_with = compatible_with_rp2() + ["@platforms//cpu:riscv32"], 10 | deps = [ 11 | "//src/rp2_common:hardware_structs", 12 | "//src/rp2_common:pico_platform", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_riscv_platform_timer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_headers_only_target(riscv_platform_timer) 2 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_rtc/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "hardware_rtc", 5 | srcs = ["rtc.c"], 6 | hdrs = ["include/hardware/rtc.h"], 7 | includes = ["include"], 8 | # TODO: Only rp2040 has a hardware/structs/rtc.h header. 9 | target_compatible_with = ["//bazel/constraint:rp2040"], 10 | deps = [ 11 | "//src/rp2_common:hardware_structs", 12 | "//src/rp2_common:pico_platform", 13 | "//src/rp2_common/hardware_clocks", 14 | "//src/rp2_common/hardware_irq", 15 | "//src/rp2_common/hardware_resets", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_rtc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(rtc) 2 | pico_mirrored_target_link_libraries(hardware_rtc INTERFACE hardware_irq hardware_resets hardware_clocks) 3 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_sha256/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "hardware_sha256", 5 | srcs = ["sha256.c"], 6 | hdrs = ["include/hardware/sha256.h"], 7 | includes = ["include"], 8 | # TODO: RP2350 only, but doesn't appear gated in CMake. 9 | target_compatible_with = ["//bazel/constraint:rp2350"], 10 | deps = [ 11 | "//src/rp2_common:hardware_structs", 12 | "//src/rp2_common:pico_platform", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_sha256/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(sha256) 2 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_sha256/sha256.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "hardware/sha256.h" 8 | 9 | void sha256_get_result(sha256_result_t *out, enum sha256_endianness endianness) { 10 | for (uint i = 0; i < count_of(out->words); i++) { 11 | uint32_t data = sha256_hw->sum[i]; 12 | if (endianness == SHA256_BIG_ENDIAN) data = __builtin_bswap32(data); 13 | out->words[i] = data; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_spi/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_spi", 7 | srcs = ["spi.c"], 8 | hdrs = ["include/hardware/spi.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/rp2_common:hardware_regs", 13 | "//src/rp2_common:hardware_structs", 14 | "//src/rp2_common:pico_platform", 15 | "//src/rp2_common/hardware_clocks", 16 | "//src/rp2_common/hardware_resets", 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_spi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(spi) 2 | 3 | pico_mirrored_target_link_libraries(hardware_spi INTERFACE hardware_resets hardware_clocks) 4 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_sync/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(sync) 2 | 3 | pico_mirrored_target_link_libraries(hardware_sync INTERFACE hardware_sync_spin_lock) 4 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_sync_spin_lock/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_sync_spin_lock_headers", 7 | hdrs = ["include/hardware/sync/spin_lock.h"], 8 | includes = ["include"], 9 | target_compatible_with = compatible_with_rp2(), 10 | visibility = [ 11 | "//src/common/pico_sync:__pkg__", 12 | "//src/rp2_common/hardware_sync:__pkg__", 13 | ], 14 | deps = [ 15 | "//src/common/pico_base_headers", 16 | ], 17 | ) 18 | 19 | cc_library( 20 | name = "hardware_sync_spin_lock", 21 | srcs = ["sync_spin_lock.c"], 22 | deps = [ 23 | ":hardware_sync_spin_lock_headers", 24 | "//src/common/pico_sync:pico_sync_headers", 25 | "//src/rp2_common/hardware_sync:hardware_sync_headers", 26 | "//src/rp2_common/pico_runtime_init", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_sync_spin_lock/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(sync_spin_lock) 2 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_ticks/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | # Break a circular dependency with hardware_watchdog. 6 | cc_library( 7 | name = "hardware_ticks_headers", 8 | hdrs = ["include/hardware/ticks.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | visibility = ["//src/rp2_common/hardware_watchdog:__pkg__"], 12 | ) 13 | 14 | cc_library( 15 | name = "hardware_ticks", 16 | srcs = ["ticks.c"], 17 | hdrs = ["include/hardware/ticks.h"], 18 | includes = ["include"], 19 | target_compatible_with = compatible_with_rp2(), 20 | deps = [ 21 | "//src/common/pico_base_headers", 22 | "//src/rp2_common:hardware_structs", 23 | "//src/rp2_common/hardware_watchdog", 24 | ], 25 | ) 26 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_ticks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(ticks) -------------------------------------------------------------------------------- /src/rp2_common/hardware_timer/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | # This exists to break a dependency cycle between 6 | # this library and //src/common/pico_time. 7 | # Application code should always use :hardware_timer instead. 8 | cc_library( 9 | name = "hardware_timer_headers", 10 | hdrs = ["include/hardware/timer.h"], 11 | includes = ["include"], 12 | target_compatible_with = compatible_with_rp2(), 13 | visibility = ["//src/common/pico_time:__pkg__"], 14 | deps = [ 15 | "//src/common/pico_base_headers", 16 | "//src/rp2_common:hardware_structs", 17 | ], 18 | ) 19 | 20 | cc_library( 21 | name = "hardware_timer", 22 | srcs = ["timer.c"], 23 | hdrs = ["include/hardware/timer.h"], 24 | includes = ["include"], 25 | target_compatible_with = compatible_with_rp2(), 26 | deps = [ 27 | "//src/common/hardware_claim", 28 | "//src/common/pico_base_headers", 29 | "//src/rp2_common:hardware_structs", 30 | "//src/rp2_common/hardware_irq", 31 | "//src/rp2_common/hardware_sync", 32 | ], 33 | ) 34 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_timer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(timer) 2 | pico_mirrored_target_link_libraries(hardware_timer INTERFACE hardware_claim hardware_irq) 3 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_uart/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | load("//bazel/util:sdk_define.bzl", "pico_sdk_define") 3 | 4 | package(default_visibility = ["//visibility:public"]) 5 | 6 | pico_sdk_define( 7 | name = "PICO_DEFAULT_UART_BAUD_RATE", 8 | define_name = "PICO_DEFAULT_UART_BAUD_RATE", 9 | from_flag = "//bazel/config:PICO_DEFAULT_UART_BAUD_RATE", 10 | ) 11 | 12 | cc_library( 13 | name = "hardware_uart", 14 | srcs = ["uart.c"], 15 | hdrs = ["include/hardware/uart.h"], 16 | includes = ["include"], 17 | target_compatible_with = compatible_with_rp2(), 18 | deps = [ 19 | ":PICO_DEFAULT_UART_BAUD_RATE", 20 | "//src/rp2_common:hardware_regs", 21 | "//src/rp2_common:hardware_structs", 22 | "//src/rp2_common:pico_platform", 23 | "//src/rp2_common:platform_defs", 24 | "//src/rp2_common/hardware_base", 25 | "//src/rp2_common/hardware_clocks", 26 | "//src/rp2_common/hardware_resets", 27 | "//src/rp2_common/hardware_timer", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_uart/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(uart) 2 | 3 | pico_mirrored_target_link_libraries(hardware_uart INTERFACE hardware_resets hardware_clocks) 4 | 5 | # PICO_CMAKE_CONFIG: PICO_DEFAULT_UART_BAUD_RATE, Define the default UART baudrate, type=int, max=921600, default=115200, group=hardware_uart 6 | if (PICO_DEFAULT_UART_BAUD_RATE) 7 | target_compile_definitions(hardware_uart INTERFACE 8 | PICO_DEFAULT_UART_BAUD_RATE=${PICO_DEFAULT_UART_BAUD_RATE}) 9 | endif() 10 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_vreg/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_vreg", 7 | srcs = ["vreg.c"], 8 | hdrs = ["include/hardware/vreg.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/rp2_common:hardware_structs", 13 | "//src/rp2_common:pico_platform_internal", 14 | "//src/rp2_common/hardware_base", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_vreg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(vreg) 2 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_watchdog/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_watchdog", 7 | srcs = ["watchdog.c"], 8 | hdrs = ["include/hardware/watchdog.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/common/pico_base_headers", 13 | "//src/rp2_common:hardware_structs", 14 | "//src/rp2_common:pico_platform_internal", 15 | "//src/rp2_common/hardware_base", 16 | "//src/rp2_common/hardware_ticks:hardware_ticks_headers", 17 | "//src/rp2_common/pico_bootrom", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_watchdog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(watchdog) 2 | 3 | pico_mirrored_target_link_libraries(hardware_watchdog INTERFACE hardware_ticks pico_bootrom) 4 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_xip_cache/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_xip_cache", 7 | srcs = ["xip_cache.c"], 8 | hdrs = ["include/hardware/xip_cache.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/rp2_common/hardware_sync", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_xip_cache/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(xip_cache) 2 | 3 | pico_mirrored_target_link_libraries(hardware_xip_cache INTERFACE hardware_sync) 4 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_xosc/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "hardware_xosc", 7 | srcs = ["xosc.c"], 8 | hdrs = ["include/hardware/xosc.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/common/pico_base_headers", 13 | "//src/rp2_common:hardware_regs", 14 | "//src/rp2_common:hardware_structs", 15 | "//src/rp2_common:pico_platform_internal", 16 | "//src/rp2_common:platform_defs", 17 | "//src/rp2_common/hardware_clocks:hardware_clocks_headers", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /src/rp2_common/hardware_xosc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(xosc) 2 | pico_mirrored_target_link_libraries(hardware_xosc INTERFACE hardware_clocks) -------------------------------------------------------------------------------- /src/rp2_common/pico_aon_timer/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_aon_timer", 7 | srcs = ["aon_timer.c"], 8 | hdrs = ["include/pico/aon_timer.h"], 9 | defines = [ 10 | "LIB_PICO_AON_TIMER=1", 11 | ], 12 | includes = ["include"], 13 | target_compatible_with = compatible_with_rp2(), 14 | deps = [ 15 | "//src/common/pico_util", 16 | "//src/common/pico_time", 17 | "//src/rp2_common:hardware_regs", 18 | "//src/rp2_common:pico_platform", 19 | "//src/rp2_common/hardware_irq", 20 | "//src/rp2_common/hardware_sync", 21 | ] + select({ 22 | "//bazel/constraint:rp2040": ["//src/rp2_common/hardware_rtc"], 23 | "//conditions:default": ["//src/rp2_common/hardware_powman"], 24 | }), 25 | ) 26 | -------------------------------------------------------------------------------- /src/rp2_common/pico_aon_timer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_aon_timer) 2 | 3 | target_sources(pico_aon_timer INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/aon_timer.c 5 | ) 6 | 7 | target_include_directories(pico_aon_timer_headers SYSTEM INTERFACE 8 | ${CMAKE_CURRENT_LIST_DIR}/include 9 | ) 10 | 11 | pico_mirrored_target_link_libraries(pico_aon_timer INTERFACE pico_util) 12 | 13 | if (TARGET hardware_rtc) 14 | pico_mirrored_target_link_libraries(pico_aon_timer INTERFACE hardware_rtc) 15 | target_link_libraries(pico_aon_timer_headers INTERFACE pico_time_headers) 16 | endif() 17 | 18 | if (TARGET hardware_powman) 19 | pico_mirrored_target_link_libraries(pico_aon_timer INTERFACE hardware_powman) 20 | endif() 21 | -------------------------------------------------------------------------------- /src/rp2_common/pico_async_context/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_async_context_base NOFLAG) 2 | target_include_directories(pico_async_context_base_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 3 | target_sources(pico_async_context_base INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/async_context_base.c 5 | ) 6 | pico_mirrored_target_link_libraries(pico_async_context_base INTERFACE pico_platform) 7 | 8 | pico_add_library(pico_async_context_poll) 9 | target_sources(pico_async_context_poll INTERFACE 10 | ${CMAKE_CURRENT_LIST_DIR}/async_context_poll.c 11 | ) 12 | pico_mirrored_target_link_libraries(pico_async_context_poll INTERFACE pico_async_context_base) 13 | 14 | pico_add_library(pico_async_context_threadsafe_background) 15 | target_sources(pico_async_context_threadsafe_background INTERFACE 16 | ${CMAKE_CURRENT_LIST_DIR}/async_context_threadsafe_background.c 17 | ) 18 | pico_mirrored_target_link_libraries(pico_async_context_threadsafe_background INTERFACE pico_async_context_base) 19 | 20 | pico_add_library(pico_async_context_freertos) 21 | target_sources(pico_async_context_freertos INTERFACE 22 | ${CMAKE_CURRENT_LIST_DIR}/async_context_freertos.c 23 | ) 24 | pico_mirrored_target_link_libraries(pico_async_context_freertos INTERFACE pico_async_context_base) 25 | -------------------------------------------------------------------------------- /src/rp2_common/pico_async_context/include/pico/async_context_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_ASYNC_CONTEXT_BASE_H 8 | #define _PICO_ASYNC_CONTEXT_BASE_H 9 | 10 | #include "pico/async_context.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | // common functions for async_context implementations to use 17 | bool async_context_base_add_at_time_worker(async_context_t *self, async_at_time_worker_t *worker); 18 | bool async_context_base_remove_at_time_worker(async_context_t *self, async_at_time_worker_t *worker); 19 | 20 | bool async_context_base_add_when_pending_worker(async_context_t *self, async_when_pending_worker_t *worker); 21 | bool async_context_base_remove_when_pending_worker(async_context_t *self, async_when_pending_worker_t *worker); 22 | 23 | async_at_time_worker_t *async_context_base_remove_ready_at_time_worker(async_context_t *self); 24 | void async_context_base_refresh_next_timeout(async_context_t *self); 25 | 26 | absolute_time_t async_context_base_execute_once(async_context_t *self); 27 | bool async_context_base_needs_servicing(async_context_t *self); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif -------------------------------------------------------------------------------- /src/rp2_common/pico_atomic/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_atomic", 7 | srcs = ["atomic.c"], 8 | hdrs = ["include/stdatomic.h"], 9 | copts = ["-Wno-atomic-alignment"], 10 | includes = ["include"], 11 | target_compatible_with = compatible_with_rp2(), 12 | deps = ["//src/common/pico_sync"], 13 | ) 14 | -------------------------------------------------------------------------------- /src/rp2_common/pico_atomic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_atomic) 2 | pico_add_library(pico_atomic) 3 | 4 | target_sources(pico_atomic INTERFACE 5 | ${CMAKE_CURRENT_LIST_DIR}/atomic.c 6 | ) 7 | 8 | target_compile_options(pico_atomic INTERFACE 9 | # -Wno-atomic-alignment 10 | ) 11 | target_include_directories(pico_atomic_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 12 | 13 | target_link_libraries(pico_atomic INTERFACE pico_sync) 14 | endif() 15 | -------------------------------------------------------------------------------- /src/rp2_common/pico_bit_ops/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_bit_ops", 7 | srcs = ["bit_ops_aeabi.S"], 8 | linkopts = select({ 9 | "//bazel/constraint:rp2040": [ 10 | "-Wl,--wrap=__clzsi2", 11 | "-Wl,--wrap=__clzsi2", 12 | "-Wl,--wrap=__clzdi2", 13 | "-Wl,--wrap=__ctzsi2", 14 | "-Wl,--wrap=__popcountsi2", 15 | "-Wl,--wrap=__popcountdi2", 16 | "-Wl,--wrap=__clz", 17 | "-Wl,--wrap=__clzl", 18 | "-Wl,--wrap=__clzsi2", 19 | "-Wl,--wrap=__clzll", 20 | ], 21 | "//conditions:default": [], 22 | }) + ["-Wl,--wrap=__ctzdi2"], 23 | target_compatible_with = compatible_with_rp2(), 24 | deps = [ 25 | "//src/common/pico_bit_ops_headers:pico_bit_ops_interface", 26 | "//src/rp2_common:pico_platform_internal", 27 | "//src/rp2_common/pico_bootrom", 28 | "//src/rp2_common/pico_runtime_init", 29 | ], 30 | alwayslink = True, # Ensures the wrapped symbols are linked in. 31 | ) 32 | -------------------------------------------------------------------------------- /src/rp2_common/pico_bootrom/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_bootrom_headers NOFLAG) 2 | 3 | target_include_directories(pico_bootrom_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 4 | 5 | add_library(pico_bootrom INTERFACE) 6 | target_sources(pico_bootrom INTERFACE 7 | ${CMAKE_CURRENT_LIST_DIR}/bootrom.c 8 | ${CMAKE_CURRENT_LIST_DIR}/bootrom_lock.c 9 | ) 10 | 11 | target_link_libraries(pico_bootrom_headers INTERFACE boot_picoboot_headers boot_bootrom_headers) 12 | pico_mirrored_target_link_libraries(pico_bootrom INTERFACE pico_base hardware_boot_lock pico_flash) 13 | 14 | # bootrom.c includes boot/picobin.h 15 | # bootrom_lock.c includes pico/runtime_init.h 16 | target_link_libraries(pico_bootrom INTERFACE boot_picobin_headers pico_runtime_init_headers) -------------------------------------------------------------------------------- /src/rp2_common/pico_bootrom/bootrom_lock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico/bootrom/lock.h" 8 | #include "pico/runtime_init.h" 9 | 10 | #if PICO_BOOTROM_LOCKING_ENABLED 11 | #if !PICO_RUNTIME_NO_INIT_BOOTROM_LOCKING_ENABLE 12 | #include "hardware/sync.h" 13 | void __weak runtime_init_bootrom_locking_enable(void) { 14 | bootrom_acquire_lock_blocking(BOOTROM_LOCK_ENABLE); 15 | } 16 | #endif 17 | 18 | #if !PICO_RUNTIME_SKIP_INIT_BOOTROM_LOCKING_ENABLE 19 | PICO_RUNTIME_INIT_FUNC_RUNTIME(runtime_init_bootrom_locking_enable, PICO_RUNTIME_INIT_BOOTROM_LOCKING_ENABLE); 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /src/rp2_common/pico_bootrom/include/pico/bootrom_constants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // new location; this file kept for backwards compatibility 8 | #include "boot/bootrom_constants.h" 9 | -------------------------------------------------------------------------------- /src/rp2_common/pico_bootsel_via_double_reset/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_bootsel_via_double_reset", 7 | srcs = ["pico_bootsel_via_double_reset.c"], 8 | target_compatible_with = compatible_with_rp2(), 9 | deps = [ 10 | "//src/common/pico_binary_info", 11 | "//src/common/pico_time", 12 | "//src/rp2_common:pico_platform", 13 | "//src/rp2_common/pico_bootrom", 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /src/rp2_common/pico_bootsel_via_double_reset/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_bootsel_via_double_reset) 2 | 3 | target_sources(pico_bootsel_via_double_reset INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/pico_bootsel_via_double_reset.c 5 | ) 6 | 7 | pico_mirrored_target_link_libraries(pico_bootsel_via_double_reset INTERFACE 8 | pico_bootrom 9 | pico_time 10 | pico_binary_info 11 | ) 12 | -------------------------------------------------------------------------------- /src/rp2_common/pico_btstack/include/pico/btstack_run_loop_async_context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_BTSTACK_RUN_LOOP_ASYNC_CONTEXT_H 8 | #define _PICO_BTSTACK_RUN_LOOP_ASYNC_CONTEXT_H 9 | 10 | #include "btstack_run_loop.h" 11 | #include "pico/async_context.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /** 18 | * \brief Initialize and return the singleton BTstack run loop instance that integrates with the async_context API 19 | * \ingroup pico_btstack 20 | * 21 | * \param context the async_context instance that provides the abstraction for handling asynchronous work. 22 | * \return the BTstack run loop instance 23 | */ 24 | const btstack_run_loop_t *btstack_run_loop_async_context_get_instance(async_context_t *context); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | #endif 30 | -------------------------------------------------------------------------------- /src/rp2_common/pico_clib_interface/doc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup pico_clib_interface pico_clib_interface 3 | * \brief Provides the necessary glue code required by the particular C/C++ runtime being used 4 | */ 5 | -------------------------------------------------------------------------------- /src/rp2_common/pico_clib_interface/include/llvm_libc/sys/cdefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef __PICO_LLVM_LIBC_SYS_CDEFS_H 8 | #define __PICO_LLVM_LIBC_SYS_CDEFS_H 9 | 10 | #if defined(__STDC__) || defined(__cplusplus) 11 | 12 | #define __CONCAT1(x,y) x ## y 13 | #define __CONCAT(x,y) __CONCAT1(x,y) 14 | #define __STRING(x) #x 15 | #define __XSTRING(x) __STRING(x) 16 | 17 | #endif 18 | 19 | #define __unused __attribute__((__unused__)) 20 | #define __used __attribute__((__used__)) 21 | #define __packed __attribute__((__packed__)) 22 | #define __aligned(x) __attribute__((__aligned__(x))) 23 | 24 | #define __always_inline __inline__ __attribute__((__always_inline__)) 25 | #define __noinline __attribute__((__noinline__)) 26 | 27 | #define __printflike(fmtarg, firstvararg) \ 28 | __attribute__((__format__ (__printf__, fmtarg, firstvararg))) 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/rp2_common/pico_clib_interface/include/llvm_libc/sys/stat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_LLVM_LIBC_SYS_STAT_H 8 | #define _PICO_LLVM_LIBC_SYS_STAT_H 9 | 10 | typedef int off_t; 11 | 12 | struct stat {}; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/rp2_common/pico_clib_interface/include/llvm_libc/sys/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_LLVM_LIBC_SYS_TIME_H 8 | #define _PICO_LLVM_LIBC_SYS_TIME_H 9 | 10 | #include <__llvm-libc-common.h> 11 | 12 | #include 13 | 14 | struct timezone { 15 | int tz_minuteswest; 16 | int tz_dsttime; 17 | }; 18 | 19 | __BEGIN_C_DECLS 20 | 21 | int gettimeofday(struct timeval *tv, struct timezone *tz); 22 | int settimeofday(const struct timeval *tv, const struct timezone *tz); 23 | 24 | __END_C_DECLS 25 | 26 | #endif // _PICO_LLVM_LIBC_SYS_TIME_H 27 | -------------------------------------------------------------------------------- /src/rp2_common/pico_clib_interface/include/llvm_libc/sys/times.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_LLVM_LIBC_SYS_TIMES_H 8 | #define _PICO_LLVM_LIBC_SYS_TIMES_H 9 | 10 | #include 11 | 12 | #define CLOCKS_PER_SEC 100 13 | 14 | typedef int clock_t; 15 | 16 | struct tms { 17 | clock_t tms_utime; 18 | clock_t tms_stime; 19 | clock_t tms_cutime; 20 | clock_t tms_cstime; 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/rp2_common/pico_clib_interface/include/llvm_libc/sys/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_LLVM_LIBC_SYS_TYPES_H 8 | #define _PICO_LLVM_LIBC_SYS_TYPES_H 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/rp2_common/pico_clib_interface/include/llvm_libc/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_LLVM_LIBC_TIME_H 8 | #define _PICO_LLVM_LIBC_TIME_H 9 | 10 | #include <__llvm-libc-common.h> 11 | 12 | #include 13 | #include 14 | 15 | __BEGIN_C_DECLS 16 | 17 | struct tm* localtime_r(const time_t* timer, struct tm* buf); 18 | 19 | __END_C_DECLS 20 | 21 | #include_next 22 | 23 | #endif // _PICO_LLVM_LIBC_TIME_H 24 | -------------------------------------------------------------------------------- /src/rp2_common/pico_clib_interface/include/llvm_libc/unistd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_LLVM_LIBC_UNISTD_H 8 | #define _PICO_LLVM_LIBC_UNISTD_H 9 | 10 | #include <__llvm-libc-common.h> 11 | 12 | typedef int pid_t; 13 | 14 | __BEGIN_C_DECLS 15 | 16 | _Noreturn void _exit(int) __NOEXCEPT; 17 | 18 | __END_C_DECLS 19 | 20 | #endif // _PICO_LLVM_LIBC_UNISTD_H 21 | -------------------------------------------------------------------------------- /src/rp2_common/pico_crt0/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_crt0) 2 | pico_add_library(pico_crt0) 3 | 4 | if (PICO_RISCV) 5 | target_sources(pico_crt0 INTERFACE ${CMAKE_CURRENT_LIST_DIR}/crt0_riscv.S) 6 | else() 7 | target_sources(pico_crt0 INTERFACE ${CMAKE_CURRENT_LIST_DIR}/crt0.S) 8 | endif() 9 | 10 | pico_mirrored_target_link_libraries(pico_crt0 INTERFACE hardware_structs hardware_regs) 11 | target_link_libraries(pico_crt0 INTERFACE boot_picobin_headers pico_bootrom_headers) 12 | endif() 13 | 14 | pico_register_common_scope_var(PICO_LINKER_SCRIPT_PATH) 15 | if (NOT PICO_LINKER_SCRIPT_PATH) 16 | set(PICO_LINKER_SCRIPT_PATH ${CMAKE_CURRENT_LIST_DIR}/${PICO_CHIP}) 17 | endif() 18 | 19 | pico_promote_common_scope_vars() -------------------------------------------------------------------------------- /src/rp2_common/pico_crt0/doc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup pico_crt0 pico_crt0 3 | * \brief Provides the default linker scripts and the program entry/exit point 4 | */ 5 | 6 | // PICO_CONFIG: PICO_EMBED_XIP_SETUP, Embed custom XIP setup (boot2) in an RP2350 binary, type=bool, default=0, group=pico_base 7 | // unused but keeps tooling happy 8 | #define PICO_EMBED_XIP_SETUP 0 -------------------------------------------------------------------------------- /src/rp2_common/pico_crt0/embedded_end_block.inc.S: -------------------------------------------------------------------------------- 1 | #if PICO_CRT0_INCLUDE_PICOBIN_END_BLOCK 2 | .section .embedded_end_block, "a" 3 | .p2align 2 4 | embedded_end_block: 5 | .word PICOBIN_BLOCK_MARKER_START 6 | 7 | .byte PICOBIN_BLOCK_ITEM_2BS_IGNORED 8 | .byte 0x1 // 1 word 9 | .hword 0 10 | 11 | .byte PICOBIN_BLOCK_ITEM_2BS_LAST 12 | .hword (embedded_end_block_end - embedded_end_block - 16 ) / 4 // total size of all items 13 | .byte 0 14 | // offset from this block to first block 15 | .word embedded_block - embedded_end_block 16 | .word PICOBIN_BLOCK_MARKER_END 17 | embedded_end_block_end: 18 | #endif 19 | -------------------------------------------------------------------------------- /src/rp2_common/pico_cxx_options/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | load("//bazel/util:sdk_define.bzl", "pico_sdk_define") 3 | 4 | package(default_visibility = ["//visibility:public"]) 5 | 6 | # PICO_BUILD_DEFINE: PICO_CXX_ENABLE_EXCEPTIONS, value of CMake var PICO_CXX_ENABLE_EXCEPTIONS, type=string, default=0, group=pico_cxx_options 7 | pico_sdk_define( 8 | name = "PICO_CXX_ENABLE_EXCEPTIONS", 9 | define_name = "PICO_CXX_ENABLE_EXCEPTIONS", 10 | from_flag = "//bazel/config:PICO_CXX_ENABLE_EXCEPTIONS", 11 | ) 12 | 13 | cc_library( 14 | name = "pico_cxx_options", 15 | srcs = ["new_delete.cpp"], 16 | target_compatible_with = compatible_with_rp2(), 17 | deps = [ 18 | ":PICO_CXX_ENABLE_EXCEPTIONS", 19 | "//src/rp2_common:pico_platform", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /src/rp2_common/pico_cxx_options/doc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup pico_cxx_options pico_cxx_options 3 | * \brief non-code library controlling C++ related compile options 4 | */ 5 | -------------------------------------------------------------------------------- /src/rp2_common/pico_cxx_options/new_delete.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #if !PICO_CXX_ENABLE_EXCEPTIONS 8 | // Override the standard allocators to use regular malloc/free 9 | 10 | #if !PICO_CXX_DISABLE_ALLOCATION_OVERRIDES // Let user override 11 | #include 12 | #include "pico.h" 13 | 14 | void *operator new(std::size_t n) { 15 | return std::malloc(n); 16 | } 17 | 18 | void *operator new[](std::size_t n) { 19 | return std::malloc(n); 20 | } 21 | 22 | void operator delete(void *p) { std::free(p); } 23 | 24 | void operator delete[](void *p) noexcept { std::free(p); } 25 | 26 | #if __cpp_sized_deallocation 27 | 28 | void operator delete(void *p, __unused std::size_t n) noexcept { std::free(p); } 29 | 30 | void operator delete[](void *p, __unused std::size_t n) noexcept { std::free(p); } 31 | 32 | #endif 33 | 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/rp2_common/pico_cyw43_arch/include/pico/cyw43_arch/arch_freertos.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_CYW43_ARCH_ARCH_FREERTOS_H 8 | #define _PICO_CYW43_ARCH_ARCH_FREERTOS_H 9 | 10 | // PICO_CONFIG: CYW43_TASK_STACK_SIZE, Stack size for the CYW43 FreeRTOS task in 4-byte words, type=int, default=1024, group=pico_cyw43_arch 11 | #ifndef CYW43_TASK_STACK_SIZE 12 | #define CYW43_TASK_STACK_SIZE 1024 13 | #endif 14 | 15 | // PICO_CONFIG: CYW43_TASK_PRIORITY, Priority for the CYW43 FreeRTOS task, type=int, default=tskIDLE_PRIORITY + 4, group=pico_cyw43_arch 16 | #ifndef CYW43_TASK_PRIORITY 17 | #define CYW43_TASK_PRIORITY (tskIDLE_PRIORITY + 4) 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/rp2_common/pico_cyw43_arch/include/pico/cyw43_arch/arch_poll.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_CYW43_ARCH_ARCH_POLL_H 8 | #define _PICO_CYW43_ARCH_ARCH_POLL_H 9 | 10 | // now obsolete; kept for backwards compatibility 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/rp2_common/pico_cyw43_arch/include/pico/cyw43_arch/arch_threadsafe_background.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_CYW43_ARCH_ARCH_THREADSAFE_BACKGROUND_H 8 | #define _PICO_CYW43_ARCH_ARCH_THREADSAFE_BACKGROUND_H 9 | 10 | // now obsolete; kept for backwards compatibility 11 | 12 | #endif -------------------------------------------------------------------------------- /src/rp2_common/pico_cyw43_driver/btstack_chipset_cyw43.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico/btstack_chipset_cyw43.h" 8 | 9 | static void chipset_set_bd_addr_command(bd_addr_t addr, uint8_t *hci_cmd_buffer) { 10 | hci_cmd_buffer[0] = 0x01; 11 | hci_cmd_buffer[1] = 0xfc; 12 | hci_cmd_buffer[2] = 0x06; 13 | reverse_bd_addr(addr, &hci_cmd_buffer[3]); 14 | } 15 | 16 | static const btstack_chipset_t btstack_chipset_cyw43 = { 17 | .name = "CYW43", 18 | .init = NULL, 19 | .next_command = NULL, 20 | .set_baudrate_command = NULL, 21 | .set_bd_addr_command = chipset_set_bd_addr_command, 22 | }; 23 | 24 | const btstack_chipset_t * btstack_chipset_cyw43_instance(void) { 25 | return &btstack_chipset_cyw43; 26 | } 27 | -------------------------------------------------------------------------------- /src/rp2_common/pico_cyw43_driver/cybt_shared_bus/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "cybt_shared_bus_driver", 5 | srcs = [ 6 | "cybt_shared_bus.c", 7 | "cybt_shared_bus_driver.c", 8 | ], 9 | hdrs = ["cybt_shared_bus_driver.h"], 10 | includes = ["."], 11 | deps = [ 12 | "@cyw43-driver//:cyw43_driver", 13 | ], 14 | alwayslink = True, 15 | ) 16 | -------------------------------------------------------------------------------- /src/rp2_common/pico_cyw43_driver/cybt_shared_bus/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # cyw43 shared bus read and write 2 | pico_add_library(cybt_shared_bus NOFLAG) 3 | 4 | target_sources(cybt_shared_bus INTERFACE 5 | ${CMAKE_CURRENT_LIST_DIR}/cybt_shared_bus.c 6 | ${CMAKE_CURRENT_LIST_DIR}/cybt_shared_bus_driver.c 7 | ) 8 | target_include_directories(cybt_shared_bus_headers SYSTEM INTERFACE 9 | ${CMAKE_CURRENT_LIST_DIR} 10 | ) 11 | 12 | # The BT firmware is supplied as a source file containing a static array with ascii hex data 13 | # Set this to true to use this for testing 14 | set(CYW43_USE_HEX_BTFW 0) 15 | if (CYW43_USE_HEX_BTFW) 16 | message("Warning: CYW43_USE_HEX_BTFW is true") 17 | target_sources(cybt_shared_bus INTERFACE 18 | ${PICO_CYW43_DRIVER_PATH}/firmware/cybt_firmware_43439.c 19 | ) 20 | target_compile_definitions(cybt_shared_bus INTERFACE 21 | CYW43_USE_HEX_BTFW=1 22 | ) 23 | endif() -------------------------------------------------------------------------------- /src/rp2_common/pico_cyw43_driver/include/pico/btstack_chipset_cyw43.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_BTSTACK_CHIPSET_CYW43_H 8 | #define _PICO_BTSTACK_CHIPSET_CYW43_H 9 | 10 | #include "btstack_chipset.h" 11 | 12 | /** 13 | * \brief Return the singleton BTstack chipset CY43 API instance 14 | * \ingroup pico_btstack 15 | */ 16 | const btstack_chipset_t * btstack_chipset_cyw43_instance(void); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/rp2_common/pico_cyw43_driver/include/pico/btstack_hci_transport_cyw43.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_BTSTACK_HCI_TRANSPORT_CYW43_H 8 | #define _PICO_BTSTACK_HCI_TRANSPORT_CYW43_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /** \file pico/btstack_hci_transport_cyw43.h 15 | * \ingroup pico_cyw43_driver 16 | * \brief Adds low level Bluetooth HCI support 17 | */ 18 | 19 | /** 20 | * \brief Get the Bluetooth HCI transport instance for cyw43 21 | * \ingroup pico_cyw43_driver 22 | * 23 | * \return An instantiation of the hci_transport_t interface for the cyw43 chipset 24 | */ 25 | const hci_transport_t *hci_transport_cyw43_instance(void); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif // HCI_TRANSPORT_CYW43_H 32 | -------------------------------------------------------------------------------- /src/rp2_common/pico_fix/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_fix", 7 | target_compatible_with = compatible_with_rp2(), 8 | ) 9 | -------------------------------------------------------------------------------- /src/rp2_common/pico_fix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_subdirectory(rp2040_usb_device_enumeration) -------------------------------------------------------------------------------- /src/rp2_common/pico_fix/rp2040_usb_device_enumeration/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "rp2040_usb_device_enumeration", 7 | srcs = ["rp2040_usb_device_enumeration.c"], 8 | hdrs = ["include/pico/fix/rp2040_usb_device_enumeration.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/common/pico_time", 13 | "//src/rp2_common:hardware_structs", 14 | "//src/rp2_common:pico_platform", 15 | "//src/rp2_common/hardware_gpio", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /src/rp2_common/pico_fix/rp2040_usb_device_enumeration/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_fix_rp2040_usb_device_enumeration) 2 | 3 | target_sources(pico_fix_rp2040_usb_device_enumeration INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/rp2040_usb_device_enumeration.c 5 | ) 6 | 7 | target_include_directories(pico_fix_rp2040_usb_device_enumeration_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 8 | 9 | pico_mirrored_target_link_libraries(pico_fix_rp2040_usb_device_enumeration INTERFACE hardware_structs hardware_gpio pico_time) -------------------------------------------------------------------------------- /src/rp2_common/pico_fix/rp2040_usb_device_enumeration/include/pico/fix/rp2040_usb_device_enumeration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_FIX_RP2040_USB_DEVICE_ENUMERATION_H 8 | #define _PICO_FIX_RP2040_USB_DEVICE_ENUMERATION_H 9 | 10 | /*! \brief Perform a brute force workaround for USB device enumeration issue 11 | * \ingroup pico_fix 12 | * 13 | * This method should be called during the IRQ handler for a bus reset 14 | */ 15 | void rp2040_usb_device_enumeration_fix(void); 16 | 17 | #endif -------------------------------------------------------------------------------- /src/rp2_common/pico_flash/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_flash) 2 | 3 | target_sources(pico_flash INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/flash.c 5 | ) 6 | 7 | target_include_directories(pico_flash_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 8 | 9 | # just include multicore headers, as we don't want to pull in the lib if it isn't pulled in already 10 | target_link_libraries(pico_flash INTERFACE pico_multicore_headers) 11 | 12 | pico_mirrored_target_link_libraries(pico_flash INTERFACE pico_time hardware_sync) 13 | -------------------------------------------------------------------------------- /src/rp2_common/pico_i2c_slave/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_i2c_slave", 7 | srcs = ["i2c_slave.c"], 8 | hdrs = ["include/pico/i2c_slave.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/rp2_common/hardware_i2c", 13 | "//src/rp2_common/hardware_irq", 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /src/rp2_common/pico_i2c_slave/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_i2c_slave) 2 | pico_add_library(pico_i2c_slave) 3 | 4 | target_sources(pico_i2c_slave INTERFACE 5 | ${CMAKE_CURRENT_LIST_DIR}/i2c_slave.c) 6 | 7 | target_include_directories(pico_i2c_slave_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 8 | 9 | pico_mirrored_target_link_libraries(pico_i2c_slave INTERFACE hardware_i2c hardware_irq) 10 | endif() 11 | -------------------------------------------------------------------------------- /src/rp2_common/pico_int64_ops/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_int64_ops", 7 | srcs = ["pico_int64_ops_aeabi.S"], 8 | hdrs = ["include/pico/int64_ops.h"], 9 | includes = ["include"], 10 | linkopts = ["-Wl,--wrap=__aeabi_lmul"], 11 | target_compatible_with = compatible_with_rp2(), 12 | deps = [ 13 | "//src/rp2_common:pico_platform", 14 | ], 15 | alwayslink = True, # Ensures the wrapped symbols are linked in. 16 | ) 17 | -------------------------------------------------------------------------------- /src/rp2_common/pico_int64_ops/include/pico/int64_ops.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_INT64_OPS_H 8 | #define _PICO_INT64_OPS_H 9 | 10 | #include "pico/types.h" 11 | 12 | /** \file int64_ops.h 13 | * \defgroup pico_int64_ops pico_int64_ops 14 | * 15 | * \brief Optimized replacement implementations of the compiler built-in 64 bit multiplication 16 | * 17 | * This library does not provide any additional functions 18 | */ 19 | 20 | #endif -------------------------------------------------------------------------------- /src/rp2_common/pico_int64_ops/pico_int64_ops_aeabi.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico/asm_helper.S" 8 | 9 | pico_default_asm_setup 10 | 11 | .macro int64_section name 12 | #if PICO_INT64_OPS_IN_RAM 13 | .section RAM_SECTION_NAME(\name), "ax" 14 | #else 15 | .section SECTION_NAME(\name), "ax" 16 | #endif 17 | .endm 18 | 19 | int64_section __aeabi_lmul 20 | 21 | wrapper_func __aeabi_lmul 22 | muls r1, r2 23 | muls r3, r0 24 | adds r1, r3 25 | mov r12, r1 26 | lsrs r1, r2, #16 27 | uxth r3, r0 28 | muls r3, r1 29 | push {r4} 30 | lsrs r4, r0, #16 31 | muls r1, r4 32 | uxth r2, r2 33 | uxth r0, r0 34 | muls r0, r2 35 | muls r2, r4 36 | lsls r4, r3, #16 37 | lsrs r3, #16 38 | adds r0, r4 39 | pop {r4} 40 | adcs r1, r3 41 | lsls r3, r2, #16 42 | lsrs r2, #16 43 | adds r0, r3 44 | adcs r1, r2 45 | add r1, r12 46 | bx lr 47 | -------------------------------------------------------------------------------- /src/rp2_common/pico_malloc/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_malloc", 7 | srcs = ["malloc.c"], 8 | hdrs = ["include/pico/malloc.h"], 9 | includes = ["include"], 10 | linkopts = [ 11 | "-Wl,--wrap=malloc", 12 | "-Wl,--wrap=calloc", 13 | "-Wl,--wrap=realloc", 14 | "-Wl,--wrap=free", 15 | ], 16 | target_compatible_with = compatible_with_rp2(), 17 | deps = [ 18 | "//src/common/pico_sync", 19 | "//src/rp2_common:pico_platform", 20 | "//src/rp2_common/pico_multicore", 21 | ], 22 | alwayslink = True, # Ensures the wrapped symbols are linked in. 23 | ) 24 | -------------------------------------------------------------------------------- /src/rp2_common/pico_malloc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_malloc) 2 | #shims for ROM functions for -lgcc functions (listed below) 3 | pico_add_library(pico_malloc) 4 | 5 | target_sources(pico_malloc INTERFACE 6 | ${CMAKE_CURRENT_LIST_DIR}/malloc.c 7 | ) 8 | 9 | target_include_directories(pico_malloc_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 10 | 11 | pico_wrap_function(pico_malloc malloc) 12 | pico_wrap_function(pico_malloc calloc) 13 | pico_wrap_function(pico_malloc realloc) 14 | pico_wrap_function(pico_malloc free) 15 | 16 | target_link_libraries(pico_malloc INTERFACE pico_sync) 17 | endif() 18 | -------------------------------------------------------------------------------- /src/rp2_common/pico_mbedtls/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_mbedtls", 7 | srcs = ["pico_mbedtls.c"], 8 | hdrs = ["include/sha256_alt.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//bazel/config:PICO_MBEDTLS_LIB", 13 | "//src/rp2_common:pico_platform", 14 | "//src/rp2_common/pico_rand", 15 | "//src/rp2_common/pico_sha256", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /src/rp2_common/pico_mbedtls/include/sha256_alt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef PICO_MBEDTLS_SHA256_ALT_H 8 | #define PICO_MBEDTLS_SHA256_ALT_H 9 | 10 | #if LIB_PICO_SHA256 11 | #include "pico/sha256.h" 12 | 13 | typedef struct pico_sha256_state mbedtls_sha256_context; 14 | #endif // PICO_RP2350 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/rp2_common/pico_mem_ops/include/pico/mem_ops.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_MEM_OPS_H 8 | #define _PICO_MEM_OPS_H 9 | 10 | #include "pico/types.h" 11 | 12 | /** \file mem_ops.h 13 | * \defgroup pico_mem_ops pico_mem_ops 14 | * 15 | * \brief Provides optimized replacement implementations of the compiler built-in memcpy, memset and related functions 16 | * 17 | * The functions include: 18 | * - memset, memcpy 19 | * - __aeabi_memset, __aeabi_memset4, __aeabi_memset8, __aeabi_memcpy, __aeabi_memcpy4, __aeabi_memcpy8 20 | * 21 | * This library does not provide any additional functions 22 | */ 23 | #endif -------------------------------------------------------------------------------- /src/rp2_common/pico_mem_ops/mem_ops.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico/mem_ops.h" 8 | -------------------------------------------------------------------------------- /src/rp2_common/pico_multicore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_multicore) 2 | pico_add_library(pico_multicore) 3 | target_include_directories(pico_multicore_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 4 | 5 | target_sources(pico_multicore INTERFACE 6 | ${CMAKE_CURRENT_LIST_DIR}/multicore.c) 7 | 8 | pico_mirrored_target_link_libraries(pico_multicore INTERFACE 9 | pico_sync 10 | hardware_irq) 11 | 12 | if (PICO_RISCV) 13 | pico_mirrored_target_link_libraries(pico_multicore INTERFACE hardware_riscv) 14 | endif() 15 | endif() 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/rp2_common/pico_platform_compiler/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_platform_compiler", 7 | hdrs = ["include/pico/platform/compiler.h"], 8 | includes = ["include"], 9 | target_compatible_with = compatible_with_rp2(), 10 | deps = [ 11 | "//src/rp2_common:platform_defs", 12 | "//src/rp2_common/pico_clib_interface", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /src/rp2_common/pico_platform_compiler/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_platform_compiler) 2 | pico_add_library(pico_platform_compiler) 3 | 4 | target_include_directories(pico_platform_compiler_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 5 | 6 | target_link_libraries(pico_platform_compiler_headers INTERFACE hardware_regs) 7 | endif() 8 | -------------------------------------------------------------------------------- /src/rp2_common/pico_platform_panic/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | # This exists to break a dependency cycle between 6 | # this library and //src/rp2_common/pico_printf. 7 | # Application code should always use :pico_platform_panic instead. 8 | cc_library( 9 | name = "pico_platform_panic_headers", 10 | hdrs = ["include/pico/platform/panic.h"], 11 | includes = ["include"], 12 | target_compatible_with = compatible_with_rp2(), 13 | visibility = [ 14 | "//src/rp2040/pico_platform:__pkg__", 15 | "//src/rp2350/pico_platform:__pkg__", 16 | ], 17 | deps = ["//src/rp2_common/pico_clib_interface"], 18 | ) 19 | 20 | cc_library( 21 | name = "pico_platform_panic", 22 | srcs = ["panic.c"], 23 | hdrs = ["include/pico/platform/panic.h"], 24 | includes = ["include"], 25 | target_compatible_with = compatible_with_rp2(), 26 | deps = [ 27 | "//src/rp2_common/pico_printf", 28 | ], 29 | alwayslink = True, 30 | ) 31 | -------------------------------------------------------------------------------- /src/rp2_common/pico_platform_panic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_platform_panic) 2 | pico_add_library(pico_platform_panic) 3 | 4 | target_sources(pico_platform_panic INTERFACE 5 | ${CMAKE_CURRENT_LIST_DIR}/panic.c 6 | ) 7 | 8 | target_include_directories(pico_platform_panic_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 9 | endif() -------------------------------------------------------------------------------- /src/rp2_common/pico_platform_panic/include/pico/platform/panic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_PLATFORM_PANIC_H 8 | #define _PICO_PLATFORM_PANIC_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #ifndef __ASSEMBLER__ 15 | 16 | /*! \brief Panics with the message "Unsupported" 17 | * \ingroup pico_platform 18 | * \see panic 19 | */ 20 | void __attribute__((noreturn)) panic_unsupported(void); 21 | 22 | /*! \brief Displays a panic message and halts execution 23 | * \ingroup pico_platform 24 | * 25 | * An attempt is made to output the message to all registered STDOUT drivers 26 | * after which this method executes a BKPT instruction. 27 | * 28 | * @param fmt format string (printf-like) 29 | * @param ... printf-like arguments 30 | */ 31 | void __attribute__((noreturn)) panic(const char *fmt, ...); 32 | 33 | #ifdef NDEBUG 34 | #define panic_compact(...) panic(__VA_ARGS__) 35 | #else 36 | #define panic_compact(...) panic("") 37 | #endif 38 | #endif 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif -------------------------------------------------------------------------------- /src/rp2_common/pico_platform_sections/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_platform_sections", 7 | hdrs = ["include/pico/platform/sections.h"], 8 | includes = ["include"], 9 | target_compatible_with = compatible_with_rp2(), 10 | ) 11 | -------------------------------------------------------------------------------- /src/rp2_common/pico_platform_sections/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_platform_sections) 2 | pico_add_library(pico_platform_sections) 3 | 4 | target_include_directories(pico_platform_sections_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 5 | endif() 6 | -------------------------------------------------------------------------------- /src/rp2_common/pico_printf/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Marco Paland 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 all 13 | 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 THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /src/rp2_common/pico_printf/printf_none.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico/asm_helper.S" 8 | #include "pico/bootrom/sf_table.h" 9 | 10 | pico_default_asm_setup 11 | 12 | wrapper_func sprintf 13 | wrapper_func snprintf 14 | wrapper_func vsnprintf 15 | // pico_stdio may itself overwrite printf, so we want to support that (hence weak), but override it 16 | // here to in case pico_stdio is not used 17 | weak_wrapper_func printf 18 | regular_func printf_none_assert 19 | #ifndef __riscv 20 | push {lr} // keep stack trace sane 21 | ldr r0, =str 22 | bl panic 23 | #else 24 | la a0, str 25 | call panic 26 | #endif 27 | 28 | str: 29 | .asciz "printf support is disabled" -------------------------------------------------------------------------------- /src/rp2_common/pico_rand/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_rand", 7 | srcs = ["rand.c"], 8 | hdrs = ["include/pico/rand.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/common/pico_time", 13 | "//src/rp2_common:hardware_structs", 14 | "//src/rp2_common:pico_platform", 15 | "//src/rp2_common/hardware_clocks", 16 | "//src/rp2_common/hardware_sync", 17 | "//src/rp2_common/pico_unique_id", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /src/rp2_common/pico_rand/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_rand) 2 | 3 | target_sources(pico_rand INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/rand.c 5 | ) 6 | 7 | target_include_directories(pico_rand_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 8 | 9 | pico_mirrored_target_link_libraries(pico_rand INTERFACE 10 | pico_unique_id 11 | hardware_clocks 12 | hardware_timer 13 | hardware_sync 14 | ) 15 | -------------------------------------------------------------------------------- /src/rp2_common/pico_runtime_init/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_runtime_init) 2 | 3 | target_sources(pico_runtime_init INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/runtime_init.c 5 | ${CMAKE_CURRENT_LIST_DIR}/runtime_init_clocks.c 6 | ${CMAKE_CURRENT_LIST_DIR}/runtime_init_stack_guard.c 7 | ) 8 | 9 | target_include_directories(pico_runtime_init_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 10 | 11 | pico_mirrored_target_link_libraries(pico_runtime_init INTERFACE 12 | pico_base 13 | ) 14 | 15 | if (TARGET hardware_clocks) 16 | pico_mirrored_target_link_libraries(pico_runtime_init INTERFACE hardware_clocks hardware_timer hardware_vreg) 17 | endif() 18 | 19 | # pico/runtime_init.h includes pico/runtime.h 20 | target_link_libraries(pico_runtime_init_headers INTERFACE pico_runtime_headers) -------------------------------------------------------------------------------- /src/rp2_common/pico_sha256/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_sha256", 7 | srcs = ["sha256.c"], 8 | hdrs = ["include/pico/sha256.h"], 9 | defines = ["LIB_PICO_SHA256=1"], 10 | implementation_deps = ["//src/rp2_common/pico_bootrom"], 11 | includes = ["include"], 12 | target_compatible_with = compatible_with_rp2(), 13 | deps = [ 14 | "//src/common/pico_time", 15 | "//src/rp2_common:hardware_structs", 16 | "//src/rp2_common/hardware_dma", 17 | "//src/rp2_common/hardware_sha256", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /src/rp2_common/pico_sha256/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET hardware_sha256) 2 | return() 3 | endif() 4 | 5 | pico_add_library(pico_sha256) 6 | 7 | target_sources(pico_sha256 INTERFACE 8 | ${CMAKE_CURRENT_LIST_DIR}/sha256.c 9 | ) 10 | 11 | target_include_directories(pico_sha256_headers SYSTEM INTERFACE 12 | ${CMAKE_CURRENT_LIST_DIR}/include 13 | ) 14 | 15 | pico_mirrored_target_link_libraries(pico_sha256 INTERFACE 16 | hardware_dma 17 | hardware_sha256 18 | pico_sync 19 | ) 20 | -------------------------------------------------------------------------------- /src/rp2_common/pico_standard_binary_info/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_standard_binary_info) 2 | pico_add_library(pico_standard_binary_info) 3 | 4 | target_sources(pico_standard_binary_info INTERFACE 5 | ${CMAKE_CURRENT_LIST_DIR}/standard_binary_info.c 6 | ) 7 | 8 | pico_mirrored_target_link_libraries(pico_standard_binary_info INTERFACE pico_binary_info) 9 | endif() -------------------------------------------------------------------------------- /src/rp2_common/pico_standard_link/doc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup pico_standard_link pico_standard_link 3 | * \brief Setup for link options for a standard SDK executable 4 | * 5 | * This includes 6 | * - C runtime initialization 7 | * - Linker scripts for 'default', 'no_flash', 'blocked_ram' and 'copy_to_ram' binaries 8 | * - 'Binary Information' support 9 | * - Linker option control 10 | */ 11 | -------------------------------------------------------------------------------- /src/rp2_common/pico_standard_link/pico_flash_region.template.ld: -------------------------------------------------------------------------------- 1 | FLASH(rx) : ORIGIN = 0x10000000, LENGTH = ${PICO_FLASH_SIZE_BYTES_STRING} -------------------------------------------------------------------------------- /src/rp2_common/pico_stdio/include/pico/stdio/driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_STDIO_DRIVER_H 8 | #define _PICO_STDIO_DRIVER_H 9 | 10 | #include "pico/stdio.h" 11 | 12 | struct stdio_driver { 13 | void (*out_chars)(const char *buf, int len); 14 | void (*out_flush)(void); 15 | int (*in_chars)(char *buf, int len); 16 | void (*set_chars_available_callback)(void (*fn)(void*), void *param); 17 | stdio_driver_t *next; 18 | #if PICO_STDIO_ENABLE_CRLF_SUPPORT 19 | bool last_ended_with_cr; 20 | bool crlf_enabled; 21 | #endif 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/rp2_common/pico_stdio_rtt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_stdio_rtt) 2 | 3 | target_sources(pico_stdio_rtt INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/stdio_rtt.c 5 | ${CMAKE_CURRENT_LIST_DIR}/SEGGER/RTT/SEGGER_RTT.c) 6 | 7 | set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/SEGGER/RTT/SEGGER_RTT.c 8 | PROPERTIES COMPILE_OPTIONS "-Wno-cast-qual;-Wno-cast-align") 9 | 10 | target_include_directories(pico_stdio_rtt_headers INTERFACE 11 | ${CMAKE_CURRENT_LIST_DIR}/include 12 | ${CMAKE_CURRENT_LIST_DIR}/SEGGER/RTT 13 | ${CMAKE_CURRENT_LIST_DIR}/SEGGER/Config) 14 | 15 | pico_mirrored_target_link_libraries(pico_stdio_rtt INTERFACE pico_stdio) 16 | -------------------------------------------------------------------------------- /src/rp2_common/pico_stdio_rtt/stdio_rtt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico/binary_info.h" 8 | #include "pico/stdio/driver.h" 9 | #include "pico/stdio_rtt.h" 10 | #include "SEGGER_RTT.h" 11 | 12 | #if PICO_NO_BI_STDIO_RTT 13 | #define stdio_bi_decl_if_func_used(x) 14 | #else 15 | #define stdio_bi_decl_if_func_used bi_decl_if_func_used 16 | #endif 17 | 18 | void stdio_rtt_init(void) { 19 | SEGGER_RTT_Init(); 20 | stdio_set_driver_enabled(&stdio_rtt, true); 21 | stdio_bi_decl_if_func_used(bi_program_feature("RTT stdin / stdout")); 22 | } 23 | 24 | void stdio_rtt_deinit(void) { 25 | stdio_set_driver_enabled(&stdio_rtt, false); 26 | } 27 | 28 | static void stdio_rtt_out_chars(const char *buf, int length) { 29 | SEGGER_RTT_Write(0, buf, (unsigned)length); 30 | } 31 | 32 | static int stdio_rtt_in_chars(char *buf, int length) { 33 | return (int)SEGGER_RTT_Read(0, buf, (unsigned)length); 34 | } 35 | 36 | stdio_driver_t stdio_rtt = { 37 | .out_chars = stdio_rtt_out_chars, 38 | .in_chars = stdio_rtt_in_chars, 39 | #if PICO_STDIO_ENABLE_CRLF_SUPPORT 40 | .crlf_enabled = PICO_STDIO_RTT_DEFAULT_CRLF 41 | #endif 42 | }; 43 | -------------------------------------------------------------------------------- /src/rp2_common/pico_stdio_semihosting/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_stdio_semihosting) 2 | 3 | target_sources(pico_stdio_semihosting INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/stdio_semihosting.c 5 | ) 6 | 7 | target_include_directories(pico_stdio_semihosting_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 8 | 9 | pico_mirrored_target_link_libraries(pico_stdio_semihosting INTERFACE pico_stdio) 10 | -------------------------------------------------------------------------------- /src/rp2_common/pico_stdio_uart/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_stdio_uart) 2 | 3 | target_sources(pico_stdio_uart INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/stdio_uart.c 5 | ) 6 | 7 | target_include_directories(pico_stdio_uart_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 8 | 9 | pico_mirrored_target_link_libraries(pico_stdio_uart INTERFACE pico_stdio) -------------------------------------------------------------------------------- /src/rp2_common/pico_stdio_usb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (TARGET tinyusb_device_unmarked) 2 | pico_add_library(pico_stdio_usb) 3 | 4 | target_include_directories(pico_stdio_usb_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 5 | 6 | target_sources(pico_stdio_usb INTERFACE 7 | ${CMAKE_CURRENT_LIST_DIR}/reset_interface.c 8 | ${CMAKE_CURRENT_LIST_DIR}/stdio_usb.c 9 | ${CMAKE_CURRENT_LIST_DIR}/stdio_usb_descriptors.c 10 | ) 11 | 12 | pico_mirrored_target_link_libraries(pico_stdio_usb INTERFACE 13 | pico_stdio 14 | pico_time 15 | pico_unique_id 16 | pico_usb_reset_interface 17 | ) 18 | target_link_libraries(pico_stdio_usb INTERFACE 19 | tinyusb_device_unmarked 20 | ) 21 | # PICO_CMAKE_CONFIG: PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS, Maximum number of milliseconds to wait during initialization for a CDC connection from the host (negative means indefinite) during initialization, type=int, default=0, group=pico_stdio_usb 22 | if (PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS) 23 | target_compile_definitions(pico_stdio_usb INTERFACE 24 | PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS=${PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS} 25 | ) 26 | endif() 27 | endif() 28 | -------------------------------------------------------------------------------- /src/rp2_common/pico_stdio_usb/include/pico/stdio_usb/reset_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_STDIO_USB_RESET_INTERFACE_H 8 | #define _PICO_STDIO_USB_RESET_INTERFACE_H 9 | 10 | // definitions have been moved here 11 | #include "pico/usb_reset_interface.h" 12 | 13 | #endif -------------------------------------------------------------------------------- /src/rp2_common/pico_stdlib/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_stdlib", 7 | srcs = ["stdlib.c"], 8 | target_compatible_with = compatible_with_rp2(), 9 | deps = [ 10 | "//src/common/pico_binary_info", 11 | "//src/common/pico_stdlib_headers", 12 | "//src/rp2_common:pico_platform", 13 | "//src/rp2_common/hardware_clocks", 14 | "//src/rp2_common/hardware_pll", 15 | "//src/rp2_common/pico_stdio", 16 | "//src/rp2_common/pico_stdio_semihosting", 17 | "//src/rp2_common/pico_stdio_uart", 18 | "//src/rp2_common/pico_stdio_usb", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /src/rp2_common/pico_stdlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_stdlib) 2 | pico_add_impl_library(pico_stdlib) 3 | target_sources(pico_stdlib INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/stdlib.c 5 | ) 6 | 7 | set(PICO_STDLIB_LIBRARIES 8 | hardware_gpio 9 | hardware_uart 10 | hardware_divider 11 | pico_time 12 | pico_util 13 | pico_platform 14 | pico_runtime 15 | pico_stdio 16 | ) 17 | foreach(LIB IN LISTS PICO_STDLIB_LIBRARIES) 18 | if (TARGET ${LIB}) 19 | pico_mirrored_target_link_libraries(pico_stdlib INTERFACE ${LIB}) 20 | endif() 21 | endforeach() 22 | endif() 23 | -------------------------------------------------------------------------------- /src/rp2_common/pico_stdlib/stdlib.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 | #if LIB_PICO_STDIO_UART 9 | #include "pico/stdio_uart.h" 10 | #else 11 | #include "pico/binary_info.h" 12 | #endif 13 | 14 | void setup_default_uart(void) { 15 | #if LIB_PICO_STDIO_UART 16 | stdio_uart_init(); 17 | #elif defined(PICO_DEFAULT_UART_BAUD_RATE) && defined(PICO_DEFAULT_UART_TX_PIN) && defined(PICO_DEFAULT_UART_RX_PIN) 18 | // this is mostly for backwards compatibility - stdio_uart_init is a bit more nuanced, and usually likely to be present 19 | uart_init(uart_default, PICO_DEFAULT_UART_BAUD_RATE); 20 | if (PICO_DEFAULT_UART_TX_PIN >= 0) 21 | gpio_set_function(PICO_DEFAULT_UART_TX_PIN, GPIO_FUNC_UART); 22 | if (PICO_DEFAULT_UART_RX_PIN >= 0) 23 | gpio_set_function(PICO_DEFAULT_UART_RX_PIN, GPIO_FUNC_UART); 24 | bi_decl_if_func_used(bi_2pins_with_func(PICO_DEFAULT_UART_RX_PIN, PICO_DEFAULT_UART_TX_PIN, GPIO_FUNC_UART)); 25 | #endif 26 | } 27 | -------------------------------------------------------------------------------- /src/rp2_common/pico_time_adapter/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_time_adapter", 7 | hdrs = ["include/pico/time_adapter.h"], 8 | includes = ["include"], 9 | target_compatible_with = compatible_with_rp2(), 10 | deps = [ 11 | "//src/common/pico_base_headers", 12 | "//src/rp2_common/hardware_irq", 13 | "//src/rp2_common/hardware_timer", 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /src/rp2_common/pico_time_adapter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_time_adapter) 2 | 3 | target_include_directories(pico_time_adapter_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 4 | 5 | pico_mirrored_target_link_libraries(pico_time INTERFACE pico_time_adapter) -------------------------------------------------------------------------------- /src/rp2_common/pico_unique_id/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "pico_unique_id", 7 | srcs = ["unique_id.c"], 8 | hdrs = ["include/pico/unique_id.h"], 9 | includes = ["include"], 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/rp2_common:pico_platform", 13 | "//src/rp2_common/hardware_flash", 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /src/rp2_common/pico_unique_id/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_unique_id) 2 | 3 | target_sources(pico_unique_id INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/unique_id.c 5 | ) 6 | 7 | target_include_directories(pico_unique_id_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 8 | 9 | pico_mirrored_target_link_libraries(pico_unique_id INTERFACE hardware_flash) 10 | -------------------------------------------------------------------------------- /src/rp2_common/tinyusb/doc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup tinyusb_device tinyusb_device 3 | * \brief TinyUSB Device-mode support for the RP2040. The TinyUSB documentation site can be found here. 4 | * 5 | * \defgroup tinyusb_host tinyusb_host 6 | * \brief TinyUSB Host-mode support for the RP2040. 7 | */ 8 | -------------------------------------------------------------------------------- /src/rp2_common/tinyusb/include/bsp/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // TinyUSB changed the location of this file, so we'll redirect to be friendly to end users 8 | #ifndef _BSP_BOARD_H 9 | #define _BSP_BOARD_H 10 | #include "bsp/board_api.h" 11 | #endif 12 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(pico_test) 2 | 3 | add_subdirectory(pico_stdlib_test) 4 | add_subdirectory(pico_stdio_test) 5 | add_subdirectory(pico_time_test) 6 | add_subdirectory(pico_divider_test) 7 | if (PICO_ON_DEVICE) 8 | add_subdirectory(pico_float_test) 9 | add_subdirectory(kitchen_sink) 10 | add_subdirectory(hardware_irq_test) 11 | add_subdirectory(hardware_pwm_test) 12 | add_subdirectory(hardware_sync_spin_lock_test) 13 | add_subdirectory(cmsis_test) 14 | add_subdirectory(pico_sem_test) 15 | add_subdirectory(pico_sha256_test) 16 | endif() 17 | -------------------------------------------------------------------------------- /test/cmsis_test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "cmsis_test", 7 | testonly = True, 8 | srcs = ["cmsis_test.c"], 9 | target_compatible_with = compatible_with_rp2(), 10 | deps = [ 11 | "//bazel/config:PICO_CMSIS_PATH", 12 | "//src/rp2_common:pico_platform", 13 | "//src/rp2_common/pico_stdlib", 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /test/cmsis_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # todo remove check 2 | if (NOT PICO_RISCV) 3 | add_executable(cmsis_test cmsis_test.c) 4 | 5 | target_link_libraries(cmsis_test PRIVATE pico_stdlib cmsis_core) 6 | pico_add_extra_outputs(cmsis_test) 7 | endif() -------------------------------------------------------------------------------- /test/cmsis_test/cmsis_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if PICO_RP2040 4 | #include "RP2040.h" 5 | #else 6 | #include "RP2350.h" 7 | #endif 8 | #include "pico/stdlib.h" 9 | #include "hardware/irq.h" 10 | 11 | __STATIC_FORCEINLINE int some_function(int i) { 12 | return __CLZ(i); 13 | } 14 | 15 | static bool pendsv_called, irq_handler_called; 16 | 17 | void PendSV_Handler(void) { 18 | pendsv_called = true; 19 | } 20 | 21 | void DMA_IRQ_0_Handler(void) { 22 | irq_handler_called = true; 23 | irq_clear(DMA_IRQ_0_IRQn); 24 | } 25 | 26 | int main(void) { 27 | stdio_init_all(); 28 | for(int i=0;i<10;i++) { 29 | printf("%d %d\n", i, some_function(i)); 30 | } 31 | SCB->ICSR = SCB_ICSR_PENDSVSET_Msk; 32 | printf("PENDSV: "); 33 | puts(pendsv_called ? "SUCCESS" : "FAILURE"); 34 | printf("DMA_IRQ_0: "); 35 | irq_set_enabled(DMA_IRQ_0_IRQn, true); 36 | irq_set_pending(DMA_IRQ_0_IRQn); 37 | puts(irq_handler_called ? "SUCCESS" : "FAILURE"); 38 | bool ok = pendsv_called && irq_handler_called; 39 | puts(ok ? "PASSED" : "FAILED"); 40 | return !ok; 41 | } 42 | -------------------------------------------------------------------------------- /test/hardware_irq_test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "hardware_irq_test", 7 | testonly = True, 8 | srcs = ["hardware_irq_test.c"], 9 | target_compatible_with = compatible_with_rp2(), 10 | deps = [ 11 | "//src/common/pico_time", 12 | "//src/rp2_common:hardware_structs", 13 | "//src/rp2_common/hardware_dma", 14 | "//src/rp2_common/hardware_irq", 15 | "//src/rp2_common/pico_stdlib", 16 | "//test/pico_test", 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /test/hardware_irq_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(hardware_irq_test hardware_irq_test.c) 2 | 3 | target_link_libraries(hardware_irq_test PRIVATE pico_test hardware_irq hardware_dma) 4 | pico_add_extra_outputs(hardware_irq_test) -------------------------------------------------------------------------------- /test/hardware_pwm_test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "hardware_pwm_test", 7 | testonly = True, 8 | srcs = ["hardware_pwm_test.c"], 9 | target_compatible_with = compatible_with_rp2(), 10 | deps = [ 11 | "//src/common/pico_time", 12 | "//src/rp2_common/hardware_irq", 13 | "//src/rp2_common/hardware_pwm", 14 | "//src/rp2_common/hardware_resets", 15 | "//src/rp2_common/pico_stdlib", 16 | "//test/pico_test", 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /test/hardware_pwm_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(hardware_pwm_test hardware_pwm_test.c) 2 | 3 | target_link_libraries(hardware_pwm_test PRIVATE pico_test hardware_pwm) 4 | pico_add_extra_outputs(hardware_pwm_test) -------------------------------------------------------------------------------- /test/hardware_sync_spin_lock_test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | load("//bazel/util:transition.bzl", "extra_copts_for_all_deps") 3 | 4 | package(default_visibility = ["//visibility:public"]) 5 | 6 | cc_binary( 7 | name = "hardware_sync_spin_lock_test_actual", 8 | testonly = True, 9 | srcs = ["hardware_sync_spin_lock_test.c"], 10 | tags = ["manual"], 11 | deps = [ 12 | "//src/rp2_common/hardware_sync", 13 | "//src/rp2_common/hardware_sync_spin_lock", 14 | "//src/rp2_common/pico_multicore", 15 | "//src/rp2_common/pico_stdio", 16 | "//test/pico_test", 17 | ], 18 | ) 19 | 20 | extra_copts_for_all_deps( 21 | name = "hardware_sync_spin_lock_test", 22 | testonly = True, 23 | src = ":hardware_sync_spin_lock_test_actual", 24 | extra_copts = ["-DPICO_STDOUT_MUTEX=0"], 25 | target_compatible_with = compatible_with_rp2(), 26 | ) 27 | -------------------------------------------------------------------------------- /test/hardware_sync_spin_lock_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(hardware_sync_spin_lock_test hardware_sync_spin_lock_test.c) 2 | 3 | target_link_libraries(hardware_sync_spin_lock_test PRIVATE pico_test hardware_sync pico_multicore) 4 | pico_add_extra_outputs(hardware_sync_spin_lock_test) 5 | 6 | target_compile_definitions(hardware_sync_spin_lock_test PRIVATE 7 | PICO_STDOUT_MUTEX=0 8 | ) 9 | -------------------------------------------------------------------------------- /test/kitchen_sink/kitchen_sink_cpp.cpp: -------------------------------------------------------------------------------- 1 | #include "kitchen_sink.c" -------------------------------------------------------------------------------- /test/kitchen_sink/lwipopts.h: -------------------------------------------------------------------------------- 1 | #ifndef _LWIPOPTS_H 2 | #define _LWIPOPTS_H 3 | 4 | // dummy lwip opts to allow compilation 5 | 6 | #define NO_SYS 1 7 | #define LWIP_DHCP 1 8 | #define LWIP_RAW 1 9 | #define LWIP_NETIF_HOSTNAME 1 10 | #define LWIP_NETIF_STATUS_CALLBACK 1 11 | #define LWIP_DNS 1 12 | #define LWIP_SOCKET 0 13 | #define LWIP_NETCONN 0 14 | #endif -------------------------------------------------------------------------------- /test/pico_divider_test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "pico_divider_test", 7 | testonly = True, 8 | srcs = ["pico_divider_test.c"], 9 | target_compatible_with = compatible_with_rp2(), 10 | deps = [ 11 | "//src/rp2_common/pico_divider", 12 | "//src/rp2_common/pico_stdlib", 13 | ] + select({ 14 | "//bazel/constraint:host": [], 15 | "//conditions:default": [ 16 | "//src/rp2_common/hardware_dma", 17 | "//src/rp2_common/hardware_irq", 18 | "//src/rp2_common/hardware_vreg", 19 | ], 20 | }), 21 | ) 22 | 23 | cc_binary( 24 | name = "pico_divider_nesting_test", 25 | testonly = True, 26 | srcs = ["pico_divider_nesting_test.c"], 27 | target_compatible_with = compatible_with_rp2(), 28 | deps = [ 29 | "//src/rp2_common/pico_divider", 30 | "//src/rp2_common/pico_stdlib", 31 | ] + select({ 32 | "//bazel/constraint:host": [], 33 | "//conditions:default": [ 34 | "//src/rp2_common/hardware_dma", 35 | "//src/rp2_common/hardware_irq", 36 | "//src/rp2_common/hardware_vreg", 37 | ], 38 | }), 39 | ) 40 | -------------------------------------------------------------------------------- /test/pico_float_test/llvm/call_apsr.S: -------------------------------------------------------------------------------- 1 | //===-- call_apsr.S - Helpers for ARM EABI floating point tests -----------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is dual licensed under the MIT and the University of Illinois Open 6 | // Source Licenses. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements helpers for ARM EABI floating point tests for the 11 | // compiler_rt library. 12 | // 13 | //===- 14 | 15 | #include "pico/asm_helper.S" 16 | 17 | pico_default_asm_setup 18 | 19 | .align 2 20 | 21 | .global call_apsr_f 22 | .type call_apsr_f,%function 23 | .thumb_func 24 | call_apsr_f: 25 | push {lr} 26 | blx r2 27 | mrs r0, apsr 28 | pop {pc} 29 | 30 | .global call_apsr_d 31 | .type call_apsr_d,%function 32 | .thumb_func 33 | call_apsr_d: 34 | push {r4, lr} 35 | ldr r4, [sp, #8] 36 | blx r4 37 | mrs r0, apsr 38 | pop {r4, pc} 39 | -------------------------------------------------------------------------------- /test/pico_sem_test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_binary( 4 | name = "pico_sem_test", 5 | testonly = True, 6 | srcs = ["pico_sem_test.c"], 7 | deps = [ 8 | "//src/common/pico_sync", 9 | "//test/pico_test", 10 | ] + select({ 11 | "//bazel/constraint:host": ["//src/host/pico_stdlib"], 12 | "//conditions:default": ["//src/rp2_common/pico_stdlib"], 13 | }), 14 | ) 15 | -------------------------------------------------------------------------------- /test/pico_sem_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(pico_sem_test pico_sem_test.c) 2 | 3 | target_link_libraries(pico_sem_test PRIVATE pico_test pico_sync) 4 | pico_add_extra_outputs(pico_sem_test) 5 | -------------------------------------------------------------------------------- /test/pico_sem_test/pico_sem_test.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | 9 | #include "pico/sem.h" 10 | #include "pico/test.h" 11 | #include "pico/stdio.h" 12 | 13 | PICOTEST_MODULE_NAME("SEM", "semaphore test"); 14 | 15 | int main() { 16 | semaphore_t sem; 17 | 18 | stdio_init_all(); 19 | sem_init(&sem, 1, 1); 20 | 21 | PICOTEST_START(); 22 | 23 | PICOTEST_START_SECTION("sem_try_acquire"); 24 | PICOTEST_CHECK(sem_try_acquire(&sem), "available permit not acquired"); 25 | PICOTEST_CHECK(!sem_try_acquire(&sem), "success with no permits"); 26 | PICOTEST_END_SECTION(); 27 | 28 | PICOTEST_END_TEST(); 29 | } 30 | -------------------------------------------------------------------------------- /test/pico_sha256_test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "pico_sha256_test", 7 | testonly = True, 8 | srcs = ["pico_sha256_test.c"], 9 | target_compatible_with = compatible_with_rp2(), 10 | deps = [ 11 | "//src/rp2_common/pico_sha256", 12 | "//src/rp2_common/pico_stdlib", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /test/pico_sha256_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET hardware_sha256) 2 | return() 3 | endif() 4 | 5 | add_executable(pico_sha256_test 6 | pico_sha256_test.c 7 | ) 8 | target_link_libraries(pico_sha256_test 9 | pico_stdlib 10 | pico_sha256 11 | ) 12 | target_include_directories(pico_sha256_test PRIVATE 13 | ${CMAKE_CURRENT_LIST_DIR} 14 | ) 15 | pico_add_extra_outputs(pico_sha256_test) 16 | -------------------------------------------------------------------------------- /test/pico_stdio_test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "pico_stdio_test", 7 | testonly = True, 8 | srcs = ["pico_stdio_test.c"], 9 | # Host doesn't support PICO_TIME_NO_ALARM_SUPPORT without pico_host_sdl. 10 | target_compatible_with = compatible_with_rp2(), 11 | deps = [ 12 | "//src/rp2_common/pico_multicore", 13 | "//src/rp2_common/pico_stdlib", 14 | "//test/pico_test", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /test/pico_stdlib_test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_binary( 4 | name = "pico_stdlib_test", 5 | testonly = True, 6 | srcs = ["pico_stdlib_test.c"], 7 | deps = select({ 8 | "//bazel/constraint:host": [ 9 | "//src/host/pico_bit_ops", 10 | "//src/host/pico_stdlib", 11 | ], 12 | "//conditions:default": [ 13 | "//src/rp2_common/pico_bit_ops", 14 | "//src/rp2_common/pico_stdlib", 15 | ], 16 | }) + [ 17 | "//src/common/pico_time", # TODO: This header should be #include'ed from source. 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /test/pico_stdlib_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(pico_stdlib_test pico_stdlib_test.c) 2 | 3 | target_compile_definitions(pico_stdlib_test PRIVATE 4 | #PICO_ENTER_USB_BOOT_ON_EXIT=1 5 | ) 6 | 7 | target_link_libraries(pico_stdlib_test PRIVATE pico_stdlib) 8 | pico_add_extra_outputs(pico_stdlib_test) 9 | -------------------------------------------------------------------------------- /test/pico_test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | cc_library( 4 | name = "pico_test", 5 | testonly = True, 6 | hdrs = [ 7 | "include/pico/test.h", 8 | "include/pico/test/xrand.h", 9 | ], 10 | includes = ["include"], 11 | deps = [ 12 | "//src:pico_platform", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /test/pico_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(pico_test INTERFACE) 2 | 3 | target_include_directories(pico_test INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 4 | target_link_libraries(pico_test INTERFACE pico_stdlib) 5 | -------------------------------------------------------------------------------- /test/pico_time_test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel:defs.bzl", "compatible_with_rp2") 2 | load("//bazel/util:transition.bzl", "extra_copts_for_all_deps") 3 | 4 | package(default_visibility = ["//visibility:public"]) 5 | 6 | cc_binary( 7 | name = "pico_time_test_actual", 8 | testonly = True, 9 | srcs = ["pico_time_test.c"], 10 | tags = ["manual"], # Built via pico_time_test. 11 | # Doesn't appear to work on host builds yet. 12 | target_compatible_with = compatible_with_rp2(), 13 | deps = [ 14 | "//src/rp2_common/pico_stdlib", 15 | "//src/rp2_common/pico_aon_timer", 16 | "//test/pico_test", 17 | ], 18 | ) 19 | 20 | extra_copts_for_all_deps( 21 | name = "pico_time_test", 22 | testonly = True, 23 | src = ":pico_time_test_actual", 24 | extra_copts = ["-DPICO_TIME_DEFAULT_ALARM_POOL_MAX_TIMERS=250"], 25 | # Host doesn't support PICO_TIME_NO_ALARM_SUPPORT without pico_host_sdl. 26 | target_compatible_with = compatible_with_rp2(), 27 | ) 28 | -------------------------------------------------------------------------------- /test/pico_time_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT PICO_TIME_NO_ALARM_SUPPORT) 2 | add_executable(pico_time_test pico_time_test.c) 3 | target_compile_definitions(pico_time_test PRIVATE 4 | PICO_TIME_DEFAULT_ALARM_POOL_MAX_TIMERS=250 5 | ) 6 | target_link_libraries(pico_time_test PRIVATE pico_test) 7 | if (PICO_RP2040) 8 | target_link_libraries(pico_time_test PRIVATE pico_aon_timer) 9 | endif() 10 | pico_add_extra_outputs(pico_time_test) 11 | endif() -------------------------------------------------------------------------------- /tools/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | -------------------------------------------------------------------------------- /tools/check_all_board_headers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | for HEADER in src/boards/include/boards/*.h; do 3 | tools/check_board_header.py $HEADER 4 | if [[ $? -ne 0 ]]; then 5 | break 6 | fi 7 | done 8 | -------------------------------------------------------------------------------- /tools/check_configs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Little script to find possibly-misnamed CONFIG lines 3 | for CONF in PICO_CONFIG PICO_CMAKE_CONFIG PICO_BUILD_DEFINE; do 4 | for DEF in $(git grep "$CONF:" | sed -n "s/.*$CONF: \+\(\w\+\).*/\1/p"); do 5 | if [ $(git grep "$DEF" | wc -l) -lt 2 ]; then 6 | echo "$CONF: $DEF only appears once" 7 | fi 8 | done 9 | done 10 | -------------------------------------------------------------------------------- /tools/pioasm/cmake/pioasmConfig.cmake: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pioasm) 2 | include("${CMAKE_CURRENT_LIST_DIR}/pioasmTargets.cmake") 3 | endif() 4 | -------------------------------------------------------------------------------- /tools/pioasm/hex_output.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "output_format.h" 8 | #include 9 | 10 | struct hex_output : public output_format { 11 | struct factory { 12 | factory() { 13 | output_format::add(new hex_output()); 14 | } 15 | }; 16 | 17 | hex_output() : output_format("hex") {} 18 | 19 | std::string get_description() { 20 | return "Raw hex output (only valid for single program inputs)"; 21 | } 22 | 23 | virtual int output(std::string destination, std::vector output_options, 24 | const compiled_source &source) { 25 | FILE *out = open_single_output(destination); 26 | if (!out) return 1; 27 | 28 | if (source.programs.size() > 1) { 29 | // todo don't have locations any more! 30 | std::cerr << "error: hex output only supports a single program input\n"; 31 | return 1; 32 | } 33 | for (const auto &i : source.programs[0].instructions) { 34 | fprintf(out, "%04x\n", i); 35 | } 36 | if (out != stdout) { fclose(out); } 37 | return 0; 38 | } 39 | }; 40 | 41 | static hex_output::factory creator; 42 | -------------------------------------------------------------------------------- /tools/pioasm/pio_disassembler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PIO_DISASSEMBLER_H 8 | #define _PIO_DISASSEMBLER_H 9 | 10 | #ifdef __cplusplus 11 | 12 | #include 13 | #include 14 | #include "pio_types.h" 15 | 16 | typedef unsigned int uint; 17 | 18 | std::string disassemble(uint inst, uint sideset_bits, bool sideset_opt); 19 | extern "C" void disassemble(char *buf, int buf_len, uint inst, uint sideset_bits, bool sideset_opt); 20 | #else 21 | void disassemble(char *buf, int buf_len, uint inst, uint sideset_bits, bool sideset_opt); 22 | #endif 23 | 24 | #endif -------------------------------------------------------------------------------- /tools/pioasm/pio_enums.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PIO_ENUMS_H 8 | #define _PIO_ENUMS_H 9 | 10 | typedef unsigned int uint; 11 | 12 | enum struct fifo_config { 13 | txrx = 0, 14 | tx = 1, 15 | rx = 2, 16 | txget = 3, 17 | txput = 4, 18 | putget = 5, 19 | }; 20 | 21 | #endif -------------------------------------------------------------------------------- /tools/pioasm/test/amethyst.pio: -------------------------------------------------------------------------------- 1 | .pio_version rp2350 2 | .pio_version ONE 3 | 4 | .pio_version 0 5 | 6 | .program bar 7 | .fifo tx 8 | 9 | .program foo 10 | .pio_version 1 11 | .clock_div 3.6 12 | //wait fling 13 | .fifo putget 14 | .out 3 auto 15 | wait jmppin 16 | wait 0 jmppin + 3 17 | mov pindirs, null 18 | set pins, 3 19 | irq 3 rel 20 | irq next 3 21 | irq prev 3 22 | set pins, (1 << 3) 23 | //irq prev 3 rel 24 | wait 1 irq 2 rel 25 | wait 1 irq next 2 26 | wait 1 irq prev 4 27 | .define flan 1 28 | mov osr, rxfifo[flan] 29 | mov rxfifo[y], isr 30 | 31 | //wait 0 jmppin + 4 32 | 33 | .program wibble 34 | .pio_version 0 35 | wait gpio 23 36 | wait gpio 7 37 | 38 | .program wibble2 39 | .pio_version 1 40 | wait gpio 23 41 | wait gpio 40 42 | 43 | .program wibble3 44 | .pio_version 1 45 | .mov_status txfifo < 12 46 | .mov_status irq next set 3 47 | 48 | .program python 49 | .pio_version 1 50 | wait 0 jmppin 51 | wait 0 jmppin + 3 52 | mov x, !x 53 | .word 0x1234 --------------------------------------------------------------------------------