In my last post I said that I seemed to have accidentally set off interrupt triggers by writing to the wrong bits of a register. It got me to wondering whether something like Ada might be a better bet. I guess Rust might be an an interesting alternative, but I couldn’t get a successful compile for the Pico.
I’m running Debian Stable, and I’m suspecting that the Ada compiler might be a little old. So I used a more recent version which I downloaded from AdaCore.
I think you also need a utility called “alire”, the Ada Library Repository. I’m a bit hazy of the details, and how I got the whole thing working. Here is a simple blink sketch:
-- -- Copyright 2021 (C) Jeremy Grosser -- -- SPDX-License-Identifier: BSD-3-Clause -- with RP.Device; with RP.Clock; with RP.GPIO; with Pico; procedure Main is begin RP.Clock.Initialize (Pico.XOSC_Frequency); Pico.LED.Configure (RP.GPIO.Output); RP.Device.Timer.Enable; loop Pico.LED.Set; RP.Device.Timer.Delay_Milliseconds (100); Pico.LED.Clear; RP.Device.Timer.Delay_Milliseconds (900); end loop; end Main;
You can find my set-up here. It uses a Makefile, which I prefer. The GNAT Programming Studio that comes with Debian seems quite snappy, but as I already said, the project doesn’t seem to build for whatever reason.
The Pico libraries are described in further detail in Jeremy Grosser’s blog.
I’ve nothing insightful add, as I’m completely new to Ada myself. I just thought it was worthwhile giving an interesting-looking project a bit of publicity.
Update 2021-07-15: I tried to get tasks working, but it appears to be an unsupported feature for the Pico. Hmmm, that’s disappointing. That removes much of the attraction of Ada for me. I have also found out today that C supports bit-fields. C++ definitely does.You’d think that feature would be heavily used in embedded systems, but I’m not aware of any library that does. That might be worth playing around with to see if it makes things a tad easier.