Minimal RP2040 (Raspberry Pi Pico) Ada demo showing concurrent tasking with a protected object.
This project demonstrates:
- 2 Ada tasks (
TA,TB) running concurrently - 1 main thread (
Pico_Tasks_Demo) driving the onboard LED - 1 protected object (
Tasks.Pobj) used for thread-safe shared state
Behavior:
TAincrementsCounter_Aevery 30 msTBincrementsCounter_Bevery 70 ms- Main loop calls
Get_Led_Periodon the protected object Get_Led_PeriodreturnsMilliseconds (Counter_A + Counter_B)
Because Get_Led_Period is a protected operation, it is safe to call from the main thread while both tasks are updating counters concurrently.
You must have the following tools installed and available on your PATH:
alr— Alire (Ada package manager / build orchestrator)elf2uf2— needed when generating.uf2for drag-and-drop flashing via the Pico mass-storage interface
Managed by Alire:
rp2040_hal = ^2.6.0pico_bsp = ^2.2.0light_tasking_rp2040 = *
From the repository root:
alr buildExpected output from alr build:
bin/pico_tasks_demo(ELF)
To create a UF2 image for drag-and-drop flashing, run elf2uf2 explicitly:
elf2uf2 bin/pico_tasks_demo bin/pico_tasks_demo.uf2- Hold BOOTSEL while plugging in the Pico.
- The board mounts as a USB mass-storage device (typically
RPI-RP2). - Copy
bin/pico_tasks_demo.uf2to that mounted volume. - The board reboots automatically and starts the demo.
The LED starts blinking fast, then slows down over time. Each loop uses a bigger delay than the last one.