├── .gitignore ├── README.md ├── adc_continuous ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── adc_continuous.gpr ├── alire.toml ├── raspberrypi-swd.cfg └── src │ └── adc_continuous.adb ├── adc_hello ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── adc_hello.gpr ├── alire.toml ├── raspberrypi-swd.cfg └── src │ └── adc_hello.adb ├── blink ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── blink.gpr ├── raspberrypi-swd.cfg └── src │ └── blink.adb ├── blog ├── 01-zfp-blink │ ├── ld │ │ └── memmap_default.ld │ ├── rpsimple.gpr │ └── src │ │ ├── boot2_w25q080.S │ │ ├── crt0.S │ │ ├── main.adb │ │ ├── rp2040_svd-adc.ads │ │ ├── rp2040_svd-busctrl.ads │ │ ├── rp2040_svd-clocks.ads │ │ ├── rp2040_svd-dma.ads │ │ ├── rp2040_svd-i2c.ads │ │ ├── rp2040_svd-interrupts.ads │ │ ├── rp2040_svd-io_bank0.ads │ │ ├── rp2040_svd-io_qspi.ads │ │ ├── rp2040_svd-pads_bank0.ads │ │ ├── rp2040_svd-pads_qspi.ads │ │ ├── rp2040_svd-pio.ads │ │ ├── rp2040_svd-pll_sys.ads │ │ ├── rp2040_svd-pll_usb.ads │ │ ├── rp2040_svd-ppb.ads │ │ ├── rp2040_svd-psm.ads │ │ ├── rp2040_svd-pwm.ads │ │ ├── rp2040_svd-resets.ads │ │ ├── rp2040_svd-rosc.ads │ │ ├── rp2040_svd-rtc.ads │ │ ├── rp2040_svd-sio.ads │ │ ├── rp2040_svd-spi.ads │ │ ├── rp2040_svd-syscfg.ads │ │ ├── rp2040_svd-sysinfo.ads │ │ ├── rp2040_svd-tbman.ads │ │ ├── rp2040_svd-timer.ads │ │ ├── rp2040_svd-uart.ads │ │ ├── rp2040_svd-usbctrl_regs.ads │ │ ├── rp2040_svd-vreg_and_chip_reset.ads │ │ ├── rp2040_svd-watchdog.ads │ │ ├── rp2040_svd-xip_ctrl.ads │ │ ├── rp2040_svd-xip_ssi.ads │ │ ├── rp2040_svd-xosc.ads │ │ ├── rp2040_svd.ads │ │ ├── systick.adb │ │ └── systick.ads ├── 02-ravenscar-blink │ ├── rpsimple.gpr │ └── src │ │ ├── main.adb │ │ ├── rp2040_svd-adc.ads │ │ ├── rp2040_svd-busctrl.ads │ │ ├── rp2040_svd-clocks.ads │ │ ├── rp2040_svd-dma.ads │ │ ├── rp2040_svd-i2c.ads │ │ ├── rp2040_svd-interrupts.ads │ │ ├── rp2040_svd-io_bank0.ads │ │ ├── rp2040_svd-io_qspi.ads │ │ ├── rp2040_svd-pads_bank0.ads │ │ ├── rp2040_svd-pads_qspi.ads │ │ ├── rp2040_svd-pio.ads │ │ ├── rp2040_svd-pll_sys.ads │ │ ├── rp2040_svd-pll_usb.ads │ │ ├── rp2040_svd-ppb.ads │ │ ├── rp2040_svd-psm.ads │ │ ├── rp2040_svd-pwm.ads │ │ ├── rp2040_svd-resets.ads │ │ ├── rp2040_svd-rosc.ads │ │ ├── rp2040_svd-rtc.ads │ │ ├── rp2040_svd-sio.ads │ │ ├── rp2040_svd-spi.ads │ │ ├── rp2040_svd-syscfg.ads │ │ ├── rp2040_svd-sysinfo.ads │ │ ├── rp2040_svd-tbman.ads │ │ ├── rp2040_svd-timer.ads │ │ ├── rp2040_svd-uart.ads │ │ ├── rp2040_svd-usbctrl_regs.ads │ │ ├── rp2040_svd-vreg_and_chip_reset.ads │ │ ├── rp2040_svd-watchdog.ads │ │ ├── rp2040_svd-xip_ctrl.ads │ │ ├── rp2040_svd-xip_ssi.ads │ │ ├── rp2040_svd-xosc.ads │ │ └── rp2040_svd.ads ├── 03-realtime-blink │ ├── rpsimple.gpr │ └── src │ │ ├── main.adb │ │ ├── rp2040_svd-adc.ads │ │ ├── rp2040_svd-busctrl.ads │ │ ├── rp2040_svd-clocks.ads │ │ ├── rp2040_svd-dma.ads │ │ ├── rp2040_svd-i2c.ads │ │ ├── rp2040_svd-interrupts.ads │ │ ├── rp2040_svd-io_bank0.ads │ │ ├── rp2040_svd-io_qspi.ads │ │ ├── rp2040_svd-pads_bank0.ads │ │ ├── rp2040_svd-pads_qspi.ads │ │ ├── rp2040_svd-pio.ads │ │ ├── rp2040_svd-pll_sys.ads │ │ ├── rp2040_svd-pll_usb.ads │ │ ├── rp2040_svd-ppb.ads │ │ ├── rp2040_svd-psm.ads │ │ ├── rp2040_svd-pwm.ads │ │ ├── rp2040_svd-resets.ads │ │ ├── rp2040_svd-rosc.ads │ │ ├── rp2040_svd-rtc.ads │ │ ├── rp2040_svd-sio.ads │ │ ├── rp2040_svd-spi.ads │ │ ├── rp2040_svd-syscfg.ads │ │ ├── rp2040_svd-sysinfo.ads │ │ ├── rp2040_svd-tbman.ads │ │ ├── rp2040_svd-timer.ads │ │ ├── rp2040_svd-uart.ads │ │ ├── rp2040_svd-usbctrl_regs.ads │ │ ├── rp2040_svd-vreg_and_chip_reset.ads │ │ ├── rp2040_svd-watchdog.ads │ │ ├── rp2040_svd-xip_ctrl.ads │ │ ├── rp2040_svd-xip_ssi.ads │ │ ├── rp2040_svd-xosc.ads │ │ └── rp2040_svd.ads ├── 04-hal-blink │ ├── .gitignore │ ├── alire.toml │ ├── rpsimple.gpr │ └── src │ │ └── main.adb └── README.md ├── clock_output ├── clock_output.gpr └── src │ └── main.adb ├── feather_rp2040_blink ├── .gitignore ├── alire.toml ├── feather_rp2040_blink.gpr └── src │ └── main.adb ├── feather_rp2040_bsp ├── .gitignore ├── alire.toml ├── feather_rp2040_bsp.gpr └── src │ └── feather_rp2040.ads ├── gpio_interrupts ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── gpio_interrupts.gpr ├── raspberrypi-swd.cfg └── src │ ├── gpio_interrupts.adb │ ├── handlers.adb │ └── handlers.ads ├── i2c_demo ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── i2c_demo.gpr ├── raspberrypi-swd.cfg └── src │ └── i2c_demo.adb ├── i2c_target ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── i2c_target.gpr ├── raspberrypi-swd.cfg └── src │ └── i2c_target.adb ├── multicore ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── multicore.gpr ├── raspberrypi-swd.cfg └── src │ ├── led_control.adb │ ├── led_control.ads │ └── multicore.adb ├── pimoroni_audio_pack ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── pimoroni_audio_pack.gpr ├── raspberrypi-swd.cfg └── src │ ├── pimoroni_audio_pack.adb │ ├── synth.adb │ └── synth.ads ├── pimoroni_rgb_keypad ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── pimoroni_rgb_keypad.gpr ├── raspberrypi-swd.cfg └── src │ └── pimoroni_rgb_keypad.adb ├── pio_assemble ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── pio_assemble.gpr ├── raspberrypi-swd.cfg └── src │ └── pio_assemble.adb ├── pio_blink ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── gen │ └── hello.ads ├── pio_blink.gpr ├── pioasm.gpr ├── raspberrypi-swd.cfg └── src │ ├── hello.pio │ └── pio_blink.adb ├── pwm ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── pwm.gpr ├── raspberrypi-swd.cfg └── src │ └── pwm.adb ├── ravenscar_blink ├── README.md ├── ravenscar_blink.gpr └── src │ └── main.adb ├── rtc ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── raspberrypi-swd.cfg ├── rtc.gpr └── src │ ├── rtc.adb │ ├── text_format.adb │ └── text_format.ads ├── spi_loopback ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── raspberrypi-swd.cfg ├── spi_loopback.gpr └── src │ ├── board.adb │ ├── board.ads │ ├── spi_loopback.adb │ ├── tests.adb │ └── tests.ads ├── timer ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── raspberrypi-swd.cfg ├── src │ └── timer.adb └── timer.gpr ├── uart_echo ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── raspberrypi-swd.cfg ├── src │ └── uart_echo.adb └── uart_echo.gpr ├── uart_interrupt ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── raspberrypi-swd.cfg ├── src │ ├── console.adb │ ├── console.ads │ └── uart_interrupt.adb └── uart_interrupt.gpr ├── usb_echo ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── raspberrypi-swd.cfg ├── src │ └── usb_echo.adb └── usb_echo.gpr ├── usb_echo_interrupt ├── .gitignore ├── .vimspector.json ├── .vscode │ ├── extensions.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── raspberrypi-swd.cfg ├── src │ ├── usb_echo_interrupt.adb │ ├── usb_int.adb │ └── usb_int.ads └── usb_echo_interrupt.gpr └── ws2812_demo ├── .gitignore ├── .vimspector.json ├── .vscode ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── alire.toml ├── raspberrypi-swd.cfg ├── src └── ws2812_demo.adb └── ws2812_demo.gpr /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | obj/ 3 | lib/ 4 | alire/ 5 | alire.lock 6 | config/ 7 | deps/ 8 | *.swp 9 | *.stderr 10 | *.stdout 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Raspberry Pi Pico Examples (Ada) 2 | 3 | Each subdirectory is a standalone project which you can build using [Alire](https://alire.ada.dev/) and flash to a [Raspberry Pi Pico](https://www.raspberrypi.com/documentation/microcontrollers/pico-series.html). It is also possible to run the debugger - see the project's own README for details. You can copy whichever project is most similar to your use case to a new location and initialize your git repo there. 4 | 5 | This is a relatively new project and you may encounter bugs. Please file GitHub issues or join the development discussion on Gitter: [https://gitter.im/ada-lang/raspberrypi-pico](https://gitter.im/ada-lang/raspberrypi-pico). 6 | 7 | [Documentation](https://pico-doc.synack.me/) 8 | -------------------------------------------------------------------------------- /adc_continuous/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /adc_continuous/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_adc_continuous": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/adc_continuous", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /adc_continuous/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /adc_continuous/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/adc_continuous", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /adc_continuous/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /adc_continuous/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile Project", 6 | "type": "process", 7 | "isBuildCommand": true, 8 | "command": "alr", 9 | "args": ["build"], 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "always", 13 | "panel": "dedicated" 14 | }, 15 | "problemMatcher": "$gcc", 16 | "windows": { 17 | "command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe" 18 | } 19 | }, 20 | { 21 | "label": "Run Project", 22 | "type": "process", 23 | "command": "${env:HOME}/.pico-sdk/picotool/2.1.1/picotool/picotool", 24 | "args": [ 25 | "load", 26 | "${command:raspberry-pi-pico.launchTargetPath}", 27 | "-fx" 28 | ], 29 | "presentation": { 30 | "reveal": "always", 31 | "panel": "dedicated" 32 | }, 33 | "problemMatcher": [], 34 | "windows": { 35 | "command": "${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool/picotool.exe" 36 | } 37 | }, 38 | { 39 | "label": "Flash", 40 | "type": "process", 41 | "command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe", 42 | "args": [ 43 | "-s", 44 | "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts", 45 | "-f", 46 | "raspberrypi-swd.cfg", 47 | "-f", 48 | "target/${command:raspberry-pi-pico.getTarget}.cfg", 49 | "-c", 50 | "adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit" 51 | ], 52 | "problemMatcher": [], 53 | "windows": { 54 | "command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe" 55 | } 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /adc_continuous/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /adc_continuous/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/adc_continuous.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/adc_continuous.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/adc_continuous 10 | 11 | bin/adc_continuous.uf2: bin/adc_continuous 12 | picotool uf2 convert bin/adc_continuous -t elf bin/adc_continuous.uf2 13 | 14 | bin/adc_continuous: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /adc_continuous/adc_continuous.gpr: -------------------------------------------------------------------------------- 1 | with "config/adc_continuous_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project adc_continuous is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & adc_continuous_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("adc_continuous.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use adc_continuous_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end adc_continuous; 32 | -------------------------------------------------------------------------------- /adc_continuous/alire.toml: -------------------------------------------------------------------------------- 1 | name = "adc_continuous" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["adc_continuous"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /adc_continuous/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /adc_hello/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /adc_hello/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_adc_hello": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/adc_hello", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /adc_hello/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /adc_hello/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/adc_hello", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /adc_hello/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /adc_hello/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile Project", 6 | "type": "process", 7 | "isBuildCommand": true, 8 | "command": "alr", 9 | "args": ["build"], 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "always", 13 | "panel": "dedicated" 14 | }, 15 | "problemMatcher": "$gcc", 16 | "windows": { 17 | "command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe" 18 | } 19 | }, 20 | { 21 | "label": "Run Project", 22 | "type": "process", 23 | "command": "${env:HOME}/.pico-sdk/picotool/2.1.1/picotool/picotool", 24 | "args": [ 25 | "load", 26 | "${command:raspberry-pi-pico.launchTargetPath}", 27 | "-fx" 28 | ], 29 | "presentation": { 30 | "reveal": "always", 31 | "panel": "dedicated" 32 | }, 33 | "problemMatcher": [], 34 | "windows": { 35 | "command": "${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool/picotool.exe" 36 | } 37 | }, 38 | { 39 | "label": "Flash", 40 | "type": "process", 41 | "command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe", 42 | "args": [ 43 | "-s", 44 | "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts", 45 | "-f", 46 | "raspberrypi-swd.cfg", 47 | "-f", 48 | "target/${command:raspberry-pi-pico.getTarget}.cfg", 49 | "-c", 50 | "adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit" 51 | ], 52 | "problemMatcher": [], 53 | "windows": { 54 | "command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe" 55 | } 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /adc_hello/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /adc_hello/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/adc_hello.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/adc_hello.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/adc_hello 10 | 11 | bin/adc_hello.uf2: bin/adc_hello 12 | picotool uf2 convert bin/adc_hello -t elf bin/adc_hello.uf2 13 | 14 | bin/adc_hello: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /adc_hello/adc_hello.gpr: -------------------------------------------------------------------------------- 1 | with "config/adc_hello_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project adc_hello is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & adc_hello_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("adc_hello.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use adc_hello_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end adc_hello; 32 | -------------------------------------------------------------------------------- /adc_hello/alire.toml: -------------------------------------------------------------------------------- 1 | name = "adc_hello" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["adc_hello"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /adc_hello/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /adc_hello/src/adc_hello.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with Ada.Text_IO; use Ada.Text_IO; 7 | with RP.Device; use RP.Device; 8 | with RP.GPIO; use RP.GPIO; 9 | with RP.ADC; use RP.ADC; 10 | with RP.Clock; 11 | with Pico; 12 | 13 | procedure Adc_hello is 14 | VSYS : Microvolts; 15 | begin 16 | RP.Clock.Initialize (Pico.XOSC_Frequency); 17 | 18 | -- The Pico's power regulator dynamically adjusts it's switching frequency 19 | -- based on load. This introduces noise that can affect ADC readings. The 20 | -- Pico datasheet recommends setting Power Save pin high while performing 21 | -- ADC measurements to minimize this noise, at tne expense of higher power 22 | -- consumption. 23 | Pico.SMPS_PS.Configure (Output, Pull_Up); 24 | Pico.SMPS_PS.Clear; 25 | 26 | RP.ADC.Enable; 27 | RP.ADC.Configure (0); 28 | RP.ADC.Configure (Pico.VSYS_DIV_3); 29 | 30 | RP.Device.Timer.Enable; 31 | loop 32 | Pico.SMPS_PS.Set; 33 | VSYS := RP.ADC.Read_Microvolts (Pico.VSYS_DIV_3) * 3; 34 | Put_Line ("Channel 0: " & RP.ADC.Read_Microvolts (0)'Image & "μv"); 35 | Put_Line ("VSYS: " & VSYS'Image & "μv"); 36 | Put_Line ("Temperature:" & RP.ADC.Temperature'Image & "°C"); 37 | Pico.SMPS_PS.Clear; 38 | RP.Device.Timer.Delay_Milliseconds (1000); 39 | end loop; 40 | end Adc_hello; 41 | -------------------------------------------------------------------------------- /blink/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /blink/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_blink": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/blink", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /blink/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /blink/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/blink", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /blink/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /blink/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile Project", 6 | "type": "process", 7 | "isBuildCommand": true, 8 | "command": "alr", 9 | "args": ["build"], 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "always", 13 | "panel": "dedicated" 14 | }, 15 | "problemMatcher": "$gcc", 16 | "windows": { 17 | "command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe" 18 | } 19 | }, 20 | { 21 | "label": "Run Project", 22 | "type": "process", 23 | "command": "${env:HOME}/.pico-sdk/picotool/2.1.1/picotool/picotool", 24 | "args": [ 25 | "load", 26 | "${command:raspberry-pi-pico.launchTargetPath}", 27 | "-fx" 28 | ], 29 | "presentation": { 30 | "reveal": "always", 31 | "panel": "dedicated" 32 | }, 33 | "problemMatcher": [], 34 | "windows": { 35 | "command": "${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool/picotool.exe" 36 | } 37 | }, 38 | { 39 | "label": "Flash", 40 | "type": "process", 41 | "command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe", 42 | "args": [ 43 | "-s", 44 | "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts", 45 | "-f", 46 | "raspberrypi-swd.cfg", 47 | "-f", 48 | "target/${command:raspberry-pi-pico.getTarget}.cfg", 49 | "-c", 50 | "adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit" 51 | ], 52 | "problemMatcher": [], 53 | "windows": { 54 | "command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe" 55 | } 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /blink/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /blink/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/blink.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/blink.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/blink 10 | 11 | bin/blink.uf2: bin/blink 12 | picotool uf2 convert bin/blink -t elf bin/blink.uf2 13 | 14 | bin/blink: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /blink/alire.toml: -------------------------------------------------------------------------------- 1 | name = "blink" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["blink"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /blink/blink.gpr: -------------------------------------------------------------------------------- 1 | with "config/blink_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project blink is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & blink_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("blink.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use blink_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end blink; 32 | -------------------------------------------------------------------------------- /blink/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /blink/src/blink.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with RP.Device; 7 | with RP.Clock; 8 | with RP.GPIO; 9 | with Pico; 10 | 11 | procedure Blink is 12 | begin 13 | RP.Clock.Initialize (Pico.XOSC_Frequency); 14 | Pico.LED.Configure (RP.GPIO.Output); 15 | RP.Device.Timer.Enable; 16 | loop 17 | Pico.LED.Toggle; 18 | RP.Device.Timer.Delay_Milliseconds (100); 19 | end loop; 20 | end Blink; 21 | -------------------------------------------------------------------------------- /blog/01-zfp-blink/rpsimple.gpr: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | project RPSimple is 7 | for Target use "arm-eabi"; 8 | for Runtime ("Ada") use "zfp-cortex-m0p"; 9 | 10 | for Languages use ("Ada", "ASM_CPP"); 11 | for Source_Dirs use ("src"); 12 | for Object_Dir use "obj"; 13 | for Create_Missing_Dirs use "true"; 14 | for Main use ("main.adb"); 15 | 16 | package Compiler is 17 | for Switches ("Ada") use 18 | ("-g", "-Og"); 19 | end Compiler; 20 | 21 | package Linker is 22 | for Switches ("Ada") use 23 | ("boot2_w25q080.o", "-T" & Project'Project_Dir & "ld/memmap_default.ld"); 24 | end Linker; 25 | 26 | end RPSimple; 27 | -------------------------------------------------------------------------------- /blog/01-zfp-blink/src/boot2_w25q080.S: -------------------------------------------------------------------------------- 1 | # 1 "pico-sdk/src/rp2_common/boot_stage2/bs2_default_padded_checksummed.S" 2 | # 1 "" 3 | # 1 "" 4 | # 1 "pico-sdk/src/rp2_common/boot_stage2/bs2_default_padded_checksummed.S" 5 | 6 | 7 | .cpu cortex-m0plus 8 | .thumb 9 | 10 | .section .boot2, "ax" 11 | 12 | .byte 0x00, 0xb5, 0x32, 0x4b, 0x21, 0x20, 0x58, 0x60, 0x98, 0x68, 0x02, 0x21, 0x88, 0x43, 0x98, 0x60 13 | .byte 0xd8, 0x60, 0x18, 0x61, 0x58, 0x61, 0x2e, 0x4b, 0x00, 0x21, 0x99, 0x60, 0x02, 0x21, 0x59, 0x61 14 | .byte 0x01, 0x21, 0xf0, 0x22, 0x99, 0x50, 0x2b, 0x49, 0x19, 0x60, 0x01, 0x21, 0x99, 0x60, 0x35, 0x20 15 | .byte 0x00, 0xf0, 0x44, 0xf8, 0x02, 0x22, 0x90, 0x42, 0x14, 0xd0, 0x06, 0x21, 0x19, 0x66, 0x00, 0xf0 16 | .byte 0x34, 0xf8, 0x19, 0x6e, 0x01, 0x21, 0x19, 0x66, 0x00, 0x20, 0x18, 0x66, 0x1a, 0x66, 0x00, 0xf0 17 | .byte 0x2c, 0xf8, 0x19, 0x6e, 0x19, 0x6e, 0x19, 0x6e, 0x05, 0x20, 0x00, 0xf0, 0x2f, 0xf8, 0x01, 0x21 18 | .byte 0x08, 0x42, 0xf9, 0xd1, 0x00, 0x21, 0x99, 0x60, 0x1b, 0x49, 0x19, 0x60, 0x00, 0x21, 0x59, 0x60 19 | .byte 0x1a, 0x49, 0x1b, 0x48, 0x01, 0x60, 0x01, 0x21, 0x99, 0x60, 0xeb, 0x21, 0x19, 0x66, 0xa0, 0x21 20 | .byte 0x19, 0x66, 0x00, 0xf0, 0x12, 0xf8, 0x00, 0x21, 0x99, 0x60, 0x16, 0x49, 0x14, 0x48, 0x01, 0x60 21 | .byte 0x01, 0x21, 0x99, 0x60, 0x01, 0xbc, 0x00, 0x28, 0x00, 0xd0, 0x00, 0x47, 0x12, 0x48, 0x13, 0x49 22 | .byte 0x08, 0x60, 0x03, 0xc8, 0x80, 0xf3, 0x08, 0x88, 0x08, 0x47, 0x03, 0xb5, 0x99, 0x6a, 0x04, 0x20 23 | .byte 0x01, 0x42, 0xfb, 0xd0, 0x01, 0x20, 0x01, 0x42, 0xf8, 0xd1, 0x03, 0xbd, 0x02, 0xb5, 0x18, 0x66 24 | .byte 0x18, 0x66, 0xff, 0xf7, 0xf2, 0xff, 0x18, 0x6e, 0x18, 0x6e, 0x02, 0xbd, 0x00, 0x00, 0x02, 0x40 25 | .byte 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x07, 0x00, 0x00, 0x03, 0x5f, 0x00, 0x21, 0x22, 0x00, 0x00 26 | .byte 0xf4, 0x00, 0x00, 0x18, 0x22, 0x20, 0x00, 0xa0, 0x00, 0x01, 0x00, 0x10, 0x08, 0xed, 0x00, 0xe0 27 | .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0xb2, 0x4e, 0x7a 28 | -------------------------------------------------------------------------------- /blog/01-zfp-blink/src/main.adb: -------------------------------------------------------------------------------- 1 | with RP2040_SVD.RESETS; use RP2040_SVD.RESETS; 2 | with RP2040_SVD.IO_BANK0; use RP2040_SVD.IO_BANK0; 3 | with RP2040_SVD.PADS_BANK0; use RP2040_SVD.PADS_BANK0; 4 | with RP2040_SVD.SIO; use RP2040_SVD.SIO; 5 | with RP2040_SVD.PPB; use RP2040_SVD.PPB; 6 | with SysTick; 7 | 8 | procedure Main is 9 | Pin_Mask : constant GPIO_OUT_GPIO_OUT_Field := 16#0200_0000#; 10 | Next_Blink : Natural := 0; 11 | begin 12 | RESETS_Periph.RESET.io_bank0 := False; 13 | RESETS_Periph.RESET.pads_bank0 := False; 14 | while not RESETS_Periph.RESET_DONE.io_bank0 or else 15 | not RESETS_Periph.RESET_DONE.pads_bank0 loop 16 | null; 17 | end loop; 18 | 19 | -- output disable off 20 | PADS_BANK0_Periph.GPIO25.OD := False; 21 | -- input enable off 22 | PADS_BANK0_Periph.GPIO25.IE := False; 23 | 24 | -- function select 25 | IO_BANK0_Periph.GPIO25_CTRL.FUNCSEL := sio_25; 26 | 27 | -- output enable 28 | SIO_Periph.GPIO_OE_SET.GPIO_OE_SET := Pin_Mask; 29 | 30 | SysTick.Enable; 31 | loop 32 | if SysTick.Ticks >= Next_Blink then 33 | SIO_Periph.GPIO_OUT_XOR.GPIO_OUT_XOR := Pin_Mask; 34 | Next_Blink := Next_Blink + 1_000; 35 | end if; 36 | SysTick.Wait; 37 | end loop; 38 | end Main; 39 | -------------------------------------------------------------------------------- /blog/01-zfp-blink/src/rp2040_svd-interrupts.ads: -------------------------------------------------------------------------------- 1 | pragma Style_Checks (Off); 2 | 3 | -- Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 4 | -- 5 | -- SPDX-License-Identifier: BSD-3-Clause 6 | 7 | -- This spec has been automatically generated from rp2040.svd 8 | 9 | -- Definition of the device's interrupts 10 | package RP2040_SVD.Interrupts is 11 | 12 | ---------------- 13 | -- Interrupts -- 14 | ---------------- 15 | 16 | TIMER_IRQ_0_Interrupt : constant := 0; 17 | TIMER_IRQ_1_Interrupt : constant := 1; 18 | TIMER_IRQ_2_Interrupt : constant := 2; 19 | TIMER_IRQ_3_Interrupt : constant := 3; 20 | PWM_IRQ_WRAP_Interrupt : constant := 4; 21 | USBCTRL_Interrupt : constant := 5; 22 | XIP_Interrupt : constant := 6; 23 | PIO0_IRQ_0_Interrupt : constant := 7; 24 | PIO0_IRQ_1_Interrupt : constant := 8; 25 | PIO1_IRQ_0_Interrupt : constant := 9; 26 | PIO1_IRQ_1_Interrupt : constant := 10; 27 | DMA_IRQ_0_Interrupt : constant := 11; 28 | DMA_IRQ_1_Interrupt : constant := 12; 29 | IO_IRQ_BANK0_Interrupt : constant := 13; 30 | IO_IRQ_QSPI_Interrupt : constant := 14; 31 | SIO_IRQ_PROC0_Interrupt : constant := 15; 32 | SIO_IRQ_PROC1_Interrupt : constant := 16; 33 | CLOCKS_Interrupt : constant := 17; 34 | SPI0_Interrupt : constant := 18; 35 | SPI1_Interrupt : constant := 19; 36 | UART0_Interrupt : constant := 20; 37 | UART1_Interrupt : constant := 21; 38 | ADC_IRQ_FIFO_Interrupt : constant := 22; 39 | I2C0_Interrupt : constant := 23; 40 | I2C1_Interrupt : constant := 24; 41 | RTC_Interrupt : constant := 25; 42 | 43 | end RP2040_SVD.Interrupts; 44 | -------------------------------------------------------------------------------- /blog/01-zfp-blink/src/rp2040_svd-tbman.ads: -------------------------------------------------------------------------------- 1 | pragma Style_Checks (Off); 2 | 3 | -- Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 4 | -- 5 | -- SPDX-License-Identifier: BSD-3-Clause 6 | 7 | -- This spec has been automatically generated from rp2040.svd 8 | 9 | pragma Restrictions (No_Elaboration_Code); 10 | 11 | with System; 12 | 13 | -- Testbench manager. Allows the programmer to know what platform their 14 | -- software is running on. 15 | package RP2040_SVD.TBMAN is 16 | pragma Preelaborate; 17 | 18 | --------------- 19 | -- Registers -- 20 | --------------- 21 | 22 | -- Indicates the type of platform in use 23 | type PLATFORM_Register is record 24 | -- Read-only. Indicates the platform is an ASIC 25 | ASIC : Boolean; 26 | -- Read-only. Indicates the platform is an FPGA 27 | FPGA : Boolean; 28 | -- unspecified 29 | Reserved_2_31 : RP2040_SVD.UInt30; 30 | end record 31 | with Volatile_Full_Access, Object_Size => 32, 32 | Bit_Order => System.Low_Order_First; 33 | 34 | for PLATFORM_Register use record 35 | ASIC at 0 range 0 .. 0; 36 | FPGA at 0 range 1 .. 1; 37 | Reserved_2_31 at 0 range 2 .. 31; 38 | end record; 39 | 40 | ----------------- 41 | -- Peripherals -- 42 | ----------------- 43 | 44 | -- Testbench manager. Allows the programmer to know what platform their 45 | -- software is running on. 46 | type TBMAN_Peripheral is record 47 | -- Indicates the type of platform in use 48 | PLATFORM : aliased PLATFORM_Register; 49 | end record 50 | with Volatile; 51 | 52 | for TBMAN_Peripheral use record 53 | PLATFORM at 0 range 0 .. 31; 54 | end record; 55 | 56 | -- Testbench manager. Allows the programmer to know what platform their 57 | -- software is running on. 58 | TBMAN_Periph : aliased TBMAN_Peripheral 59 | with Import, Address => TBMAN_Base; 60 | 61 | end RP2040_SVD.TBMAN; 62 | -------------------------------------------------------------------------------- /blog/01-zfp-blink/src/systick.adb: -------------------------------------------------------------------------------- 1 | with RP2040_SVD.PPB; use RP2040_SVD.PPB; 2 | --with RP2040_SVD; use RP2040_SVD; 3 | with System.Machine_Code; 4 | 5 | package body SysTick is 6 | procedure SysTick_Handler is 7 | begin 8 | Ticks := Ticks + 1; 9 | end SysTick_Handler; 10 | 11 | procedure Enable is 12 | begin 13 | -- reload every 1ms 14 | PPB_Periph.SYST_RVR.RELOAD := SYST_RVR_RELOAD_Field (12_000_000 / 1_000); 15 | 16 | PPB_Periph.SYST_CSR := 17 | (CLKSOURCE => True, -- cpu clock 18 | TICKINT => True, 19 | ENABLE => True, 20 | others => <>); 21 | end Enable; 22 | 23 | procedure Wait is 24 | begin 25 | System.Machine_Code.Asm ("wfi", Volatile => True); 26 | end Wait; 27 | end SysTick; 28 | -------------------------------------------------------------------------------- /blog/01-zfp-blink/src/systick.ads: -------------------------------------------------------------------------------- 1 | package SysTick is 2 | 3 | Ticks : Natural := 0; 4 | 5 | procedure Enable; 6 | procedure Wait; 7 | 8 | private 9 | 10 | procedure SysTick_Handler 11 | with Export => True, 12 | Convention => C, 13 | External_Name => "isr_systick"; 14 | 15 | end SysTick; 16 | -------------------------------------------------------------------------------- /blog/02-ravenscar-blink/rpsimple.gpr: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | project RPSimple is 7 | for Target use "arm-eabi"; 8 | for Runtime ("Ada") use Project'Project_Dir & "../bb-runtimes/install/ravenscar-full-rpi-pico-mp"; 9 | 10 | for Languages use ("Ada"); 11 | for Source_Dirs use ("src"); 12 | for Object_Dir use "obj"; 13 | for Create_Missing_Dirs use "true"; 14 | for Main use ("main.adb"); 15 | 16 | package Compiler is 17 | for Switches ("Ada") use 18 | ("-g", "-Og"); 19 | end Compiler; 20 | 21 | end RPSimple; 22 | -------------------------------------------------------------------------------- /blog/02-ravenscar-blink/src/main.adb: -------------------------------------------------------------------------------- 1 | with RP2040_SVD.RESETS; use RP2040_SVD.RESETS; 2 | with RP2040_SVD.IO_BANK0; use RP2040_SVD.IO_BANK0; 3 | with RP2040_SVD.PADS_BANK0; use RP2040_SVD.PADS_BANK0; 4 | with RP2040_SVD.SIO; use RP2040_SVD.SIO; 5 | with RP2040_SVD.PPB; use RP2040_SVD.PPB; 6 | 7 | procedure Main is 8 | Pin_Mask : constant GPIO_OUT_GPIO_OUT_Field := 16#0200_0000#; 9 | begin 10 | RESETS_Periph.RESET.io_bank0 := False; 11 | RESETS_Periph.RESET.pads_bank0 := False; 12 | while not RESETS_Periph.RESET_DONE.io_bank0 or else 13 | not RESETS_Periph.RESET_DONE.pads_bank0 loop 14 | null; 15 | end loop; 16 | 17 | -- output disable off 18 | PADS_BANK0_Periph.GPIO25.OD := False; 19 | -- input enable off 20 | PADS_BANK0_Periph.GPIO25.IE := False; 21 | 22 | -- function select 23 | IO_BANK0_Periph.GPIO25_CTRL.FUNCSEL := sio_25; 24 | 25 | -- output enable 26 | SIO_Periph.GPIO_OE_SET.GPIO_OE_SET := Pin_Mask; 27 | 28 | loop 29 | SIO_Periph.GPIO_OUT_XOR.GPIO_OUT_XOR := Pin_Mask; 30 | delay 1.0; 31 | end loop; 32 | end Main; 33 | -------------------------------------------------------------------------------- /blog/02-ravenscar-blink/src/rp2040_svd-interrupts.ads: -------------------------------------------------------------------------------- 1 | pragma Style_Checks (Off); 2 | 3 | -- Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 4 | -- 5 | -- SPDX-License-Identifier: BSD-3-Clause 6 | 7 | -- This spec has been automatically generated from rp2040.svd 8 | 9 | -- Definition of the device's interrupts 10 | package RP2040_SVD.Interrupts is 11 | 12 | ---------------- 13 | -- Interrupts -- 14 | ---------------- 15 | 16 | TIMER_IRQ_0_Interrupt : constant := 0; 17 | TIMER_IRQ_1_Interrupt : constant := 1; 18 | TIMER_IRQ_2_Interrupt : constant := 2; 19 | TIMER_IRQ_3_Interrupt : constant := 3; 20 | PWM_IRQ_WRAP_Interrupt : constant := 4; 21 | USBCTRL_Interrupt : constant := 5; 22 | XIP_Interrupt : constant := 6; 23 | PIO0_IRQ_0_Interrupt : constant := 7; 24 | PIO0_IRQ_1_Interrupt : constant := 8; 25 | PIO1_IRQ_0_Interrupt : constant := 9; 26 | PIO1_IRQ_1_Interrupt : constant := 10; 27 | DMA_IRQ_0_Interrupt : constant := 11; 28 | DMA_IRQ_1_Interrupt : constant := 12; 29 | IO_IRQ_BANK0_Interrupt : constant := 13; 30 | IO_IRQ_QSPI_Interrupt : constant := 14; 31 | SIO_IRQ_PROC0_Interrupt : constant := 15; 32 | SIO_IRQ_PROC1_Interrupt : constant := 16; 33 | CLOCKS_Interrupt : constant := 17; 34 | SPI0_Interrupt : constant := 18; 35 | SPI1_Interrupt : constant := 19; 36 | UART0_Interrupt : constant := 20; 37 | UART1_Interrupt : constant := 21; 38 | ADC_IRQ_FIFO_Interrupt : constant := 22; 39 | I2C0_Interrupt : constant := 23; 40 | I2C1_Interrupt : constant := 24; 41 | RTC_Interrupt : constant := 25; 42 | 43 | end RP2040_SVD.Interrupts; 44 | -------------------------------------------------------------------------------- /blog/02-ravenscar-blink/src/rp2040_svd-tbman.ads: -------------------------------------------------------------------------------- 1 | pragma Style_Checks (Off); 2 | 3 | -- Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 4 | -- 5 | -- SPDX-License-Identifier: BSD-3-Clause 6 | 7 | -- This spec has been automatically generated from rp2040.svd 8 | 9 | pragma Restrictions (No_Elaboration_Code); 10 | 11 | with System; 12 | 13 | -- Testbench manager. Allows the programmer to know what platform their 14 | -- software is running on. 15 | package RP2040_SVD.TBMAN is 16 | pragma Preelaborate; 17 | 18 | --------------- 19 | -- Registers -- 20 | --------------- 21 | 22 | -- Indicates the type of platform in use 23 | type PLATFORM_Register is record 24 | -- Read-only. Indicates the platform is an ASIC 25 | ASIC : Boolean; 26 | -- Read-only. Indicates the platform is an FPGA 27 | FPGA : Boolean; 28 | -- unspecified 29 | Reserved_2_31 : RP2040_SVD.UInt30; 30 | end record 31 | with Volatile_Full_Access, Object_Size => 32, 32 | Bit_Order => System.Low_Order_First; 33 | 34 | for PLATFORM_Register use record 35 | ASIC at 0 range 0 .. 0; 36 | FPGA at 0 range 1 .. 1; 37 | Reserved_2_31 at 0 range 2 .. 31; 38 | end record; 39 | 40 | ----------------- 41 | -- Peripherals -- 42 | ----------------- 43 | 44 | -- Testbench manager. Allows the programmer to know what platform their 45 | -- software is running on. 46 | type TBMAN_Peripheral is record 47 | -- Indicates the type of platform in use 48 | PLATFORM : aliased PLATFORM_Register; 49 | end record 50 | with Volatile; 51 | 52 | for TBMAN_Peripheral use record 53 | PLATFORM at 0 range 0 .. 31; 54 | end record; 55 | 56 | -- Testbench manager. Allows the programmer to know what platform their 57 | -- software is running on. 58 | TBMAN_Periph : aliased TBMAN_Peripheral 59 | with Import, Address => TBMAN_Base; 60 | 61 | end RP2040_SVD.TBMAN; 62 | -------------------------------------------------------------------------------- /blog/03-realtime-blink/rpsimple.gpr: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | project RPSimple is 7 | for Target use "arm-eabi"; 8 | for Runtime ("Ada") use Project'Project_Dir & "../bb-runtimes/install/ravenscar-full-rpi-pico-mp"; 9 | 10 | for Languages use ("Ada"); 11 | for Source_Dirs use ("src"); 12 | for Object_Dir use "obj"; 13 | for Create_Missing_Dirs use "true"; 14 | for Main use ("main.adb"); 15 | 16 | package Compiler is 17 | for Switches ("Ada") use 18 | ("-g", "-Og"); 19 | end Compiler; 20 | 21 | end RPSimple; 22 | -------------------------------------------------------------------------------- /blog/03-realtime-blink/src/main.adb: -------------------------------------------------------------------------------- 1 | with RP2040_SVD.RESETS; use RP2040_SVD.RESETS; 2 | with RP2040_SVD.IO_BANK0; use RP2040_SVD.IO_BANK0; 3 | with RP2040_SVD.PADS_BANK0; use RP2040_SVD.PADS_BANK0; 4 | with RP2040_SVD.SIO; use RP2040_SVD.SIO; 5 | with RP2040_SVD.PPB; use RP2040_SVD.PPB; 6 | with Ada.Real_Time; use Ada.Real_Time; 7 | 8 | procedure Main is 9 | Pin_Mask : constant GPIO_OUT_GPIO_OUT_Field := 16#0200_0000#; 10 | Next_Blink : Time := Clock; 11 | begin 12 | RESETS_Periph.RESET.io_bank0 := False; 13 | RESETS_Periph.RESET.pads_bank0 := False; 14 | while not RESETS_Periph.RESET_DONE.io_bank0 or else 15 | not RESETS_Periph.RESET_DONE.pads_bank0 loop 16 | null; 17 | end loop; 18 | 19 | -- output disable off 20 | PADS_BANK0_Periph.GPIO25.OD := False; 21 | -- input enable off 22 | PADS_BANK0_Periph.GPIO25.IE := False; 23 | 24 | -- function select 25 | IO_BANK0_Periph.GPIO25_CTRL.FUNCSEL := sio_25; 26 | 27 | -- output enable 28 | SIO_Periph.GPIO_OE_SET.GPIO_OE_SET := Pin_Mask; 29 | 30 | loop 31 | SIO_Periph.GPIO_OUT_XOR.GPIO_OUT_XOR := Pin_Mask; 32 | delay until Next_Blink; 33 | Next_Blink := Next_Blink + Seconds (1); 34 | end loop; 35 | end Main; 36 | -------------------------------------------------------------------------------- /blog/03-realtime-blink/src/rp2040_svd-interrupts.ads: -------------------------------------------------------------------------------- 1 | pragma Style_Checks (Off); 2 | 3 | -- Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 4 | -- 5 | -- SPDX-License-Identifier: BSD-3-Clause 6 | 7 | -- This spec has been automatically generated from rp2040.svd 8 | 9 | -- Definition of the device's interrupts 10 | package RP2040_SVD.Interrupts is 11 | 12 | ---------------- 13 | -- Interrupts -- 14 | ---------------- 15 | 16 | TIMER_IRQ_0_Interrupt : constant := 0; 17 | TIMER_IRQ_1_Interrupt : constant := 1; 18 | TIMER_IRQ_2_Interrupt : constant := 2; 19 | TIMER_IRQ_3_Interrupt : constant := 3; 20 | PWM_IRQ_WRAP_Interrupt : constant := 4; 21 | USBCTRL_Interrupt : constant := 5; 22 | XIP_Interrupt : constant := 6; 23 | PIO0_IRQ_0_Interrupt : constant := 7; 24 | PIO0_IRQ_1_Interrupt : constant := 8; 25 | PIO1_IRQ_0_Interrupt : constant := 9; 26 | PIO1_IRQ_1_Interrupt : constant := 10; 27 | DMA_IRQ_0_Interrupt : constant := 11; 28 | DMA_IRQ_1_Interrupt : constant := 12; 29 | IO_IRQ_BANK0_Interrupt : constant := 13; 30 | IO_IRQ_QSPI_Interrupt : constant := 14; 31 | SIO_IRQ_PROC0_Interrupt : constant := 15; 32 | SIO_IRQ_PROC1_Interrupt : constant := 16; 33 | CLOCKS_Interrupt : constant := 17; 34 | SPI0_Interrupt : constant := 18; 35 | SPI1_Interrupt : constant := 19; 36 | UART0_Interrupt : constant := 20; 37 | UART1_Interrupt : constant := 21; 38 | ADC_IRQ_FIFO_Interrupt : constant := 22; 39 | I2C0_Interrupt : constant := 23; 40 | I2C1_Interrupt : constant := 24; 41 | RTC_Interrupt : constant := 25; 42 | 43 | end RP2040_SVD.Interrupts; 44 | -------------------------------------------------------------------------------- /blog/03-realtime-blink/src/rp2040_svd-tbman.ads: -------------------------------------------------------------------------------- 1 | pragma Style_Checks (Off); 2 | 3 | -- Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 4 | -- 5 | -- SPDX-License-Identifier: BSD-3-Clause 6 | 7 | -- This spec has been automatically generated from rp2040.svd 8 | 9 | pragma Restrictions (No_Elaboration_Code); 10 | 11 | with System; 12 | 13 | -- Testbench manager. Allows the programmer to know what platform their 14 | -- software is running on. 15 | package RP2040_SVD.TBMAN is 16 | pragma Preelaborate; 17 | 18 | --------------- 19 | -- Registers -- 20 | --------------- 21 | 22 | -- Indicates the type of platform in use 23 | type PLATFORM_Register is record 24 | -- Read-only. Indicates the platform is an ASIC 25 | ASIC : Boolean; 26 | -- Read-only. Indicates the platform is an FPGA 27 | FPGA : Boolean; 28 | -- unspecified 29 | Reserved_2_31 : RP2040_SVD.UInt30; 30 | end record 31 | with Volatile_Full_Access, Object_Size => 32, 32 | Bit_Order => System.Low_Order_First; 33 | 34 | for PLATFORM_Register use record 35 | ASIC at 0 range 0 .. 0; 36 | FPGA at 0 range 1 .. 1; 37 | Reserved_2_31 at 0 range 2 .. 31; 38 | end record; 39 | 40 | ----------------- 41 | -- Peripherals -- 42 | ----------------- 43 | 44 | -- Testbench manager. Allows the programmer to know what platform their 45 | -- software is running on. 46 | type TBMAN_Peripheral is record 47 | -- Indicates the type of platform in use 48 | PLATFORM : aliased PLATFORM_Register; 49 | end record 50 | with Volatile; 51 | 52 | for TBMAN_Peripheral use record 53 | PLATFORM at 0 range 0 .. 31; 54 | end record; 55 | 56 | -- Testbench manager. Allows the programmer to know what platform their 57 | -- software is running on. 58 | TBMAN_Periph : aliased TBMAN_Peripheral 59 | with Import, Address => TBMAN_Base; 60 | 61 | end RP2040_SVD.TBMAN; 62 | -------------------------------------------------------------------------------- /blog/04-hal-blink/.gitignore: -------------------------------------------------------------------------------- 1 | obj/ 2 | lib/ 3 | alire/ 4 | -------------------------------------------------------------------------------- /blog/04-hal-blink/alire.toml: -------------------------------------------------------------------------------- 1 | name = "rpsimple" 2 | description = "Shiny new project" 3 | version = "0.0.0" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | 9 | executables = ["rpsimple"] 10 | 11 | [[depends-on]] # This line was added by `alr with` 12 | rp2040_hal = "~0.2.1" # This line was added by `alr with` 13 | -------------------------------------------------------------------------------- /blog/04-hal-blink/rpsimple.gpr: -------------------------------------------------------------------------------- 1 | -- begin auto-gpr-with -- 2 | -- This section was automatically added by Alire 3 | with "hal.gpr"; 4 | with "rp2040_hal.gpr"; 5 | -- end auto-gpr-with -- 6 | -- 7 | -- Copyright 2021 (C) Jeremy Grosser 8 | -- 9 | -- SPDX-License-Identifier: BSD-3-Clause 10 | -- 11 | project RPSimple is 12 | for Target use "arm-eabi"; 13 | for Runtime ("Ada") use Project'Project_Dir & "../bb-runtimes/install/ravenscar-full-rpi-pico-mp"; 14 | 15 | for Languages use ("Ada"); 16 | for Source_Dirs use ("src"); 17 | for Object_Dir use "obj"; 18 | for Create_Missing_Dirs use "true"; 19 | for Main use ("main.adb"); 20 | 21 | package Compiler is 22 | for Switches ("Ada") use 23 | ("-g", "-Og"); 24 | end Compiler; 25 | 26 | end RPSimple; 27 | -------------------------------------------------------------------------------- /blog/04-hal-blink/src/main.adb: -------------------------------------------------------------------------------- 1 | with Ada.Real_Time; use Ada.Real_Time; 2 | with RP.GPIO; use RP.GPIO; 3 | 4 | procedure Main is 5 | LED : GPIO_Point := (Pin => 25); 6 | Next_Blink : Time := Clock; 7 | begin 8 | LED.Configure (Output); 9 | loop 10 | LED.Toggle; 11 | delay until Next_Blink; 12 | Next_Blink := Next_Blink + Seconds (1); 13 | end loop; 14 | end Main; 15 | -------------------------------------------------------------------------------- /blog/README.md: -------------------------------------------------------------------------------- 1 | Examples here relate to these blog posts: 2 | 3 | - https://synack.me/ada/pico/2021/03/03/from-zero-to-blinky-ada.html 4 | - https://synack.me/ada/pico/2021/03/03/abstractions-and-runtimes.html 5 | - https://synack.me/ada/pico/2021/03/03/using-drivers.html 6 | -------------------------------------------------------------------------------- /clock_output/clock_output.gpr: -------------------------------------------------------------------------------- 1 | with "pico_bsp.gpr"; 2 | 3 | project Clock_Output is 4 | 5 | for Runtime ("Ada") use "light-cortex-m0p"; 6 | for Target use "arm-eabi"; 7 | for Main use ("main.adb"); 8 | for Languages use ("Ada"); 9 | for Source_Dirs use ("src"); 10 | for Object_Dir use "obj"; 11 | for Create_Missing_Dirs use "True"; 12 | 13 | package Linker is 14 | for Default_Switches ("Ada") use 15 | Pico_BSP.Linker_Switches; 16 | end Linker; 17 | 18 | end Clock_Output; 19 | -------------------------------------------------------------------------------- /clock_output/src/main.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2022 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | -- This example outputs a 10 MHz clock driven by clk_sys on GPOUT0 (Pico.GP21) 7 | -- 8 | with RP.Clock; use RP.Clock; 9 | with RP.GPIO; use RP.GPIO; 10 | with Pico; 11 | 12 | procedure Main is 13 | begin 14 | RP.Clock.Initialize (Pico.XOSC_Frequency); 15 | Pico.LED.Configure (Output); 16 | Pico.LED.Set; 17 | 18 | Pico.GP21.Configure (Output, Pull_Up, RP.GPIO.CLOCK, Slew_Fast => True); 19 | RP.Clock.Set_Source (GPOUT0, SYS); 20 | RP.Clock.Set_Divider (GPOUT0, 12.5); 21 | RP.Clock.Enable (GPOUT0); 22 | 23 | loop 24 | null; 25 | end loop; 26 | end Main; 27 | -------------------------------------------------------------------------------- /feather_rp2040_blink/.gitignore: -------------------------------------------------------------------------------- 1 | obj/ 2 | lib/ 3 | alire/ 4 | config/ 5 | -------------------------------------------------------------------------------- /feather_rp2040_blink/alire.toml: -------------------------------------------------------------------------------- 1 | name = "feather_rp2040_blink" 2 | description = "Blink example with a custom BSP" 3 | version = "0.7.0" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | 9 | executables = ["feather_rp2040_blink"] 10 | 11 | [[depends-on]] 12 | feather_rp2040_bsp = "^1" 13 | 14 | [[pins]] 15 | feather_rp2040_bsp = { path='../feather_rp2040_bsp' } 16 | [[pins]] # Added by alr 17 | rp2040_hal = { url='https://github.com/JeremyGrosser/rp2040_hal' } # Added by alr 18 | -------------------------------------------------------------------------------- /feather_rp2040_blink/src/main.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with Feather_RP2040; use Feather_RP2040; 7 | with HAL; use HAL; 8 | with RP.Device; 9 | with RP.Clock; 10 | with RP.GPIO; 11 | with RP.DMA; 12 | 13 | procedure Main is 14 | H : UInt8 := UInt8'Last; 15 | S : constant UInt8 := UInt8'Last; 16 | V : constant UInt8 := 10; 17 | begin 18 | RP.Clock.Initialize (XOSC_Frequency, XOSC_Startup_Delay); 19 | LED.Configure (RP.GPIO.Output); 20 | 21 | RP.DMA.Enable; 22 | Neopixel.PIO.Enable; 23 | 24 | Neopixel.Initialize; 25 | Neopixel.Enable_DMA (0); 26 | 27 | RP.Device.Timer.Enable; 28 | loop 29 | LED.Toggle; 30 | H := H + 1; 31 | Neopixel.Set_HSV (1, H, S, V); 32 | Neopixel.Update; 33 | RP.Device.Timer.Delay_Milliseconds (5); 34 | end loop; 35 | end Main; 36 | -------------------------------------------------------------------------------- /feather_rp2040_bsp/.gitignore: -------------------------------------------------------------------------------- 1 | obj/ 2 | lib/ 3 | alire/ 4 | config/ 5 | -------------------------------------------------------------------------------- /feather_rp2040_bsp/alire.toml: -------------------------------------------------------------------------------- 1 | name = "feather_rp2040_bsp" 2 | description = "Board support package for the Adafruit Feather RP2040" 3 | version = "0.7.0" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | tags = ["embedded", "nostd", "adafruit", "feather", "rp2040", "bsp"] 9 | 10 | [[depends-on]] 11 | rp2040_hal = "~0.7.0" 12 | 13 | [configuration.values] 14 | rp2040_hal.Flash_Chip = "generic_qspi" 15 | -------------------------------------------------------------------------------- /gpio_interrupts/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /gpio_interrupts/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_gpio_interrupts": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/gpio_interrupts", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /gpio_interrupts/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /gpio_interrupts/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/gpio_interrupts", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /gpio_interrupts/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /gpio_interrupts/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /gpio_interrupts/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/gpio_interrupts.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/gpio_interrupts.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/gpio_interrupts 10 | 11 | bin/gpio_interrupts.uf2: bin/gpio_interrupts 12 | picotool uf2 convert bin/gpio_interrupts -t elf bin/gpio_interrupts.uf2 13 | 14 | bin/gpio_interrupts: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /gpio_interrupts/alire.toml: -------------------------------------------------------------------------------- 1 | name = "gpio_interrupts" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["gpio_interrupts"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /gpio_interrupts/gpio_interrupts.gpr: -------------------------------------------------------------------------------- 1 | with "config/gpio_interrupts_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project gpio_interrupts is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & gpio_interrupts_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("gpio_interrupts.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use gpio_interrupts_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end gpio_interrupts; 32 | -------------------------------------------------------------------------------- /gpio_interrupts/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /gpio_interrupts/src/gpio_interrupts.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with RP.GPIO; use RP.GPIO; 7 | with RP.GPIO.Interrupts; 8 | with RP.Clock; 9 | with Pico; 10 | 11 | with Handlers; 12 | 13 | procedure Gpio_interrupts is 14 | begin 15 | RP.Clock.Initialize (Pico.XOSC_Frequency); 16 | RP.GPIO.Enable; 17 | 18 | -- GP9 is connected to a normally open button that connects to GND when pressed 19 | -- debouncing is an exercise left to the reader 20 | Pico.GP9.Configure (Input, Pull_Up); 21 | 22 | RP.GPIO.Interrupts.Attach_Handler (Pico.GP9, Handlers.Toggle_LED'Access); 23 | Pico.GP9.Enable_Interrupt (Falling_Edge); 24 | 25 | Pico.LED.Configure (Output); 26 | Pico.LED.Set; 27 | 28 | loop 29 | null; 30 | end loop; 31 | end Gpio_interrupts; 32 | -------------------------------------------------------------------------------- /gpio_interrupts/src/handlers.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with Pico; 7 | 8 | package body Handlers is 9 | procedure Toggle_LED 10 | (Pin : GPIO_Pin; 11 | Trigger : Interrupt_Triggers) 12 | is 13 | pragma Unreferenced (Pin); 14 | pragma Unreferenced (Trigger); 15 | begin 16 | Pico.LED.Toggle; 17 | end Toggle_LED; 18 | end Handlers; 19 | -------------------------------------------------------------------------------- /gpio_interrupts/src/handlers.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with RP.GPIO; use RP.GPIO; 7 | 8 | package Handlers is 9 | procedure Toggle_LED 10 | (Pin : GPIO_Pin; 11 | Trigger : Interrupt_Triggers); 12 | end Handlers; 13 | -------------------------------------------------------------------------------- /i2c_demo/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /i2c_demo/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_i2c_demo": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/i2c_demo", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /i2c_demo/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /i2c_demo/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/i2c_demo", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /i2c_demo/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /i2c_demo/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile Project", 6 | "type": "process", 7 | "isBuildCommand": true, 8 | "command": "alr", 9 | "args": ["build"], 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "always", 13 | "panel": "dedicated" 14 | }, 15 | "problemMatcher": "$gcc", 16 | "windows": { 17 | "command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe" 18 | } 19 | }, 20 | { 21 | "label": "Run Project", 22 | "type": "process", 23 | "command": "${env:HOME}/.pico-sdk/picotool/2.1.1/picotool/picotool", 24 | "args": [ 25 | "load", 26 | "${command:raspberry-pi-pico.launchTargetPath}", 27 | "-fx" 28 | ], 29 | "presentation": { 30 | "reveal": "always", 31 | "panel": "dedicated" 32 | }, 33 | "problemMatcher": [], 34 | "windows": { 35 | "command": "${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool/picotool.exe" 36 | } 37 | }, 38 | { 39 | "label": "Flash", 40 | "type": "process", 41 | "command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe", 42 | "args": [ 43 | "-s", 44 | "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts", 45 | "-f", 46 | "raspberrypi-swd.cfg", 47 | "-f", 48 | "target/${command:raspberry-pi-pico.getTarget}.cfg", 49 | "-c", 50 | "adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit" 51 | ], 52 | "problemMatcher": [], 53 | "windows": { 54 | "command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe" 55 | } 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /i2c_demo/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /i2c_demo/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/i2c_demo.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/i2c_demo.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/i2c_demo 10 | 11 | bin/i2c_demo.uf2: bin/i2c_demo 12 | picotool uf2 convert bin/i2c_demo -t elf bin/i2c_demo.uf2 13 | 14 | bin/i2c_demo: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /i2c_demo/alire.toml: -------------------------------------------------------------------------------- 1 | name = "i2c_demo" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["i2c_demo"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /i2c_demo/i2c_demo.gpr: -------------------------------------------------------------------------------- 1 | with "config/i2c_demo_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project i2c_demo is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & i2c_demo_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("i2c_demo.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use i2c_demo_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end i2c_demo; 32 | -------------------------------------------------------------------------------- /i2c_demo/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /i2c_demo/src/i2c_demo.adb: -------------------------------------------------------------------------------- 1 | with RP.GPIO; use RP.GPIO; 2 | with RP.Clock; 3 | with RP.Device; 4 | with RP.Timer; 5 | 6 | with RP.I2C_Master; 7 | with HAL; use HAL; 8 | with HAL.I2C; use HAL.I2C; 9 | 10 | with Ada.Text_IO; use Ada.Text_IO; 11 | 12 | procedure I2C_Demo is 13 | SDA : GPIO_Point := (Pin => 0); 14 | SCL : GPIO_Point := (Pin => 1); 15 | 16 | Addr_HAL : constant HAL.I2C.I2C_Address := 2#11101100#; 17 | 18 | REG_CHIP_ID : constant UInt8 := 16#D0#; 19 | 20 | -- Read the chip ID register from a BME280/BMP280 21 | procedure Read_Id_HAL is 22 | Port : RP.I2C_Master.I2C_Master_Port renames RP.Device.I2CM_0; 23 | Data : I2C_Data (1 .. 1); 24 | Status : HAL.I2C.I2C_Status; 25 | begin 26 | Port.Configure 27 | (Baudrate => 100_000, 28 | Address_Size => RP.I2C_Master.Address_Size_7b); 29 | Port.Mem_Read 30 | (Addr => Addr_HAL, 31 | Mem_Addr => UInt16 (REG_CHIP_ID), 32 | Mem_Addr_Size => Memory_Size_8b, 33 | Data => Data, 34 | Status => Status, 35 | Timeout => 1000); 36 | if Status /= HAL.I2C.Ok then 37 | Put_Line ("Read chip id error (HAL)"); 38 | return; 39 | end if; 40 | Put ("RP.I2C_Master:"); 41 | Put (Data (1)'Image); 42 | New_Line; 43 | end Read_Id_HAL; 44 | begin 45 | RP.Clock.Initialize (12_000_000); 46 | SDA.Configure (Output, Pull_Up, RP.GPIO.I2C, Schmitt => True); 47 | SCL.Configure (Output, Pull_Up, RP.GPIO.I2C, Schmitt => True); 48 | 49 | RP.Device.Timer.Enable; 50 | loop 51 | Read_Id_HAL; 52 | RP.Device.Timer.Delay_Milliseconds (100); 53 | end loop; 54 | end I2C_Demo; 55 | -------------------------------------------------------------------------------- /i2c_target/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /i2c_target/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_i2c_target": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/i2c_target", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /i2c_target/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /i2c_target/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/i2c_target", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /i2c_target/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /i2c_target/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile Project", 6 | "type": "process", 7 | "isBuildCommand": true, 8 | "command": "alr", 9 | "args": ["build"], 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "always", 13 | "panel": "dedicated" 14 | }, 15 | "problemMatcher": "$gcc", 16 | "windows": { 17 | "command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe" 18 | } 19 | }, 20 | { 21 | "label": "Run Project", 22 | "type": "process", 23 | "command": "${env:HOME}/.pico-sdk/picotool/2.1.1/picotool/picotool", 24 | "args": [ 25 | "load", 26 | "${command:raspberry-pi-pico.launchTargetPath}", 27 | "-fx" 28 | ], 29 | "presentation": { 30 | "reveal": "always", 31 | "panel": "dedicated" 32 | }, 33 | "problemMatcher": [], 34 | "windows": { 35 | "command": "${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool/picotool.exe" 36 | } 37 | }, 38 | { 39 | "label": "Flash", 40 | "type": "process", 41 | "command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe", 42 | "args": [ 43 | "-s", 44 | "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts", 45 | "-f", 46 | "raspberrypi-swd.cfg", 47 | "-f", 48 | "target/${command:raspberry-pi-pico.getTarget}.cfg", 49 | "-c", 50 | "adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit" 51 | ], 52 | "problemMatcher": [], 53 | "windows": { 54 | "command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe" 55 | } 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /i2c_target/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /i2c_target/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/i2c_target.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/i2c_target.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/i2c_target 10 | 11 | bin/i2c_target.uf2: bin/i2c_target 12 | picotool uf2 convert bin/i2c_target -t elf bin/i2c_target.uf2 13 | 14 | bin/i2c_target: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /i2c_target/alire.toml: -------------------------------------------------------------------------------- 1 | name = "i2c_target" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["i2c_target"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /i2c_target/i2c_target.gpr: -------------------------------------------------------------------------------- 1 | with "config/i2c_target_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project i2c_target is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & i2c_target_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("i2c_target.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use i2c_target_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end i2c_target; 32 | -------------------------------------------------------------------------------- /i2c_target/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /i2c_target/src/i2c_target.adb: -------------------------------------------------------------------------------- 1 | with HAL; 2 | with RP.GPIO; use RP.GPIO; 3 | with RP.Device; 4 | with RP.Clock; 5 | with RP.I2C; 6 | with Pico; 7 | 8 | procedure I2C_Target is 9 | XOSC_Frequency : constant := 12_000_000; 10 | SDA : GPIO_Point renames Pico.GP0; 11 | SCL : GPIO_Point renames Pico.GP1; 12 | Port : RP.I2C.I2C_Port renames RP.Device.I2C_0; 13 | Addr : constant HAL.UInt7 := 2#1110110#; 14 | 15 | subtype Sensor_Id is HAL.UInt8 range 1 .. 4; 16 | Data : array (Sensor_Id) of HAL.UInt8; 17 | Request : HAL.UInt8; 18 | 19 | use type RP.I2C.I2C_Status; 20 | Status : RP.I2C.I2C_Status; 21 | begin 22 | RP.Clock.Initialize (XOSC_Frequency); 23 | SDA.Configure (Output, Pull_Up, RP.GPIO.I2C, Schmitt => True); 24 | SCL.Configure (Output, Pull_Up, RP.GPIO.I2C, Schmitt => True); 25 | 26 | Port.Configure ((Role => RP.I2C.Target, others => <>)); 27 | Port.Set_Address (Addr); 28 | Port.Enable; 29 | 30 | loop 31 | Port.Start_Read (Length => 1); 32 | if Port.Read_Ready then 33 | Port.Read (Request, Status); 34 | if Status = RP.I2C.Ok and then Request in Sensor_Id'Range then 35 | Port.Start_Write (Length => 1); 36 | Port.Write (Data (Request), Status); 37 | end if; 38 | end if; 39 | end loop; 40 | end I2C_Target; 41 | -------------------------------------------------------------------------------- /multicore/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /multicore/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_multicore": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/multicore", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /multicore/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /multicore/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/multicore", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /multicore/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /multicore/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile Project", 6 | "type": "process", 7 | "isBuildCommand": true, 8 | "command": "alr", 9 | "args": ["build"], 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "always", 13 | "panel": "dedicated" 14 | }, 15 | "problemMatcher": "$gcc", 16 | "windows": { 17 | "command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe" 18 | } 19 | }, 20 | { 21 | "label": "Run Project", 22 | "type": "process", 23 | "command": "${env:HOME}/.pico-sdk/picotool/2.1.1/picotool/picotool", 24 | "args": [ 25 | "load", 26 | "${command:raspberry-pi-pico.launchTargetPath}", 27 | "-fx" 28 | ], 29 | "presentation": { 30 | "reveal": "always", 31 | "panel": "dedicated" 32 | }, 33 | "problemMatcher": [], 34 | "windows": { 35 | "command": "${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool/picotool.exe" 36 | } 37 | }, 38 | { 39 | "label": "Flash", 40 | "type": "process", 41 | "command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe", 42 | "args": [ 43 | "-s", 44 | "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts", 45 | "-f", 46 | "raspberrypi-swd.cfg", 47 | "-f", 48 | "target/${command:raspberry-pi-pico.getTarget}.cfg", 49 | "-c", 50 | "adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit" 51 | ], 52 | "problemMatcher": [], 53 | "windows": { 54 | "command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe" 55 | } 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /multicore/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /multicore/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/multicore.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/multicore.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/multicore 10 | 11 | bin/multicore.uf2: bin/multicore 12 | picotool uf2 convert bin/multicore -t elf bin/multicore.uf2 13 | 14 | bin/multicore: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /multicore/alire.toml: -------------------------------------------------------------------------------- 1 | name = "multicore" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["multicore"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /multicore/multicore.gpr: -------------------------------------------------------------------------------- 1 | with "config/multicore_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project multicore is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & multicore_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("multicore.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use multicore_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end multicore; 32 | -------------------------------------------------------------------------------- /multicore/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /multicore/src/led_control.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2022 Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | package LED_Control is 7 | 8 | procedure Initialize; 9 | -- Initialize configures the clock and GPIO 10 | 11 | procedure Start; 12 | -- Start wakes up Core 1 and configures it to call Run_Core1 13 | 14 | private 15 | 16 | procedure Run_Core0; 17 | -- Run_Core0 pushes into the multicore FIFO once every second 18 | 19 | procedure Run_Core1; 20 | -- Run_Core1 blocks on reading from the FIFO, then toggles the LED 21 | 22 | end LED_Control; 23 | -------------------------------------------------------------------------------- /multicore/src/multicore.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2022 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with LED_Control; 7 | 8 | procedure Multicore is 9 | begin 10 | LED_Control.Initialize; 11 | LED_Control.Start; 12 | end Multicore; 13 | -------------------------------------------------------------------------------- /pimoroni_audio_pack/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /pimoroni_audio_pack/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_pimoroni_audio_pack": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/pimoroni_audio_pack", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /pimoroni_audio_pack/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /pimoroni_audio_pack/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/pimoroni_audio_pack", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /pimoroni_audio_pack/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /pimoroni_audio_pack/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /pimoroni_audio_pack/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/pimoroni_audio_pack.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/pimoroni_audio_pack.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/pimoroni_audio_pack 10 | 11 | bin/pimoroni_audio_pack.uf2: bin/pimoroni_audio_pack 12 | picotool uf2 convert bin/pimoroni_audio_pack -t elf bin/pimoroni_audio_pack.uf2 13 | 14 | bin/pimoroni_audio_pack: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /pimoroni_audio_pack/alire.toml: -------------------------------------------------------------------------------- 1 | name = "pimoroni_audio_pack" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["pimoroni_audio_pack"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /pimoroni_audio_pack/pimoroni_audio_pack.gpr: -------------------------------------------------------------------------------- 1 | with "config/pimoroni_audio_pack_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project pimoroni_audio_pack is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & pimoroni_audio_pack_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("pimoroni_audio_pack.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use pimoroni_audio_pack_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end pimoroni_audio_pack; 32 | -------------------------------------------------------------------------------- /pimoroni_audio_pack/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /pimoroni_audio_pack/src/pimoroni_audio_pack.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with RP.GPIO; use RP.GPIO; 7 | with RP.Clock; 8 | with Pico.Pimoroni.Audio_Pack; 9 | with RP.PIO.Audio_I2S; 10 | with Pico; 11 | 12 | with HAL.Audio; 13 | with Synth; 14 | 15 | procedure Pimoroni_audio_pack is 16 | Line_Out : RP.PIO.Audio_I2S.I2S_Device renames Pico.Pimoroni.Audio_Pack.I2S; 17 | Mute : RP.GPIO.GPIO_Point renames Pico.Pimoroni.Audio_Pack.MUTE; 18 | 19 | Buffer : HAL.Audio.Audio_Buffer (1 .. Line_Out.Buffer_Size); 20 | Sine : Synth.Oscillator (Channels => Line_Out.Channels); 21 | Frequency : Positive := 10; 22 | T : Natural := 0; 23 | begin 24 | RP.Clock.Initialize (Pico.XOSC_Frequency); 25 | RP.GPIO.Enable; 26 | 27 | Pico.LED.Configure (Output); 28 | Pico.LED.Clear; 29 | 30 | -- Mute is active-low 31 | Mute.Configure (Output, Pull_Both); 32 | Mute.Clear; 33 | 34 | Line_Out.Initialize 35 | (Frequency => HAL.Audio.Audio_Freq_44kHz, 36 | Channels => 2); 37 | 38 | -- Generate the sine wavetable 39 | Sine.Initialize (Amplitude => 0.5); 40 | 41 | Pico.LED.Set; 42 | Mute.Set; 43 | 44 | loop 45 | -- Every 1ms, increase the frequency by 100 Hz, keeping it in the range 10 - 2_000 Hz 46 | if T mod (Synth.Sample_Rate / 1_000) = 0 then 47 | Frequency := Frequency + 100; 48 | Sine.Set_Frequency (Frequency); 49 | if Frequency >= 2_000 then 50 | Frequency := 10; 51 | end if; 52 | end if; 53 | T := T + Buffer'Length; 54 | 55 | Sine.Receive (Buffer); 56 | Line_Out.Transmit (Buffer); 57 | end loop; 58 | end Pimoroni_audio_pack; 59 | -------------------------------------------------------------------------------- /pimoroni_audio_pack/src/synth.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with RP.ROM.Floating_Point; 7 | with Interfaces.C; 8 | with Interfaces; 9 | 10 | package body Synth is 11 | 12 | procedure Initialize 13 | (This : in out Oscillator; 14 | Amplitude : Float := 1.0) 15 | is 16 | -- Wrap fsin to convert to and from C_float 17 | function Sin (F : Float) return Float is 18 | (Float (RP.ROM.Floating_Point.fsin (F))); 19 | 20 | Pi : constant := 3.14159; -- probably enough digits 21 | W : constant := 2.0 * Pi; -- angular velocity 22 | Gain : Float; 23 | Period : Float; -- time per sample (seconds) 24 | F : Float; 25 | begin 26 | Gain := Float (Interfaces.Integer_16'Last) * Amplitude; 27 | Period := 1.0 / Float (This.Wave'Length); 28 | for T in This.Wave'Range loop 29 | -- F := Sin (2.0 * Pi * T * (1.0 / Sample_Rate)); 30 | F := Float (T); 31 | F := F * Period; 32 | F := F * W; 33 | F := Sin (F); 34 | F := F * Gain; 35 | This.Wave (T) := Interfaces.Integer_16 (F); 36 | end loop; 37 | end Initialize; 38 | 39 | procedure Set_Frequency 40 | (This : in out Oscillator; 41 | Frequency : Positive) 42 | is 43 | begin 44 | This.Frequency := Frequency; 45 | end Set_Frequency; 46 | 47 | procedure Receive 48 | (This : in out Oscillator; 49 | Buffer : out Audio_Buffer) 50 | is 51 | I : Integer := Buffer'First; 52 | begin 53 | while I < Buffer'Last loop 54 | for Channel in 1 .. This.Channels loop 55 | Buffer (I) := This.Wave (This.T); 56 | I := I + 1; 57 | end loop; 58 | 59 | This.T := (This.T + This.Frequency) mod This.Wave'Length; 60 | end loop; 61 | end Receive; 62 | 63 | end Synth; 64 | -------------------------------------------------------------------------------- /pimoroni_audio_pack/src/synth.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with HAL.Audio; use HAL.Audio; 7 | with Interfaces; 8 | 9 | package Synth is 10 | subtype Sample is Interfaces.Integer_16; 11 | 12 | -- This Sample_Rate is used to set the size of the wavetable buffer. If it 13 | -- were a variable we would need dynamic memory allocation, which we're 14 | -- trying to avoid. Curious things may happen if this doesn't match the 15 | -- output device's sample rate. 16 | Sample_Rate : constant := 44_100; 17 | 18 | type Oscillator 19 | (Channels : Positive) 20 | is tagged private; 21 | 22 | procedure Initialize 23 | (This : in out Oscillator; 24 | Amplitude : Float := 1.0); 25 | 26 | procedure Set_Frequency 27 | (This : in out Oscillator; 28 | Frequency : Positive); 29 | 30 | procedure Receive 31 | (This : in out Oscillator; 32 | Buffer : out Audio_Buffer); 33 | 34 | private 35 | 36 | type Oscillator 37 | (Channels : Positive) 38 | is tagged record 39 | Wave : HAL.Audio.Audio_Buffer (0 .. Sample_Rate); 40 | Frequency : Positive := 1; 41 | T : Natural := 0; 42 | end record; 43 | 44 | end Synth; 45 | -------------------------------------------------------------------------------- /pimoroni_rgb_keypad/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /pimoroni_rgb_keypad/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_pimoroni_rgb_keypad": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/pimoroni_rgb_keypad", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /pimoroni_rgb_keypad/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /pimoroni_rgb_keypad/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/pimoroni_rgb_keypad", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /pimoroni_rgb_keypad/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /pimoroni_rgb_keypad/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /pimoroni_rgb_keypad/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/pimoroni_rgb_keypad.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/pimoroni_rgb_keypad.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/pimoroni_rgb_keypad 10 | 11 | bin/pimoroni_rgb_keypad.uf2: bin/pimoroni_rgb_keypad 12 | picotool uf2 convert bin/pimoroni_rgb_keypad -t elf bin/pimoroni_rgb_keypad.uf2 13 | 14 | bin/pimoroni_rgb_keypad: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /pimoroni_rgb_keypad/alire.toml: -------------------------------------------------------------------------------- 1 | name = "pimoroni_rgb_keypad" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["pimoroni_rgb_keypad"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /pimoroni_rgb_keypad/pimoroni_rgb_keypad.gpr: -------------------------------------------------------------------------------- 1 | with "config/pimoroni_rgb_keypad_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project pimoroni_rgb_keypad is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & pimoroni_rgb_keypad_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("pimoroni_rgb_keypad.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use pimoroni_rgb_keypad_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end pimoroni_rgb_keypad; 32 | -------------------------------------------------------------------------------- /pimoroni_rgb_keypad/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /pimoroni_rgb_keypad/src/pimoroni_rgb_keypad.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with HAL; use HAL; 7 | with HAL.GPIO; use HAL.GPIO; 8 | with RP.GPIO; use RP.GPIO; 9 | with RP.Clock; 10 | with Pico; 11 | with Pico.Pimoroni.RGB_Keypad; 12 | 13 | procedure Pimoroni_rgb_keypad is 14 | Count : UInt8 := 0; 15 | begin 16 | RP.Clock.Initialize (Pico.XOSC_Frequency); 17 | RP.GPIO.Enable; 18 | 19 | Pico.Pimoroni.RGB_Keypad.Initialize; 20 | 21 | Pico.LED.Configure (Output); 22 | Pico.LED.Set; 23 | 24 | for P in Pico.Pimoroni.RGB_Keypad.Pad loop 25 | Pico.Pimoroni.RGB_Keypad.Set (P, 0, 0, 0, 0); 26 | end loop; 27 | Pico.Pimoroni.RGB_Keypad.Update; 28 | 29 | loop 30 | for P in Pico.Pimoroni.RGB_Keypad.Pad loop 31 | 32 | if Pico.Pimoroni.RGB_Keypad.Pressed (P) then 33 | Pico.Pimoroni.RGB_Keypad.Set_HSV 34 | (P, 35 | H => Count, 36 | S => 255, 37 | V => 50, 38 | Brightness => 5); 39 | end if; 40 | Count := Count + 1; 41 | end loop; 42 | Pico.Pimoroni.RGB_Keypad.Update; 43 | Pico.LED.Toggle; 44 | end loop; 45 | end Pimoroni_rgb_keypad; 46 | -------------------------------------------------------------------------------- /pio_assemble/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /pio_assemble/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_pio_assemble": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/pio_assemble", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /pio_assemble/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /pio_assemble/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/pio_assemble", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /pio_assemble/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /pio_assemble/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile Project", 6 | "type": "process", 7 | "isBuildCommand": true, 8 | "command": "alr", 9 | "args": ["build"], 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "always", 13 | "panel": "dedicated" 14 | }, 15 | "problemMatcher": "$gcc", 16 | "windows": { 17 | "command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe" 18 | } 19 | }, 20 | { 21 | "label": "Run Project", 22 | "type": "process", 23 | "command": "${env:HOME}/.pico-sdk/picotool/2.1.1/picotool/picotool", 24 | "args": [ 25 | "load", 26 | "${command:raspberry-pi-pico.launchTargetPath}", 27 | "-fx" 28 | ], 29 | "presentation": { 30 | "reveal": "always", 31 | "panel": "dedicated" 32 | }, 33 | "problemMatcher": [], 34 | "windows": { 35 | "command": "${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool/picotool.exe" 36 | } 37 | }, 38 | { 39 | "label": "Flash", 40 | "type": "process", 41 | "command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe", 42 | "args": [ 43 | "-s", 44 | "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts", 45 | "-f", 46 | "raspberrypi-swd.cfg", 47 | "-f", 48 | "target/${command:raspberry-pi-pico.getTarget}.cfg", 49 | "-c", 50 | "adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit" 51 | ], 52 | "problemMatcher": [], 53 | "windows": { 54 | "command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe" 55 | } 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /pio_assemble/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /pio_assemble/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/pio_assemble.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/pio_assemble.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/pio_assemble 10 | 11 | bin/pio_assemble.uf2: bin/pio_assemble 12 | picotool uf2 convert bin/pio_assemble -t elf bin/pio_assemble.uf2 13 | 14 | bin/pio_assemble: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /pio_assemble/alire.toml: -------------------------------------------------------------------------------- 1 | name = "pio_assemble" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["pio_assemble"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /pio_assemble/pio_assemble.gpr: -------------------------------------------------------------------------------- 1 | with "config/pio_assemble_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project pio_assemble is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & pio_assemble_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("pio_assemble.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use pio_assemble_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end pio_assemble; 32 | -------------------------------------------------------------------------------- /pio_assemble/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /pio_assemble/src/pio_assemble.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2022 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with RP.PIO.Encoding; use RP.PIO.Encoding; 7 | with RP.PIO; use RP.PIO; 8 | with RP.Device; 9 | with RP.Clock; 10 | with RP.GPIO; 11 | with Pico; 12 | 13 | procedure Pio_assemble is 14 | Blink_Program : constant RP.PIO.Program := 15 | (Encode (PULL' (Block => True, others => <>)), 16 | Encode (SHIFT_OUT' (Destination => PINS, Bit_Count => 1, others => <>))); 17 | Program_Offset : constant PIO_Address := 0; 18 | SM : constant PIO_SM := 0; 19 | Config : PIO_SM_Config := Default_SM_Config; 20 | P : PIO_Device renames RP.Device.PIO_0; 21 | begin 22 | RP.Clock.Initialize (Pico.XOSC_Frequency); 23 | Pico.LED.Configure (RP.GPIO.Output, RP.GPIO.Floating, P.GPIO_Function); 24 | 25 | P.Enable; 26 | P.Load (Blink_Program, Program_Offset); 27 | 28 | Set_Out_Pins (Config, Pico.LED.Pin, 1); 29 | Set_Set_Pins (Config, Pico.LED.Pin, 1); 30 | Set_Wrap (Config, 31 | Wrap_Target => Program_Offset, 32 | Wrap => Program_Offset + Blink_Program'Length); 33 | Set_Clock_Frequency (Config, 50_000_000); 34 | 35 | P.SM_Initialize (SM, 36 | Initial_PC => Program_Offset, 37 | Config => Config); 38 | P.Set_Pin_Direction (SM, Pico.LED.Pin, Output); 39 | P.Set_Enabled (SM, True); 40 | 41 | RP.Device.Timer.Enable; 42 | loop 43 | P.Put (SM, 1); 44 | RP.Device.Timer.Delay_Milliseconds (100); 45 | P.Put (SM, 0); 46 | RP.Device.Timer.Delay_Milliseconds (100); 47 | end loop; 48 | end Pio_assemble; 49 | -------------------------------------------------------------------------------- /pio_blink/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /pio_blink/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_pio_blink": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/pio_blink", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /pio_blink/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /pio_blink/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/pio_blink", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /pio_blink/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /pio_blink/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile Project", 6 | "type": "process", 7 | "isBuildCommand": true, 8 | "command": "alr", 9 | "args": ["build"], 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "always", 13 | "panel": "dedicated" 14 | }, 15 | "problemMatcher": "$gcc", 16 | "windows": { 17 | "command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe" 18 | } 19 | }, 20 | { 21 | "label": "Run Project", 22 | "type": "process", 23 | "command": "${env:HOME}/.pico-sdk/picotool/2.1.1/picotool/picotool", 24 | "args": [ 25 | "load", 26 | "${command:raspberry-pi-pico.launchTargetPath}", 27 | "-fx" 28 | ], 29 | "presentation": { 30 | "reveal": "always", 31 | "panel": "dedicated" 32 | }, 33 | "problemMatcher": [], 34 | "windows": { 35 | "command": "${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool/picotool.exe" 36 | } 37 | }, 38 | { 39 | "label": "Flash", 40 | "type": "process", 41 | "command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe", 42 | "args": [ 43 | "-s", 44 | "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts", 45 | "-f", 46 | "raspberrypi-swd.cfg", 47 | "-f", 48 | "target/${command:raspberry-pi-pico.getTarget}.cfg", 49 | "-c", 50 | "adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit" 51 | ], 52 | "problemMatcher": [], 53 | "windows": { 54 | "command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe" 55 | } 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /pio_blink/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /pio_blink/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/pio_blink.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/pio_blink.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/pio_blink 10 | 11 | bin/pio_blink.uf2: bin/pio_blink 12 | picotool uf2 convert bin/pio_blink -t elf bin/pio_blink.uf2 13 | 14 | bin/pio_blink: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /pio_blink/README.md: -------------------------------------------------------------------------------- 1 | src/hello.pio needs to be assembled into gen/hello.ads before we can compile 2 | the program. This currently requires a 3 | [modified version of pioasm](https://github.com/JeremyGrosser/pico-sdk/tree/pioasm_ada) 4 | in your path. 5 | 6 | Step 1: 7 | 8 | gprbuild -P pioasm.gpr 9 | 10 | Step 2: 11 | 12 | alr build 13 | -------------------------------------------------------------------------------- /pio_blink/alire.toml: -------------------------------------------------------------------------------- 1 | name = "pio_blink" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["pio_blink"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /pio_blink/gen/hello.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------- 2 | -- This file is autogenerated by pioasm; do not edit! -- 3 | -------------------------------------------------------- 4 | 5 | pragma Style_Checks (Off); 6 | 7 | with RP.PIO; 8 | 9 | package Hello is 10 | 11 | ----------- 12 | -- Hello -- 13 | ----------- 14 | 15 | Hello_Wrap_Target : constant := 0; 16 | Hello_Wrap : constant := 1; 17 | 18 | Hello_Program_Instructions : RP.PIO.Program := ( 19 | -- .wrap_target 20 | 16#80a0#, -- 0: pull block 21 | 16#6001#); -- 1: out pins, 1 22 | -- .wrap 23 | 24 | end Hello; 25 | -------------------------------------------------------------------------------- /pio_blink/pio_blink.gpr: -------------------------------------------------------------------------------- 1 | with "config/pio_blink_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project pio_blink is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & pio_blink_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("pio_blink.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use pio_blink_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end pio_blink; 32 | -------------------------------------------------------------------------------- /pio_blink/pioasm.gpr: -------------------------------------------------------------------------------- 1 | project pioasm is 2 | 3 | for Languages use ("Asm_Pio"); 4 | for Source_Dirs use ("src"); 5 | for Object_Dir use "gen"; 6 | for Create_Missing_Dirs use "True"; 7 | 8 | package Naming is 9 | for Body_Suffix ("Asm_Pio") use ".pio"; 10 | end Naming; 11 | 12 | package Compiler is 13 | for Driver ("Asm_Pio") use "pioasm"; 14 | for Leading_Required_Switches ("Asm_Pio") use ("-o", "ada"); 15 | for Switches ("Asm_Pio") use ("-p", "Hello"); 16 | for Object_File_Switches ("Asm_Pio") use (""); 17 | for Object_File_Suffix ("Asm_Pio") use ".ads"; 18 | end Compiler; 19 | 20 | end pioasm; 21 | -------------------------------------------------------------------------------- /pio_blink/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /pio_blink/src/hello.pio: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 | ; 4 | ; SPDX-License-Identifier: BSD-3-Clause 5 | ; 6 | 7 | .program hello 8 | 9 | ; Repeatedly get one word of data from the TX FIFO, stalling when the FIFO is 10 | ; empty. Write the least significant bit to the OUT pin group. 11 | .wrap_target 12 | pull 13 | out pins, 1 14 | .wrap 15 | -------------------------------------------------------------------------------- /pio_blink/src/pio_blink.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with RP.GPIO; use RP.GPIO; 7 | with RP.PIO; use RP.PIO; 8 | with RP.Device; 9 | with RP.Clock; 10 | with Pico; 11 | with Hello; 12 | 13 | procedure Pio_blink is 14 | Program_Offset : constant PIO_Address := 0; 15 | SM : constant PIO_SM := 0; 16 | Config : PIO_SM_Config := Default_SM_Config; 17 | P : PIO_Device renames RP.Device.PIO_0; 18 | begin 19 | RP.Clock.Initialize (Pico.XOSC_Frequency); 20 | RP.GPIO.Enable; 21 | 22 | Pico.LED.Configure (Output, Pull_Up, P.GPIO_Function); 23 | 24 | P.Enable; 25 | P.Load (Hello.Hello_Program_Instructions, Program_Offset); 26 | 27 | Set_Out_Pins (Config, Pico.LED.Pin, 1); 28 | Set_Set_Pins (Config, Pico.LED.Pin, 1); 29 | Set_Wrap (Config, 30 | Wrap_Target => Hello.Hello_Wrap_Target, 31 | Wrap => Hello.Hello_Wrap); 32 | Set_Clock_Frequency (Config, 50_000_000); 33 | 34 | P.SM_Initialize (SM, 35 | Initial_PC => Program_Offset, 36 | Config => Config); 37 | P.Set_Pin_Direction (SM, Pico.LED.Pin, Output); 38 | P.Set_Enabled (SM, True); 39 | 40 | RP.Device.Timer.Enable; 41 | loop 42 | P.Put (SM, 1); 43 | RP.Device.Timer.Delay_Milliseconds (100); 44 | P.Put (SM, 0); 45 | RP.Device.Timer.Delay_Milliseconds (100); 46 | end loop; 47 | end Pio_blink; 48 | -------------------------------------------------------------------------------- /pwm/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /pwm/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_pwm": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/pwm", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /pwm/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /pwm/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/pwm", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /pwm/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /pwm/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile Project", 6 | "type": "process", 7 | "isBuildCommand": true, 8 | "command": "alr", 9 | "args": ["build"], 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "always", 13 | "panel": "dedicated" 14 | }, 15 | "problemMatcher": "$gcc", 16 | "windows": { 17 | "command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe" 18 | } 19 | }, 20 | { 21 | "label": "Run Project", 22 | "type": "process", 23 | "command": "${env:HOME}/.pico-sdk/picotool/2.1.1/picotool/picotool", 24 | "args": [ 25 | "load", 26 | "${command:raspberry-pi-pico.launchTargetPath}", 27 | "-fx" 28 | ], 29 | "presentation": { 30 | "reveal": "always", 31 | "panel": "dedicated" 32 | }, 33 | "problemMatcher": [], 34 | "windows": { 35 | "command": "${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool/picotool.exe" 36 | } 37 | }, 38 | { 39 | "label": "Flash", 40 | "type": "process", 41 | "command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe", 42 | "args": [ 43 | "-s", 44 | "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts", 45 | "-f", 46 | "raspberrypi-swd.cfg", 47 | "-f", 48 | "target/${command:raspberry-pi-pico.getTarget}.cfg", 49 | "-c", 50 | "adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit" 51 | ], 52 | "problemMatcher": [], 53 | "windows": { 54 | "command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe" 55 | } 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /pwm/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /pwm/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/pwm.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/pwm.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/pwm 10 | 11 | bin/pwm.uf2: bin/pwm 12 | picotool uf2 convert bin/pwm -t elf bin/pwm.uf2 13 | 14 | bin/pwm: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /pwm/alire.toml: -------------------------------------------------------------------------------- 1 | name = "pwm" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["pwm"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /pwm/pwm.gpr: -------------------------------------------------------------------------------- 1 | with "config/pwm_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project pwm is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & pwm_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("pwm.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use pwm_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end pwm; 32 | -------------------------------------------------------------------------------- /pwm/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /pwm/src/pwm.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with HAL; use HAL; 7 | with RP.Timer; use RP.Timer; 8 | with RP.PWM; use RP.PWM; 9 | with RP.Device; 10 | with RP.Clock; 11 | with RP.GPIO; 12 | with Pico; 13 | 14 | procedure Pwm is 15 | GP0 : constant PWM_Point := To_PWM (Pico.GP0); 16 | LED : constant PWM_Point := To_PWM (Pico.LED); 17 | 18 | -- The PWM will count up at Frequency until it reaches Reload 19 | -- While the counter is less than Duty_Cycle, the output is High 20 | Frequency : constant RP.Hertz := 1_000_000; 21 | Reload : constant Period := 1_000; 22 | Duty_Cycle : Period := Reload / 2; -- start at 50% 23 | T : RP.Timer.Time := RP.Timer.Clock; 24 | begin 25 | RP.Clock.Initialize (Pico.XOSC_Frequency); 26 | RP.Device.Timer.Enable; 27 | RP.PWM.Initialize; 28 | 29 | Pico.LED.Configure 30 | (RP.GPIO.Output, RP.GPIO.Floating, RP.GPIO.PWM); 31 | Pico.GP0.Configure 32 | (RP.GPIO.Output, RP.GPIO.Floating, RP.GPIO.PWM); 33 | 34 | Set_Frequency (LED.Slice, Frequency); 35 | Set_Interval (LED.Slice, Reload); 36 | Enable (LED.Slice); 37 | 38 | Set_Frequency (GP0.Slice, Frequency); 39 | Set_Interval (GP0.Slice, Reload); 40 | Enable (GP0.Slice); 41 | 42 | loop 43 | Set_Duty_Cycle (GP0.Slice, GP0.Channel, Duty_Cycle); 44 | Set_Duty_Cycle (LED.Slice, LED.Channel, Duty_Cycle); 45 | 46 | -- Increase the duty cycle by 1% every 10ms 47 | Duty_Cycle := (Duty_Cycle + (Reload / 100)) mod Reload; 48 | 49 | T := T + Milliseconds (10); 50 | RP.Device.Timer.Delay_Until (T); 51 | end loop; 52 | end Pwm; 53 | -------------------------------------------------------------------------------- /ravenscar_blink/README.md: -------------------------------------------------------------------------------- 1 | The ravenscar examples are broken with the current pico_bsp. The pico_bsp 2 | project adds a linker script and some startup files to the build which conflict 3 | with the ravenscar runtime. Making this conditional will require some changes 4 | to alire that have not been released yet. Until then, if you need to use 5 | ravenscar, you will need to switch to the `zfp_split` branch of pico_bsp. 6 | -------------------------------------------------------------------------------- /ravenscar_blink/ravenscar_blink.gpr: -------------------------------------------------------------------------------- 1 | with "pico_bsp.gpr"; 2 | 3 | project Ravenscar_Blink is 4 | 5 | for Runtime ("Ada") use "ravenscar-full-rpi-pico-mp"; 6 | for Target use "arm-eabi"; 7 | 8 | for Main use ("main.adb"); 9 | for Languages use ("Ada"); 10 | for Source_Dirs use ("src"); 11 | for Object_Dir use "obj"; 12 | for Create_Missing_Dirs use "True"; 13 | 14 | end Ravenscar_Blink; 15 | -------------------------------------------------------------------------------- /ravenscar_blink/src/main.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with RP.GPIO; 7 | with Pico; 8 | 9 | procedure Main is 10 | begin 11 | Pico.LED.Configure (RP.GPIO.Output); 12 | loop 13 | Pico.LED.Toggle; 14 | delay 0.1; 15 | end loop; 16 | end Main; 17 | -------------------------------------------------------------------------------- /rtc/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /rtc/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_rtc": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/rtc", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /rtc/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /rtc/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/rtc", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /rtc/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /rtc/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile Project", 6 | "type": "process", 7 | "isBuildCommand": true, 8 | "command": "alr", 9 | "args": ["build"], 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "always", 13 | "panel": "dedicated" 14 | }, 15 | "problemMatcher": "$gcc", 16 | "windows": { 17 | "command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe" 18 | } 19 | }, 20 | { 21 | "label": "Run Project", 22 | "type": "process", 23 | "command": "${env:HOME}/.pico-sdk/picotool/2.1.1/picotool/picotool", 24 | "args": [ 25 | "load", 26 | "${command:raspberry-pi-pico.launchTargetPath}", 27 | "-fx" 28 | ], 29 | "presentation": { 30 | "reveal": "always", 31 | "panel": "dedicated" 32 | }, 33 | "problemMatcher": [], 34 | "windows": { 35 | "command": "${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool/picotool.exe" 36 | } 37 | }, 38 | { 39 | "label": "Flash", 40 | "type": "process", 41 | "command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe", 42 | "args": [ 43 | "-s", 44 | "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts", 45 | "-f", 46 | "raspberrypi-swd.cfg", 47 | "-f", 48 | "target/${command:raspberry-pi-pico.getTarget}.cfg", 49 | "-c", 50 | "adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit" 51 | ], 52 | "problemMatcher": [], 53 | "windows": { 54 | "command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe" 55 | } 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /rtc/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /rtc/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/rtc.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/rtc.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/rtc 10 | 11 | bin/rtc.uf2: bin/rtc 12 | picotool uf2 convert bin/rtc -t elf bin/rtc.uf2 13 | 14 | bin/rtc: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /rtc/alire.toml: -------------------------------------------------------------------------------- 1 | name = "rtc" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["rtc"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /rtc/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /rtc/rtc.gpr: -------------------------------------------------------------------------------- 1 | with "config/rtc_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project rtc is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & rtc_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("rtc.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use rtc_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end rtc; 32 | -------------------------------------------------------------------------------- /rtc/src/rtc.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with HAL.Real_Time_Clock; use HAL.Real_Time_Clock; 7 | with RP.Timer; use RP.Timer; 8 | with RP.Device; 9 | with RP.Clock; 10 | with RP.GPIO; 11 | with Pico; 12 | 13 | -- Helper methods for formatting date and time as an ISO 8601 string 14 | with Text_Format; 15 | with Ada.Text_IO; 16 | 17 | procedure Rtc is 18 | -- Try to trigger a Y2K bug 19 | Date : RTC_Date := 20 | (Day_Of_Week => Sunday, 21 | Year => 99, 22 | Month => December, 23 | Day => 31); 24 | Time : RTC_Time := 25 | (Hour => 23, 26 | Min => 59, 27 | Sec => 50); 28 | 29 | T : RP.Timer.Time; 30 | begin 31 | RP.Clock.Initialize (Pico.XOSC_Frequency); 32 | RP.Device.Timer.Enable; 33 | 34 | Pico.LED.Configure (RP.GPIO.Output); 35 | 36 | RP.Device.RTC.Configure; 37 | RP.Device.RTC.Set (Time, Date); 38 | 39 | -- Wait a couple seconds after setting the time to ensure it reads back 40 | -- correctly. 41 | T := RP.Timer.Clock + Ticks_Per_Second * 2; 42 | RP.Device.Timer.Delay_Until (T); 43 | 44 | loop 45 | RP.Device.RTC.Get (Time, Date); 46 | 47 | -- Printing over semihosting I/O is slow enough that we occasionally 48 | -- lose a second. If you're using this for anything important, consider 49 | -- using a UART for output instead. 50 | Ada.Text_IO.Put_Line 51 | (Text_Format.To_String (Time, Date)); 52 | 53 | Pico.LED.Toggle; 54 | 55 | T := T + Ticks_Per_Second; 56 | RP.Device.Timer.Delay_Until (T); 57 | end loop; 58 | end Rtc; 59 | -------------------------------------------------------------------------------- /rtc/src/text_format.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | package body Text_Format is 7 | 8 | function To_String 9 | (N : Integer; 10 | Pad : Positive := 1; 11 | Base : Positive := 10) 12 | return String 13 | is 14 | Translate : constant String := "0123456789ABCDEF"; 15 | S : String (1 .. Pad); 16 | Magnitude : Natural := 1; 17 | J : Integer; 18 | begin 19 | for I in 1 .. Pad loop 20 | J := (N / Magnitude) mod Base; 21 | S (S'Last - (I - 1)) := Translate (Translate'First + J); 22 | Magnitude := Magnitude * Base; 23 | end loop; 24 | if N < 0 then 25 | return "-" & S; 26 | else 27 | return S; 28 | end if; 29 | end To_String; 30 | 31 | function To_String 32 | (Time : RTC_Time; 33 | Date : RTC_Date; 34 | Year_Offset : Integer := 2000) 35 | return String 36 | is (To_String (Integer (Date.Year) + Year_Offset, 4) 37 | & "-" 38 | & To_String (RTC_Month'Pos (Date.Month) + 1, 2) 39 | & "-" 40 | & To_String (Integer (Date.Day), 2) 41 | & " " 42 | & To_String (Integer (Time.Hour), 2) 43 | & ":" 44 | & To_String (Integer (Time.Min), 2) 45 | & ":" 46 | & To_String (Integer (Time.Sec), 2)); 47 | 48 | end Text_Format; 49 | -------------------------------------------------------------------------------- /rtc/src/text_format.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with HAL.Real_Time_Clock; use HAL.Real_Time_Clock; 7 | with HAL; 8 | 9 | package Text_Format is 10 | 11 | function To_String 12 | (N : Integer; 13 | Pad : Positive := 1; 14 | Base : Positive := 10) 15 | return String; 16 | 17 | function To_String 18 | (Time : RTC_Time; 19 | Date : RTC_Date; 20 | Year_Offset : Integer := 2000) 21 | return String; 22 | 23 | end Text_Format; 24 | -------------------------------------------------------------------------------- /spi_loopback/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /spi_loopback/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_spi_loopback": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/spi_loopback", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spi_loopback/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /spi_loopback/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/spi_loopback", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /spi_loopback/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /spi_loopback/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile Project", 6 | "type": "process", 7 | "isBuildCommand": true, 8 | "command": "alr", 9 | "args": ["build"], 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "always", 13 | "panel": "dedicated" 14 | }, 15 | "problemMatcher": "$gcc", 16 | "windows": { 17 | "command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe" 18 | } 19 | }, 20 | { 21 | "label": "Run Project", 22 | "type": "process", 23 | "command": "${env:HOME}/.pico-sdk/picotool/2.1.1/picotool/picotool", 24 | "args": [ 25 | "load", 26 | "${command:raspberry-pi-pico.launchTargetPath}", 27 | "-fx" 28 | ], 29 | "presentation": { 30 | "reveal": "always", 31 | "panel": "dedicated" 32 | }, 33 | "problemMatcher": [], 34 | "windows": { 35 | "command": "${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool/picotool.exe" 36 | } 37 | }, 38 | { 39 | "label": "Flash", 40 | "type": "process", 41 | "command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe", 42 | "args": [ 43 | "-s", 44 | "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts", 45 | "-f", 46 | "raspberrypi-swd.cfg", 47 | "-f", 48 | "target/${command:raspberry-pi-pico.getTarget}.cfg", 49 | "-c", 50 | "adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit" 51 | ], 52 | "problemMatcher": [], 53 | "windows": { 54 | "command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe" 55 | } 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /spi_loopback/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /spi_loopback/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/spi_loopback.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/spi_loopback.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/spi_loopback 10 | 11 | bin/spi_loopback.uf2: bin/spi_loopback 12 | picotool uf2 convert bin/spi_loopback -t elf bin/spi_loopback.uf2 13 | 14 | bin/spi_loopback: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /spi_loopback/alire.toml: -------------------------------------------------------------------------------- 1 | name = "spi_loopback" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["spi_loopback"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /spi_loopback/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /spi_loopback/spi_loopback.gpr: -------------------------------------------------------------------------------- 1 | with "config/spi_loopback_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project spi_loopback is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & spi_loopback_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("spi_loopback.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use spi_loopback_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end spi_loopback; 32 | -------------------------------------------------------------------------------- /spi_loopback/src/board.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | package body Board is 7 | 8 | procedure Initialize is 9 | use RP.GPIO; 10 | begin 11 | Master_MISO.Configure (Input, Pull_Up, SPI); 12 | Master_NSS.Configure (Output, Pull_Up, SPI); 13 | Master_SCK.Configure (Output, Pull_Up, SPI); 14 | Master_MOSI.Configure (Output, Pull_Up, SPI); 15 | 16 | Slave_MISO.Configure (Output, Floating, SPI); 17 | Slave_NSS.Configure (Input, Floating, SPI); 18 | Slave_SCK.Configure (Input, Floating, SPI); 19 | Slave_MOSI.Configure (Input, Floating, SPI); 20 | end Initialize; 21 | 22 | end Board; 23 | -------------------------------------------------------------------------------- /spi_loopback/src/board.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with RP.Device; 7 | with RP.GPIO; 8 | with RP.SPI; 9 | with Pico; 10 | 11 | package Board is 12 | 13 | SPI_Master : RP.SPI.SPI_Port renames RP.Device.SPI_0; 14 | SPI_Slave : RP.SPI.SPI_Port renames RP.Device.SPI_1; 15 | 16 | Master_MISO : RP.GPIO.GPIO_Point renames Pico.GP0; 17 | Master_NSS : RP.GPIO.GPIO_Point renames Pico.GP1; 18 | Master_SCK : RP.GPIO.GPIO_Point renames Pico.GP2; 19 | Master_MOSI : RP.GPIO.GPIO_Point renames Pico.GP3; 20 | 21 | Slave_MISO : RP.GPIO.GPIO_Point renames Pico.GP11; 22 | Slave_NSS : RP.GPIO.GPIO_Point renames Pico.GP9; 23 | Slave_SCK : RP.GPIO.GPIO_Point renames Pico.GP10; 24 | Slave_MOSI : RP.GPIO.GPIO_Point renames Pico.GP12; 25 | 26 | procedure Initialize; 27 | 28 | end Board; 29 | -------------------------------------------------------------------------------- /spi_loopback/src/tests.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with RP.SPI; use RP.SPI; 7 | 8 | package Tests is 9 | 10 | procedure Test_8 11 | (Name : String; 12 | Master_Config : SPI_Configuration; 13 | Slave_Config : SPI_Configuration); 14 | 15 | procedure Test_16 16 | (Name : String; 17 | Master_Config : SPI_Configuration; 18 | Slave_Config : SPI_Configuration; 19 | Transfer_Length : Positive := 1); 20 | 21 | procedure Test_Slave 22 | (Name : String; 23 | Master_Config : SPI_Configuration; 24 | Slave_Config : SPI_Configuration); 25 | 26 | procedure Test_Slave_8 27 | (Name : String; 28 | Master_Config : SPI_Configuration; 29 | Slave_Config : SPI_Configuration); 30 | 31 | procedure Test_DMA 32 | (Name : String; 33 | Master_Config : SPI_Configuration; 34 | Slave_Config : SPI_Configuration); 35 | 36 | end Tests; 37 | -------------------------------------------------------------------------------- /timer/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /timer/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_timer": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/timer", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /timer/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /timer/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/timer", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /timer/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /timer/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile Project", 6 | "type": "process", 7 | "isBuildCommand": true, 8 | "command": "alr", 9 | "args": ["build"], 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "always", 13 | "panel": "dedicated" 14 | }, 15 | "problemMatcher": "$gcc", 16 | "windows": { 17 | "command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe" 18 | } 19 | }, 20 | { 21 | "label": "Run Project", 22 | "type": "process", 23 | "command": "${env:HOME}/.pico-sdk/picotool/2.1.1/picotool/picotool", 24 | "args": [ 25 | "load", 26 | "${command:raspberry-pi-pico.launchTargetPath}", 27 | "-fx" 28 | ], 29 | "presentation": { 30 | "reveal": "always", 31 | "panel": "dedicated" 32 | }, 33 | "problemMatcher": [], 34 | "windows": { 35 | "command": "${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool/picotool.exe" 36 | } 37 | }, 38 | { 39 | "label": "Flash", 40 | "type": "process", 41 | "command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe", 42 | "args": [ 43 | "-s", 44 | "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts", 45 | "-f", 46 | "raspberrypi-swd.cfg", 47 | "-f", 48 | "target/${command:raspberry-pi-pico.getTarget}.cfg", 49 | "-c", 50 | "adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit" 51 | ], 52 | "problemMatcher": [], 53 | "windows": { 54 | "command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe" 55 | } 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /timer/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /timer/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/timer.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/timer.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/timer 10 | 11 | bin/timer.uf2: bin/timer 12 | picotool uf2 convert bin/timer -t elf bin/timer.uf2 13 | 14 | bin/timer: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /timer/alire.toml: -------------------------------------------------------------------------------- 1 | name = "timer" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["timer"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /timer/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /timer/src/timer.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with HAL.GPIO; use HAL.GPIO; 7 | with RP.Device; use RP.Device; 8 | with RP.GPIO; use RP.GPIO; 9 | with RP.Timer; use RP.Timer; 10 | with RP.Clock; 11 | with Pico; 12 | 13 | procedure Timer is 14 | begin 15 | RP.Clock.Initialize (Pico.XOSC_Frequency); 16 | RP.GPIO.Enable; 17 | 18 | Pico.LED.Configure (Output); 19 | Pico.LED.Set; 20 | 21 | Timer.Enable; 22 | loop 23 | Pico.LED.Toggle; 24 | Timer.Delay_Microseconds (1_000_000); 25 | 26 | Pico.LED.Toggle; 27 | Timer.Delay_Milliseconds (1_000); 28 | 29 | Pico.LED.Toggle; 30 | Timer.Delay_Seconds (1); 31 | 32 | Pico.LED.Toggle; 33 | Timer.Delay_Until (Clock + Ticks_Per_Second); 34 | end loop; 35 | end Timer; 36 | -------------------------------------------------------------------------------- /timer/timer.gpr: -------------------------------------------------------------------------------- 1 | with "config/timer_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project timer is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & timer_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("timer.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use timer_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end timer; 32 | -------------------------------------------------------------------------------- /uart_echo/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /uart_echo/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_uart_echo": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/uart_echo", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /uart_echo/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /uart_echo/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/uart_echo", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /uart_echo/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /uart_echo/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile Project", 6 | "type": "process", 7 | "isBuildCommand": true, 8 | "command": "alr", 9 | "args": ["build"], 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "always", 13 | "panel": "dedicated" 14 | }, 15 | "problemMatcher": "$gcc", 16 | "windows": { 17 | "command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe" 18 | } 19 | }, 20 | { 21 | "label": "Run Project", 22 | "type": "process", 23 | "command": "${env:HOME}/.pico-sdk/picotool/2.1.1/picotool/picotool", 24 | "args": [ 25 | "load", 26 | "${command:raspberry-pi-pico.launchTargetPath}", 27 | "-fx" 28 | ], 29 | "presentation": { 30 | "reveal": "always", 31 | "panel": "dedicated" 32 | }, 33 | "problemMatcher": [], 34 | "windows": { 35 | "command": "${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool/picotool.exe" 36 | } 37 | }, 38 | { 39 | "label": "Flash", 40 | "type": "process", 41 | "command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe", 42 | "args": [ 43 | "-s", 44 | "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts", 45 | "-f", 46 | "raspberrypi-swd.cfg", 47 | "-f", 48 | "target/${command:raspberry-pi-pico.getTarget}.cfg", 49 | "-c", 50 | "adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit" 51 | ], 52 | "problemMatcher": [], 53 | "windows": { 54 | "command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe" 55 | } 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /uart_echo/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /uart_echo/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/uart_echo.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/uart_echo.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/uart_echo 10 | 11 | bin/uart_echo.uf2: bin/uart_echo 12 | picotool uf2 convert bin/uart_echo -t elf bin/uart_echo.uf2 13 | 14 | bin/uart_echo: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /uart_echo/alire.toml: -------------------------------------------------------------------------------- 1 | name = "uart_echo" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["uart_echo"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /uart_echo/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /uart_echo/uart_echo.gpr: -------------------------------------------------------------------------------- 1 | with "config/uart_echo_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project uart_echo is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & uart_echo_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("uart_echo.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use uart_echo_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end uart_echo; 32 | -------------------------------------------------------------------------------- /uart_interrupt/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /uart_interrupt/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_uart_interrupt": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/uart_interrupt", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /uart_interrupt/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /uart_interrupt/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/uart_interrupt", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /uart_interrupt/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /uart_interrupt/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /uart_interrupt/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/uart_interrupt.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/uart_interrupt.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/uart_interrupt 10 | 11 | bin/uart_interrupt.uf2: bin/uart_interrupt 12 | picotool uf2 convert bin/uart_interrupt -t elf bin/uart_interrupt.uf2 13 | 14 | bin/uart_interrupt: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /uart_interrupt/alire.toml: -------------------------------------------------------------------------------- 1 | name = "uart_interrupt" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["uart_interrupt"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /uart_interrupt/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /uart_interrupt/src/console.ads: -------------------------------------------------------------------------------- 1 | with RP_Interrupts; 2 | 3 | package Console is 4 | 5 | procedure Configure; 6 | 7 | procedure Get 8 | (Ch : out Character); 9 | 10 | procedure Put 11 | (Ch : Character); 12 | 13 | private 14 | 15 | procedure Interrupt; 16 | 17 | end Console; 18 | -------------------------------------------------------------------------------- /uart_interrupt/src/uart_interrupt.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2022 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with RP.Clock; 7 | with RP.GPIO; 8 | with Pico; 9 | 10 | with Console; 11 | 12 | procedure Uart_interrupt is 13 | Ch : Character; 14 | begin 15 | RP.Clock.Initialize (Pico.XOSC_Frequency); 16 | Pico.GP16.Configure (RP.GPIO.Output, RP.GPIO.Floating, RP.GPIO.UART); -- UART0 TX 17 | Pico.GP17.Configure (RP.GPIO.Output, RP.GPIO.Floating, RP.GPIO.UART); -- UART0 RX 18 | 19 | Console.Configure; 20 | 21 | loop 22 | Console.Get (Ch); 23 | Console.Put (Ch); 24 | end loop; 25 | end Uart_interrupt; 26 | -------------------------------------------------------------------------------- /uart_interrupt/uart_interrupt.gpr: -------------------------------------------------------------------------------- 1 | with "config/uart_interrupt_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project uart_interrupt is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & uart_interrupt_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("uart_interrupt.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use uart_interrupt_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end uart_interrupt; 32 | -------------------------------------------------------------------------------- /usb_echo/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /usb_echo/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_usb_echo": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/usb_echo", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /usb_echo/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /usb_echo/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/usb_echo", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /usb_echo/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /usb_echo/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile Project", 6 | "type": "process", 7 | "isBuildCommand": true, 8 | "command": "alr", 9 | "args": ["build"], 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "always", 13 | "panel": "dedicated" 14 | }, 15 | "problemMatcher": "$gcc", 16 | "windows": { 17 | "command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe" 18 | } 19 | }, 20 | { 21 | "label": "Run Project", 22 | "type": "process", 23 | "command": "${env:HOME}/.pico-sdk/picotool/2.1.1/picotool/picotool", 24 | "args": [ 25 | "load", 26 | "${command:raspberry-pi-pico.launchTargetPath}", 27 | "-fx" 28 | ], 29 | "presentation": { 30 | "reveal": "always", 31 | "panel": "dedicated" 32 | }, 33 | "problemMatcher": [], 34 | "windows": { 35 | "command": "${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool/picotool.exe" 36 | } 37 | }, 38 | { 39 | "label": "Flash", 40 | "type": "process", 41 | "command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe", 42 | "args": [ 43 | "-s", 44 | "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts", 45 | "-f", 46 | "raspberrypi-swd.cfg", 47 | "-f", 48 | "target/${command:raspberry-pi-pico.getTarget}.cfg", 49 | "-c", 50 | "adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit" 51 | ], 52 | "problemMatcher": [], 53 | "windows": { 54 | "command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe" 55 | } 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /usb_echo/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /usb_echo/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/usb_echo.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/usb_echo.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/usb_echo 10 | 11 | bin/usb_echo.uf2: bin/usb_echo 12 | picotool uf2 convert bin/usb_echo -t elf bin/usb_echo.uf2 13 | 14 | bin/usb_echo: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /usb_echo/alire.toml: -------------------------------------------------------------------------------- 1 | name = "usb_echo" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["usb_echo"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /usb_echo/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /usb_echo/src/usb_echo.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2021 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with RP.Device; 7 | with RP.Clock; 8 | with Pico; 9 | 10 | with USB.HAL.Device; 11 | with USB.Device.Serial; 12 | with USB.Device; 13 | with USB; 14 | with HAL; use HAL; 15 | 16 | procedure Usb_echo is 17 | Fatal_Error : exception; 18 | Max_Packet_Size : constant := 64; 19 | 20 | USB_Stack : USB.Device.USB_Device_Stack (Max_Classes => 1); 21 | USB_Serial : aliased USB.Device.Serial.Default_Serial_Class 22 | (TX_Buffer_Size => Max_Packet_Size, 23 | RX_Buffer_Size => Max_Packet_Size); 24 | 25 | use type USB.Device.Init_Result; 26 | Status : USB.Device.Init_Result; 27 | 28 | Message : String (1 .. Max_Packet_Size); 29 | Length : HAL.UInt32; 30 | begin 31 | RP.Clock.Initialize (Pico.XOSC_Frequency); 32 | 33 | if not USB_Stack.Register_Class (USB_Serial'Unchecked_Access) then 34 | raise Fatal_Error with "Failed to register USB Serial device class"; 35 | end if; 36 | 37 | Status := USB_Stack.Initialize 38 | (Controller => RP.Device.UDC'Access, 39 | Manufacturer => USB.To_USB_String ("Raspberry Pi"), 40 | Product => USB.To_USB_String ("Ada Echo Test"), 41 | Serial_Number => USB.To_USB_String ("42"), 42 | Max_Packet_Size => Max_Packet_Size); 43 | 44 | if Status /= USB.Device.Ok then 45 | raise Fatal_Error with "USB stack initialization failed: " & Status'Image; 46 | end if; 47 | 48 | USB_Stack.Start; 49 | 50 | loop 51 | USB_Stack.Poll; 52 | 53 | if USB_Serial.List_Ctrl_State.DTE_Is_Present then 54 | USB_Serial.Read (Message, Length); 55 | if Length > 0 then 56 | USB_Serial.Write (RP.Device.UDC, Message (1 .. Natural (Length)), Length); 57 | end if; 58 | end if; 59 | end loop; 60 | end Usb_echo; 61 | -------------------------------------------------------------------------------- /usb_echo/usb_echo.gpr: -------------------------------------------------------------------------------- 1 | with "config/usb_echo_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project usb_echo is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & usb_echo_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("usb_echo.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use usb_echo_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end usb_echo; 32 | -------------------------------------------------------------------------------- /usb_echo_interrupt/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /usb_echo_interrupt/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_usb_echo_interrupt": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/usb_echo_interrupt", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /usb_echo_interrupt/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /usb_echo_interrupt/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/usb_echo_interrupt", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /usb_echo_interrupt/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /usb_echo_interrupt/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /usb_echo_interrupt/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/usb_echo_interrupt.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/usb_echo_interrupt.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/usb_echo_interrupt 10 | 11 | bin/usb_echo_interrupt.uf2: bin/usb_echo_interrupt 12 | picotool uf2 convert bin/usb_echo_interrupt -t elf bin/usb_echo_interrupt.uf2 13 | 14 | bin/usb_echo_interrupt: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /usb_echo_interrupt/alire.toml: -------------------------------------------------------------------------------- 1 | name = "usb_echo_interrupt" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["usb_echo_interrupt"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /usb_echo_interrupt/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /usb_echo_interrupt/src/usb_echo_interrupt.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2022 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with RP.Device; 7 | with RP.Clock; 8 | with Pico; 9 | 10 | with USB.Device.Serial; 11 | with USB.Device; 12 | with USB; 13 | with HAL; use HAL; 14 | 15 | with USB_Int; 16 | 17 | procedure Usb_echo_interrupt is 18 | Message : String (1 .. USB_Int.Max_Packet_Size); 19 | Length : HAL.UInt32; 20 | begin 21 | RP.Clock.Initialize (Pico.XOSC_Frequency); 22 | 23 | -- See usb_int.adb for initialization and interrupt handling setup 24 | USB_Int.Initialize; 25 | 26 | loop 27 | if USB_Int.USB_Serial.List_Ctrl_State.DTE_Is_Present then 28 | USB_Int.USB_Serial.Read (Message, Length); 29 | if Length > 0 then 30 | USB_Int.USB_Serial.Write (RP.Device.UDC, Message (1 .. Natural (Length)), Length); 31 | end if; 32 | end if; 33 | end loop; 34 | end Usb_echo_interrupt; 35 | -------------------------------------------------------------------------------- /usb_echo_interrupt/src/usb_int.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2022 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | 7 | with RP_Interrupts; 8 | with Cortex_M.NVIC; 9 | 10 | with RP2040_SVD.Interrupts; 11 | 12 | with RP.Device; 13 | 14 | with USB.Device; 15 | with USB; 16 | 17 | package body USB_Int is 18 | 19 | Fatal_Error : exception; 20 | 21 | Int_ID : constant RP_Interrupts.Interrupt_ID := 22 | RP2040_SVD.Interrupts.USBCTRL_Interrupt; 23 | 24 | USB_Stack : USB.Device.USB_Device_Stack (Max_Classes => 1); 25 | 26 | procedure USB_Int_Handler is 27 | begin 28 | 29 | -- Interrupt based USB device only requiers to call the stack Poll 30 | -- procedure for every interrupt of the RP USB device controller. 31 | USB_Stack.Poll; 32 | 33 | end USB_Int_Handler; 34 | 35 | procedure Initialize is 36 | use type USB.Device.Init_Result; 37 | Status : USB.Device.Init_Result; 38 | begin 39 | if not USB_Stack.Register_Class (USB_Serial'Unchecked_Access) then 40 | raise Fatal_Error with "Failed to register USB Serial device class"; 41 | end if; 42 | 43 | Status := USB_Stack.Initialize 44 | (Controller => RP.Device.UDC'Access, 45 | Manufacturer => USB.To_USB_String ("Raspberry Pi"), 46 | Product => USB.To_USB_String ("Ada Echo Int Test"), 47 | Serial_Number => USB.To_USB_String ("42"), 48 | Max_Packet_Size => Max_Packet_Size); 49 | 50 | if Status /= USB.Device.Ok then 51 | raise Fatal_Error with "USB stack initialization failed: " & Status'Image; 52 | end if; 53 | 54 | USB_Stack.Start; 55 | 56 | -- Attach a handler to the RP USB device controller interrupt 57 | RP_Interrupts.Attach_Handler 58 | (USB_Int_Handler'Access, 59 | Int_ID, 60 | RP_Interrupts.Interrupt_Priority'First); 61 | 62 | -- Enable the RP USB device controller interrupt 63 | Cortex_M.NVIC.Enable_Interrupt (Int_ID); 64 | 65 | end Initialize; 66 | 67 | end USB_Int; 68 | -------------------------------------------------------------------------------- /usb_echo_interrupt/src/usb_int.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2022 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | 7 | with USB.Device.Serial; 8 | 9 | package USB_Int is 10 | 11 | Max_Packet_Size : constant := 64; 12 | USB_Serial : aliased USB.Device.Serial.Default_Serial_Class 13 | (TX_Buffer_Size => Max_Packet_Size, 14 | RX_Buffer_Size => Max_Packet_Size); 15 | 16 | procedure Initialize; 17 | 18 | end USB_Int; 19 | -------------------------------------------------------------------------------- /usb_echo_interrupt/usb_echo_interrupt.gpr: -------------------------------------------------------------------------------- 1 | with "config/usb_echo_interrupt_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project usb_echo_interrupt is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & usb_echo_interrupt_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("usb_echo_interrupt.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use usb_echo_interrupt_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end usb_echo_interrupt; 32 | -------------------------------------------------------------------------------- /ws2812_demo/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /ws2812_demo/.vimspector.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": { 3 | "gdb_ws2812_demo": { 4 | "adapter": "vscode-cpptools", 5 | "configuration": { 6 | "request": "launch", 7 | "program": "${workspaceRoot}/bin/ws2812_demo", 8 | "miDebuggerServerAddress": "localhost:3333", 9 | "args": [], 10 | "stopAtEntry": true, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "arm-eabi-gdb", 16 | "setupCommands": [] 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ws2812_demo/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "marus25.cortex-debug", 4 | "ms-vscode.cpptools", 5 | "ms-vscode.cpptools-extension-pack", 6 | "ms-vscode.vscode-serial-monitor", 7 | "raspberry-pi.raspberry-pi-pico" 8 | ] 9 | } -------------------------------------------------------------------------------- /ws2812_demo/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "gdb with OpenOCD", 6 | "type": "gdb", 7 | "request": "launch", 8 | "target": "${workspaceFolder}/bin/ws2812_demo", 9 | "gdbpath": "${userHome}/.local/share/alire/toolchains/gnat_arm_elf_14.2.1_524d4d41/bin/arm-eabi-gdb", 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}", 12 | "autorun": [ 13 | "target extended-remote localhost:3333", 14 | "monitor arm semihosting enable" 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /ws2812_demo/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "idf.pythonInstallPath": "/usr/bin/python3" 3 | } 4 | -------------------------------------------------------------------------------- /ws2812_demo/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Compile Project", 6 | "type": "process", 7 | "isBuildCommand": true, 8 | "command": "alr", 9 | "args": ["build"], 10 | "group": "build", 11 | "presentation": { 12 | "reveal": "always", 13 | "panel": "dedicated" 14 | }, 15 | "problemMatcher": "$gcc", 16 | "windows": { 17 | "command": "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1/ninja.exe" 18 | } 19 | }, 20 | { 21 | "label": "Run Project", 22 | "type": "process", 23 | "command": "${env:HOME}/.pico-sdk/picotool/2.1.1/picotool/picotool", 24 | "args": [ 25 | "load", 26 | "${command:raspberry-pi-pico.launchTargetPath}", 27 | "-fx" 28 | ], 29 | "presentation": { 30 | "reveal": "always", 31 | "panel": "dedicated" 32 | }, 33 | "problemMatcher": [], 34 | "windows": { 35 | "command": "${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool/picotool.exe" 36 | } 37 | }, 38 | { 39 | "label": "Flash", 40 | "type": "process", 41 | "command": "${userHome}/.pico-sdk/openocd/0.12.0+dev/openocd.exe", 42 | "args": [ 43 | "-s", 44 | "${userHome}/.pico-sdk/openocd/0.12.0+dev/scripts", 45 | "-f", 46 | "raspberrypi-swd.cfg", 47 | "-f", 48 | "target/${command:raspberry-pi-pico.getTarget}.cfg", 49 | "-c", 50 | "adapter speed 5000; program \"${command:raspberry-pi-pico.launchTargetPath}\" verify reset exit" 51 | ], 52 | "problemMatcher": [], 53 | "windows": { 54 | "command": "${env:USERPROFILE}/.pico-sdk/openocd/0.12.0+dev/openocd.exe" 55 | } 56 | } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /ws2812_demo/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Jeremy Grosser 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /ws2812_demo/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: deploy build 2 | 3 | deploy: bin/ws2812_demo.uf2 4 | @echo "Hold bootsel button on pico while you plug in the USB cable and press any key to continue. You can release the bootsel while Loading into Flash." 5 | @read anykey 6 | picotool load bin/ws2812_demo.uf2 7 | @echo "Now reboot the device by replugging the USB cable." 8 | 9 | build: bin/ws2812_demo 10 | 11 | bin/ws2812_demo.uf2: bin/ws2812_demo 12 | picotool uf2 convert bin/ws2812_demo -t elf bin/ws2812_demo.uf2 13 | 14 | bin/ws2812_demo: src/* *.gpr config/* 15 | alr build --development 16 | -------------------------------------------------------------------------------- /ws2812_demo/alire.toml: -------------------------------------------------------------------------------- 1 | name = "ws2812_demo" 2 | description = "hello_world_ada_pico" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Jeremy Grosser"] 6 | maintainers = ["Jeremy Grosser "] 7 | maintainers-logins = ["JeremyGrosser"] 8 | licenses = "MIT OR Apache-2.0 WITH LLVM-exception" 9 | website = "" 10 | tags = [] 11 | 12 | executables = ["ws2812_demo"] 13 | 14 | [[depends-on]] 15 | pico_bsp = "^2.0.0" 16 | -------------------------------------------------------------------------------- /ws2812_demo/raspberrypi-swd.cfg: -------------------------------------------------------------------------------- 1 | adapter driver linuxgpiod 2 | 3 | adapter gpio swdio -chip 0 24 4 | adapter gpio swclk -chip 0 25 5 | -------------------------------------------------------------------------------- /ws2812_demo/src/ws2812_demo.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2022 (C) Jeremy Grosser 3 | -- 4 | -- SPDX-License-Identifier: BSD-3-Clause 5 | -- 6 | with HAL; use HAL; 7 | with RP.PIO.WS2812; 8 | with RP.Device; 9 | with RP.Clock; 10 | with RP.GPIO; 11 | with RP.DMA; 12 | with Pico; 13 | 14 | -- Tested with a generic strip of WS2812B LEDs. 15 | -- https://www.amazon.com/gp/product/B01CDTEJBG/?tag=synack-20 16 | procedure Ws2812_demo is 17 | Strip : RP.PIO.WS2812.Strip 18 | (Pin => Pico.GP28'Access, 19 | PIO => RP.Device.PIO_0'Access, 20 | SM => 0, 21 | Number_Of_LEDs => 300); 22 | 23 | Hue : UInt8 := 0; 24 | Saturation : UInt8 := 255; 25 | Value : UInt8 := 32; 26 | begin 27 | RP.Clock.Initialize (Pico.XOSC_Frequency); 28 | Pico.LED.Configure (RP.GPIO.Output); 29 | RP.DMA.Enable; 30 | 31 | Strip.Initialize; 32 | Strip.Enable_DMA (Chan => 0); 33 | Strip.Clear; 34 | Strip.Update (Blocking => True); 35 | 36 | RP.Device.Timer.Enable; 37 | loop 38 | Hue := Hue + 1; 39 | for I in 1 .. Strip.Number_Of_LEDs loop 40 | Strip.Set_HSV (I, Hue + UInt8 (I mod 256), Saturation, Value); 41 | end loop; 42 | Strip.Update; 43 | 44 | Pico.LED.Toggle; 45 | RP.Device.Timer.Delay_Milliseconds (100); 46 | end loop; 47 | end Ws2812_demo; 48 | -------------------------------------------------------------------------------- /ws2812_demo/ws2812_demo.gpr: -------------------------------------------------------------------------------- 1 | with "config/ws2812_demo_config.gpr"; 2 | with "pico_bsp.gpr"; 3 | 4 | project ws2812_demo is 5 | 6 | for Target use "arm-eabi"; 7 | for Runtime ("Ada") use "light-cortex-m0p"; 8 | 9 | package Linker is 10 | for Switches ("Ada") use pico_bsp.linker_switches; 11 | end Linker; 12 | 13 | for Source_Dirs use ("src/", "config/"); 14 | for Object_Dir use "obj/" & ws2812_demo_Config.Build_Profile; 15 | for Create_Missing_Dirs use "True"; 16 | for Exec_Dir use "bin"; 17 | for Main use ("ws2812_demo.adb"); 18 | 19 | package Compiler is 20 | for Default_Switches ("Ada") use ws2812_demo_Config.Ada_Compiler_Switches; 21 | end Compiler; 22 | 23 | package Binder is 24 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 25 | end Binder; 26 | 27 | package Install is 28 | for Artifacts (".") use ("share"); 29 | end Install; 30 | 31 | end ws2812_demo; 32 | --------------------------------------------------------------------------------