├── .gitignore ├── FlashDev.c ├── FlashOS.h ├── FlashPrg.c ├── LICENSE ├── README.md ├── documents └── Pictures │ ├── Debug_printf_Viewer.png │ ├── EnableThePikaBeforeBuild.png │ ├── Reset_Pico.png │ └── enable_lcd_1in3 ├── pico-sdk ├── .github │ ├── pull_request_template.md │ └── workflows │ │ ├── choco_packages.config │ │ ├── cmake.yml │ │ ├── macOS.yml │ │ ├── multi-gcc.yml │ │ ├── scripts │ │ └── generate_multi_gcc_workflow.py │ │ └── windows.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE.TXT ├── README.md ├── cmake │ ├── Platform │ │ └── PICO.cmake │ ├── pico_pre_load_platform.cmake │ ├── pico_pre_load_toolchain.cmake │ ├── pico_utils.cmake │ └── preload │ │ ├── platforms │ │ ├── host.cmake │ │ ├── pico │ │ │ └── pico.cmake │ │ └── rp2040.cmake │ │ └── toolchains │ │ ├── find_compiler.cmake │ │ ├── pico_arm_clang.cmake │ │ ├── pico_arm_clang_arm.cmake │ │ ├── pico_arm_gcc.cmake │ │ └── set_flags.cmake ├── docs │ ├── CMakeLists.txt │ ├── Doxyfile.in │ ├── DoxygenLayout.xml │ ├── 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 │ ├── CMakeLists.txt │ ├── board_setup.cmake │ ├── boards │ │ ├── generic_board.cmake │ │ ├── include │ │ │ └── boards │ │ │ │ ├── adafruit_feather_rp2040.h │ │ │ │ ├── adafruit_itsybitsy_rp2040.h │ │ │ │ ├── adafruit_kb2040.h │ │ │ │ ├── adafruit_macropad_rp2040.h │ │ │ │ ├── adafruit_qtpy_rp2040.h │ │ │ │ ├── adafruit_trinkey_qt2040.h │ │ │ │ ├── arduino_nano_rp2040_connect.h │ │ │ │ ├── datanoisetv_rp2040_dsp.h │ │ │ │ ├── eetree_gamekit_rp2040.h │ │ │ │ ├── garatronic_pybstick26_rp2040.h │ │ │ │ ├── melopero_shake_rp2040.h │ │ │ │ ├── none.h │ │ │ │ ├── nullbits_bit_c_pro.h │ │ │ │ ├── pico.h │ │ │ │ ├── pico_w.h │ │ │ │ ├── pimoroni_badger2040.h │ │ │ │ ├── pimoroni_interstate75.h │ │ │ │ ├── pimoroni_keybow2040.h │ │ │ │ ├── pimoroni_motor2040.h │ │ │ │ ├── pimoroni_pga2040.h │ │ │ │ ├── pimoroni_picolipo_16mb.h │ │ │ │ ├── pimoroni_picolipo_4mb.h │ │ │ │ ├── pimoroni_picosystem.h │ │ │ │ ├── pimoroni_plasma2040.h │ │ │ │ ├── pimoroni_servo2040.h │ │ │ │ ├── pimoroni_tiny2040.h │ │ │ │ ├── pimoroni_tiny2040_2mb.h │ │ │ │ ├── seeed_xiao_rp2040.h │ │ │ │ ├── solderparty_rp2040_stamp.h │ │ │ │ ├── solderparty_rp2040_stamp_carrier.h │ │ │ │ ├── solderparty_rp2040_stamp_round_carrier.h │ │ │ │ ├── sparkfun_micromod.h │ │ │ │ ├── sparkfun_promicro.h │ │ │ │ ├── sparkfun_thingplus.h │ │ │ │ ├── vgaboard.h │ │ │ │ ├── waveshare_rp2040_lcd_0.96.h │ │ │ │ ├── waveshare_rp2040_lcd_1.28.h │ │ │ │ ├── waveshare_rp2040_one.h │ │ │ │ ├── waveshare_rp2040_plus_16mb.h │ │ │ │ ├── waveshare_rp2040_plus_4mb.h │ │ │ │ ├── waveshare_rp2040_zero.h │ │ │ │ └── wiznet_w5100s_evb_pico.h │ │ └── pico_w.cmake │ ├── common │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── boot_picoboot │ │ │ ├── CMakeLists.txt │ │ │ └── include │ │ │ │ └── boot │ │ │ │ └── picoboot.h │ │ ├── boot_uf2 │ │ │ ├── CMakeLists.txt │ │ │ └── include │ │ │ │ └── boot │ │ │ │ └── uf2.h │ │ ├── pico_base │ │ │ ├── CMakeLists.txt │ │ │ ├── generate_config_header.cmake │ │ │ └── include │ │ │ │ ├── pico.h │ │ │ │ └── pico │ │ │ │ ├── assert.h │ │ │ │ ├── config.h │ │ │ │ ├── error.h │ │ │ │ ├── types.h │ │ │ │ └── version.h.in │ │ ├── pico_binary_info │ │ │ ├── CMakeLists.txt │ │ │ └── include │ │ │ │ └── pico │ │ │ │ ├── binary_info.h │ │ │ │ └── binary_info │ │ │ │ ├── code.h │ │ │ │ ├── defs.h │ │ │ │ └── structure.h │ │ ├── pico_bit_ops │ │ │ ├── CMakeLists.txt │ │ │ └── include │ │ │ │ └── pico │ │ │ │ └── bit_ops.h │ │ ├── pico_divider │ │ │ ├── CMakeLists.txt │ │ │ └── include │ │ │ │ └── pico │ │ │ │ └── divider.h │ │ ├── pico_stdlib │ │ │ ├── CMakeLists.txt │ │ │ └── include │ │ │ │ └── pico │ │ │ │ └── stdlib.h │ │ ├── pico_sync │ │ │ ├── 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 │ │ │ ├── CMakeLists.txt │ │ │ ├── include │ │ │ │ └── pico │ │ │ │ │ ├── time.h │ │ │ │ │ └── timeout_helper.h │ │ │ ├── time.c │ │ │ └── timeout_helper.c │ │ ├── pico_usb_reset_interface │ │ │ ├── CMakeLists.txt │ │ │ └── include │ │ │ │ └── pico │ │ │ │ └── usb_reset_interface.h │ │ └── pico_util │ │ │ ├── CMakeLists.txt │ │ │ ├── datetime.c │ │ │ ├── doc.h │ │ │ ├── include │ │ │ └── pico │ │ │ │ └── util │ │ │ │ ├── datetime.h │ │ │ │ ├── pheap.h │ │ │ │ └── queue.h │ │ │ ├── pheap.c │ │ │ └── queue.c │ ├── host.cmake │ ├── host │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── boot_stage2.c │ │ ├── hardware_divider │ │ │ ├── CMakeLists.txt │ │ │ ├── divider.c │ │ │ └── include │ │ │ │ └── hardware │ │ │ │ └── divider.h │ │ ├── hardware_gpio │ │ │ ├── CMakeLists.txt │ │ │ ├── gpio.c │ │ │ └── include │ │ │ │ └── hardware │ │ │ │ └── gpio.h │ │ ├── hardware_sync │ │ │ ├── CMakeLists.txt │ │ │ ├── include │ │ │ │ └── hardware │ │ │ │ │ └── sync.h │ │ │ └── sync_core0_only.c │ │ ├── hardware_timer │ │ │ ├── CMakeLists.txt │ │ │ ├── include │ │ │ │ └── hardware │ │ │ │ │ └── timer.h │ │ │ └── timer.c │ │ ├── hardware_uart │ │ │ ├── CMakeLists.txt │ │ │ ├── include │ │ │ │ └── hardware │ │ │ │ │ └── uart.h │ │ │ └── uart.c │ │ ├── pico_bit_ops │ │ │ ├── CMakeLists.txt │ │ │ └── bit_ops.c │ │ ├── pico_divider │ │ │ ├── CMakeLists.txt │ │ │ └── divider.c │ │ ├── pico_multicore │ │ │ ├── CMakeLists.txt │ │ │ └── include │ │ │ │ └── pico │ │ │ │ └── multicore.h │ │ ├── pico_platform │ │ │ ├── CMakeLists.txt │ │ │ ├── include │ │ │ │ ├── hardware │ │ │ │ │ └── platform_defs.h │ │ │ │ └── pico │ │ │ │ │ └── platform.h │ │ │ └── platform_base.c │ │ ├── pico_printf │ │ │ └── CMakeLists.txt │ │ ├── pico_stdio │ │ │ ├── CMakeLists.txt │ │ │ ├── include │ │ │ │ └── pico │ │ │ │ │ └── stdio.h │ │ │ └── stdio.c │ │ └── pico_stdlib │ │ │ ├── CMakeLists.txt │ │ │ └── stdlib.c │ ├── rp2040.cmake │ ├── rp2040 │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── hardware_regs │ │ │ ├── CMakeLists.txt │ │ │ ├── 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 │ │ │ └── rp2040.svd │ │ └── hardware_structs │ │ │ ├── CMakeLists.txt │ │ │ └── include │ │ │ └── hardware │ │ │ └── structs │ │ │ ├── adc.h │ │ │ ├── bus_ctrl.h │ │ │ ├── clocks.h │ │ │ ├── dma.h │ │ │ ├── i2c.h │ │ │ ├── interp.h │ │ │ ├── iobank0.h │ │ │ ├── ioqspi.h │ │ │ ├── mpu.h │ │ │ ├── nvic.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 │ │ │ ├── systick.h │ │ │ ├── timer.h │ │ │ ├── uart.h │ │ │ ├── usb.h │ │ │ ├── vreg_and_chip_reset.h │ │ │ ├── watchdog.h │ │ │ ├── xip_ctrl.h │ │ │ └── xosc.h │ ├── rp2_common.cmake │ └── rp2_common │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── boot_stage2 │ │ ├── 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 │ │ ├── cmsis │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── cmsis │ │ │ │ └── rename_exceptions.h │ │ └── stub │ │ │ └── CMSIS │ │ │ ├── Core │ │ │ └── Include │ │ │ │ ├── cmsis_armcc.h │ │ │ │ ├── cmsis_armclang.h │ │ │ │ ├── cmsis_armclang_ltm.h │ │ │ │ ├── cmsis_compiler.h │ │ │ │ ├── cmsis_gcc.h │ │ │ │ ├── cmsis_iccarm.h │ │ │ │ ├── cmsis_version.h │ │ │ │ ├── core_cm0plus.h │ │ │ │ └── mpu_armv7.h │ │ │ ├── Device │ │ │ └── RaspberryPi │ │ │ │ └── RP2040 │ │ │ │ ├── Include │ │ │ │ ├── RP2040.h │ │ │ │ └── system_RP2040.h │ │ │ │ └── Source │ │ │ │ └── system_RP2040.c │ │ │ └── LICENSE.txt │ │ ├── hardware_adc │ │ ├── CMakeLists.txt │ │ ├── adc.c │ │ └── include │ │ │ └── hardware │ │ │ └── adc.h │ │ ├── hardware_base │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── hardware │ │ │ └── address_mapped.h │ │ ├── hardware_claim │ │ ├── CMakeLists.txt │ │ ├── claim.c │ │ └── include │ │ │ └── hardware │ │ │ └── claim.h │ │ ├── hardware_clocks │ │ ├── CMakeLists.txt │ │ ├── clocks.c │ │ ├── include │ │ │ └── hardware │ │ │ │ └── clocks.h │ │ └── scripts │ │ │ └── vcocalc.py │ │ ├── hardware_divider │ │ ├── CMakeLists.txt │ │ ├── divider.S │ │ └── include │ │ │ └── hardware │ │ │ ├── divider.h │ │ │ └── divider_helper.S │ │ ├── hardware_dma │ │ ├── CMakeLists.txt │ │ ├── dma.c │ │ └── include │ │ │ └── hardware │ │ │ └── dma.h │ │ ├── hardware_exception │ │ ├── CMakeLists.txt │ │ ├── exception.c │ │ └── include │ │ │ └── hardware │ │ │ └── exception.h │ │ ├── hardware_flash │ │ ├── CMakeLists.txt │ │ ├── flash.c │ │ └── include │ │ │ └── hardware │ │ │ └── flash.h │ │ ├── hardware_gpio │ │ ├── CMakeLists.txt │ │ ├── gpio.c │ │ └── include │ │ │ └── hardware │ │ │ └── gpio.h │ │ ├── hardware_i2c │ │ ├── CMakeLists.txt │ │ ├── i2c.c │ │ └── include │ │ │ └── hardware │ │ │ └── i2c.h │ │ ├── hardware_interp │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ └── interp.h │ │ └── interp.c │ │ ├── hardware_irq │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ └── irq.h │ │ ├── irq.c │ │ └── irq_handler_chain.S │ │ ├── hardware_pio │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ ├── pio.h │ │ │ │ └── pio_instructions.h │ │ └── pio.c │ │ ├── hardware_pll │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ └── pll.h │ │ └── pll.c │ │ ├── hardware_pwm │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── hardware │ │ │ └── pwm.h │ │ ├── hardware_resets │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── hardware │ │ │ └── resets.h │ │ ├── hardware_rtc │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ └── rtc.h │ │ └── rtc.c │ │ ├── hardware_spi │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ └── spi.h │ │ └── spi.c │ │ ├── hardware_sync │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ └── sync.h │ │ └── sync.c │ │ ├── hardware_timer │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ └── timer.h │ │ └── timer.c │ │ ├── hardware_uart │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ └── uart.h │ │ └── uart.c │ │ ├── hardware_vreg │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ └── vreg.h │ │ └── vreg.c │ │ ├── hardware_watchdog │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ └── watchdog.h │ │ └── watchdog.c │ │ ├── hardware_xosc │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── hardware │ │ │ │ └── xosc.h │ │ └── xosc.c │ │ ├── pico_async_context │ │ ├── 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_bit_ops │ │ ├── CMakeLists.txt │ │ └── bit_ops_aeabi.S │ │ ├── pico_bootrom │ │ ├── CMakeLists.txt │ │ ├── bootrom.c │ │ └── include │ │ │ └── pico │ │ │ ├── bootrom.h │ │ │ └── bootrom │ │ │ └── sf_table.h │ │ ├── pico_bootsel_via_double_reset │ │ ├── CMakeLists.txt │ │ └── pico_bootsel_via_double_reset.c │ │ ├── pico_btstack │ │ ├── CMakeLists.txt │ │ ├── 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_cxx_options │ │ ├── CMakeLists.txt │ │ └── doc.h │ │ ├── pico_cyw43_arch │ │ ├── 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 │ │ ├── CMakeLists.txt │ │ ├── btstack_cyw43.c │ │ ├── btstack_hci_transport_cyw43.c │ │ ├── cybt_shared_bus │ │ │ ├── CMakeLists.txt │ │ │ ├── cybt_shared_bus.c │ │ │ ├── cybt_shared_bus_driver.c │ │ │ └── cybt_shared_bus_driver.h │ │ ├── cyw43_bus_pio_spi.c │ │ ├── cyw43_bus_pio_spi.pio │ │ ├── cyw43_driver.c │ │ └── include │ │ │ ├── cyw43_configport.h │ │ │ └── pico │ │ │ ├── btstack_cyw43.h │ │ │ ├── btstack_hci_transport_cyw43.h │ │ │ └── cyw43_driver.h │ │ ├── pico_divider │ │ ├── CMakeLists.txt │ │ └── divider.S │ │ ├── pico_double │ │ ├── CMakeLists.txt │ │ ├── double_aeabi.S │ │ ├── double_init_rom.c │ │ ├── double_math.c │ │ ├── double_none.S │ │ ├── double_v1_rom_shim.S │ │ └── include │ │ │ └── pico │ │ │ └── double.h │ │ ├── pico_fix │ │ ├── CMakeLists.txt │ │ └── rp2040_usb_device_enumeration │ │ │ ├── CMakeLists.txt │ │ │ ├── include │ │ │ └── pico │ │ │ │ └── fix │ │ │ │ └── rp2040_usb_device_enumeration.h │ │ │ └── rp2040_usb_device_enumeration.c │ │ ├── pico_float │ │ ├── CMakeLists.txt │ │ ├── float_aeabi.S │ │ ├── float_init_rom.c │ │ ├── float_math.c │ │ ├── float_none.S │ │ ├── float_v1_rom_shim.S │ │ └── include │ │ │ └── pico │ │ │ └── float.h │ │ ├── pico_i2c_slave │ │ ├── CMakeLists.txt │ │ ├── i2c_slave.c │ │ └── include │ │ │ └── pico │ │ │ └── i2c_slave.h │ │ ├── pico_int64_ops │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ └── int64_ops.h │ │ └── pico_int64_ops_aeabi.S │ │ ├── pico_lwip │ │ ├── CMakeLists.txt │ │ ├── doc.h │ │ ├── include │ │ │ ├── arch │ │ │ │ └── cc.h │ │ │ └── pico │ │ │ │ ├── lwip_freertos.h │ │ │ │ └── lwip_nosys.h │ │ ├── lwip_freertos.c │ │ └── lwip_nosys.c │ │ ├── pico_malloc │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ └── malloc.h │ │ └── pico_malloc.c │ │ ├── pico_mbedtls │ │ ├── CMakeLists.txt │ │ └── pico_mbedtls.c │ │ ├── pico_mem_ops │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ └── mem_ops.h │ │ ├── mem_ops.c │ │ └── mem_ops_aeabi.S │ │ ├── pico_multicore │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ └── multicore.h │ │ └── multicore.c │ │ ├── pico_platform │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ ├── asm_helper.S │ │ │ │ └── platform.h │ │ └── platform.c │ │ ├── pico_printf │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ └── printf.h │ │ ├── printf.c │ │ └── printf_none.S │ │ ├── pico_rand │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ └── rand.h │ │ └── rand.c │ │ ├── pico_runtime │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ └── runtime.h │ │ └── runtime.c │ │ ├── pico_standard_link │ │ ├── CMakeLists.txt │ │ ├── binary_info.c │ │ ├── crt0.S │ │ ├── doc.h │ │ ├── memmap_blocked_ram.ld │ │ ├── memmap_copy_to_ram.ld │ │ ├── memmap_default.ld │ │ ├── memmap_no_flash.ld │ │ └── new_delete.cpp │ │ ├── pico_stdio │ │ ├── CMakeLists.txt │ │ ├── LICENSE │ │ ├── include │ │ │ └── pico │ │ │ │ ├── stdio.h │ │ │ │ └── stdio │ │ │ │ └── driver.h │ │ └── stdio.c │ │ ├── pico_stdio_semihosting │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ └── stdio_semihosting.h │ │ └── stdio_semihosting.c │ │ ├── pico_stdio_uart │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ └── stdio_uart.h │ │ └── stdio_uart.c │ │ ├── pico_stdio_usb │ │ ├── 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 │ │ ├── CMakeLists.txt │ │ └── stdlib.c │ │ ├── pico_unique_id │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── pico │ │ │ │ └── unique_id.h │ │ └── unique_id.c │ │ └── tinyusb │ │ ├── CMakeLists.txt │ │ └── doc.h ├── test │ ├── CMakeLists.txt │ ├── cmsis_test │ │ ├── CMakeLists.txt │ │ └── cmsis_test.c │ ├── hardware_irq_test │ │ ├── CMakeLists.txt │ │ └── hardware_irq_test.c │ ├── hardware_pwm_test │ │ ├── CMakeLists.txt │ │ └── hardware_pwm_test.c │ ├── kitchen_sink │ │ ├── CMakeLists.txt │ │ ├── btstack_config.h │ │ ├── kitchen_sink.c │ │ ├── kitchen_sink_cpp.cpp │ │ ├── lwipopts.h │ │ └── mbedtls_config.h │ ├── pico_divider_test │ │ ├── CMakeLists.txt │ │ ├── pico_divider_nesting_test.c │ │ └── pico_divider_test.c │ ├── pico_float_test │ │ ├── CMakeLists.txt │ │ ├── llvm │ │ │ ├── LICENSE.TXT │ │ │ ├── call_apsr.S │ │ │ └── call_apsr.h │ │ ├── pico_double_test.c │ │ └── pico_float_test.c │ ├── pico_sem_test │ │ ├── CMakeLists.txt │ │ └── pico_sem_test.c │ ├── pico_stdio_test │ │ ├── CMakeLists.txt │ │ └── pico_stdio_test.c │ ├── pico_stdlib_test │ │ ├── CMakeLists.txt │ │ └── pico_stdlib_test.c │ ├── pico_test │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── pico │ │ │ └── test.h │ └── pico_time_test │ │ ├── CMakeLists.txt │ │ └── pico_time_test.c └── tools │ ├── CMakeLists.txt │ ├── FindELF2UF2.cmake │ ├── FindPioasm.cmake │ ├── check_configs.sh │ ├── check_doxygen_groups.py │ ├── elf2uf2 │ ├── CMakeLists.txt │ ├── elf.h │ └── main.cpp │ ├── extract_configs.py │ └── pioasm │ ├── CMakeLists.txt │ ├── ada_output.cpp │ ├── c_sdk_output.cpp │ ├── gen │ ├── lexer.cpp │ ├── location.h │ ├── parser.cpp │ └── parser.hpp │ ├── hex_output.cpp │ ├── lexer.ll │ ├── main.cpp │ ├── output_format.h │ ├── parser.yy │ ├── pio_assembler.cpp │ ├── pio_assembler.h │ ├── pio_disassembler.cpp │ ├── pio_disassembler.h │ ├── pio_types.h │ └── python_output.cpp └── project └── mdk ├── AC6-flash-FLM.BAT ├── AC6-flash.BAT ├── RP2040_flash_flm.sct ├── RTE └── Compiler │ └── EventRecorderConf.h ├── Raspberry_Pi_Pico.FLM ├── axf2uf2.bat ├── debug_with_cmsis-dap.ini ├── debug_with_cmsis-dap_in_ram.ini ├── startup_RP2040.c ├── template.uvoptx ├── template.uvprojx └── wrapper ├── env_wrapper.c ├── env_wrapper.h ├── hardware └── sync.h ├── pico └── platform.h ├── pico_base └── pico │ ├── config_autogen.h │ └── version.h ├── runtime.c ├── stdio.c └── sys └── cdefs.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.out 33 | *.app 34 | *.i*86 35 | *.x86_64 36 | *.hex 37 | 38 | # Debug files 39 | *.dSYM/ 40 | *.su 41 | *.idb 42 | *.pdb 43 | 44 | # Kernel Module Compile Results 45 | *.mod* 46 | *.cmd 47 | .tmp_versions/ 48 | modules.order 49 | Module.symvers 50 | Mkfile.old 51 | dkms.conf 52 | *.dep 53 | project/mdk/template.uvguix.* 54 | project/mdk/Objects 55 | *.scvd 56 | *.iex 57 | project/mdk/JLinkLog.txt 58 | project/mdk/template.uf2 59 | *._ac 60 | *.__i 61 | *@* 62 | 63 | project/mdk/RTE/PikaScript 64 | RTE_Components.h 65 | Pre_Include_* 66 | project/mdk/RTE/Acceleration/README.md 67 | project/mdk/RTE/Acceleration/img2c.py 68 | project/mdk/RTE/Acceleration/arm_2d.c 69 | -------------------------------------------------------------------------------- /documents/Pictures/Debug_printf_Viewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aladdin-Wang/RP2040_Flash_Algorithm/8a5bf5c4e8f04f3863cb179ca439e6560bcc14a3/documents/Pictures/Debug_printf_Viewer.png -------------------------------------------------------------------------------- /documents/Pictures/EnableThePikaBeforeBuild.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aladdin-Wang/RP2040_Flash_Algorithm/8a5bf5c4e8f04f3863cb179ca439e6560bcc14a3/documents/Pictures/EnableThePikaBeforeBuild.png -------------------------------------------------------------------------------- /documents/Pictures/Reset_Pico.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aladdin-Wang/RP2040_Flash_Algorithm/8a5bf5c4e8f04f3863cb179ca439e6560bcc14a3/documents/Pictures/Reset_Pico.png -------------------------------------------------------------------------------- /documents/Pictures/enable_lcd_1in3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aladdin-Wang/RP2040_Flash_Algorithm/8a5bf5c4e8f04f3863cb179ca439e6560bcc14a3/documents/Pictures/enable_lcd_1in3 -------------------------------------------------------------------------------- /pico-sdk/.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 | -------------------------------------------------------------------------------- /pico-sdk/.github/workflows/choco_packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /pico-sdk/.github/workflows/cmake.yml: -------------------------------------------------------------------------------- 1 | name: CMake 2 | on: [push, pull_request] 3 | 4 | env: 5 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) 6 | BUILD_TYPE: Release 7 | 8 | jobs: 9 | build: 10 | if: github.repository_owner == 'raspberrypi' 11 | runs-on: [self-hosted, Linux, X64] 12 | 13 | steps: 14 | - name: Clean workspace 15 | run: | 16 | echo "Cleaning up previous run" 17 | rm -rf "${{ github.workspace }}" 18 | mkdir -p "${{ github.workspace }}" 19 | 20 | - name: Checkout repo 21 | uses: actions/checkout@v2 22 | 23 | - name: Checkout submodules 24 | run: git submodule update --init 25 | 26 | - name: Create Build Environment 27 | # Some projects don't allow in-source building, so create a separate build directory 28 | # We'll use this as our working directory for all subsequent commands 29 | run: cmake -E make_directory ${{github.workspace}}/build 30 | 31 | - name: Configure CMake 32 | # Use a bash shell so we can use the same syntax for environment variable 33 | # access regardless of the host operating system 34 | shell: bash 35 | working-directory: ${{github.workspace}}/build 36 | # Note the current convention is to use the -S and -B options here to specify source 37 | # and build directories, but this is only available with CMake 3.13 and higher. 38 | # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 39 | run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPICO_SDK_TESTS_ENABLED=1 40 | 41 | - name: Get core count 42 | id: core_count 43 | run : cat /proc/cpuinfo | grep processor | wc -l 44 | 45 | - name: Build 46 | working-directory: ${{github.workspace}}/build 47 | shell: bash 48 | # Execute the build. You can specify a specific target with "--target " 49 | run: cmake --build . --config $BUILD_TYPE --parallel ${{steps.core_count.outputs.output}} 50 | -------------------------------------------------------------------------------- /pico-sdk/.github/workflows/macOS.yml: -------------------------------------------------------------------------------- 1 | name: Build on macOS 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: 6 | - 'develop' 7 | - 'master' 8 | - 'test_workflow' 9 | 10 | jobs: 11 | build: 12 | runs-on: macos-12 13 | steps: 14 | - name: Clean workspace 15 | run: | 16 | echo "Cleaning up previous run" 17 | rm -rf "${{ github.workspace }}" 18 | mkdir -p "${{ github.workspace }}" 19 | - name: Checkout repo 20 | uses: actions/checkout@v3 21 | - name: Checkout submodules 22 | run: git submodule update --init 23 | - name: Install dependencies 24 | run: | 25 | brew install cmake 26 | brew tap ArmMbed/homebrew-formulae 27 | brew install arm-none-eabi-gcc 28 | 29 | - name: Build Project 30 | # bash required otherwise this mysteriously (no error) fails at "Generating cyw43_bus_pio_spi.pio.h" 31 | shell: bash 32 | run: | 33 | mkdir build 34 | cd build 35 | cmake .. -G "Unix Makefiles" -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_BOARD=pico_w 36 | cmake --build . 37 | 38 | - name: Build Native 39 | # bash required otherwise this mysteriously (no error) fails at "Generating cyw43_bus_pio_spi.pio.h" 40 | shell: bash 41 | run: | 42 | mkdir build_native 43 | cd build_native 44 | cmake .. -G "Unix Makefiles" -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_PLATFORM=host 45 | cmake --build . 46 | -------------------------------------------------------------------------------- /pico-sdk/.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@v3 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 | # bash required otherwise this mysteriously (no error) fails at "Generating cyw43_bus_pio_spi.pio.h" 28 | shell: bash 29 | run: | 30 | mkdir build 31 | cd build 32 | cmake .. -G Ninja -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_BOARD=pico_w 33 | cmake --build . 34 | -------------------------------------------------------------------------------- /pico-sdk/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | cmake-* 4 | .DS_Store 5 | build 6 | -------------------------------------------------------------------------------- /pico-sdk/.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 | -------------------------------------------------------------------------------- /pico-sdk/LICENSE.TXT: -------------------------------------------------------------------------------- 1 | Copyright 2020 (c) 2020 Raspberry Pi (Trading) Ltd. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 4 | following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following 7 | disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 10 | disclaimer in the documentation and/or other materials provided with the distribution. 11 | 12 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 16 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 18 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 20 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 21 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /pico-sdk/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) -------------------------------------------------------------------------------- /pico-sdk/cmake/pico_pre_load_platform.cmake: -------------------------------------------------------------------------------- 1 | # PICO_CMAKE_CONFIG: PICO_PLATFORM, platform to build for e.g. rp2040/host, default=rp2040 or environment value, group=build 2 | if (DEFINED ENV{PICO_PLATFORM} AND (NOT PICO_PLATFORM)) 3 | set(PICO_PLATFORM $ENV{PICO_PLATFORM}) 4 | message("Using PICO_PLATFORM from environment ('${PICO_PLATFORM}')") 5 | else() 6 | if (NOT PICO_PLATFORM) 7 | set(PICO_PLATFORM "rp2040") 8 | pico_message("Defaulting PICO_PLATFORM to ${PICO_PLATFORM} since not specified.") 9 | else() 10 | message("PICO platform is ${PICO_PLATFORM}.") 11 | endif() 12 | endif () 13 | 14 | set(PICO_PLATFORM ${PICO_PLATFORM} CACHE STRING "PICO Build platform (e.g. rp2040, host)") 15 | 16 | # PICO_CMAKE_CONFIG: PICO_CMAKE_PRELOAD_PLATFORM_FILE, custom CMake file to use to set up the platform environment, default=none, group=build 17 | set(PICO_CMAKE_PRELOAD_PLATFORM_FILE "" CACHE INTERNAL "") 18 | set(PICO_CMAKE_PRELOAD_PLATFORM_DIR "${CMAKE_CURRENT_LIST_DIR}/preload/platforms" CACHE INTERNAL "") 19 | 20 | if (NOT PICO_CMAKE_PRELOAD_PLATFORM_FILE) 21 | set(PICO_CMAKE_PRELOAD_PLATFORM_FILE ${PICO_CMAKE_PRELOAD_PLATFORM_DIR}/${PICO_PLATFORM}.cmake CACHE INTERNAL "") 22 | endif () 23 | 24 | if (NOT EXISTS "${PICO_CMAKE_PRELOAD_PLATFORM_FILE}") 25 | message(FATAL_ERROR "${PICO_CMAKE_PRELOAD_PLATFORM_FILE} does not exist. \ 26 | Either specify a valid PICO_PLATFORM (or PICO_CMAKE_PRELOAD_PLATFORM_FILE).") 27 | endif () 28 | 29 | include(${PICO_CMAKE_PRELOAD_PLATFORM_FILE}) 30 | -------------------------------------------------------------------------------- /pico-sdk/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() -------------------------------------------------------------------------------- /pico-sdk/cmake/preload/platforms/host.cmake: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aladdin-Wang/RP2040_Flash_Algorithm/8a5bf5c4e8f04f3863cb179ca439e6560bcc14a3/pico-sdk/cmake/preload/platforms/host.cmake -------------------------------------------------------------------------------- /pico-sdk/cmake/preload/platforms/pico/pico.cmake: -------------------------------------------------------------------------------- 1 | if (NOT (DEFINED PICO_COMPILER OR DEFINED CMAKE_TOOLCHAIN_FILE)) 2 | pico_message("Defaulting PICO platform compiler to pico_arm_gcc since not specified.") 3 | set(PICO_COMPILER "pico_arm_gcc") 4 | endif () 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /pico-sdk/cmake/preload/platforms/rp2040.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/pico/pico.cmake) -------------------------------------------------------------------------------- /pico-sdk/cmake/preload/toolchains/find_compiler.cmake: -------------------------------------------------------------------------------- 1 | # Toolchain file is processed multiple times, however, it cannot access CMake cache on some runs. 2 | # We store the search path in an environment variable so that we can always access it. 3 | if (NOT "${PICO_TOOLCHAIN_PATH}" STREQUAL "") 4 | set(ENV{PICO_TOOLCHAIN_PATH} "${PICO_TOOLCHAIN_PATH}") 5 | endif () 6 | 7 | # Find the compiler executable and store its path in a cache entry ${compiler_path}. 8 | # If not found, issue a fatal message and stop processing. PICO_TOOLCHAIN_PATH can be provided from 9 | # commandline as additional search path. 10 | function(pico_find_compiler compiler_path compiler_exe) 11 | # Search user provided path first. 12 | find_program( 13 | ${compiler_path} ${compiler_exe} 14 | PATHS ENV PICO_TOOLCHAIN_PATH 15 | PATH_SUFFIXES bin 16 | NO_DEFAULT_PATH 17 | ) 18 | 19 | # If not then search system paths. 20 | if ("${${compiler_path}}" STREQUAL "${compiler_path}-NOTFOUND") 21 | if (DEFINED ENV{PICO_TOOLCHAIN_PATH}) 22 | message(WARNING "PICO_TOOLCHAIN_PATH specified ($ENV{PICO_TOOLCHAIN_PATH}), but ${compiler_exe} not found there") 23 | endif() 24 | find_program(${compiler_path} ${compiler_exe}) 25 | endif () 26 | if ("${${compiler_path}}" STREQUAL "${compiler_path}-NOTFOUND") 27 | set(PICO_TOOLCHAIN_PATH "" CACHE PATH "Path to search for compiler.") 28 | message(FATAL_ERROR "Compiler '${compiler_exe}' not found, you can specify search path with\ 29 | \"PICO_TOOLCHAIN_PATH\".") 30 | endif () 31 | endfunction() 32 | -------------------------------------------------------------------------------- /pico-sdk/cmake/preload/toolchains/set_flags.cmake: -------------------------------------------------------------------------------- 1 | 2 | get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE) 3 | foreach(LANG IN ITEMS C CXX ASM) 4 | set(CMAKE_${LANG}_FLAGS_INIT "${ARM_TOOLCHAIN_COMMON_FLAGS}") 5 | if (PICO_DEOPTIMIZED_DEBUG) 6 | set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-O0") 7 | else() 8 | set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-Og") 9 | endif() 10 | set(CMAKE_${LANG}_LINK_FLAGS "-Wl,--build-id=none") 11 | 12 | # try_compile is where the feature testing is done, and at that point, 13 | # pico_standard_link is not ready to be linked in to provide essential 14 | # functions like _exit. So pass -nostdlib so it doesn't link in an exit() 15 | # function at all. 16 | if(IS_IN_TRY_COMPILE) 17 | set(CMAKE_${LANG}_LINK_FLAGS "${CMAKE_${LANG}_LINK_FLAGS} -nostdlib") 18 | endif() 19 | endforeach() 20 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/docs/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/docs/pico.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aladdin-Wang/RP2040_Flash_Algorithm/8a5bf5c4e8f04f3863cb179ca439e6560bcc14a3/pico-sdk/docs/pico.jpg -------------------------------------------------------------------------------- /pico-sdk/docs/rp2040.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aladdin-Wang/RP2040_Flash_Algorithm/8a5bf5c4e8f04f3863cb179ca439e6560bcc14a3/pico-sdk/docs/rp2040.png -------------------------------------------------------------------------------- /pico-sdk/docs/search.svg: -------------------------------------------------------------------------------- 1 | Jemis Mali -------------------------------------------------------------------------------- /pico-sdk/docs/weblinks_page.md: -------------------------------------------------------------------------------- 1 | ## Documentation and datasheets {#weblinks_page} 2 | 3 | The full documentation for the RP2040 and Raspberry Pi Pico board can be found at the following links 4 | 5 | - [RP2040 Datasheet](https://rptl.io/rp2040-datasheet) 6 | - [Raspberry Pi Pico Datasheet](https://rptl.io/pico-datasheet) 7 | - [Raspberry Pi Pico W Datasheet](https://rptl.io/picow-datasheet) 8 | - [Hardware design with RP2040](https://rptl.io/rp2040-design) 9 | - [Raspberry Pi Pico C/C++ SDK](https://rptl.io/pico-c-sdk) 10 | - [Raspberry Pi Pico Python SDK](https://rptl.io/pico-micropython) 11 | - [Getting started with Raspberry Pi Pico](https://rptl.io/pico-get-started) 12 | - [Connecting to the Internet with Raspberry Pi Pico W](https://rptl.io/picow-connect) 13 | 14 | ### Weblinks 15 | 16 | At Raspberry Pi we have a very community-based attitude to help. We run a very popular and busy forum where you can ask questions about any aspect of the Raspberry Pi ecosystem, including the Raspberry Pi Pico. 17 | 18 | You can find our forums at the [following link](https://forums.raspberrypi.com/). 19 | 20 | For the main Raspberry Pi website, [see here](https://www.raspberrypi.com) 21 | 22 | For the Raspberry Pi Pico page, [see here](https://rptl.io/rp2040-get-started) 23 | 24 | ### GitHub 25 | 26 | All the source code for the Raspberry Pi Pico SDK, examples and other libraries can be found on GitHub. 27 | 28 | - [Raspberry Pi Pico SDK](https://github.com/raspberrypi/pico-sdk) 29 | - [Pico Examples](https://github.com/raspberrypi/pico-examples) 30 | - [Pico Extras - Libraries under development](https://github.com/raspberrypi/pico-extras) 31 | - [Pico Playground - Examples that use Pico Extras](https://github.com/raspberrypi/pico-playground) 32 | - [Pico Bootrom source code](https://github.com/raspberrypi/pico-bootrom) 33 | -------------------------------------------------------------------------------- /pico-sdk/pico_sdk_version.cmake: -------------------------------------------------------------------------------- 1 | # PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, group=pico_base 2 | # PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, group=pico_base 3 | set(PICO_SDK_VERSION_MAJOR 1) 4 | # PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, group=pico_base 5 | # PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, group=pico_base 6 | set(PICO_SDK_VERSION_MINOR 5) 7 | # PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, group=pico_base 8 | # PICO_CMAKE_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, group=pico_base 9 | set(PICO_SDK_VERSION_REVISION 0) 10 | # PICO_BUILD_DEFINE: PICO_SDK_VERSION_PRE_RELEASE_ID, optional SDK pre-release version identifier, type=string, group=pico_base 11 | # PICO_CMAKE_CONFIG: PICO_SDK_VERSION_PRE_RELEASE_ID, optional SDK pre-release version identifier, type=string, group=pico_base 12 | #set(PICO_SDK_VERSION_PRE_RELEASE_ID develop) 13 | 14 | # PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version, type=string, group=pico_base 15 | # PICO_CMAKE_CONFIG: PICO_SDK_VERSION_STRING, SDK version, type=string, group=pico_base 16 | set(PICO_SDK_VERSION_STRING "${PICO_SDK_VERSION_MAJOR}.${PICO_SDK_VERSION_MINOR}.${PICO_SDK_VERSION_REVISION}") 17 | 18 | if (PICO_SDK_VERSION_PRE_RELEASE_ID) 19 | set(PICO_SDK_VERSION_STRING "${PICO_SDK_VERSION_STRING}-${PICO_SDK_VERSION_PRE_RELEASE_ID}") 20 | endif() 21 | -------------------------------------------------------------------------------- /pico-sdk/src/board_setup.cmake: -------------------------------------------------------------------------------- 1 | # PICO_CMAKE_CONFIG: PICO_BOARD, The board name being built for. This is overridable from the user environment, type=string, default=pico, group=build 2 | if (DEFINED ENV{PICO_BOARD}) 3 | set(PICO_BOARD $ENV{PICO_BOARD}) 4 | message("Using PICO_BOARD from environment ('${PICO_BOARD}')") 5 | else() 6 | if (NOT PICO_BOARD) 7 | set(PICO_BOARD "pico") 8 | pico_message("Defaulting PICO target board to ${PICO_BOARD} since not specified.") 9 | else() 10 | message("PICO target board is ${PICO_BOARD}.") 11 | endif() 12 | endif() 13 | set(PICO_BOARD ${PICO_BOARD} CACHE STRING "PICO target board (e.g. pico)") 14 | 15 | # PICO_CMAKE_CONFIG: PICO_BOARD_CMAKE_DIRS, Directories to look for .cmake in. This is overridable from the user environment, type=list, default="", group=build 16 | if (DEFINED ENV{PICO_BOARD_CMAKE_DIRS}) 17 | set(PICO_BOARD_CMAKE_DIRS $ENV{PICO_BOARD_CMAKE_DIRS}) 18 | message("Using PICO_BOARD_CMAKE_DIRS from environment ('${PICO_BOARD_CMAKE_DIRS}')") 19 | endif() 20 | 21 | list(APPEND PICO_BOARD_CMAKE_DIRS ${CMAKE_CURRENT_LIST_DIR}/boards) 22 | 23 | pico_find_in_paths(PICO_BOARD_CMAKE_FILE PICO_BOARD_CMAKE_DIRS ${PICO_BOARD}.cmake) 24 | if (EXISTS "${PICO_BOARD_CMAKE_FILE}") 25 | message("Using CMake board configuration from ${PICO_BOARD_CMAKE_FILE}") 26 | include(${PICO_BOARD_CMAKE_FILE} board_config) 27 | else() 28 | include(boards/generic_board.cmake) 29 | endif() 30 | 31 | list(APPEND PICO_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/boards/include) # so boards/foo.h can be explicitly included 32 | -------------------------------------------------------------------------------- /pico-sdk/src/boards/generic_board.cmake: -------------------------------------------------------------------------------- 1 | # For boards without their own cmake file, simply include a header 2 | 3 | # PICO_CMAKE_CONFIG: PICO_BOARD_HEADER_DIRS, Directories to look for .h in. This is overridable from the user environment, type=list, default="", group=build 4 | if (DEFINED ENV{PICO_BOARD_HEADER_DIRS}) 5 | set(PICO_BOARD_HEADER_DIRS $ENV{PICO_BOARD_HEADER_DIRS}) 6 | message("Using PICO_BOARD_HEADER_DIRS from environment ('${PICO_BOARD_HEADER_DIRS}')") 7 | endif() 8 | set(PICO_BOARD_HEADER_DIRS ${PICO_BOARD_HEADER_DIRS} CACHE STRING "PICO board header directories") 9 | 10 | list(APPEND PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}/include/boards) 11 | pico_find_in_paths(PICO_BOARD_HEADER_FILE PICO_BOARD_HEADER_DIRS ${PICO_BOARD}.h) 12 | 13 | if (EXISTS ${PICO_BOARD_HEADER_FILE}) 14 | message("Using board configuration from ${PICO_BOARD_HEADER_FILE}") 15 | list(APPEND PICO_CONFIG_HEADER_FILES ${PICO_BOARD_HEADER_FILE}) 16 | else() 17 | set(msg "Unable to find definition of board '${PICO_BOARD}' (specified by PICO_BOARD):\n") 18 | list(JOIN PICO_BOARD_HEADER_DIRS ", " DIRS) 19 | string(CONCAT msg ${msg} " Looked for ${PICO_BOARD}.h in ${DIRS} (additional paths specified by PICO_BOARD_HEADER_DIRS)\n") 20 | list(JOIN PICO_BOARD_CMAKE_DIRS ", " DIRS) 21 | string(CONCAT msg ${msg} " Looked for ${PICO_BOARD}.cmake in ${DIRS} (additional paths specified by PICO_BOARD_CMAKE_DIRS)") 22 | message(FATAL_ERROR ${msg}) 23 | endif() 24 | -------------------------------------------------------------------------------- /pico-sdk/src/boards/include/boards/adafruit_trinkey_qt2040.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 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_ADAFRUIT_TRINKEY_QT2040_H 13 | #define _BOARDS_ADAFRUIT_TRINKEY_QT2040_H 14 | 15 | // For board detection 16 | #define ADAFRUIT_TRINKEY_QT2040 17 | 18 | // On some samples, the xosc can take longer to stabilize than is usual 19 | #ifndef PICO_XOSC_STARTUP_DELAY_MULTIPLIER 20 | #define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64 21 | #endif 22 | 23 | //------------- UART -------------// 24 | // no PICO_DEFAULT_UART 25 | // no PICO_DEFAULT_UART_TX_PIN 26 | // no PICO_DEFAULT_UART_RX_PIN 27 | 28 | //------------- LED -------------// 29 | // No normal LED 30 | // #define PICO_DEFAULT_LED_PIN 13 31 | 32 | #ifndef PICO_DEFAULT_WS2812_PIN 33 | #define PICO_DEFAULT_WS2812_PIN 27 34 | #endif 35 | 36 | //------------- I2C -------------// 37 | #ifndef PICO_DEFAULT_I2C 38 | #define PICO_DEFAULT_I2C 0 39 | #endif 40 | 41 | #ifndef PICO_DEFAULT_I2C_SDA_PIN 42 | #define PICO_DEFAULT_I2C_SDA_PIN 16 43 | #endif 44 | 45 | #ifndef PICO_DEFAULT_I2C_SCL_PIN 46 | #define PICO_DEFAULT_I2C_SCL_PIN 17 47 | #endif 48 | 49 | //------------- SPI -------------// 50 | // no PICO_DEFAULT_SPI 51 | // no PICO_DEFAULT_SPI_SCK_PIN 52 | // no PICO_DEFAULT_SPI_TX_PIN 53 | // no PICO_DEFAULT_SPI_RX_PIN 54 | // no PICO_DEFAULT_SPI_CSN_PIN 55 | 56 | //------------- FLASH -------------// 57 | 58 | #define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 59 | 60 | #ifndef PICO_FLASH_SPI_CLKDIV 61 | #define PICO_FLASH_SPI_CLKDIV 2 62 | #endif 63 | 64 | #ifndef PICO_FLASH_SIZE_BYTES 65 | #define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024) 66 | #endif 67 | 68 | // All boards have B1 RP2040 69 | #ifndef PICO_RP2040_B0_SUPPORTED 70 | #define PICO_RP2040_B0_SUPPORTED 0 71 | #endif 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /pico-sdk/src/boards/include/boards/datanoisetv_rp2040_dsp.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 DatanoiseTV RP2040 DSP Board 14 | // 15 | // This header may be included by other board headers as "boards/datanoisetv_rp2040_dsp.h" 16 | 17 | #ifndef _BOARDS_DATANOISETV_RP2040_DSP_H 18 | #define _BOARDS_DATANOISETV_RP2040_DSP_H 19 | 20 | // For board detection 21 | #define DATANOISETV_RP2040_DSP 22 | 23 | // --- I2C --- 24 | #ifndef PICO_DEFAULT_I2C 25 | #define PICO_DEFAULT_I2C 0 26 | #endif 27 | #ifndef PICO_DEFAULT_I2C_SDA_PIN 28 | #define PICO_DEFAULT_I2C_SDA_PIN 24 29 | #endif 30 | #ifndef PICO_DEFAULT_I2C_SCL_PIN 31 | #define PICO_DEFAULT_I2C_SCL_PIN 25 32 | #endif 33 | 34 | // -- FLASH -- 35 | #define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 36 | 37 | #ifndef PICO_FLASH_SPI_CLKDIV 38 | #define PICO_FLASH_SPI_CLKDIV 2 39 | #endif 40 | 41 | #ifndef PICO_FLASH_SIZE_BYTES 42 | #define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024) 43 | #endif 44 | 45 | #ifndef PICO_RP2040_B0_SUPPORTED 46 | #define PICO_RP2040_B0_SUPPORTED 0 47 | #endif 48 | 49 | 50 | // --- I2S --- 51 | #ifndef PICO_AUDIO_I2S_DATA_PIN 52 | #define PICO_AUDIO_I2S_DATA_PIN 16 53 | #endif 54 | #ifndef PICO_AUDIO_I2S_CLOCK_PIN_BASE 55 | #define PICO_AUDIO_I2S_CLOCK_PIN_BASE 17 56 | #endif 57 | 58 | #include "boards/pico.h" 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /pico-sdk/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 -------------------------------------------------------------------------------- /pico-sdk/src/boards/include/boards/pimoroni_pga2040.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_PIMORONI_PGA2040_H 13 | #define _BOARDS_PIMORONI_PGA2040_H 14 | 15 | // For board detection 16 | #define PIMORONI_PGA2040 17 | 18 | // --- UART --- 19 | #ifndef PICO_DEFAULT_UART 20 | #define PICO_DEFAULT_UART 0 21 | #endif 22 | 23 | #ifndef PICO_DEFAULT_UART_TX_PIN 24 | #define PICO_DEFAULT_UART_TX_PIN 0 25 | #endif 26 | 27 | #ifndef PICO_DEFAULT_UART_RX_PIN 28 | #define PICO_DEFAULT_UART_RX_PIN 1 29 | #endif 30 | 31 | // --- LED --- 32 | // no PICO_DEFAULT_LED_PIN 33 | // no PICO_DEFAULT_WS2812_PIN 34 | 35 | // --- I2C --- 36 | #ifndef PICO_DEFAULT_I2C 37 | #define PICO_DEFAULT_I2C 0 38 | #endif 39 | #ifndef PICO_DEFAULT_I2C_SDA_PIN 40 | #define PICO_DEFAULT_I2C_SDA_PIN 4 41 | #endif 42 | #ifndef PICO_DEFAULT_I2C_SCL_PIN 43 | #define PICO_DEFAULT_I2C_SCL_PIN 5 44 | #endif 45 | 46 | // --- SPI --- 47 | #ifndef PICO_DEFAULT_SPI 48 | #define PICO_DEFAULT_SPI 0 49 | #endif 50 | #ifndef PICO_DEFAULT_SPI_SCK_PIN 51 | #define PICO_DEFAULT_SPI_SCK_PIN 18 52 | #endif 53 | #ifndef PICO_DEFAULT_SPI_TX_PIN 54 | #define PICO_DEFAULT_SPI_TX_PIN 19 55 | #endif 56 | #ifndef PICO_DEFAULT_SPI_RX_PIN 57 | #define PICO_DEFAULT_SPI_RX_PIN 16 58 | #endif 59 | #ifndef PICO_DEFAULT_SPI_CSN_PIN 60 | #define PICO_DEFAULT_SPI_CSN_PIN 17 61 | #endif 62 | 63 | // --- FLASH --- 64 | #define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 65 | 66 | #ifndef PICO_FLASH_SPI_CLKDIV 67 | #define PICO_FLASH_SPI_CLKDIV 2 68 | #endif 69 | 70 | #ifndef PICO_FLASH_SIZE_BYTES 71 | #define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024) 72 | #endif 73 | 74 | // All boards have B1 RP2040 75 | #ifndef PICO_RP2040_B0_SUPPORTED 76 | #define PICO_RP2040_B0_SUPPORTED 0 77 | #endif 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /pico-sdk/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 | #ifndef _BOARDS_SOLDERPARTY_RP2040_STAMP_CARRIER_H 18 | #define _BOARDS_SOLDERPARTY_RP2040_STAMP_CARRIER_H 19 | 20 | // For board detection 21 | #define SOLDERPARTY_RP2040_STAMP_CARRIER 22 | 23 | #ifndef PICO_DEFAULT_LED_PIN 24 | #define PICO_DEFAULT_LED_PIN 20 25 | #endif 26 | 27 | #include "solderparty_rp2040_stamp.h" 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /pico-sdk/src/boards/pico_w.cmake: -------------------------------------------------------------------------------- 1 | set(PICO_CYW43_SUPPORTED "1") 2 | pico_register_common_scope_var(PICO_CYW43_SUPPORTED) 3 | include(${CMAKE_CURRENT_LIST_DIR}/generic_board.cmake) 4 | -------------------------------------------------------------------------------- /pico-sdk/src/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_subdirectory(boot_picoboot) 2 | pico_add_subdirectory(boot_uf2) 3 | pico_add_subdirectory(pico_base) 4 | pico_add_subdirectory(pico_usb_reset_interface) 5 | 6 | # PICO_CMAKE_CONFIG: PICO_BARE_METAL, Flag to exclude anything except base headers from the build, type=bool, default=0, group=build 7 | if (NOT PICO_BARE_METAL) 8 | pico_add_subdirectory(pico_bit_ops) 9 | pico_add_subdirectory(pico_binary_info) 10 | pico_add_subdirectory(pico_divider) 11 | pico_add_subdirectory(pico_sync) 12 | pico_add_subdirectory(pico_time) 13 | pico_add_subdirectory(pico_util) 14 | pico_add_subdirectory(pico_stdlib) 15 | endif() 16 | 17 | pico_add_doxygen(${CMAKE_CURRENT_LIST_DIR}) 18 | 19 | pico_promote_common_scope_vars() -------------------------------------------------------------------------------- /pico-sdk/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`` -------------------------------------------------------------------------------- /pico-sdk/src/common/boot_picoboot/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(boot_picoboot_headers INTERFACE) 2 | target_include_directories(boot_picoboot_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 3 | -------------------------------------------------------------------------------- /pico-sdk/src/common/boot_uf2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(boot_uf2_headers INTERFACE) 2 | target_include_directories(boot_uf2_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 3 | -------------------------------------------------------------------------------- /pico-sdk/src/common/boot_uf2/include/boot/uf2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _BOOT_UF2_H 8 | #define _BOOT_UF2_H 9 | 10 | #include 11 | #include 12 | 13 | /** \file uf2.h 14 | * \defgroup boot_uf2 boot_uf2 15 | * 16 | * Header file for the UF2 format supported by an RP2040 in BOOTSEL mode. 17 | */ 18 | 19 | #define UF2_MAGIC_START0 0x0A324655u 20 | #define UF2_MAGIC_START1 0x9E5D5157u 21 | #define UF2_MAGIC_END 0x0AB16F30u 22 | 23 | #define UF2_FLAG_NOT_MAIN_FLASH 0x00000001u 24 | #define UF2_FLAG_FILE_CONTAINER 0x00001000u 25 | #define UF2_FLAG_FAMILY_ID_PRESENT 0x00002000u 26 | #define UF2_FLAG_MD5_PRESENT 0x00004000u 27 | 28 | #define RP2040_FAMILY_ID 0xe48bff56 29 | 30 | struct uf2_block { 31 | // 32 byte header 32 | uint32_t magic_start0; 33 | uint32_t magic_start1; 34 | uint32_t flags; 35 | uint32_t target_addr; 36 | uint32_t payload_size; 37 | uint32_t block_no; 38 | uint32_t num_blocks; 39 | uint32_t file_size; // or familyID; 40 | uint8_t data[476]; 41 | uint32_t magic_end; 42 | }; 43 | 44 | static_assert(sizeof(struct uf2_block) == 512, "uf2_block not sector sized"); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_base/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_base_headers) 2 | pico_add_library(pico_base NOFLAG) 3 | target_include_directories(pico_base_headers 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 | target_link_libraries(pico_base_headers INTERFACE pico_platform_headers) 10 | 11 | list(APPEND PICO_SDK_POST_LIST_FILES ${CMAKE_CURRENT_LIST_DIR}/generate_config_header.cmake) 12 | pico_promote_common_scope_vars() 13 | endif() -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_base/generate_config_header.cmake: -------------------------------------------------------------------------------- 1 | # build the auto gen config headers 2 | 3 | set(header_content "// AUTOGENERATED FROM PICO_CONFIG_HEADER_FILES and then PICO__CONFIG_HEADER_FILES\n// DO NOT EDIT!\n") 4 | string(TOUPPER ${PICO_PLATFORM} PICO_PLATFORM_UPPER) 5 | 6 | macro(add_header_content_from_var VAR) 7 | set(header_content "${header_content}\n\n// based on ${VAR}:\n") 8 | foreach(var IN LISTS ${VAR}) 9 | set(header_content "${header_content}\n#include \"${var}\"") 10 | endforeach() 11 | endmacro() 12 | 13 | # PICO_CMAKE_CONFIG: PICO_CONFIG_HEADER_FILES, List of extra header files to include from pico/config.h for all platforms, type=list, default="", group=pico_base 14 | add_header_content_from_var(PICO_CONFIG_HEADER_FILES) 15 | 16 | # PICO_CMAKE_CONFIG: PICO_RP2040_CONFIG_HEADER_FILES, List of extra header files to include from pico/config.h for rp2040 platform, type=list, default="", group=pico_base 17 | # PICO_CMAKE_CONFIG: PICO_HOST_CONFIG_HEADER_FILES, List of extra header files to include from pico/config.h for host platform, type=list, default="", group=pico_base 18 | add_header_content_from_var(PICO_${PICO_PLATFORM_UPPER}_CONFIG_HEADER_FILES) 19 | 20 | file(GENERATE 21 | OUTPUT ${CMAKE_BINARY_DIR}/generated/pico_base/pico/config_autogen.h 22 | CONTENT "${header_content}" 23 | ) 24 | 25 | configure_file( ${CMAKE_CURRENT_LIST_DIR}/include/pico/version.h.in ${CMAKE_BINARY_DIR}/generated/pico_base/pico/version.h) 26 | 27 | foreach(DIR IN LISTS PICO_INCLUDE_DIRS) 28 | target_include_directories(pico_base_headers INTERFACE ${DIR}) 29 | endforeach() 30 | -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_base/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 | * Core types and macros for the Raspberry Pi Pico SDK. This header is intended to be included by all source code 14 | * as it includes configuration headers and overrides in the correct order 15 | * 16 | * This header may be included by assembly code 17 | */ 18 | 19 | // We may be included by assembly which cant include 20 | #define __PICO_STRING(x) #x 21 | #define __PICO_XSTRING(x) __PICO_STRING(x) 22 | #define __PICO_CONCAT1(x, y) x ## y 23 | 24 | #include "pico/types.h" 25 | #include "pico/version.h" 26 | 27 | // 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 28 | #ifdef PICO_CONFIG_HEADER 29 | #include __PICO_XSTRING(PICO_CONFIG_HEADER) 30 | #else 31 | #include "pico/config.h" 32 | #endif 33 | #include "pico/platform.h" 34 | #include "pico/error.h" 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_base/include/pico/assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_ASSERT_H 8 | #define _PICO_ASSERT_H 9 | 10 | #include 11 | 12 | #ifdef __cplusplus 13 | 14 | #include 15 | 16 | extern "C" { 17 | #else 18 | #include 19 | #endif 20 | 21 | // PICO_CONFIG: PARAM_ASSERTIONS_ENABLE_ALL, Global assert enable, type=bool, default=0, group=pico_base 22 | // PICO_CONFIG: PARAM_ASSERTIONS_DISABLE_ALL, Global assert disable, type=bool, default=0, group=pico_base 23 | 24 | #ifndef PARAM_ASSERTIONS_ENABLE_ALL 25 | #define PARAM_ASSERTIONS_ENABLE_ALL 0 26 | #endif 27 | 28 | #ifndef PARAM_ASSERTIONS_DISABLE_ALL 29 | #define PARAM_ASSERTIONS_DISABLE_ALL 0 30 | #endif 31 | 32 | #define PARAM_ASSERTIONS_ENABLED(x) ((PARAM_ASSERTIONS_ENABLED_ ## x || PARAM_ASSERTIONS_ENABLE_ALL) && !PARAM_ASSERTIONS_DISABLE_ALL) 33 | 34 | #define invalid_params_if(x, test) ({if (PARAM_ASSERTIONS_ENABLED(x)) assert(!(test));}) 35 | #define valid_params_if(x, test) ({if (PARAM_ASSERTIONS_ENABLED(x)) assert(test);}) 36 | #define hard_assert_if(x, test) ({if (PARAM_ASSERTIONS_ENABLED(x)) hard_assert(!(test));}) 37 | 38 | #ifdef NDEBUG 39 | extern void hard_assertion_failure(void); 40 | static inline void hard_assert(bool condition, ...) { 41 | if (!condition) 42 | hard_assertion_failure(); 43 | } 44 | #else 45 | #define hard_assert assert 46 | #endif 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | #endif 52 | -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_base/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 | -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_base/include/pico/error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_ERROR_H 8 | #define _PICO_ERROR_H 9 | 10 | #ifndef __ASSEMBLER__ 11 | 12 | /*! 13 | * \brief Common return codes from pico_sdk methods that return a status 14 | * \ingroup pico_base 15 | */ 16 | enum pico_error_codes { 17 | PICO_OK = 0, 18 | PICO_ERROR_NONE = 0, 19 | PICO_ERROR_TIMEOUT = -1, 20 | PICO_ERROR_GENERIC = -2, 21 | PICO_ERROR_NO_DATA = -3, 22 | PICO_ERROR_NOT_PERMITTED = -4, 23 | PICO_ERROR_INVALID_ARG = -5, 24 | PICO_ERROR_IO = -6, 25 | PICO_ERROR_BADAUTH = -7, 26 | PICO_ERROR_CONNECT_FAILED = -8, 27 | }; 28 | 29 | #endif // !__ASSEMBLER__ 30 | 31 | #endif -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_base/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 | -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_binary_info/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(pico_binary_info_headers INTERFACE) 2 | 3 | target_include_directories(pico_binary_info_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 4 | 5 | if (COMMAND pico_add_platform_library) 6 | pico_add_platform_library(pico_binary_info) 7 | else() 8 | add_library(pico_binary_info INTERFACE) 9 | endif() 10 | 11 | target_link_libraries(pico_binary_info INTERFACE pico_binary_info_headers) 12 | 13 | function(pico_set_program_name TARGET name) 14 | # PICO_BUILD_DEFINE: PICO_PROGRAM_NAME, value passed to pico_set_program_name, type=string, default=none, group=pico_binary_info 15 | target_compile_definitions(${TARGET} PRIVATE -DPICO_PROGRAM_NAME="${name}") 16 | endfunction() 17 | 18 | function(pico_set_program_description TARGET description) 19 | # since this is the command line, we will remove newlines 20 | string(REPLACE "\n" " " description ${description}) 21 | string(REPLACE "\"" "\\\"" description ${description}) 22 | # PICO_BUILD_DEFINE: PICO_PROGRAM_DESCRIPTION, value passed to pico_set_program_description, type=string, default=none, group=pico_binary_info 23 | target_compile_definitions(${TARGET} PRIVATE -DPICO_PROGRAM_DESCRIPTION="${description}") 24 | endfunction() 25 | 26 | function(pico_set_program_url TARGET url) 27 | # PICO_BUILD_DEFINE: PICO_PROGRAM_URL, value passed to pico_set_program_url, type=string, default=none, group=pico_binary_info 28 | target_compile_definitions(${TARGET} PRIVATE -DPICO_PROGRAM_URL="${url}") 29 | endfunction() 30 | 31 | function(pico_set_program_version TARGET version) 32 | # PICO_BUILD_DEFINE: PICO_PROGRAM_VERSION_STRING, value passed to pico_set_program_version, type=string, default=none, group=pico_binary_info 33 | target_compile_definitions(${TARGET} PRIVATE -DPICO_PROGRAM_VERSION_STRING="${version}") 34 | endfunction() 35 | -------------------------------------------------------------------------------- /pico-sdk/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 | * 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 | #if !PICO_ON_DEVICE && !defined(PICO_NO_BINARY_INFO) 26 | #define PICO_NO_BINARY_INFO 1 27 | #endif 28 | #include "pico/binary_info/code.h" 29 | #endif 30 | -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_binary_info/include/pico/binary_info/defs.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_DEFS_H 8 | #define _PICO_BINARY_INFO_DEFS_H 9 | 10 | // this file is for pre-processor definitions only 11 | 12 | // should be found within the first 256 bytes of the real binary (i.e. after the flash second stage if a flash binary) 13 | // 14 | // Note the layout is: 15 | // 16 | // addr : BINARY_INFO_MARKER_START 17 | // addr+0x04 : __binary_info_start 18 | // addr+0x08 : __binary_info_end 19 | // addr+0x0c : __address_mapping_table 20 | // addr+0x10 | BINARY_INFO_MARKER_END 21 | // 22 | // __binary_info_start to __binary_info_end are the start, end (non inclusive) of an array 23 | // of pointers to binary_info_t structures 24 | // 25 | // __address_mapping_table is an array of the following items: 26 | // 27 | // uint32_t source_addr_start 28 | // uint32_t dest_addr_start 29 | // uint32_t dest_addr_end 30 | // 31 | // representing a mapping from the stored address in the binary/flash to addresses at runtime. 32 | // The linker will store pointers within the binary using their runtime values, however because of 33 | // "AT" mapping in the link script these addresses actually correspond to a different address in the binary 34 | // image. This mapping (which in the case of crt0.S is simply the data copy table used at initialization 35 | // to copy data into it's runtime location) can be used by picotool or others to reverse the mapping to find data 36 | // within the binary. 37 | // 38 | // Note the above array is terminated with a NULL source_addr_start 39 | 40 | #define BINARY_INFO_MARKER_START 0x7188ebf2 41 | #define BINARY_INFO_MARKER_END 0xe71aa390 42 | 43 | #endif -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_bit_ops/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 INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 4 | target_link_libraries(pico_bit_ops_headers INTERFACE pico_base_headers) 5 | endif() -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_bit_ops/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 | * Optimized bit manipulation functions. 20 | * Additionally provides replacement implementations of the compiler built-ins __builtin_popcount, __builtin_clz 21 | * and __bulitin_ctz 22 | */ 23 | 24 | /*! \brief Reverse the bits in a 32 bit word 25 | * \ingroup pico_bit_ops 26 | * 27 | * \param bits 32 bit input 28 | * \return the 32 input bits reversed 29 | */ 30 | uint32_t __rev(uint32_t bits); 31 | 32 | /*! \brief Reverse the bits in a 64 bit double word 33 | * \ingroup pico_bit_ops 34 | * 35 | * \param bits 64 bit input 36 | * \return the 64 input bits reversed 37 | */ 38 | uint64_t __revll(uint64_t bits); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_divider/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_divider_headers) 2 | add_library(pico_divider_headers INTERFACE) 3 | target_include_directories(pico_divider_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 4 | target_link_libraries(pico_divider_headers INTERFACE pico_base_headers) 5 | endif() -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_stdlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_stdlib_headers) 2 | add_library(pico_stdlib_headers INTERFACE) 3 | target_include_directories(pico_stdlib_headers INTERFACE include) 4 | # dependencies handled in implementation CMakeLists.txt 5 | endif() -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_sync/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_sync_headers) 2 | add_library(pico_sync_headers INTERFACE) 3 | target_link_libraries(pico_sync_headers INTERFACE 4 | hardware_sync_headers 5 | pico_time_headers) 6 | endif() 7 | 8 | if (NOT TARGET pico_sync) 9 | pico_add_impl_library(pico_sync) 10 | target_include_directories(pico_sync_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 11 | pico_mirrored_target_link_libraries(pico_sync INTERFACE pico_sync_sem pico_sync_mutex pico_sync_critical_section pico_time hardware_sync) 12 | endif() 13 | 14 | 15 | if (NOT TARGET pico_sync_core) 16 | pico_add_library(pico_sync_core NOFLAG) 17 | target_sources(pico_sync_core INTERFACE 18 | ${CMAKE_CURRENT_LIST_DIR}/lock_core.c 19 | ) 20 | endif() 21 | 22 | if (NOT TARGET pico_sync_sem) 23 | pico_add_library(pico_sync_sem) 24 | target_sources(pico_sync_sem INTERFACE 25 | ${CMAKE_CURRENT_LIST_DIR}/sem.c 26 | ) 27 | pico_mirrored_target_link_libraries(pico_sync_sem INTERFACE pico_sync_core) 28 | endif() 29 | 30 | if (NOT TARGET pico_sync_mutex) 31 | pico_add_library(pico_sync_mutex) 32 | target_sources(pico_sync_mutex INTERFACE 33 | ${CMAKE_CURRENT_LIST_DIR}/mutex.c 34 | ) 35 | pico_mirrored_target_link_libraries(pico_sync_mutex INTERFACE pico_sync_core) 36 | endif() 37 | 38 | if (NOT TARGET pico_sync_critical_section) 39 | pico_add_library(pico_sync_critical_section) 40 | target_sources(pico_sync_critical_section INTERFACE 41 | ${CMAKE_CURRENT_LIST_DIR}/critical_section.c 42 | ) 43 | pico_mirrored_target_link_libraries(pico_sync_critical_section INTERFACE pico_sync_core) 44 | endif() 45 | 46 | 47 | -------------------------------------------------------------------------------- /pico-sdk/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_NO_HARDWARE 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 | } -------------------------------------------------------------------------------- /pico-sdk/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 | * 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 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/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 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 | -------------------------------------------------------------------------------- /pico-sdk/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); 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 -------------------------------------------------------------------------------- /pico-sdk/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) { 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) { 19 | if (time_reached(ts->next_timeout)) { 20 | return true; 21 | } 22 | ts->next_timeout = make_timeout_time_us(ts->param); 23 | return false; 24 | } 25 | 26 | check_timeout_fn init_per_iteration_timeout_us(timeout_state_t *ts, uint64_t per_iteration_timeout_us) { 27 | ts->next_timeout = make_timeout_time_us(per_iteration_timeout_us); 28 | ts->param = per_iteration_timeout_us; 29 | return check_per_iteration_timeout_us; 30 | } 31 | -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_usb_reset_interface/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 INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 7 | -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_usb_reset_interface/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 pico_usb_reset_interface 12 | * 13 | * 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 -------------------------------------------------------------------------------- /pico-sdk/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 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 | -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_util/datetime.c: -------------------------------------------------------------------------------- 1 | #include "pico/util/datetime.h" 2 | 3 | #include 4 | 5 | static const char *DATETIME_MONTHS[12] = { 6 | "January", 7 | "February", 8 | "March", 9 | "April", 10 | "May", 11 | "June", 12 | "July", 13 | "August", 14 | "September", 15 | "October", 16 | "November", 17 | "December" 18 | }; 19 | 20 | static const char *DATETIME_DOWS[7] = { 21 | "Sunday", 22 | "Monday", 23 | "Tuesday", 24 | "Wednesday", 25 | "Thursday", 26 | "Friday", 27 | "Saturday", 28 | }; 29 | 30 | void datetime_to_str(char *buf, uint buf_size, const datetime_t *t) { 31 | snprintf(buf, 32 | buf_size, 33 | "%s %d %s %d:%02d:%02d %d", 34 | DATETIME_DOWS[t->dotw], 35 | t->day, 36 | DATETIME_MONTHS[t->month - 1], 37 | t->hour, 38 | t->min, 39 | t->sec, 40 | t->year); 41 | }; -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_util/doc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup pico_util pico_util 3 | * \brief Useful data structures and utility functions 4 | */ 5 | -------------------------------------------------------------------------------- /pico-sdk/src/common/pico_util/include/pico/util/datetime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_UTIL_DATETIME_H 8 | #define _PICO_UTIL_DATETIME_H 9 | 10 | #include "pico.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /** \file datetime.h 17 | * \defgroup util_datetime datetime 18 | * \brief Date/Time formatting 19 | * \ingroup pico_util 20 | */ 21 | 22 | /*! \brief Convert a datetime_t structure to a string 23 | * \ingroup util_datetime 24 | * 25 | * \param buf character buffer to accept generated string 26 | * \param buf_size The size of the passed in buffer 27 | * \param t The datetime to be converted. 28 | */ 29 | void datetime_to_str(char *buf, uint buf_size, const datetime_t *t); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | #endif 35 | -------------------------------------------------------------------------------- /pico-sdk/src/host.cmake: -------------------------------------------------------------------------------- 1 | # For targeting the host for testing purposes 2 | 3 | function(pico_add_extra_outputs TARGET) 4 | endfunction() 5 | 6 | set(PICO_NO_HARDWARE "1" CACHE INTERNAL "") 7 | set(PICO_ON_DEVICE "0" CACHE INTERNAL "") 8 | 9 | add_subdirectory(common) 10 | add_subdirectory(host) -------------------------------------------------------------------------------- /pico-sdk/src/host/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_subdirectory(hardware_divider) 2 | pico_add_subdirectory(hardware_gpio) 3 | pico_add_subdirectory(hardware_sync) 4 | pico_add_subdirectory(hardware_timer) 5 | pico_add_subdirectory(hardware_uart) 6 | pico_add_subdirectory(pico_bit_ops) 7 | pico_add_subdirectory(pico_divider) 8 | pico_add_subdirectory(pico_multicore) 9 | pico_add_subdirectory(pico_platform) 10 | pico_add_subdirectory(pico_printf) 11 | pico_add_subdirectory(pico_stdio) 12 | pico_add_subdirectory(pico_stdlib) 13 | 14 | pico_add_doxygen(${CMAKE_CURRENT_LIST_DIR}) 15 | 16 | macro(pico_set_float_implementation TARGET IMPL) 17 | # ignore 18 | endmacro() 19 | 20 | macro(pico_set_double_implementation TARGET IMPL) 21 | # ignore 22 | endmacro() 23 | 24 | macro(pico_set_binary_type TARGET IMPL) 25 | # ignore 26 | endmacro() 27 | 28 | macro(pico_set_boot_stage2 TARGET IMPL) 29 | # ignore 30 | endmacro() 31 | 32 | set(PICO_HOST_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "") 33 | function(pico_define_boot_stage2 NAME) 34 | add_executable(${NAME} ${PICO_HOST_DIR}/boot_stage2.c) 35 | endfunction() 36 | 37 | pico_promote_common_scope_vars() -------------------------------------------------------------------------------- /pico-sdk/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 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 | -------------------------------------------------------------------------------- /pico-sdk/src/host/boot_stage2.c: -------------------------------------------------------------------------------- 1 | void main() { 2 | 3 | } -------------------------------------------------------------------------------- /pico-sdk/src/host/hardware_divider/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(divider) -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/src/host/hardware_gpio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(gpio) -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/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() -------------------------------------------------------------------------------- /pico-sdk/src/host/hardware_timer/include/hardware/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _HARDWARE_TIMER_H 8 | #define _HARDWARE_TIMER_H 9 | 10 | #include "pico.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | 17 | #ifndef PARAM_ASSERTIONS_ENABLED_TIMER 18 | #define PARAM_ASSERTIONS_ENABLED_TIMER 0 19 | #endif 20 | 21 | static inline void check_hardware_alarm_num_param(uint alarm_num) { 22 | invalid_params_if(TIMER, alarm_num >= NUM_TIMERS); 23 | } 24 | 25 | uint32_t time_us_32(); 26 | uint64_t time_us_64(); 27 | void busy_wait_us_32(uint32_t delay_us); 28 | void busy_wait_us(uint64_t delay_us); 29 | void busy_wait_until(absolute_time_t t); 30 | bool time_reached(absolute_time_t t); 31 | typedef void (*hardware_alarm_callback_t)(uint alarm_num); 32 | void hardware_alarm_claim(uint alarm_num); 33 | void hardware_alarm_unclaim(uint alarm_num); 34 | int hardware_alarm_claim_unused(bool required); 35 | void hardware_alarm_set_callback(uint alarm_num, hardware_alarm_callback_t callback); 36 | bool hardware_alarm_set_target(uint alarm_num, absolute_time_t t); 37 | void hardware_alarm_cancel(uint alarm_num); 38 | void hardware_alarm_force_irq(uint alarm_num); 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /pico-sdk/src/host/hardware_uart/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(uart) -------------------------------------------------------------------------------- /pico-sdk/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() -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/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() -------------------------------------------------------------------------------- /pico-sdk/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 INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 5 | 6 | pico_mirrored_target_link_libraries(pico_multicore INTERFACE pico_base) 7 | endif() 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /pico-sdk/src/host/pico_multicore/include/pico/multicore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_MULTICORE_H 8 | #define _PICO_MULTICORE_H 9 | 10 | #include "pico/types.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | void multicore_reset_core1(void); 17 | void multicore_launch_core1(void (*entry)(void)); 18 | void multicore_launch_core1_with_stack(void (*entry)(void), uint32_t *stack_bottom, size_t stack_size_bytes); 19 | void multicore_launch_core1_raw(void (*entry)(void), uint32_t *sp, uint32_t vector_table); 20 | 21 | bool multicore_fifo_rvalid(void); 22 | bool multicore_fifo_wready(void); 23 | void multicore_fifo_push_blocking(uint32_t data); 24 | bool multicore_fifo_push_timeout_us(uint32_t data, uint64_t timeout_us); 25 | uint32_t multicore_fifo_pop_blocking(); 26 | bool multicore_fifo_pop_timeout_us(uint64_t timeout_us, uint32_t *out); 27 | void multicore_fifo_drain(void); 28 | void multicore_fifo_clear_irq(void); 29 | uint32_t multicore_fifo_get_status(void); 30 | 31 | // call this from the lockout victim thread 32 | void multicore_lockout_victim_init(void); 33 | 34 | // start locking out the other core (it will be 35 | bool multicore_lockout_start_timeout_us(uint64_t timeout_us); 36 | void multicore_lockout_start_blocking(void); 37 | 38 | bool multicore_lockout_end_timeout_us(uint64_t timeout_us); 39 | void multicore_lockout_end_blocking(void); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /pico-sdk/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 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 | -------------------------------------------------------------------------------- /pico-sdk/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_TIMERS 4u 15 | 16 | #define NUM_IRQS 32u 17 | 18 | #define NUM_SPIN_LOCKS 32u 19 | 20 | #define XOSC_MHZ 12 21 | 22 | #define NUM_SPIN_LOCKS 32u 23 | 24 | #ifndef _u 25 | #define _u(x) x ## u 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /pico-sdk/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 | 11 | PICO_WEAK_FUNCTION_DEF(tight_loop_contents) 12 | 13 | void PICO_WEAK_FUNCTION_IMPL_NAME(tight_loop_contents)() { 14 | 15 | } 16 | 17 | void __noreturn panic_unsupported() { 18 | panic("not supported"); 19 | } 20 | 21 | void hard_assertion_failure(void) { 22 | panic("Hard assert"); 23 | } 24 | 25 | void panic(const char *fmt, ...) { 26 | va_list args; 27 | 28 | puts("*** PANIC ***\n"); 29 | if (fmt) { 30 | va_start(args, fmt); 31 | vprintf(fmt, args); 32 | va_end(args); 33 | } 34 | 35 | puts("\n"); 36 | 37 | __breakpoint(); 38 | } 39 | 40 | void __breakpoint() { 41 | #ifdef _MSC_VER 42 | __debugbreak(); 43 | #else 44 | __builtin_trap(); 45 | #endif 46 | } -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/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 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 | endif() 20 | 21 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/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 | } -------------------------------------------------------------------------------- /pico-sdk/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_stdio 16 | hardware_gpio 17 | hardware_uart 18 | ) 19 | endif() 20 | 21 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2040.cmake: -------------------------------------------------------------------------------- 1 | # include everything needed to build against rp2040 2 | 3 | include(rp2_common.cmake) 4 | 5 | add_subdirectory(rp2040) 6 | 7 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2040/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Targets specific to B0 silicon 2 | pico_add_subdirectory(hardware_regs) 3 | pico_add_subdirectory(hardware_structs) 4 | 5 | pico_add_doxygen(${CMAKE_CURRENT_LIST_DIR}) 6 | pico_add_doxygen_exclude(${CMAKE_CURRENT_LIST_DIR}/hardware_regs) # very very big 7 | 8 | pico_promote_common_scope_vars() -------------------------------------------------------------------------------- /pico-sdk/src/rp2040/README.md: -------------------------------------------------------------------------------- 1 | This directory contains header files defining the RP2040 hardware. It is selected when 2 | `PICO_PLATFORM=rp2040` (the default) is specified for the build 3 | 4 | `hardware_regs` contains low level hardware register #defines autogenerated from the RP2040 chip definition itself. 5 | 6 | `hardware_structs` contains C structures for accessing memory mapped registers 7 | 8 | -------------------------------------------------------------------------------- /pico-sdk/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 INTERFACE include) 4 | pico_mirrored_target_link_libraries(hardware_regs INTERFACE hardware_base) 5 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2040/hardware_regs/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 | // This header is included from C and assembler - intended mostly for #defines; guard other stuff with #ifdef __ASSEMBLER__ 11 | 12 | #ifndef _u 13 | #ifdef __ASSEMBLER__ 14 | #define _u(x) x 15 | #else 16 | #define _u(x) x ## u 17 | #endif 18 | #endif 19 | 20 | #define NUM_CORES _u(2) 21 | #define NUM_DMA_CHANNELS _u(12) 22 | #define NUM_DMA_TIMERS _u(4) 23 | #define NUM_IRQS _u(32) 24 | #define NUM_USER_IRQS _u(6) 25 | #define NUM_PIOS _u(2) 26 | #define NUM_PIO_STATE_MACHINES _u(4) 27 | #define NUM_PWM_SLICES _u(8) 28 | #define NUM_SPIN_LOCKS _u(32) 29 | #define NUM_UARTS _u(2) 30 | #define NUM_I2CS _u(2) 31 | #define NUM_SPIS _u(2) 32 | #define NUM_TIMERS _u(4) 33 | #define NUM_ADC_CHANNELS _u(5) 34 | 35 | #define NUM_BANK0_GPIOS _u(30) 36 | #define NUM_QSPI_GPIOS _u(6) 37 | 38 | #define PIO_INSTRUCTION_COUNT _u(32) 39 | 40 | // PICO_CONFIG: XOSC_MHZ, The crystal oscillator frequency in Mhz, type=int, default=12, advanced=true, group=hardware_base 41 | #ifndef XOSC_MHZ 42 | #define XOSC_MHZ _u(12) 43 | #endif 44 | 45 | #define FIRST_USER_IRQ (NUM_IRQS - NUM_USER_IRQS) 46 | #define VTABLE_FIRST_IRQ 16 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2040/hardware_regs/include/hardware/regs/dreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | #ifndef _DREQ_H_ 7 | #define _DREQ_H_ 8 | 9 | #define DREQ_PIO0_TX0 0x0 10 | #define DREQ_PIO0_TX1 0x1 11 | #define DREQ_PIO0_TX2 0x2 12 | #define DREQ_PIO0_TX3 0x3 13 | #define DREQ_PIO0_RX0 0x4 14 | #define DREQ_PIO0_RX1 0x5 15 | #define DREQ_PIO0_RX2 0x6 16 | #define DREQ_PIO0_RX3 0x7 17 | #define DREQ_PIO1_TX0 0x8 18 | #define DREQ_PIO1_TX1 0x9 19 | #define DREQ_PIO1_TX2 0xa 20 | #define DREQ_PIO1_TX3 0xb 21 | #define DREQ_PIO1_RX0 0xc 22 | #define DREQ_PIO1_RX1 0xd 23 | #define DREQ_PIO1_RX2 0xe 24 | #define DREQ_PIO1_RX3 0xf 25 | #define DREQ_SPI0_TX 0x10 26 | #define DREQ_SPI0_RX 0x11 27 | #define DREQ_SPI1_TX 0x12 28 | #define DREQ_SPI1_RX 0x13 29 | #define DREQ_UART0_TX 0x14 30 | #define DREQ_UART0_RX 0x15 31 | #define DREQ_UART1_TX 0x16 32 | #define DREQ_UART1_RX 0x17 33 | #define DREQ_PWM_WRAP0 0x18 34 | #define DREQ_PWM_WRAP1 0x19 35 | #define DREQ_PWM_WRAP2 0x1a 36 | #define DREQ_PWM_WRAP3 0x1b 37 | #define DREQ_PWM_WRAP4 0x1c 38 | #define DREQ_PWM_WRAP5 0x1d 39 | #define DREQ_PWM_WRAP6 0x1e 40 | #define DREQ_PWM_WRAP7 0x1f 41 | #define DREQ_I2C0_TX 0x20 42 | #define DREQ_I2C0_RX 0x21 43 | #define DREQ_I2C1_TX 0x22 44 | #define DREQ_I2C1_RX 0x23 45 | #define DREQ_ADC 0x24 46 | #define DREQ_XIP_STREAM 0x25 47 | #define DREQ_XIP_SSITX 0x26 48 | #define DREQ_XIP_SSIRX 0x27 49 | 50 | #endif // _DREQ_H_ 51 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2040/hardware_regs/include/hardware/regs/intctrl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | #ifndef _INTCTRL_H_ 7 | #define _INTCTRL_H_ 8 | 9 | #define TIMER_IRQ_0 0 10 | #define TIMER_IRQ_1 1 11 | #define TIMER_IRQ_2 2 12 | #define TIMER_IRQ_3 3 13 | #define PWM_IRQ_WRAP 4 14 | #define USBCTRL_IRQ 5 15 | #define XIP_IRQ 6 16 | #define PIO0_IRQ_0 7 17 | #define PIO0_IRQ_1 8 18 | #define PIO1_IRQ_0 9 19 | #define PIO1_IRQ_1 10 20 | #define DMA_IRQ_0 11 21 | #define DMA_IRQ_1 12 22 | #define IO_IRQ_BANK0 13 23 | #define IO_IRQ_QSPI 14 24 | #define SIO_IRQ_PROC0 15 25 | #define SIO_IRQ_PROC1 16 26 | #define CLOCKS_IRQ 17 27 | #define SPI0_IRQ 18 28 | #define SPI1_IRQ 19 29 | #define UART0_IRQ 20 30 | #define UART1_IRQ 21 31 | #define ADC_IRQ_FIFO 22 32 | #define I2C0_IRQ 23 33 | #define I2C1_IRQ 24 34 | #define RTC_IRQ 25 35 | 36 | #define isr_timer_0 isr_irq0 37 | #define isr_timer_1 isr_irq1 38 | #define isr_timer_2 isr_irq2 39 | #define isr_timer_3 isr_irq3 40 | #define isr_pwm_wrap isr_irq4 41 | #define isr_usbctrl isr_irq5 42 | #define isr_xip isr_irq6 43 | #define isr_pio0_0 isr_irq7 44 | #define isr_pio0_1 isr_irq8 45 | #define isr_pio1_0 isr_irq9 46 | #define isr_pio1_1 isr_irq10 47 | #define isr_dma_0 isr_irq11 48 | #define isr_dma_1 isr_irq12 49 | #define isr_io_bank0 isr_irq13 50 | #define isr_io_qspi isr_irq14 51 | #define isr_sio_proc0 isr_irq15 52 | #define isr_sio_proc1 isr_irq16 53 | #define isr_clocks isr_irq17 54 | #define isr_spi0 isr_irq18 55 | #define isr_spi1 isr_irq19 56 | #define isr_uart0 isr_irq20 57 | #define isr_uart1 isr_irq21 58 | #define isr_adc_fifo isr_irq22 59 | #define isr_i2c0 isr_irq23 60 | #define isr_i2c1 isr_irq24 61 | #define isr_rtc isr_irq25 62 | 63 | #endif // _INTCTRL_H_ 64 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2040/hardware_regs/include/hardware/regs/tbman.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | // ============================================================================= 7 | // Register block : TBMAN 8 | // Version : 1 9 | // Bus type : apb 10 | // Description : Testbench manager. Allows the programmer to know what 11 | // platform their software is running on. 12 | // ============================================================================= 13 | #ifndef HARDWARE_REGS_TBMAN_DEFINED 14 | #define HARDWARE_REGS_TBMAN_DEFINED 15 | // ============================================================================= 16 | // Register : TBMAN_PLATFORM 17 | // Description : Indicates the type of platform in use 18 | #define TBMAN_PLATFORM_OFFSET _u(0x00000000) 19 | #define TBMAN_PLATFORM_BITS _u(0x00000003) 20 | #define TBMAN_PLATFORM_RESET _u(0x00000005) 21 | // ----------------------------------------------------------------------------- 22 | // Field : TBMAN_PLATFORM_FPGA 23 | // Description : Indicates the platform is an FPGA 24 | #define TBMAN_PLATFORM_FPGA_RESET _u(0x0) 25 | #define TBMAN_PLATFORM_FPGA_BITS _u(0x00000002) 26 | #define TBMAN_PLATFORM_FPGA_MSB _u(1) 27 | #define TBMAN_PLATFORM_FPGA_LSB _u(1) 28 | #define TBMAN_PLATFORM_FPGA_ACCESS "RO" 29 | // ----------------------------------------------------------------------------- 30 | // Field : TBMAN_PLATFORM_ASIC 31 | // Description : Indicates the platform is an ASIC 32 | #define TBMAN_PLATFORM_ASIC_RESET _u(0x1) 33 | #define TBMAN_PLATFORM_ASIC_BITS _u(0x00000001) 34 | #define TBMAN_PLATFORM_ASIC_MSB _u(0) 35 | #define TBMAN_PLATFORM_ASIC_LSB _u(0) 36 | #define TBMAN_PLATFORM_ASIC_ACCESS "RO" 37 | // ============================================================================= 38 | #endif // HARDWARE_REGS_TBMAN_DEFINED 39 | -------------------------------------------------------------------------------- /pico-sdk/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 INTERFACE include) 4 | pico_mirrored_target_link_libraries(hardware_structs INTERFACE hardware_regs) -------------------------------------------------------------------------------- /pico-sdk/src/rp2040/hardware_structs/include/hardware/structs/pads_qspi.h: -------------------------------------------------------------------------------- 1 | // THIS HEADER FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT 2 | 3 | /* 4 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd. 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #ifndef _HARDWARE_STRUCTS_PADS_QSPI_H 10 | #define _HARDWARE_STRUCTS_PADS_QSPI_H 11 | 12 | #include "hardware/address_mapped.h" 13 | #include "hardware/regs/pads_qspi.h" 14 | 15 | // Reference to datasheet: https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf#tab-registerlist_pads_qspi 16 | // 17 | // The _REG_ macro is intended to help make the register navigable in your IDE (for example, using the "Go to Definition" feature) 18 | // _REG_(x) will link to the corresponding register in hardware/regs/pads_qspi.h. 19 | // 20 | // Bit-field descriptions are of the form: 21 | // BITMASK [BITRANGE]: FIELDNAME (RESETVALUE): DESCRIPTION 22 | 23 | typedef struct { 24 | _REG_(PADS_QSPI_VOLTAGE_SELECT_OFFSET) // PADS_QSPI_VOLTAGE_SELECT 25 | // Voltage select 26 | // 0x00000001 [0] : VOLTAGE_SELECT (0) 27 | io_rw_32 voltage_select; 28 | 29 | _REG_(PADS_QSPI_GPIO_QSPI_SCLK_OFFSET) // PADS_QSPI_GPIO_QSPI_SCLK 30 | // (Description copied from array index 0 register PADS_QSPI_GPIO_QSPI_SCLK applies similarly to other array indexes) 31 | // 32 | // Pad control register 33 | // 0x00000080 [7] : OD (0): Output disable 34 | // 0x00000040 [6] : IE (1): Input enable 35 | // 0x00000030 [5:4] : DRIVE (1): Drive strength 36 | // 0x00000008 [3] : PUE (0): Pull up enable 37 | // 0x00000004 [2] : PDE (1): Pull down enable 38 | // 0x00000002 [1] : SCHMITT (1): Enable schmitt trigger 39 | // 0x00000001 [0] : SLEWFAST (0): Slew rate control 40 | io_rw_32 io[NUM_QSPI_GPIOS]; // 6 41 | } pads_qspi_hw_t; 42 | 43 | #define pads_qspi_hw ((pads_qspi_hw_t *)PADS_QSPI_BASE) 44 | 45 | static_assert( NUM_QSPI_GPIOS == 6, ""); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2040/hardware_structs/include/hardware/structs/padsbank0.h: -------------------------------------------------------------------------------- 1 | // THIS HEADER FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT 2 | 3 | /* 4 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd. 5 | * 6 | * SPDX-License-Identifier: BSD-3-Clause 7 | */ 8 | 9 | #ifndef _HARDWARE_STRUCTS_PADSBANK0_H 10 | #define _HARDWARE_STRUCTS_PADSBANK0_H 11 | 12 | #include "hardware/address_mapped.h" 13 | #include "hardware/regs/pads_bank0.h" 14 | 15 | // Reference to datasheet: https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf#tab-registerlist_pads_bank0 16 | // 17 | // The _REG_ macro is intended to help make the register navigable in your IDE (for example, using the "Go to Definition" feature) 18 | // _REG_(x) will link to the corresponding register in hardware/regs/pads_bank0.h. 19 | // 20 | // Bit-field descriptions are of the form: 21 | // BITMASK [BITRANGE]: FIELDNAME (RESETVALUE): DESCRIPTION 22 | 23 | typedef struct { 24 | _REG_(PADS_BANK0_VOLTAGE_SELECT_OFFSET) // PADS_BANK0_VOLTAGE_SELECT 25 | // Voltage select 26 | // 0x00000001 [0] : VOLTAGE_SELECT (0) 27 | io_rw_32 voltage_select; 28 | 29 | _REG_(PADS_BANK0_GPIO0_OFFSET) // PADS_BANK0_GPIO0 30 | // (Description copied from array index 0 register PADS_BANK0_GPIO0 applies similarly to other array indexes) 31 | // 32 | // Pad control register 33 | // 0x00000080 [7] : OD (0): Output disable 34 | // 0x00000040 [6] : IE (1): Input enable 35 | // 0x00000030 [5:4] : DRIVE (1): Drive strength 36 | // 0x00000008 [3] : PUE (0): Pull up enable 37 | // 0x00000004 [2] : PDE (1): Pull down enable 38 | // 0x00000002 [1] : SCHMITT (1): Enable schmitt trigger 39 | // 0x00000001 [0] : SLEWFAST (0): Slew rate control 40 | io_rw_32 io[NUM_BANK0_GPIOS]; // 30 41 | } padsbank0_hw_t; 42 | 43 | #define padsbank0_hw ((padsbank0_hw_t *)PADS_BANK0_BASE) 44 | 45 | static_assert( NUM_BANK0_GPIOS == 30, ""); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/README.md: -------------------------------------------------------------------------------- 1 | This directory contains libraries specifically targeting the RP2040 or possible future related devices. It is selected when 2 | `PICO_PLATFORM=rp2040` (the default) is specified for the build 3 | 4 | `hardware_` libraries exist for individual hardware components to provide a simple API 5 | providing a thin abstraction hiding the details of accessing the hardware registers directly. 6 | 7 | `pico_` provides higher level functionality you might generally find in say an OS kernel, as well 8 | as runtime support familiar to most C programmers. 9 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/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 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/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 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/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 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/boot_stage2/boot2_usb_blinky.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // Stub second stage which calls into USB bootcode, with parameters. 8 | // USB boot takes two parameters: 9 | // - A GPIO mask for activity LED -- if mask is 0, don't touch GPIOs at all 10 | // - A mask of interfaces to disable. Bit 0 disables MSC, bit 1 disables PICOBoot 11 | // The bootrom passes 0 for both of these parameters, but user code (or this 12 | // second stage) can pass anything. 13 | 14 | #define USB_BOOT_MSD_AND_PICOBOOT 0x0 15 | #define USB_BOOT_MSD_ONLY 0x2 16 | #define USB_BOOT_PICOBOOT_ONLY 0x1 17 | 18 | // Config 19 | #define ACTIVITY_LED 0 20 | #define BOOT_MODE USB_BOOT_MSD_AND_PICOBOOT 21 | 22 | .cpu cortex-m0 23 | .thumb 24 | 25 | .section .text 26 | 27 | .global _stage2_boot 28 | .type _stage2_boot,%function 29 | 30 | .thumb_func 31 | _stage2_boot: 32 | mov r7, #0x14 // Pointer to _well_known pointer table in ROM 33 | ldrh r0, [r7, #0] // Offset 0 is 16 bit pointer to function table 34 | ldrh r7, [r7, #4] // Offset 4 is 16 bit pointer to table lookup routine 35 | ldr r1, =('U' | ('B' << 8)) // Symbol for USB Boot 36 | blx r7 37 | cmp r0, #0 38 | beq dead 39 | 40 | mov r7, r0 41 | ldr r0, =(1u << ACTIVITY_LED) // Mask of which GPIO (or GPIOs) to use 42 | mov r1, #BOOT_MODE 43 | blx r7 44 | 45 | dead: 46 | wfi 47 | b dead 48 | 49 | .global literals 50 | literals: 51 | .ltorg 52 | 53 | .end 54 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/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 | *(.entry) 11 | *(.text) 12 | } >SRAM 13 | } 14 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/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 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/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 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/cmsis/include/cmsis/rename_exceptions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _CMSIS_RENAME_EXCEPTIONS_H 8 | #define _CMSIS_RENAME_EXCEPTIONS_H 9 | 10 | #if LIB_CMSIS_CORE 11 | // PICO_CONFIG: PICO_CMSIS_RENAME_EXCEPTIONS, Whether to rename SDK exceptions such as isr_nmi to their CMSIS equivalent i.e. NMI_Handler, type=bool, default=1, group=cmsis_core 12 | 13 | // Note that since this header is included at the config stage, if you wish to override this you should do so via build compiler define 14 | #ifndef PICO_CMSIS_RENAME_EXCEPTIONS 15 | #define PICO_CMSIS_RENAME_EXCEPTIONS 1 16 | #endif 17 | 18 | #if PICO_CMSIS_RENAME_EXCEPTIONS 19 | #define isr_nmi NMI_Handler 20 | #define isr_hardfault HardFault_Handler 21 | #define isr_svcall SVC_Handler 22 | #define isr_pendsv PendSV_Handler 23 | #define isr_systick SysTick_Handler 24 | #define isr_irq0 TIMER_IRQ_0_Handler 25 | #define isr_irq1 TIMER_IRQ_1_Handler 26 | #define isr_irq2 TIMER_IRQ_2_Handler 27 | #define isr_irq3 TIMER_IRQ_3_Handler 28 | #define isr_irq4 PWM_IRQ_WRAP_Handler 29 | #define isr_irq5 USBCTRL_IRQ_Handler 30 | #define isr_irq6 XIP_IRQ_Handler 31 | #define isr_irq7 PIO0_IRQ_0_Handler 32 | #define isr_irq8 PIO0_IRQ_1_Handler 33 | #define isr_irq9 PIO1_IRQ_0_Handler 34 | #define isr_irq10 PIO1_IRQ_1_Handler 35 | #define isr_irq11 DMA_IRQ_0_Handler 36 | #define isr_irq12 DMA_IRQ_1_Handler 37 | #define isr_irq13 IO_IRQ_BANK0_Handler 38 | #define isr_irq14 IO_IRQ_QSPI_Handler 39 | #define isr_irq15 SIO_IRQ_PROC0_Handler 40 | #define isr_irq16 SIO_IRQ_PROC1_Handler 41 | #define isr_irq17 CLOCKS_IRQ_Handler 42 | #define isr_irq18 SPI0_IRQ_Handler 43 | #define isr_irq19 SPI1_IRQ_Handler 44 | #define isr_irq20 UART0_IRQ_Handler 45 | #define isr_irq21 UART1_IRQ_Handler 46 | #define isr_irq22 ADC_IRQ_FIFO_Handler 47 | #define isr_irq23 I2C0_IRQ_Handler 48 | #define isr_irq24 I2C1_IRQ_Handler 49 | #define isr_irq25 RTC_IRQ_Handler 50 | #endif 51 | 52 | #endif 53 | #endif /* _CMSIS_RENAME_EXCEPTIONS_H */ 54 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/cmsis/stub/CMSIS/Core/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.4 5 | * @date 23. July 2019 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2019 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 4U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /pico-sdk/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) -------------------------------------------------------------------------------- /pico-sdk/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_block(RESETS_RESET_ADC_BITS); 14 | unreset_block_wait(RESETS_RESET_ADC_BITS); 15 | 16 | // Now turn it back on. Staging of clock etc is handled internally 17 | adc_hw->cs = ADC_CS_EN_BITS; 18 | 19 | // Internal staging completes in a few cycles, but poll to be sure 20 | while (!(adc_hw->cs & ADC_CS_READY_BITS)) { 21 | tight_loop_contents(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /pico-sdk/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 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) -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_claim/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(claim) 2 | 3 | pico_mirrored_target_link_libraries(hardware_claim INTERFACE hardware_sync) -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_claim/claim.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "hardware/claim.h" 8 | 9 | uint32_t hw_claim_lock() { 10 | return spin_lock_blocking(spin_lock_instance(PICO_SPINLOCK_ID_HARDWARE_CLAIM)); 11 | } 12 | 13 | void hw_claim_unlock(uint32_t save) { 14 | spin_unlock(spin_lock_instance(PICO_SPINLOCK_ID_HARDWARE_CLAIM), save); 15 | } 16 | 17 | inline bool hw_is_claimed(const uint8_t *bits, uint bit_index) { 18 | return (bits[bit_index >> 3u] & (1u << (bit_index & 7u))); 19 | } 20 | 21 | void hw_claim_or_assert(uint8_t *bits, uint bit_index, const char *message) { 22 | uint32_t save = hw_claim_lock(); 23 | if (hw_is_claimed(bits, bit_index)) { 24 | panic(message, bit_index); 25 | } else { 26 | bits[bit_index >> 3u] |= (uint8_t)(1u << (bit_index & 7u)); 27 | } 28 | hw_claim_unlock(save); 29 | } 30 | 31 | int hw_claim_unused_from_range(uint8_t *bits, bool required, uint bit_lsb, uint bit_msb, const char *message) { 32 | // don't bother check lsb / msb order as if wrong, then it'll fail anyway 33 | uint32_t save = hw_claim_lock(); 34 | int found_bit = -1; 35 | for(uint bit=bit_lsb; bit <= bit_msb; bit++) { 36 | if (!hw_is_claimed(bits, bit)) { 37 | bits[bit >> 3u] |= (uint8_t)(1u << (bit & 7u)); 38 | found_bit = (int)bit; 39 | break; 40 | } 41 | } 42 | hw_claim_unlock(save); 43 | if (found_bit < 0 && required) { 44 | panic(message); 45 | } 46 | return found_bit; 47 | } 48 | 49 | void hw_claim_clear(uint8_t *bits, uint bit_index) { 50 | uint32_t save = hw_claim_lock(); 51 | assert(hw_is_claimed(bits, bit_index)); 52 | bits[bit_index >> 3u] &= (uint8_t) ~(1u << (bit_index & 7u)); 53 | hw_claim_unlock(save); 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /pico-sdk/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 | ) -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_divider/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_headers_only_target(divider) 2 | target_sources(hardware_divider INTERFACE ${CMAKE_CURRENT_LIST_DIR}/divider.S) 3 | target_link_libraries(hardware_divider_headers INTERFACE hardware_structs) -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_divider/divider.S: -------------------------------------------------------------------------------- 1 | #include "pico/asm_helper.S" 2 | #include "hardware/regs/addressmap.h" 3 | #include "hardware/regs/sio.h" 4 | 5 | .syntax unified 6 | .cpu cortex-m0plus 7 | .thumb 8 | 9 | // tag::hw_div_s32[] 10 | regular_func_with_section hw_divider_divmod_s32 11 | ldr r3, =(SIO_BASE) 12 | str r0, [r3, #SIO_DIV_SDIVIDEND_OFFSET] 13 | str r1, [r3, #SIO_DIV_SDIVISOR_OFFSET] 14 | b hw_divider_divmod_return 15 | // end::hw_div_s32[] 16 | 17 | // tag::hw_div_u32[] 18 | regular_func_with_section hw_divider_divmod_u32 19 | ldr r3, =(SIO_BASE) 20 | str r0, [r3, #SIO_DIV_UDIVIDEND_OFFSET] 21 | str r1, [r3, #SIO_DIV_UDIVISOR_OFFSET] 22 | b hw_divider_divmod_return 23 | // end::hw_div_u32[] 24 | 25 | // Common delay and return section for s32 and u32 26 | .section .text.hw_divider_divmod_return 27 | hw_divider_divmod_return: 28 | // Branching here is 2 cycles, delay another 6 29 | b 1f 30 | 1: b 1f 31 | 1: b 1f 32 | 1: // return 64 bit value so we can efficiently return both (note quotient must be read last) 33 | ldr r1, [r3, #SIO_DIV_REMAINDER_OFFSET] 34 | ldr r0, [r3, #SIO_DIV_QUOTIENT_OFFSET] 35 | bx lr 36 | 37 | regular_func_with_section hw_divider_save_state 38 | ldr r3, =SIO_BASE 39 | ldr r1, [r3, #SIO_DIV_UDIVIDEND_OFFSET] 40 | ldr r2, [r3, #SIO_DIV_UDIVISOR_OFFSET] 41 | stmia r0!, {r1-r2} 42 | // The 8 cycles needed to guarantee that the result is ready is ensured by the preceeding 43 | // code of 7 cycles together with any branch to it taking at least 2 cycles. 44 | ldr r1, [r3, #SIO_DIV_REMAINDER_OFFSET] 45 | ldr r2, [r3, #SIO_DIV_QUOTIENT_OFFSET] 46 | stmia r0!, {r1-r2} 47 | bx lr 48 | 49 | regular_func_with_section hw_divider_restore_state 50 | ldr r3, =SIO_BASE 51 | ldmia r0!, {r1-r2} 52 | str r1, [r3, #SIO_DIV_UDIVIDEND_OFFSET] 53 | str r2, [r3, #SIO_DIV_UDIVISOR_OFFSET] 54 | ldmia r0!, {r1-r2} 55 | str r1, [r3, #SIO_DIV_REMAINDER_OFFSET] 56 | str r2, [r3, #SIO_DIV_QUOTIENT_OFFSET] 57 | bx lr 58 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_dma/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(dma) 2 | pico_mirrored_target_link_libraries(hardware_dma INTERFACE hardware_claim) -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_exception/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(exception) 2 | pico_mirrored_target_link_libraries(hardware_exception INTERFACE hardware_sync) -------------------------------------------------------------------------------- /pico-sdk/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-sdk/src/rp2_common/hardware_gpio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(gpio) 2 | pico_mirrored_target_link_libraries(hardware_gpio INTERFACE hardware_irq) -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_interp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(interp) -------------------------------------------------------------------------------- /pico-sdk/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 | pico_mirrored_target_link_libraries(hardware_irq INTERFACE pico_sync) -------------------------------------------------------------------------------- /pico-sdk/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 | ) -------------------------------------------------------------------------------- /pico-sdk/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) -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_pll/include/hardware/pll.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _HARDWARE_PLL_H 8 | #define _HARDWARE_PLL_H 9 | 10 | #include "pico.h" 11 | #include "hardware/structs/pll.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /** \file hardware/pll.h 18 | * \defgroup hardware_pll hardware_pll 19 | * 20 | * Phase Locked Loop control APIs 21 | * 22 | * There are two PLLs in RP2040. They are: 23 | * - pll_sys - Used to generate up to a 133MHz system clock 24 | * - pll_usb - Used to generate a 48MHz USB reference clock 25 | * 26 | * For details on how the PLL's are calculated, please refer to the RP2040 datasheet. 27 | */ 28 | 29 | typedef pll_hw_t *PLL; 30 | 31 | #define pll_sys pll_sys_hw 32 | #define pll_usb pll_usb_hw 33 | 34 | #ifndef PICO_PLL_VCO_MIN_FREQ_MHZ 35 | #define PICO_PLL_VCO_MIN_FREQ_MHZ 750 36 | #endif 37 | 38 | #ifndef PICO_PLL_VCO_MAX_FREQ_MHZ 39 | #define PICO_PLL_VCO_MAX_FREQ_MHZ 1600 40 | #endif 41 | 42 | /*! \brief Initialise specified PLL. 43 | * \ingroup hardware_pll 44 | * \param pll pll_sys or pll_usb 45 | * \param ref_div Input clock divider. 46 | * \param vco_freq Requested output from the VCO (voltage controlled oscillator) 47 | * \param post_div1 Post Divider 1 - range 1-7. Must be >= post_div2 48 | * \param post_div2 Post Divider 2 - range 1-7 49 | */ 50 | void pll_init(PLL pll, uint ref_div, uint vco_freq, uint post_div1, uint post_div2); 51 | 52 | /*! \brief Release/uninitialise specified PLL. 53 | * \ingroup hardware_pll 54 | * 55 | * This will turn off the power to the specified PLL. Note this function does not currently check if 56 | * the PLL is in use before powering it off so should be used with care. 57 | * 58 | * \param pll pll_sys or pll_usb 59 | */ 60 | void pll_deinit(PLL pll); 61 | 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_pwm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_headers_only_target(pwm) 2 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_resets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_headers_only_target(resets) 2 | -------------------------------------------------------------------------------- /pico-sdk/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) -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_sync/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(sync) 2 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/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) -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_vreg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(vreg) 2 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_vreg/include/hardware/vreg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _HARDWARE_VREG_H 8 | #define _HARDWARE_VREG_H 9 | 10 | #include "pico.h" 11 | #include "hardware/structs/vreg_and_chip_reset.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /** \file vreg.h 18 | * \defgroup hardware_vreg hardware_vreg 19 | * 20 | * Voltage Regulation API 21 | * 22 | */ 23 | 24 | /** Possible voltage values that can be applied to the regulator 25 | */ 26 | enum vreg_voltage { 27 | VREG_VOLTAGE_0_85 = 0b0110, ///< 0.85v 28 | VREG_VOLTAGE_0_90 = 0b0111, ///< 0.90v 29 | VREG_VOLTAGE_0_95 = 0b1000, ///< 0.95v 30 | VREG_VOLTAGE_1_00 = 0b1001, ///< 1.00v 31 | VREG_VOLTAGE_1_05 = 0b1010, ///< 1.05v 32 | VREG_VOLTAGE_1_10 = 0b1011, ///< 1.10v 33 | VREG_VOLTAGE_1_15 = 0b1100, ///< 1.15v 34 | VREG_VOLTAGE_1_20 = 0b1101, ///< 1.20v 35 | VREG_VOLTAGE_1_25 = 0b1110, ///< 1.25v 36 | VREG_VOLTAGE_1_30 = 0b1111, ///< 1.30v 37 | 38 | VREG_VOLTAGE_MIN = VREG_VOLTAGE_0_85, ///< Always the minimum possible voltage 39 | VREG_VOLTAGE_DEFAULT = VREG_VOLTAGE_1_10, ///< Default voltage on power up. 40 | VREG_VOLTAGE_MAX = VREG_VOLTAGE_1_30, ///< Always the maximum possible voltage 41 | }; 42 | 43 | 44 | /*! \brief Set voltage 45 | * \ingroup hardware_vreg 46 | * 47 | * \param voltage The voltage (from enumeration \ref vreg_voltage) to apply to the voltage regulator 48 | **/ 49 | void vreg_set_voltage(enum vreg_voltage voltage); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_vreg/vreg.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/vreg.h" 9 | 10 | void vreg_set_voltage(enum vreg_voltage voltage) { 11 | hw_write_masked(&vreg_and_chip_reset_hw->vreg, ((uint)voltage) << VREG_AND_CHIP_RESET_VREG_VSEL_LSB, VREG_AND_CHIP_RESET_VREG_VSEL_BITS); 12 | } 13 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_watchdog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(watchdog) -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_xosc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_simple_hardware_target(xosc) 2 | pico_mirrored_target_link_libraries(hardware_xosc INTERFACE hardware_clocks) -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_xosc/include/hardware/xosc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _HARDWARE_XOSC_H 8 | #define _HARDWARE_XOSC_H 9 | 10 | #include "pico.h" 11 | #include "hardware/structs/xosc.h" 12 | 13 | 14 | // Allow lengthening startup delay to accommodate slow-starting oscillators 15 | 16 | // PICO_CONFIG: PICO_XOSC_STARTUP_DELAY_MULTIPLIER, Multiplier to lengthen xosc startup delay to accommodate slow-starting oscillators, type=int, min=1, default=1, group=hardware_xosc 17 | #ifndef PICO_XOSC_STARTUP_DELAY_MULTIPLIER 18 | #define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 1 19 | #endif 20 | 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /** \file hardware/xosc.h 27 | * \defgroup hardware_xosc hardware_xosc 28 | * 29 | * Crystal Oscillator (XOSC) API 30 | */ 31 | 32 | /*! \brief Initialise the crystal oscillator system 33 | * \ingroup hardware_xosc 34 | * 35 | * This function will block until the crystal oscillator has stabilised. 36 | **/ 37 | void xosc_init(void); 38 | 39 | /*! \brief Disable the Crystal oscillator 40 | * \ingroup hardware_xosc 41 | * 42 | * Turns off the crystal oscillator source, and waits for it to become unstable 43 | **/ 44 | void xosc_disable(void); 45 | 46 | /*! \brief Set the crystal oscillator system to dormant 47 | * \ingroup hardware_xosc 48 | * 49 | * Turns off the crystal oscillator until it is woken by an interrupt. This will block and hence 50 | * the entire system will stop, until an interrupt wakes it up. This function will 51 | * continue to block until the oscillator becomes stable after its wakeup. 52 | **/ 53 | void xosc_dormant(void); 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/hardware_xosc/xosc.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 | 9 | // For MHZ definitions etc 10 | #include "hardware/clocks.h" 11 | 12 | #include "hardware/platform_defs.h" 13 | #include "hardware/regs/xosc.h" 14 | #include "hardware/xosc.h" 15 | 16 | #if XOSC_MHZ < 1 || XOSC_MHZ > 50 17 | #error XOSC_MHZ must be in the range 1-50 18 | #endif 19 | 20 | #define STARTUP_DELAY (((((XOSC_MHZ * MHZ) / 1000) + 128) / 256) * PICO_XOSC_STARTUP_DELAY_MULTIPLIER) 21 | 22 | // The DELAY field in xosc_hw->startup is 14 bits wide. 23 | #if STARTUP_DELAY >= (1 << 13) 24 | #error PICO_XOSC_STARTUP_DELAY_MULTIPLIER is too large: XOSC STARTUP.DELAY must be < 8192 25 | #endif 26 | 27 | void xosc_init(void) { 28 | // Assumes 1-15 MHz input, checked above. 29 | xosc_hw->ctrl = XOSC_CTRL_FREQ_RANGE_VALUE_1_15MHZ; 30 | 31 | // Set xosc startup delay 32 | xosc_hw->startup = STARTUP_DELAY; 33 | 34 | // Set the enable bit now that we have set freq range and startup delay 35 | hw_set_bits(&xosc_hw->ctrl, XOSC_CTRL_ENABLE_VALUE_ENABLE << XOSC_CTRL_ENABLE_LSB); 36 | 37 | // Wait for XOSC to be stable 38 | while(!(xosc_hw->status & XOSC_STATUS_STABLE_BITS)); 39 | } 40 | 41 | void xosc_disable(void) { 42 | uint32_t tmp = xosc_hw->ctrl; 43 | tmp &= (~XOSC_CTRL_ENABLE_BITS); 44 | tmp |= (XOSC_CTRL_ENABLE_VALUE_DISABLE << XOSC_CTRL_ENABLE_LSB); 45 | xosc_hw->ctrl = tmp; 46 | // Wait for stable to go away 47 | while(xosc_hw->status & XOSC_STATUS_STABLE_BITS); 48 | } 49 | 50 | void xosc_dormant(void) { 51 | // WARNING: This stops the xosc until woken up by an irq 52 | xosc_hw->dormant = XOSC_DORMANT_VALUE_DORMANT; 53 | // Wait for it to become stable once woken up 54 | while(!(xosc_hw->status & XOSC_STATUS_STABLE_BITS)); 55 | } 56 | -------------------------------------------------------------------------------- /pico-sdk/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 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 | -------------------------------------------------------------------------------- /pico-sdk/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 -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_async_context/include/pico/async_context_poll.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_POLL_H 8 | #define _PICO_ASYNC_CONTEXT_POLL_H 9 | 10 | /** \file pico/async_context.h 11 | * \defgroup async_context_poll async_context_poll 12 | * \ingroup pico_async_context 13 | * 14 | * async_context_poll provides an implementation of \ref async_context that is intended for use with a simple 15 | * polling loop on one core. It is not thread safe. 16 | * 17 | * The \ref async_context_poll() method must be called periodically to handle asynchronous work that may now be 18 | * pending. \ref async_context_wait_for_work_until() may be used to block a polling loop until there is work to do, 19 | * and prevent tight spinning. 20 | */ 21 | #include "pico/async_context.h" 22 | #include "pico/sem.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | typedef struct async_context_poll { 29 | async_context_t core; 30 | semaphore_t sem; 31 | } async_context_poll_t; 32 | 33 | /*! 34 | * \brief Initialize an async_context_poll instance with default values 35 | * \ingroup async_context_poll 36 | * 37 | * If this method succeeds (returns true), then the async_context is available for use 38 | * and can be de-initialized by calling async_context_deinit(). 39 | * 40 | * \param self a pointer to async_context_poll structure to initialize 41 | * \return true if initialization is successful, false otherwise 42 | */ 43 | bool async_context_poll_init_with_defaults(async_context_poll_t *self); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_bootrom/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_bootrom_headers NOFLAG) 2 | 3 | target_include_directories(pico_bootrom_headers 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 | ) 9 | 10 | pico_mirrored_target_link_libraries(pico_bootrom INTERFACE pico_base) 11 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_bootrom/bootrom.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico/bootrom.h" 8 | 9 | /// \tag::table_lookup[] 10 | 11 | // Bootrom function: rom_table_lookup 12 | // Returns the 32 bit pointer into the ROM if found or NULL otherwise. 13 | typedef void *(*rom_table_lookup_fn)(uint16_t *table, uint32_t code); 14 | 15 | void *rom_func_lookup(uint32_t code) { 16 | return rom_func_lookup_inline(code); 17 | } 18 | 19 | void *rom_data_lookup(uint32_t code) { 20 | rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18); 21 | uint16_t *data_table = (uint16_t *) rom_hword_as_ptr(0x16); 22 | return rom_table_lookup(data_table, code); 23 | } 24 | /// \end::table_lookup[] 25 | 26 | bool rom_funcs_lookup(uint32_t *table, unsigned int count) { 27 | bool ok = true; 28 | for (unsigned int i = 0; i < count; i++) { 29 | table[i] = (uintptr_t) rom_func_lookup(table[i]); 30 | if (!table[i]) ok = false; 31 | } 32 | return ok; 33 | } 34 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom/sf_table.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_BOOTROM_SF_TABLE_H 8 | #define _PICO_BOOTROM_SF_TABLE_H 9 | 10 | // NOTE THESE FUNCTION IMPLEMENTATIONS MATCH THE BEHAVIOR DESCRIBED IN THE BOOTROM SECTION OF THE RP2040 DATASHEET 11 | 12 | #define SF_TABLE_FADD 0x00 13 | #define SF_TABLE_FSUB 0x04 14 | #define SF_TABLE_FMUL 0x08 15 | #define SF_TABLE_FDIV 0x0c 16 | #define SF_TABLE_FCMP_FAST 0x10 17 | #define SF_TABLE_FCMP_FAST_FLAGS 0x14 18 | #define SF_TABLE_FSQRT 0x18 19 | #define SF_TABLE_FLOAT2INT 0x1c 20 | #define SF_TABLE_FLOAT2FIX 0x20 21 | #define SF_TABLE_FLOAT2UINT 0x24 22 | #define SF_TABLE_FLOAT2UFIX 0x28 23 | #define SF_TABLE_INT2FLOAT 0x2c 24 | #define SF_TABLE_FIX2FLOAT 0x30 25 | #define SF_TABLE_UINT2FLOAT 0x34 26 | #define SF_TABLE_UFIX2FLOAT 0x38 27 | #define SF_TABLE_FCOS 0x3c 28 | #define SF_TABLE_FSIN 0x40 29 | #define SF_TABLE_FTAN 0x44 30 | #define SF_TABLE_V3_FSINCOS 0x48 31 | #define SF_TABLE_FEXP 0x4c 32 | #define SF_TABLE_FLN 0x50 33 | 34 | #define SF_TABLE_V1_SIZE 0x54 35 | 36 | #define SF_TABLE_FCMP_BASIC 0x54 37 | #define SF_TABLE_FATAN2 0x58 38 | #define SF_TABLE_INT642FLOAT 0x5c 39 | #define SF_TABLE_FIX642FLOAT 0x60 40 | #define SF_TABLE_UINT642FLOAT 0x64 41 | #define SF_TABLE_UFIX642FLOAT 0x68 42 | #define SF_TABLE_FLOAT2INT64 0x6c 43 | #define SF_TABLE_FLOAT2FIX64 0x70 44 | #define SF_TABLE_FLOAT2UINT64 0x74 45 | #define SF_TABLE_FLOAT2UFIX64 0x78 46 | #define SF_TABLE_FLOAT2DOUBLE 0x7c 47 | 48 | #define SF_TABLE_V2_SIZE 0x80 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_btstack/btstack_stdin_pico.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "btstack_config.h" 8 | 9 | #ifdef HAVE_BTSTACK_STDIN 10 | 11 | #include "btstack_stdin.h" 12 | #include "btstack_run_loop.h" 13 | #include "pico/stdio.h" 14 | 15 | static btstack_data_source_t stdin_data_source; 16 | static void (*stdin_handler)(char c); 17 | 18 | // Data source callback, return any character received 19 | static void btstack_stdin_process(__unused struct btstack_data_source *ds, __unused btstack_data_source_callback_type_t callback_type){ 20 | if (stdin_handler) { 21 | while(true) { 22 | int c = getchar_timeout_us(0); 23 | if (c == PICO_ERROR_TIMEOUT) return; 24 | (*stdin_handler)(c); 25 | } 26 | } 27 | } 28 | 29 | void on_chars_available_callback(__unused void *param) { 30 | btstack_run_loop_poll_data_sources_from_irq(); 31 | } 32 | 33 | // Test code calls this if HAVE_BTSTACK_STDIN is defined and it wants key presses 34 | void btstack_stdin_setup(void (*handler)(char c)) { 35 | if (stdin_handler) { 36 | return; 37 | } 38 | 39 | // set handler 40 | stdin_handler = handler; 41 | 42 | // set up polling data_source 43 | btstack_run_loop_set_data_source_handler(&stdin_data_source, &btstack_stdin_process); 44 | btstack_run_loop_enable_data_source_callbacks(&stdin_data_source, DATA_SOURCE_CALLBACK_POLL); 45 | btstack_run_loop_add_data_source(&stdin_data_source); 46 | 47 | stdio_set_chars_available_callback(on_chars_available_callback, NULL); 48 | } 49 | 50 | // Deinit everything 51 | void btstack_stdin_reset(void){ 52 | if (!stdin_handler) { 53 | return; 54 | } 55 | stdio_set_chars_available_callback(NULL, NULL); 56 | stdin_handler = NULL; 57 | btstack_run_loop_remove_data_source(&stdin_data_source); 58 | } 59 | 60 | #endif -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_btstack/include/pico/btstack_flash_bank.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_BTSTACK_FLASH_BANK_H 8 | #define _PICO_BTSTACK_FLASH_BANK_H 9 | 10 | #include "pico.h" 11 | #include "hal_flash_bank.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | // PICO_CONFIG: PICO_FLASH_BANK_TOTAL_SIZE, Total size of the Bluetooth flash storage. Must be an even multiple of FLASH_SECTOR_SIZE, type=int default=FLASH_SECTOR_SIZE*2, group=pico_btstack 18 | #ifndef PICO_FLASH_BANK_TOTAL_SIZE 19 | #define PICO_FLASH_BANK_TOTAL_SIZE (FLASH_SECTOR_SIZE * 2u) 20 | #endif 21 | 22 | // PICO_CONFIG: PICO_FLASH_BANK_STORAGE_OFFSET, Offset in flash of the Bluetooth flash storage, type=int default=PICO_FLASH_SIZE_BYTES-PICO_FLASH_BANK_TOTAL_SIZE, group=pico_btstack 23 | #ifndef PICO_FLASH_BANK_STORAGE_OFFSET 24 | #define PICO_FLASH_BANK_STORAGE_OFFSET (PICO_FLASH_SIZE_BYTES - PICO_FLASH_BANK_TOTAL_SIZE) 25 | #endif 26 | 27 | /** 28 | * \brief Return the singleton BTstack HAL flash instance, used for non-volatile storage 29 | * \ingroup pico_btstack 30 | * 31 | * \note By default two sectors at the end of flash are used (see \c PICO_FLASH_BANK_STORAGE_OFFSET 32 | */ 33 | const hal_flash_bank_t *pico_flash_bank_instance(void); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | #endif 39 | -------------------------------------------------------------------------------- /pico-sdk/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 eturn 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 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_cxx_options/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_cxx_options) 2 | add_library(pico_cxx_options INTERFACE) 3 | 4 | # PICO_CMAKE_CONFIG: PICO_CXX_ENABLE_EXCEPTIONS, Enabled CXX exception handling, type=bool, default=0, group=pico_cxx_options 5 | # PICO_BUILD_DEFINE: PICO_CXX_ENABLE_EXCEPTIONS, value of CMake var PICO_CXX_ENABLE_EXCEPTIONS, type=string, default=0, group=pico_cxx_options 6 | if (NOT PICO_CXX_ENABLE_EXCEPTIONS) 7 | target_compile_definitions( pico_cxx_options INTERFACE PICO_CXX_ENABLE_EXCEPTIONS=0) 8 | target_compile_options( pico_cxx_options INTERFACE $<$:-fno-exceptions>) 9 | target_compile_options( pico_cxx_options INTERFACE $<$:-fno-unwind-tables>) 10 | else() 11 | target_compile_definitions( pico_cxx_options INTERFACE PICO_CXX_ENABLE_EXCEPTIONS=1) 12 | endif() 13 | 14 | # PICO_CMAKE_CONFIG: PICO_CXX_ENABLE_RTTI, Enabled CXX rtti, type=bool, default=0, group=pico_cxx_options 15 | if (NOT PICO_CXX_ENABLE_RTTI) 16 | target_compile_options( pico_cxx_options INTERFACE $<$:-fno-rtti>) 17 | endif() 18 | 19 | # PICO_CMAKE_CONFIG: PICO_CXX_ENABLE_CXA_ATEXIT, Enabled cxa-atexit, type=bool, default=0, group=pico_cxx_options 20 | if (NOT PICO_CXX_ENABLE_CXA_ATEXIT) 21 | target_compile_options( pico_cxx_options INTERFACE $<$:-fno-use-cxa-atexit>) 22 | endif() 23 | endif() 24 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/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=4, group=pico_cyw43_arch 16 | #ifndef CYW43_TASK_PRIORITY 17 | #define CYW43_TASK_PRIORITY (tskIDLE_PRIORITY + 4) 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/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 -------------------------------------------------------------------------------- /pico-sdk/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 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() -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.pio: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | ; 4 | ; SPDX-License-Identifier: BSD-3-Clause 5 | ; 6 | 7 | .program spi_gap0_sample1 8 | .side_set 1 9 | 10 | ; always transmit multiple of 32 bytes 11 | lp: out pins, 1 side 0 12 | jmp x-- lp side 1 13 | public lp1_end: 14 | set pindirs, 0 side 0 15 | lp2: 16 | in pins, 1 side 1 17 | jmp y-- lp2 side 0 18 | public end: 19 | 20 | .program spi_gap01_sample0 21 | .side_set 1 22 | 23 | ; always transmit multiple of 32 bytes 24 | lp: out pins, 1 side 0 25 | jmp x-- lp side 1 26 | public lp1_end: 27 | set pindirs, 0 side 0 28 | nop side 1 29 | lp2: 30 | in pins, 1 side 0 31 | jmp y-- lp2 side 1 32 | public end: 33 | 34 | .program spi_gap010_sample1 35 | .side_set 1 36 | 37 | ; always transmit multiple of 32 bytes 38 | lp: out pins, 1 side 0 39 | jmp x-- lp side 1 40 | public lp1_end: 41 | set pindirs, 0 side 0 42 | nop side 1 43 | nop side 0 44 | lp2: 45 | in pins, 1 side 1 46 | jmp y-- lp2 side 0 47 | public end: 48 | 49 | .program spi_gap0_sample1_regular 50 | .side_set 1 51 | 52 | ; always transmit multiple of 32 bytes 53 | lp: out pins, 1 side 0 54 | jmp x-- lp side 1 55 | public lp1_end: 56 | set pindirs, 0 side 0 57 | lp2: 58 | in pins, 1 side 1 59 | jmp y-- lp2 side 0 60 | public end: 61 | 62 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_cyw43_driver/include/pico/btstack_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_CYW43_H 8 | #define _PICO_BTSTACK_CYW43_H 9 | 10 | #include "pico/async_context.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /** \file pico/btstack_cyw43.h 16 | * \defgroup pico_bstack_cyw43 17 | * \ingroup pico_cyw43_driver 18 | * 19 | * \brief Low-level Bluetooth HCI support. 20 | * 21 | * This library provides utility functions to initialise and de-initialise BTstack for CYW43, 22 | */ 23 | 24 | /* 25 | * \brief Perform initialisation of BTstack/CYW43 integration 26 | * \ingroup pico_btstack_cyw43 27 | * 28 | * \param context the async_context instance that provides the abstraction for handling asynchronous work. 29 | * \return true on success or false an error 30 | */ 31 | bool btstack_cyw43_init(async_context_t *context); 32 | 33 | /* 34 | * \brief De-initialise BTstack/CYW43 integration 35 | * \ingroup pico_btstack_cyw43 36 | * 37 | * \param context the async_context the btstack_cyw43 support was added to via \ref btstack_cyw43_init 38 | */ 39 | void btstack_cyw43_deinit(async_context_t *context); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | #endif 45 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_cyw43_driver/include/pico/cyw43_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_CYW43_DRIVER_H 8 | #define _PICO_CYW43_DRIVER_H 9 | 10 | /** \file pico/cyw43_driver.h 11 | * \defgroup pico_cyw43_driver pico_cyw43_driver 12 | * 13 | * A wrapper around the lower level cyw43_driver, that integrates it with \ref pico_async_context 14 | * for handling background work. 15 | */ 16 | 17 | #include "pico.h" 18 | #include "pico/async_context.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /*! \brief Initializes the lower level cyw43_driver and integrates it with the provided async_context 25 | * \ingroup pico_cyw43_driver 26 | * 27 | * If the initialization succeeds, \ref lwip_nosys_deinit() can be called to shutdown lwIP support 28 | * 29 | * \param context the async_context instance that provides the abstraction for handling asynchronous work. 30 | * \return true if the initialization succeeded 31 | */ 32 | bool cyw43_driver_init(async_context_t *context); 33 | 34 | /*! \brief De-initialize the lowever level cyw43_driver and unhooks it from the async_context 35 | * \ingroup pico_cyw43_driver 36 | * 37 | * \param context the async_context the cyw43_driver support was added to via \ref cyw43_driver_init 38 | */ 39 | void cyw43_driver_deinit(async_context_t *context); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | #endif -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_fix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_subdirectory(rp2040_usb_device_enumeration) -------------------------------------------------------------------------------- /pico-sdk/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 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) -------------------------------------------------------------------------------- /pico-sdk/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 -------------------------------------------------------------------------------- /pico-sdk/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 INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 8 | 9 | pico_mirrored_target_link_libraries(pico_i2c_slave INTERFACE hardware_i2c hardware_irq) 10 | endif() 11 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_int64_ops/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_int64_ops) 2 | 3 | #shims for ROM functions for -lgcc functions (listed below) 4 | pico_add_library(pico_int64_ops) 5 | 6 | # no custom implementation; falls thru to compiler 7 | pico_add_library(pico_int64_ops_compiler) 8 | 9 | # add alias "default" which is just pico. 10 | add_library(pico_int64_ops_default INTERFACE) 11 | target_link_libraries(pico_int64_ops_default INTERFACE pico_int64_ops_pico) 12 | 13 | set(PICO_DEFAULT_INT64_OPS_IMPL pico_int64_ops_default) 14 | 15 | target_link_libraries(pico_int64_ops INTERFACE 16 | $>,$,${PICO_DEFAULT_INT64_OPS_IMPL}>) 17 | 18 | pico_add_library(pico_int64_ops_pico) 19 | target_include_directories(pico_int64_ops_pico INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 20 | pico_mirrored_target_link_libraries(pico_int64_ops_pico INTERFACE pico_base) 21 | 22 | target_sources(pico_int64_ops_pico INTERFACE 23 | ${CMAKE_CURRENT_LIST_DIR}/pico_int64_ops_aeabi.S 24 | ) 25 | 26 | pico_wrap_function(pico_int64_ops_pico __aeabi_lmul) 27 | 28 | macro(pico_set_int64_ops_implementation TARGET IMPL) 29 | get_target_property(target_type ${TARGET} TYPE) 30 | if ("EXECUTABLE" STREQUAL "${target_type}") 31 | set_target_properties(${TARGET} PROPERTIES PICO_TARGET_INT64_OPS_IMPL "pico_int64_ops_${IMPL}") 32 | else() 33 | message(FATAL_ERROR "int64_ops implementation must be set on executable not library") 34 | endif() 35 | endmacro() 36 | endif() -------------------------------------------------------------------------------- /pico-sdk/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 | * 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 -------------------------------------------------------------------------------- /pico-sdk/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 | .syntax unified 8 | .cpu cortex-m0plus 9 | .thumb 10 | 11 | #include "pico/asm_helper.S" 12 | 13 | .macro int64_section name 14 | #if PICO_INT64_OPS_IN_RAM 15 | .section RAM_SECTION_NAME(\name), "ax" 16 | #else 17 | .section SECTION_NAME(\name), "ax" 18 | #endif 19 | .endm 20 | 21 | int64_section __aeabi_lmul 22 | 23 | wrapper_func __aeabi_lmul 24 | muls r1, r2 25 | muls r3, r0 26 | adds r1, r3 27 | mov r12, r1 28 | lsrs r1, r2, #16 29 | uxth r3, r0 30 | muls r3, r1 31 | push {r4} 32 | lsrs r4, r0, #16 33 | muls r1, r4 34 | uxth r2, r2 35 | uxth r0, r0 36 | muls r0, r2 37 | muls r2, r4 38 | lsls r4, r3, #16 39 | lsrs r3, #16 40 | adds r0, r4 41 | pop {r4} 42 | adcs r1, r3 43 | lsls r3, r2, #16 44 | lsrs r2, #16 45 | adds r0, r3 46 | adcs r1, r2 47 | add r1, r12 48 | bx lr 49 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_lwip/include/pico/lwip_freertos.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_LWIP_FREERTOS_H 8 | #define _PICO_LWIP_FREERTOS_H 9 | 10 | #include "pico.h" 11 | #include "pico/async_context.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /** \file pico/lwip_freertos.h 18 | * \defgroup pico_lwip_freertos pico_lwip_freertos 19 | * \ingroup pico_lwip 20 | * \brief Glue library for integration lwIP in \c NO_SYS=0 mode with the SDK. Simple \c init and \c deinit 21 | * are all that is required to hook up lwIP (with full blocking API support) via an \ref async_context instance. 22 | */ 23 | 24 | /*! \brief Initializes lwIP (NO_SYS=0 mode) support support for FreeRTOS using the provided async_context 25 | * \ingroup pico_lwip_freertos 26 | * 27 | * If the initialization succeeds, \ref lwip_freertos_deinit() can be called to shutdown lwIP support 28 | * 29 | * \param context the async_context instance that provides the abstraction for handling asynchronous work. Note in general 30 | * this would be an \ref async_context_freertos instance, though it doesn't have to be. 31 | * 32 | * \return true if the initialization succeeded 33 | */ 34 | bool lwip_freertos_init(async_context_t *context); 35 | 36 | /*! \brief De-initialize lwIP (NO_SYS=0 mode) support for FreeRTOS 37 | * \ingroup pico_lwip_freertos 38 | * 39 | * Note that since lwIP may only be initialized once, and doesn't itself provide a shutdown mechanism, lwIP 40 | * itself may still consume resources. 41 | * 42 | * It is however safe to call \ref lwip_freertos_init again later. 43 | * 44 | * \param context the async_context the lwip_freertos support was added to via \ref lwip_freertos_init 45 | */ 46 | void lwip_freertos_deinit(async_context_t *context); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | #endif -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_lwip/include/pico/lwip_nosys.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_LWIP_NOSYS_H 8 | #define _PICO_LWIP_NOSYS_H 9 | 10 | #include "pico.h" 11 | #include "pico/async_context.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /** \file pico/lwip_nosys.h 18 | * \defgroup pico_lwip_nosys pico_lwip_nosys 19 | * \ingroup pico_lwip 20 | * \brief Glue library for integration lwIP in \c NO_SYS=1 mode with the SDK. Simple \c init and \c deinit 21 | * are all that is required to hook up lwIP via an \ref async_context instance. 22 | */ 23 | 24 | /*! \brief Initializes lwIP (NO_SYS=1 mode) support support using the provided async_context 25 | * \ingroup pico_lwip_nosys 26 | * 27 | * If the initialization succeeds, \ref lwip_nosys_deinit() can be called to shutdown lwIP support 28 | * 29 | * \param context the async_context instance that provides the abstraction for handling asynchronous work. 30 | * \return true if the initialization succeeded 31 | */ 32 | bool lwip_nosys_init(async_context_t *context); 33 | 34 | /*! \brief De-initialize lwIP (NO_SYS=1 mode) support 35 | * \ingroup pico_lwip_nosys 36 | * 37 | * Note that since lwIP may only be initialized once, and doesn't itself provide a shutdown mechanism, lwIP 38 | * itself may still consume resources 39 | * 40 | * It is however safe to call \ref lwip_nosys_init again later. 41 | * 42 | * \param context the async_context the lwip_nosys support was added to via \ref lwip_nosys_init 43 | */ 44 | void lwip_nosys_deinit(async_context_t *context); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #endif -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_lwip/lwip_freertos.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | // todo graham #ifdef for LWIP inclusion? 8 | 9 | #include "pico/async_context.h" 10 | #include "pico/time.h" 11 | #include "lwip/tcpip.h" 12 | #include "lwip/timeouts.h" 13 | 14 | #include "FreeRTOS.h" 15 | #include "semphr.h" 16 | 17 | #if NO_SYS 18 | #error lwip_freertos_async_context_bindings requires NO_SYS=0 19 | #endif 20 | 21 | static async_context_t * volatile lwip_context; 22 | // lwIP tcpip_task cannot be shutdown, so we block it when we are de-initialized. 23 | static SemaphoreHandle_t tcpip_task_blocker; 24 | 25 | static void tcpip_init_done(void *param) { 26 | xSemaphoreGive((SemaphoreHandle_t)param); 27 | } 28 | 29 | bool lwip_freertos_init(async_context_t *context) { 30 | assert(!lwip_context); 31 | lwip_context = context; 32 | static bool done_lwip_init; 33 | if (!done_lwip_init) { 34 | done_lwip_init = true; 35 | SemaphoreHandle_t init_sem = xSemaphoreCreateBinary(); 36 | tcpip_task_blocker = xSemaphoreCreateBinary(); 37 | tcpip_init(tcpip_init_done, init_sem); 38 | xSemaphoreTake(init_sem, portMAX_DELAY); 39 | vSemaphoreDelete(init_sem); 40 | } else { 41 | xSemaphoreGive(tcpip_task_blocker); 42 | } 43 | return true; 44 | } 45 | 46 | static uint32_t clear_lwip_context(__unused void *param) { 47 | lwip_context = NULL; 48 | return 0; 49 | } 50 | 51 | void lwip_freertos_deinit(__unused async_context_t *context) { 52 | // clear the lwip context under lock as lwIP may still be running in tcpip_task 53 | async_context_execute_sync(context, clear_lwip_context, NULL); 54 | } 55 | 56 | void pico_lwip_custom_lock_tcpip_core(void) { 57 | while (!lwip_context) { 58 | xSemaphoreTake(tcpip_task_blocker, portMAX_DELAY); 59 | } 60 | async_context_acquire_lock_blocking(lwip_context); 61 | } 62 | 63 | void pico_lwip_custom_unlock_tcpip_core(void) { 64 | async_context_release_lock(lwip_context); 65 | } 66 | -------------------------------------------------------------------------------- /pico-sdk/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}/pico_malloc.c 7 | ) 8 | 9 | target_include_directories(pico_malloc_headers 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 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_malloc/include/pico/malloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_MALLOC_H 8 | #define _PICO_MALLOC_H 9 | 10 | /** \file malloc.h 11 | * \defgroup pico_malloc pico_malloc 12 | * 13 | * Multi-core safety for malloc, calloc and free 14 | * 15 | * This library does not provide any additional functions 16 | */ 17 | 18 | // PICO_CONFIG: PICO_USE_MALLOC_MUTEX, Whether to protect malloc etc with a mutex, type=bool, default=1 with pico_multicore, 0 otherwise, group=pico_malloc 19 | #if LIB_PICO_MULTICORE && !defined(PICO_USE_MALLOC_MUTEX) 20 | #define PICO_USE_MALLOC_MUTEX 1 21 | #endif 22 | 23 | // PICO_CONFIG: PICO_MALLOC_PANIC, Enable/disable panic when an allocation failure occurs, type=bool, default=1, group=pico_malloc 24 | #ifndef PICO_MALLOC_PANIC 25 | #define PICO_MALLOC_PANIC 1 26 | #endif 27 | 28 | // PICO_CONFIG: PICO_DEBUG_MALLOC, Enable/disable debug printf from malloc, type=bool, default=0, group=pico_malloc 29 | #ifndef PICO_DEBUG_MALLOC 30 | #define PICO_DEBUG_MALLOC 0 31 | #endif 32 | 33 | // PICO_CONFIG: PICO_DEBUG_MALLOC_LOW_WATER, Define the lower bound for allocation addresses to be printed by PICO_DEBUG_MALLOC, min=0, default=0, group=pico_malloc 34 | #ifndef PICO_DEBUG_MALLOC_LOW_WATER 35 | #define PICO_DEBUG_MALLOC_LOW_WATER 0 36 | #endif 37 | 38 | #endif -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_mbedtls/pico_mbedtls.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pico/platform.h" 3 | #include "pico/rand.h" 4 | 5 | /* Function to feed mbedtls entropy. */ 6 | int mbedtls_hardware_poll(void *data __unused, unsigned char *output, size_t len, size_t *olen) { 7 | *olen = 0; 8 | while(*olen < len) { 9 | uint64_t rand_data = get_rand_64(); 10 | size_t to_copy = MIN(len, sizeof(rand_data)); 11 | memcpy(output + *olen, &rand_data, to_copy); 12 | *olen += to_copy; 13 | } 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /pico-sdk/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 | * Provides optimized replacement implementations of the compiler built-in memcpy, memset and related functions: 16 | * 17 | * - memset, memcpy 18 | * - __aeabi_memset, __aeabi_memset4, __aeabi_memset8, __aeabi_memcpy, __aeabi_memcpy4, __aeabi_memcpy8 19 | * 20 | * This library does not provide any additional functions 21 | */ 22 | #endif -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/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 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 | endif() 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_platform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_platform_headers) 2 | add_library(pico_platform_headers INTERFACE) 3 | 4 | target_compile_definitions(pico_platform_headers INTERFACE 5 | PICO_NO_HARDWARE=0 6 | PICO_ON_DEVICE=1 7 | PICO_BUILD=1 8 | ) 9 | 10 | target_include_directories(pico_platform_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 11 | 12 | target_link_libraries(pico_platform_headers INTERFACE hardware_regs) 13 | endif() 14 | 15 | if (NOT TARGET pico_platform) 16 | pico_add_impl_library(pico_platform) 17 | target_sources(pico_platform INTERFACE 18 | ${CMAKE_CURRENT_LIST_DIR}/platform.c) 19 | 20 | target_link_libraries(pico_platform INTERFACE pico_platform_headers) 21 | endif() 22 | 23 | function(pico_add_platform_library TARGET) 24 | target_link_libraries(pico_platform INTERFACE ${TARGET}) 25 | endfunction() -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_platform/include/pico/asm_helper.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico.h" 8 | 9 | // do not put align in here as it is used mid function sometimes 10 | .macro regular_func x 11 | .global \x 12 | .type \x,%function 13 | .thumb_func 14 | \x: 15 | .endm 16 | 17 | .macro regular_func_with_section x 18 | .section .text.\x 19 | regular_func \x 20 | .endm 21 | 22 | // do not put align in here as it is used mid function sometimes 23 | .macro wrapper_func x 24 | regular_func WRAPPER_FUNC_NAME(\x) 25 | .endm 26 | 27 | .macro __pre_init func, priority_string 28 | .section .preinit_array.\priority_string 29 | .align 2 30 | .word \func 31 | .endm 32 | 33 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_platform/platform.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/address_mapped.h" 9 | #include "hardware/regs/tbman.h" 10 | #include "hardware/regs/sysinfo.h" 11 | 12 | // Note we leave the FPGA check in by default so that we can run bug repro 13 | // binaries coming in from the wild on the FPGA platform. It takes up around 14 | // 48 bytes if you include all the calls, so you can pass PICO_NO_FPGA_CHECK=1 15 | // to remove it. The FPGA check is used to skip initialisation of hardware 16 | // (mainly clock generators and oscillators) that aren't present on FPGA. 17 | 18 | #if !PICO_NO_FPGA_CHECK 19 | // Inline stub provided in header if this code is unused (so folding can be 20 | // done in each TU instead of relying on LTO) 21 | bool running_on_fpga() { 22 | return !!((*(io_ro_32 *)TBMAN_BASE) & TBMAN_PLATFORM_FPGA_BITS); 23 | } 24 | #endif 25 | 26 | #define MANUFACTURER_RPI 0x927 27 | #define PART_RP2 0x2 28 | 29 | uint8_t rp2040_chip_version() { 30 | // First register of sysinfo is chip id 31 | uint32_t chip_id = *((io_ro_32*)(SYSINFO_BASE + SYSINFO_CHIP_ID_OFFSET)); 32 | uint32_t __unused manufacturer = chip_id & SYSINFO_CHIP_ID_MANUFACTURER_BITS; 33 | uint32_t __unused part = (chip_id & SYSINFO_CHIP_ID_PART_BITS) >> SYSINFO_CHIP_ID_PART_LSB; 34 | assert(manufacturer == MANUFACTURER_RPI); 35 | assert(part == PART_RP2); 36 | // Version 1 == B0/B1 37 | uint version = (chip_id & SYSINFO_CHIP_ID_REVISION_BITS) >> SYSINFO_CHIP_ID_REVISION_LSB; 38 | return (uint8_t)version; 39 | } -------------------------------------------------------------------------------- /pico-sdk/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 | .syntax unified 11 | .cpu cortex-m0plus 12 | .thumb 13 | 14 | wrapper_func sprintf 15 | wrapper_func snprintf 16 | wrapper_func vsnprintf 17 | regular_func printf_none_assert 18 | push {lr} // keep stack trace sane 19 | ldr r0, =str 20 | bl panic 21 | 22 | str: 23 | .asciz "printf support is disabled" -------------------------------------------------------------------------------- /pico-sdk/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 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 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_runtime/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | pico_add_library(pico_runtime) 2 | 3 | target_sources(pico_runtime INTERFACE 4 | ${CMAKE_CURRENT_LIST_DIR}/runtime.c 5 | ) 6 | 7 | target_include_directories(pico_runtime_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 8 | 9 | pico_mirrored_target_link_libraries(pico_runtime INTERFACE 10 | hardware_uart 11 | hardware_clocks 12 | hardware_irq 13 | pico_printf 14 | pico_sync 15 | ) 16 | 17 | if (TARGET pico_bit_ops) 18 | pico_mirrored_target_link_libraries(pico_runtime INTERFACE pico_bit_ops) 19 | endif() 20 | if (TARGET pico_divider) 21 | pico_mirrored_target_link_libraries(pico_runtime INTERFACE pico_divider) 22 | endif() 23 | if (TARGET pico_double) 24 | pico_mirrored_target_link_libraries(pico_runtime INTERFACE pico_double) 25 | endif() 26 | if (TARGET pico_int64_ops) 27 | pico_mirrored_target_link_libraries(pico_runtime INTERFACE pico_int64_ops) 28 | endif() 29 | if (TARGET pico_float) 30 | pico_mirrored_target_link_libraries(pico_runtime INTERFACE pico_float) 31 | endif() 32 | if (TARGET pico_malloc) 33 | pico_mirrored_target_link_libraries(pico_runtime INTERFACE pico_malloc) 34 | endif() 35 | if (TARGET pico_mem_ops) 36 | pico_mirrored_target_link_libraries(pico_runtime INTERFACE pico_mem_ops) 37 | endif() 38 | if (TARGET pico_standard_link) 39 | pico_mirrored_target_link_libraries(pico_runtime INTERFACE pico_standard_link) 40 | endif() 41 | 42 | # todo is this correct/needed? 43 | target_link_options(pico_runtime INTERFACE "--specs=nosys.specs") 44 | 45 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_runtime/include/pico/runtime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_RUNTIME_H 8 | #define _PICO_RUNTIME_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /** \file runtime.h 15 | * \defgroup pico_runtime pico_runtime 16 | * Aggregate runtime support including @ref pico_bit_ops, @ref pico_divider, @ref pico_double, @ref pico_int64_ops, @ref pico_float, @ref pico_malloc, @ref pico_mem_ops and @ref pico_standard_link 17 | */ 18 | 19 | 20 | void runtime_install_stack_guard(void *stack_bottom); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_standard_link/doc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup pico_standard_link pico_standard_link 3 | * \brief Standard link step providing the basics for creating a runnable binary 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 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_standard_link/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 | 13 | void *operator new(std::size_t n) { 14 | return std::malloc(n); 15 | } 16 | 17 | void *operator new[](std::size_t n) { 18 | return std::malloc(n); 19 | } 20 | 21 | void operator delete(void *p) { std::free(p); } 22 | 23 | void operator delete[](void *p) noexcept { std::free(p); } 24 | 25 | #if __cpp_sized_deallocation 26 | 27 | void operator delete(void *p, __unused std::size_t n) noexcept { std::free(p); } 28 | 29 | void operator delete[](void *p, __unused std::size_t n) noexcept { std::free(p); } 30 | 31 | #endif 32 | 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_stdio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT TARGET pico_stdio) 2 | pico_add_library(pico_stdio) 3 | 4 | target_include_directories(pico_stdio_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 5 | 6 | target_sources(pico_stdio INTERFACE 7 | ${CMAKE_CURRENT_LIST_DIR}/stdio.c 8 | ) 9 | 10 | pico_wrap_function(pico_stdio printf) 11 | pico_wrap_function(pico_stdio vprintf) 12 | pico_wrap_function(pico_stdio puts) 13 | pico_wrap_function(pico_stdio putchar) 14 | pico_wrap_function(pico_stdio getchar) 15 | 16 | if (TARGET pico_printf) 17 | pico_mirrored_target_link_libraries(pico_stdio INTERFACE pico_printf) 18 | endif() 19 | endif() -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_stdio/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 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/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 INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 8 | 9 | pico_mirrored_target_link_libraries(pico_stdio_semihosting INTERFACE pico_stdio) -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_stdio_semihosting/include/pico/stdio_semihosting.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _PICO_STDIO_SEMIHOSTING_H 8 | #define _PICO_STDIO_SEMIHOSTING_H 9 | 10 | #include "pico/stdio.h" 11 | 12 | /** \brief Experimental support for stdout using RAM semihosting 13 | * \defgroup pico_stdio_semihosting pico_stdio_semihosting 14 | * \ingroup pico_stdio 15 | * 16 | * Linking this library or calling `pico_enable_stdio_semihosting(TARGET ENABLED)` in the CMake (which 17 | * achieves the same thing) will add semihosting to the drivers used for standard output 18 | */ 19 | 20 | // PICO_CONFIG: PICO_STDIO_SEMIHOSTING_DEFAULT_CRLF, Default state of CR/LF translation for semihosting output, type=bool, default=PICO_STDIO_DEFAULT_CRLF, group=pico_stdio_semihosting 21 | #ifndef PICO_STDIO_SEMIHOSTING_DEFAULT_CRLF 22 | #define PICO_STDIO_SEMIHOSTING_DEFAULT_CRLF PICO_STDIO_DEFAULT_CRLF 23 | #endif 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | extern stdio_driver_t stdio_semihosting; 30 | 31 | /*! \brief Explicitly initialize stdout over semihosting and add it to the current set of stdout targets 32 | * \ingroup pico_stdio_semihosting 33 | * 34 | * \note this method is automatically called by \ref stdio_init_all() if `pico_stdio_semihosting` is included in the build 35 | */ 36 | void stdio_semihosting_init(void); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_stdio_semihosting/stdio_semihosting.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "pico/stdio/driver.h" 8 | #include "pico/stdio_semihosting.h" 9 | #include "pico/binary_info.h" 10 | 11 | static void stdio_semihosting_out_chars(const char *buf, int length) { 12 | // must be volatile or the buffer gets put in registers & optimized away 13 | volatile struct { 14 | // https://developer.arm.com/documentation/dui0375/g/What-is-Semihosting-/SYS-WRITE--0x05- 15 | // arguments, in order: 16 | // word 0 = file handle (1 = stdout) 17 | // word 1 = pointer to buffer 18 | // word 2 = length of buffer 19 | size_t fd; 20 | const char *buf; 21 | size_t len; 22 | } args; 23 | 24 | args.fd = 1; // 1 = stdout 25 | args.buf = buf; 26 | args.len = length; 27 | 28 | __asm ( 29 | // r1 must contain a pointer to the arguments 30 | "mov r1, %[args]\n" 31 | // semihosting call number 0x05 = SYS_WRITE 32 | "mov r0, #5\n" 33 | // make the semihosting call: https://developer.arm.com/documentation/dui0375/g/What-is-Semihosting-/The-semihosting-interface 34 | "bkpt 0xab\n" 35 | : 36 | : [args] "r" (&args) 37 | : "r0", "r1"); 38 | } 39 | 40 | stdio_driver_t stdio_semihosting = { 41 | .out_chars = stdio_semihosting_out_chars, 42 | #if PICO_STDIO_ENABLE_CRLF_SUPPORT 43 | .crlf_enabled = PICO_STDIO_SEMIHOSTING_DEFAULT_CRLF 44 | #endif 45 | }; 46 | 47 | void stdio_semihosting_init() { 48 | #if !PICO_NO_BI_STDIO_SEMIHOSTING 49 | bi_decl_if_func_used(bi_program_feature("semihosting stdout")); 50 | #endif 51 | stdio_set_driver_enabled(&stdio_semihosting, true); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /pico-sdk/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 INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 8 | 9 | pico_mirrored_target_link_libraries(pico_stdio_uart INTERFACE pico_stdio) -------------------------------------------------------------------------------- /pico-sdk/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 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 | endif() 22 | -------------------------------------------------------------------------------- /pico-sdk/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 -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_stdio_usb/include/tusb_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 5 | * Copyright (c) 2020 Damien P. George 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | #ifndef _PICO_STDIO_USB_TUSB_CONFIG_H 28 | #define _PICO_STDIO_USB_TUSB_CONFIG_H 29 | 30 | #include "pico/stdio_usb.h" 31 | 32 | #if !defined(LIB_TINYUSB_HOST) && !defined(LIB_TINYUSB_DEVICE) 33 | #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE) 34 | 35 | #define CFG_TUD_CDC (1) 36 | #define CFG_TUD_CDC_RX_BUFSIZE (256) 37 | #define CFG_TUD_CDC_TX_BUFSIZE (256) 38 | 39 | // We use a vendor specific interface but with our own driver 40 | #define CFG_TUD_VENDOR (0) 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /pico-sdk/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 INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 8 | 9 | pico_mirrored_target_link_libraries(pico_unique_id INTERFACE hardware_flash) 10 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/pico_unique_id/unique_id.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include "hardware/flash.h" 8 | #include "pico/unique_id.h" 9 | 10 | static_assert(PICO_UNIQUE_BOARD_ID_SIZE_BYTES == FLASH_UNIQUE_ID_SIZE_BYTES, "Board ID size must match flash ID size"); 11 | 12 | static pico_unique_board_id_t retrieved_id; 13 | 14 | static void __attribute__((constructor)) _retrieve_unique_id_on_boot(void) { 15 | #if PICO_NO_FLASH 16 | // The hardware_flash call will panic() if called directly on a NO_FLASH 17 | // build. Since this constructor is pre-main it would be annoying to 18 | // debug, so just produce something well-defined and obviously wrong. 19 | for (int i = 0; i < PICO_UNIQUE_BOARD_ID_SIZE_BYTES; i++) 20 | retrieved_id.id[i] = 0xee; 21 | #else 22 | flash_get_unique_id(retrieved_id.id); 23 | #endif 24 | } 25 | 26 | void pico_get_unique_board_id(pico_unique_board_id_t *id_out) { 27 | *id_out = retrieved_id; 28 | } 29 | 30 | void pico_get_unique_board_id_string(char *id_out, uint len) { 31 | assert(len > 0); 32 | size_t i; 33 | // Generate hex one nibble at a time 34 | for (i = 0; (i < len - 1) && (i < PICO_UNIQUE_BOARD_ID_SIZE_BYTES * 2); i++) { 35 | int nibble = (retrieved_id.id[i/2] >> (4 - 4 * (i&1))) & 0xf; 36 | id_out[i] = (char)(nibble < 10 ? nibble + '0' : nibble + 'A' - 10); 37 | } 38 | id_out[i] = 0; 39 | } 40 | -------------------------------------------------------------------------------- /pico-sdk/src/rp2_common/tinyusb/doc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \defgroup tinyusb_device tinyusb_device 3 | * TinyUSB Device-mode support for the RP2040. The TinyUSB documentation site can be found here. 4 | * 5 | * \defgroup tinyusb_host tinyusb_host 6 | * TinyUSB Host-mode support for the RP2040. 7 | */ 8 | -------------------------------------------------------------------------------- /pico-sdk/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(cmsis_test) 13 | add_subdirectory(pico_sem_test) 14 | endif() 15 | -------------------------------------------------------------------------------- /pico-sdk/test/cmsis_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(cmsis_test cmsis_test.c) 2 | 3 | target_link_libraries(cmsis_test PRIVATE pico_stdlib cmsis_core) 4 | pico_add_extra_outputs(cmsis_test) -------------------------------------------------------------------------------- /pico-sdk/test/cmsis_test/cmsis_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "RP2040.h" 4 | #include "pico/stdio.h" 5 | 6 | __STATIC_FORCEINLINE int some_function(int i) { 7 | return __CLZ(i); 8 | } 9 | 10 | static bool pendsv_called; 11 | 12 | void PendSV_Handler(void) { 13 | pendsv_called = true; 14 | } 15 | 16 | int main(void) { 17 | stdio_init_all(); 18 | for(int i=0;i<10;i++) { 19 | printf("%d %d\n", i, some_function(i)); 20 | } 21 | SCB->ICSR = SCB_ICSR_PENDSVSET_Msk; 22 | puts(pendsv_called ? "SUCCESS" : "FAILURE"); 23 | } 24 | -------------------------------------------------------------------------------- /pico-sdk/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) -------------------------------------------------------------------------------- /pico-sdk/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) -------------------------------------------------------------------------------- /pico-sdk/test/kitchen_sink/kitchen_sink_cpp.cpp: -------------------------------------------------------------------------------- 1 | #include "kitchen_sink.c" -------------------------------------------------------------------------------- /pico-sdk/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 -------------------------------------------------------------------------------- /pico-sdk/test/pico_divider_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT(pico_divider_test) 2 | 3 | if (PICO_ON_DEVICE) 4 | add_executable(pico_divider_test 5 | pico_divider_test.c 6 | ) 7 | 8 | target_link_libraries(pico_divider_test pico_stdlib) 9 | 10 | pico_set_divider_implementation(pico_divider_test hardware_explicit) # want to compare against compiler impl 11 | 12 | pico_add_extra_outputs(pico_divider_test) 13 | 14 | target_compile_definitions(pico_divider_test PRIVATE 15 | # PICO_DIVIDER_DISABLE_INTERRUPTS=1 16 | # TURBO 17 | ) 18 | 19 | # this is a separate test as hardware_explicit above causes it not to be tested at all! 20 | add_library(pico_divider_nesting_test_core INTERFACE) 21 | target_sources(pico_divider_nesting_test_core INTERFACE 22 | pico_divider_nesting_test.c 23 | ) 24 | target_link_libraries(pico_divider_nesting_test_core INTERFACE pico_stdlib hardware_dma) 25 | 26 | add_executable(pico_divider_nesting_test_with_dirty_check) 27 | target_link_libraries(pico_divider_nesting_test_with_dirty_check pico_divider_nesting_test_core) 28 | pico_set_divider_implementation(pico_divider_nesting_test_with_dirty_check hardware) 29 | pico_add_extra_outputs(pico_divider_nesting_test_with_dirty_check) 30 | 31 | add_executable(pico_divider_nesting_test_with_disable_irq) 32 | target_link_libraries(pico_divider_nesting_test_with_disable_irq pico_divider_nesting_test_core) 33 | target_compile_definitions(pico_divider_nesting_test_with_disable_irq PRIVATE 34 | PICO_DIVIDER_DISABLE_INTERRUPTS=1) 35 | pico_set_divider_implementation(pico_divider_nesting_test_with_disable_irq hardware) 36 | pico_add_extra_outputs(pico_divider_nesting_test_with_disable_irq) 37 | 38 | endif() -------------------------------------------------------------------------------- /pico-sdk/test/pico_float_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT(pico_float_test) 2 | 3 | add_executable(pico_float_test 4 | pico_float_test.c 5 | llvm/call_apsr.S 6 | ) 7 | 8 | add_executable(pico_double_test 9 | pico_double_test.c 10 | llvm/call_apsr.S 11 | ) 12 | 13 | 14 | #todo split out variants with different flags 15 | target_compile_definitions(pico_float_test PRIVATE 16 | PICO_USE_CRT_PRINTF=1 # want full precision output 17 | # PICO_FLOAT_PROPAGATE_NANS=1 18 | # PICO_DIVIDER_DISABLE_INTERRUPTS=1 19 | ) 20 | 21 | #todo split out variants with different flags 22 | target_compile_definitions(pico_double_test PRIVATE 23 | PICO_USE_CRT_PRINTF=1 # want full precision output 24 | PICO_FLOAT_PROPAGATE_NANS=1 25 | #PICO_DOUBLE_PROPAGATE_NANS=1 26 | #PICO_DIVIDER_DISABLE_INTERRUPTS=1 27 | ) 28 | 29 | # handy for testing we aren't pulling in extra stuff 30 | #target_link_options(pico_float_test PRIVATE -nodefaultlibs) 31 | 32 | target_include_directories(pico_float_test PRIVATE ${CMAKE_CURRENT_LIST_DIR}/llvm) 33 | target_link_libraries(pico_float_test pico_float pico_stdlib) 34 | pico_add_extra_outputs(pico_float_test) 35 | #pico_set_float_implementation(pico_float_test compiler) 36 | #pico_set_double_implementation(pico_float_test compiler) 37 | 38 | target_include_directories(pico_double_test PRIVATE ${CMAKE_CURRENT_LIST_DIR}/llvm) 39 | target_link_libraries(pico_double_test pico_double pico_stdlib) 40 | pico_add_extra_outputs(pico_double_test) 41 | #pico_set_float_implementation(pico_double_test compiler) 42 | #pico_set_double_implementation(pico_double_test compiler) -------------------------------------------------------------------------------- /pico-sdk/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 | .syntax unified 16 | .cpu cortex-m0plus 17 | .thumb 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 | -------------------------------------------------------------------------------- /pico-sdk/test/pico_float_test/llvm/call_apsr.h: -------------------------------------------------------------------------------- 1 | //todo check license 2 | //===-- call_apsr.h - Helpers for ARM EABI floating point tests -----------===// 3 | // 4 | // The LLVM Compiler Infrastructure 5 | // 6 | // This file is dual licensed under the MIT and the University of Illinois Open 7 | // Source Licenses. See LICENSE.TXT for details. 8 | // 9 | //===----------------------------------------------------------------------===// 10 | // 11 | // This file declares helpers for ARM EABI floating point tests for the 12 | // compiler_rt library. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef CALL_APSR_H 17 | #define CALL_APSR_H 18 | 19 | #if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ 20 | #error big endian support not implemented 21 | #endif 22 | 23 | union cpsr { 24 | struct { 25 | uint32_t filler: 28; 26 | uint32_t v: 1; 27 | uint32_t c: 1; 28 | uint32_t z: 1; 29 | uint32_t n: 1; 30 | } flags; 31 | uint32_t value; 32 | }; 33 | 34 | extern __attribute__((pcs("aapcs"))) 35 | uint32_t call_apsr_f(float a, float b, __attribute__((pcs("aapcs"))) void (*fn)(float, float)); 36 | 37 | extern __attribute__((pcs("aapcs"))) 38 | uint32_t call_apsr_d(double a, double b, __attribute__((pcs("aapcs"))) void (*fn)(double, double)); 39 | 40 | #endif // CALL_APSR_H 41 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/test/pico_stdio_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT PICO_TIME_NO_ALARM_SUPPORT) 2 | add_executable(pico_stdio_test_uart pico_stdio_test.c) 3 | target_link_libraries(pico_stdio_test_uart PRIVATE pico_stdlib pico_test pico_multicore) 4 | pico_add_extra_outputs(pico_stdio_test_uart) 5 | pico_enable_stdio_uart(pico_stdio_test_uart 1) 6 | pico_enable_stdio_usb(pico_stdio_test_uart 0) 7 | 8 | add_executable(pico_stdio_test_usb pico_stdio_test.c) 9 | target_link_libraries(pico_stdio_test_usb PRIVATE pico_stdlib pico_test pico_multicore) 10 | target_compile_definitions(pico_stdio_test_usb PRIVATE 11 | PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS=-1) # wait for USB connect 12 | 13 | pico_add_extra_outputs(pico_stdio_test_usb) 14 | pico_enable_stdio_uart(pico_stdio_test_usb 0) 15 | pico_enable_stdio_usb(pico_stdio_test_usb 1) 16 | endif() -------------------------------------------------------------------------------- /pico-sdk/test/pico_stdio_test/pico_stdio_test.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2023 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #include 8 | #include "pico/stdlib.h" 9 | #include "pico/multicore.h" 10 | #include "pico/test.h" 11 | 12 | PICOTEST_MODULE_NAME("pico_stdio_test", "pico_stdio test harness"); 13 | 14 | static volatile bool deadlock_test_done; 15 | static void deadlock_test_core1(void) { 16 | busy_wait_ms(250); 17 | for(int i=0;i<1000;i++) { 18 | if (deadlock_test_done) break; 19 | printf("Hello from core 1 - %d\n", i); 20 | busy_wait_ms(23); 21 | } 22 | } 23 | 24 | static volatile bool deadlock_test_irq_called; 25 | 26 | static int64_t deadlock_test_alarm(alarm_id_t id, void *param) { 27 | static int foo; 28 | printf("Here is a printf from the IRQ %d\n", ++foo); 29 | deadlock_test_irq_called = true; 30 | return 100; 31 | } 32 | 33 | int main() { 34 | stdio_init_all(); 35 | 36 | for(int i=0;i<10;i++) { 37 | printf("Hello %d\n", i); 38 | } 39 | printf("pico_stdio_test begins\n"); 40 | PICOTEST_START(); 41 | 42 | // Check default config has valid data in it 43 | PICOTEST_START_SECTION("STDIO deadlock test"); 44 | multicore_launch_core1(deadlock_test_core1); 45 | alarm_id_t alarm_id = add_alarm_in_ms(500, deadlock_test_alarm, NULL, false); 46 | PICOTEST_CHECK(getchar_timeout_us(2000000) < 0, "someone pressed a key!"); 47 | 48 | deadlock_test_done = true; 49 | cancel_alarm(alarm_id); 50 | 51 | sleep_ms(100); 52 | PICOTEST_CHECK(deadlock_test_irq_called, "deadlock_test_irq was not called"); 53 | PICOTEST_END_SECTION(); 54 | 55 | PICOTEST_END_TEST(); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/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 | pico_add_extra_outputs(pico_time_test) 8 | endif() -------------------------------------------------------------------------------- /pico-sdk/tools/FindELF2UF2.cmake: -------------------------------------------------------------------------------- 1 | # Finds (or builds) the ELF2UF2 executable 2 | # 3 | # This will define the following variables 4 | # 5 | # ELF2UF2_FOUND 6 | # 7 | # and the following imported targets 8 | # 9 | # ELF2UF2 10 | # 11 | 12 | if (NOT ELF2UF2_FOUND) 13 | # todo we would like to use pckgconfig to look for it first 14 | # see https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/ 15 | 16 | include(ExternalProject) 17 | 18 | set(ELF2UF2_SOURCE_DIR ${PICO_SDK_PATH}/tools/elf2uf2) 19 | set(ELF2UF2_BINARY_DIR ${CMAKE_BINARY_DIR}/elf2uf2) 20 | 21 | set(ELF2UF2_BUILD_TARGET ELF2UF2Build) 22 | set(ELF2UF2_TARGET ELF2UF2) 23 | 24 | if (NOT TARGET ${ELF2UF2_BUILD_TARGET}) 25 | pico_message_debug("ELF2UF2 will need to be built") 26 | ExternalProject_Add(${ELF2UF2_BUILD_TARGET} 27 | PREFIX elf2uf2 28 | SOURCE_DIR ${ELF2UF2_SOURCE_DIR} 29 | BINARY_DIR ${ELF2UF2_BINARY_DIR} 30 | CMAKE_ARGS "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}" 31 | BUILD_ALWAYS 1 # force dependency checking 32 | INSTALL_COMMAND "" 33 | ) 34 | endif() 35 | 36 | set(ELF2UF2_EXECUTABLE ${ELF2UF2_BINARY_DIR}/elf2uf2) 37 | if(NOT TARGET ${ELF2UF2_TARGET}) 38 | add_executable(${ELF2UF2_TARGET} IMPORTED) 39 | endif() 40 | set_property(TARGET ${ELF2UF2_TARGET} PROPERTY IMPORTED_LOCATION 41 | ${ELF2UF2_EXECUTABLE}) 42 | 43 | add_dependencies(${ELF2UF2_TARGET} ${ELF2UF2_BUILD_TARGET}) 44 | set(ELF2UF2_FOUND 1) 45 | endif() 46 | -------------------------------------------------------------------------------- /pico-sdk/tools/FindPioasm.cmake: -------------------------------------------------------------------------------- 1 | # Finds (or builds) the Pioasm executable 2 | # 3 | # This will define the following variables 4 | # 5 | # Pioasm_FOUND 6 | # 7 | # and the following imported targets 8 | # 9 | # Pioasm 10 | # 11 | 12 | if (NOT Pioasm_FOUND) 13 | # todo we would like to use pckgconfig to look for it first 14 | # see https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/ 15 | 16 | include(ExternalProject) 17 | 18 | set(PIOASM_SOURCE_DIR ${PICO_SDK_PATH}/tools/pioasm) 19 | set(PIOASM_BINARY_DIR ${CMAKE_BINARY_DIR}/pioasm) 20 | 21 | set(PioasmBuild_TARGET PioasmBuild) 22 | set(Pioasm_TARGET Pioasm) 23 | 24 | if (NOT TARGET ${PioasmBuild_TARGET}) 25 | pico_message_debug("PIOASM will need to be built") 26 | # message("Adding external project ${PioasmBuild_Target} in ${CMAKE_CURRENT_LIST_DIR}}") 27 | ExternalProject_Add(${PioasmBuild_TARGET} 28 | PREFIX pioasm 29 | SOURCE_DIR ${PIOASM_SOURCE_DIR} 30 | BINARY_DIR ${PIOASM_BINARY_DIR} 31 | CMAKE_ARGS "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}" 32 | CMAKE_CACHE_ARGS "-DPIOASM_EXTRA_SOURCE_FILES:STRING=${PIOASM_EXTRA_SOURCE_FILES}" 33 | BUILD_ALWAYS 1 # force dependency checking 34 | INSTALL_COMMAND "" 35 | ) 36 | endif() 37 | 38 | if (CMAKE_HOST_WIN32) 39 | set(Pioasm_EXECUTABLE ${PIOASM_BINARY_DIR}/pioasm.exe) 40 | else() 41 | set(Pioasm_EXECUTABLE ${PIOASM_BINARY_DIR}/pioasm) 42 | endif() 43 | if(NOT TARGET ${Pioasm_TARGET}) 44 | # message("Adding executable ${Pioasm_Target} in ${CMAKE_CURRENT_LIST_DIR}") 45 | add_executable(${Pioasm_TARGET} IMPORTED) 46 | endif() 47 | set_property(TARGET ${Pioasm_TARGET} PROPERTY IMPORTED_LOCATION 48 | ${Pioasm_EXECUTABLE}) 49 | 50 | # message("EXE is ${Pioasm_EXECUTABLE}") 51 | add_dependencies(${Pioasm_TARGET} ${PioasmBuild_TARGET}) 52 | set(Pioasm_FOUND 1) 53 | endif() 54 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/tools/check_doxygen_groups.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2021 Raspberry Pi (Trading) Ltd. 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | # 7 | # 8 | # Little script to check that every \ingroup has a matching \defgroup 9 | # 10 | # Usage: 11 | # 12 | # Run from the root of the tree to check 13 | 14 | 15 | import subprocess 16 | import re 17 | import sys 18 | import os 19 | 20 | groups = {} 21 | any_errors = False 22 | 23 | res = subprocess.run(['git', 'grep', '\\defgroup'], check=True, stdout=subprocess.PIPE) 24 | for line in res.stdout.decode('utf8').split('\n'): 25 | m = re.match(r'^(\S+):.*\\defgroup\s+(\w+)', line) 26 | if m: 27 | filename = m.group(1) 28 | group = m.group(2) 29 | if os.path.basename(filename) in ('check_doxygen_groups.py', 'index.h'): 30 | continue 31 | if group in groups: 32 | any_errors = True 33 | print("{} uses \\defgroup {} but so does {}".format(groups[group], group, filename)) 34 | else: 35 | groups[group] = filename 36 | 37 | res = subprocess.run(['git', 'grep', '\\ingroup'], check=True, stdout=subprocess.PIPE) 38 | for line in res.stdout.decode('utf8').split('\n'): 39 | m = re.match(r'^(\S+):.*\\ingroup\s+(\w+)', line) 40 | if m: 41 | filename = m.group(1) 42 | group = m.group(2) 43 | if os.path.basename(filename) in ('check_doxygen_groups.py', 'index.h'): 44 | continue 45 | if group not in groups: 46 | any_errors = True 47 | print("{} uses \\ingroup {} which was never defined".format(filename, group)) 48 | 49 | sys.exit(any_errors) 50 | -------------------------------------------------------------------------------- /pico-sdk/tools/elf2uf2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | project(elf2uf2) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | add_subdirectory(../../src/common/boot_uf2 boot_uf2_headers) 7 | 8 | add_executable(elf2uf2 main.cpp) 9 | if (WIN32 AND NOT MINGW AND (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) 10 | target_compile_definitions(elf2uf2 PRIVATE _CRT_SECURE_NO_WARNINGS) 11 | endif() 12 | target_link_libraries(elf2uf2 boot_uf2_headers) -------------------------------------------------------------------------------- /pico-sdk/tools/elf2uf2/elf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef _ELF_H 8 | #define _ELF_H 9 | 10 | #include 11 | 12 | #define ELF_MAGIC 0x464c457fu 13 | 14 | #define EM_ARM 0x28u 15 | 16 | #define EF_ARM_ABI_FLOAT_HARD 0x00000400u 17 | 18 | #define PT_LOAD 0x00000001u 19 | 20 | #pragma pack(push, 1) 21 | struct elf_header { 22 | uint32_t magic; 23 | uint8_t arch_class; 24 | uint8_t endianness; 25 | uint8_t version; 26 | uint8_t abi; 27 | uint8_t abi_version; 28 | uint8_t _pad[7]; 29 | uint16_t type; 30 | uint16_t machine; 31 | uint32_t version2; 32 | }; 33 | 34 | struct elf32_header { 35 | struct elf_header common; 36 | uint32_t entry; 37 | uint32_t ph_offset; 38 | uint32_t sh_offset; 39 | uint32_t flags; 40 | uint16_t eh_size; 41 | uint16_t ph_entry_size; 42 | uint16_t ph_num; 43 | uint16_t sh_entry_size; 44 | uint16_t sh_num; 45 | uint16_t sh_str_index; 46 | }; 47 | 48 | struct elf32_ph_entry { 49 | uint32_t type; 50 | uint32_t offset; 51 | uint32_t vaddr; 52 | uint32_t paddr; 53 | uint32_t filez; 54 | uint32_t memsz; 55 | uint32_t flags; 56 | uint32_t align; 57 | }; 58 | #pragma pack(pop) 59 | 60 | #endif -------------------------------------------------------------------------------- /pico-sdk/tools/pioasm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4) 2 | project(pioasm CXX) 3 | 4 | set(CMAKE_CXX_STANDARD 11) 5 | 6 | if (PIOASM_GENERATE_PARSER) 7 | find_package(BISON 3.4.2) 8 | find_package(FLEX 2.5.13) # no idea about the version 9 | 10 | FLEX_TARGET(pioasm_lexer lexer.ll ${CMAKE_CURRENT_SOURCE_DIR}/gen/lexer.cpp) 11 | BISON_TARGET(pioasm_parser parser.yy ${CMAKE_CURRENT_SOURCE_DIR}/gen/parser.cpp COMPILE_FLAGS "-Wcounterexamples") 12 | ADD_FLEX_BISON_DEPENDENCY(pioasm_lexer pioasm_parser) 13 | endif() 14 | 15 | add_executable(pioasm 16 | main.cpp 17 | pio_assembler.cpp 18 | pio_disassembler.cpp 19 | gen/lexer.cpp 20 | gen/parser.cpp 21 | ) 22 | 23 | target_sources(pioasm PRIVATE c_sdk_output.cpp) 24 | target_sources(pioasm PRIVATE python_output.cpp) 25 | target_sources(pioasm PRIVATE hex_output.cpp) 26 | target_sources(pioasm PRIVATE ada_output.cpp) 27 | target_sources(pioasm PRIVATE ${PIOASM_EXTRA_SOURCE_FILES}) 28 | 29 | if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND 30 | (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "7") AND 31 | (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9") AND 32 | (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm.*$")) 33 | # disable GCC ARM info notice about ABI change 34 | target_compile_options(pioasm PRIVATE -Wno-psabi) 35 | endif() 36 | 37 | target_include_directories(pioasm PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/gen) 38 | 39 | if (MSVC OR 40 | (WIN32 AND NOT MINGW AND (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))) 41 | target_compile_definitions(pioasm PRIVATE YY_NO_UNISTD_H) 42 | endif() 43 | if (MSVC) 44 | target_compile_options(pioasm PRIVATE "/std:c++latest") 45 | endif() 46 | 47 | -------------------------------------------------------------------------------- /pico-sdk/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 | -------------------------------------------------------------------------------- /pico-sdk/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 | 14 | typedef unsigned int uint; 15 | 16 | std::string disassemble(uint16_t inst, uint sideset_bits, bool sideset_opt); 17 | extern "C" void disassemble(char *buf, int buf_len, uint16_t inst, uint sideset_bits, bool sideset_opt); 18 | #else 19 | void disassemble(char *buf, int buf_len, uint inst, uint sideset_bits, bool sideset_opt); 20 | #endif 21 | 22 | #endif -------------------------------------------------------------------------------- /project/mdk/AC6-flash-FLM.BAT: -------------------------------------------------------------------------------- 1 | SET PATH=D:\Keil_v5\ARM\ARMCLANG\Bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility;C:\Program Files\TortoiseGit\bin;C:\Program Files\Git\cmd;C:\Program Files\LLVM\bin;D:\Keil_v5\ARM\ARMCLANG\bin;C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Scripts\;C:\Users\Administrator\AppData\Local\Programs\Python\Python311\;C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\Administrator\AppData\Local\Programs\Python\Python37\;D:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2015q3\bin;C:\msys64\mingw64\bin;D:\Keil_v5\ARM\ARMCLANG\bin;;C:\Program Files (x86)\Linaro\gcc-linaro-arm-linux-gnueabihf-4.9-2014.07\bin 2 | SET CPU_TYPE=ARMCM0P_MPU 3 | SET CPU_VENDOR=ARM 4 | SET UV2_TARGET=AC6-flash-FLM 5 | SET CPU_CLOCK=0x00B71B00 6 | "D:\Keil_v5\ARM\ARMCLANG\Bin\ArmClang.exe" @".\objects\flashprg.__i" 7 | "D:\Keil_v5\ARM\ARMCLANG\Bin\ArmClang.exe" @".\objects\flashdev.__i" 8 | "D:\Keil_v5\ARM\ARMCLANG\Bin\ArmClang.exe" @".\objects\bootrom.__i" 9 | "D:\Keil_v5\ARM\ARMCLANG\Bin\ArmClang.exe" @".\objects\flash.__i" 10 | "D:\Keil_v5\ARM\ARMCLANG\Bin\ArmLink" --Via ".\Objects\RP2040.lnp" 11 | cmd.exe /C copy ".\Objects\RP2040.axf" "..\RP2040.FLM" 12 | -------------------------------------------------------------------------------- /project/mdk/RP2040_flash_flm.sct: -------------------------------------------------------------------------------- 1 | ; Linker Control File (scatter-loading) 2 | ; 3 | 4 | PRG 0 PI ; Programming Functions 5 | { 6 | PrgCode +0 ; Code 7 | { 8 | * (+RO) 9 | } 10 | PrgData +0 ; Data 11 | { 12 | * (+RW,+ZI) 13 | } 14 | } 15 | 16 | DSCR +0 ; Device Description 17 | { 18 | DevDscr +0 19 | { 20 | FlashDev.o 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /project/mdk/RTE/Compiler/EventRecorderConf.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * MDK - Component ::Event Recorder 3 | * Copyright (c) 2016-2018 ARM Germany GmbH. All rights reserved. 4 | *------------------------------------------------------------------------------ 5 | * Name: EventRecorderConf.h 6 | * Purpose: Event Recorder Configuration 7 | * Rev.: V1.1.0 8 | *----------------------------------------------------------------------------*/ 9 | 10 | //-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- 11 | 12 | // Event Recorder 13 | 14 | // Number of Records 15 | // <8=>8 <16=>16 <32=>32 <64=>64 <128=>128 <256=>256 <512=>512 <1024=>1024 16 | // <2048=>2048 <4096=>4096 <8192=>8192 <16384=>16384 <32768=>32768 17 | // <65536=>65536 18 | // Configures size of Event Record Buffer (each record is 16 bytes) 19 | // Must be 2^n (min=8, max=65536) 20 | #define EVENT_RECORD_COUNT 64U 21 | 22 | // Time Stamp Source 23 | // <0=> DWT Cycle Counter <1=> SysTick <2=> CMSIS-RTOS2 System Timer 24 | // <3=> User Timer (Normal Reset) <4=> User Timer (Power-On Reset) 25 | // Selects source for 32-bit time stamp 26 | #define EVENT_TIMESTAMP_SOURCE 3 27 | 28 | // Time Stamp Clock Frequency [Hz] <0-1000000000> 29 | // Defines initial time stamp clock frequency (0 when not used) 30 | #define EVENT_TIMESTAMP_FREQ 125000000U 31 | 32 | // 33 | 34 | //------------- <<< end of configuration section >>> --------------------------- 35 | -------------------------------------------------------------------------------- /project/mdk/Raspberry_Pi_Pico.FLM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aladdin-Wang/RP2040_Flash_Algorithm/8a5bf5c4e8f04f3863cb179ca439e6560bcc14a3/project/mdk/Raspberry_Pi_Pico.FLM -------------------------------------------------------------------------------- /project/mdk/axf2uf2.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set MDK_ROOT=%1 3 | 4 | @if not exist "%MDK_ROOT%Arm\Flash\Raspberry_Pi_Pico.FLM" ( 5 | 6 | @echo ================================================== 7 | @echo Try to install RP2040 flash programming algorithm... 8 | @echo If you didn't see "1 file(s) copied", please manually copy Raspberry_Pi_Pico.FLM to "\Arm\Flash", e.g. "C:\Keil_v5\Arm\Flash\" 9 | @echo ================================================== 10 | @copy /B ".\Raspberry_Pi_Pico.FLM" "%MDK_ROOT%Arm\Flash\Raspberry_Pi_Pico.FLM" 11 | 12 | ) -------------------------------------------------------------------------------- /project/mdk/debug_with_cmsis-dap.ini: -------------------------------------------------------------------------------- 1 | 2 | FUNC void reset_pico(void) 3 | { 4 | exec("RESET"); 5 | exec("G, Reset_Handler"); 6 | } 7 | 8 | DEFINE BUTTON "Reset Pico", "reset_pico()" 9 | 10 | reset_pico(); -------------------------------------------------------------------------------- /project/mdk/debug_with_cmsis-dap_in_ram.ini: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | FUNC void debug_from_ram(void) 5 | { 6 | //extern unsigned int Image$$ARM_LIB_STACK$$ZI$$Limit; 7 | 8 | printf("Entry Point: %08x\r\n", Reset_Handler); 9 | printf("Main Stack Pointer: %08x\r\n", Image$$ARM_LIB_STACK$$ZI$$Limit); 10 | 11 | /* 12 | typedef struct { 13 | unsigned int ctrl; 14 | unsigned int load; 15 | unsigned int reason; 16 | unsigned int scratch[8]; 17 | unsigned int tick; 18 | } watchdog_hw_t; 19 | 20 | #define watchdog_hw ((watchdog_hw_t *const)0x40058000) 21 | */ 22 | 23 | _WWORD(0x4005801C ,0xb007c0d3); //! scratch 4 24 | _WWORD(0x40058020 ,-0xb007c0d3 ^ (Reset_Handler | 0x01)); //! scratch 5 25 | _WWORD(0x40058024 ,Image$$ARM_LIB_STACK$$ZI$$Limit); //! scratch 6 26 | _WWORD(0x40058028 ,Reset_Handler | 0x01); //! scratch 7 27 | 28 | exec("RESET"); 29 | //exec("BS main"); 30 | //exec("G, Reset_Handler"); 31 | exec("G, main"); 32 | } 33 | 34 | DEFINE BUTTON "Reset Pico", "debug_from_ram()" 35 | 36 | debug_from_ram(); 37 | debug_from_ram(); 38 | -------------------------------------------------------------------------------- /project/mdk/wrapper/pico_base/pico/config_autogen.h: -------------------------------------------------------------------------------- 1 | // AUTOGENERATED FROM PICO_CONFIG_HEADER_FILES and then PICO__CONFIG_HEADER_FILES 2 | // DO NOT EDIT! 3 | 4 | // based on PICO_CONFIG_HEADER_FILES: 5 | #include "..\..\..\..\..\pico-sdk\src\boards\include\boards\pico.h" 6 | 7 | // based on PICO_RP2040_CONFIG_HEADER_FILES: 8 | #include "..\..\..\..\..\pico-sdk\src\rp2_common\cmsis\include\cmsis\rename_exceptions.h" -------------------------------------------------------------------------------- /project/mdk/wrapper/pico_base/pico/version.h: -------------------------------------------------------------------------------- 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 1 15 | #define PICO_SDK_VERSION_MINOR 2 16 | #define PICO_SDK_VERSION_REVISION 0 17 | #define PICO_SDK_VERSION_STRING "1.2.0" 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /project/mdk/wrapper/sys/cdefs.h: -------------------------------------------------------------------------------- 1 | //! a fake header file --------------------------------------------------------------------------------