Announcing rp2040_hal 1.0
rp2040_hal is a library of drivers for the Raspberry Pi RP2040 microcontroller written in Ada.
It’s been 11 months since the first Ada code running on an RP2040 blinked an LED. In that time, rp2040_hal has grown considerably, with support for a veritable alphabet soup of peripherals; UART, SPI, I2C, USB, DMA, PWM, PIO, RTC, Timer, and ADC.
I’m pleased with the state of things and feel like rp2040_hal is a solid foundation for other projects to build upon. Up to this point, each release came with exciting new features and functionality. This release marks a new stage of development, where the focus is on providing bug fixes, performance improvements, and a stable API. In the words of Linus, "We do not break userspace."
Documentation
If you have questions about Ada, the RP2040, or just microcontrollers in general, come join the conversation at ada-lang/raspberrypi-pico on gitter.im. Gitter.im is available over Matrix if you’d prefer to bring your own chat client.
Demos
I often share what I’m working on via on Twitter @JeremyGrosser. I’ve embedded some tweets about my RP2040 Ada projects below.
I needed to charge some NiMH batteries but I was worried they'd overheat. Only took an hour to build a nice little temperature monitor! pic.twitter.com/pcJXoAt8yk
— Jeremy Grosser (@JeremyGrosser) October 5, 2021
I've got working bitmap tiles on the Picosystem now. I went with 2-bit 8x8 bitmaps, with switchable color palettes, similar to the Game Boy. pic.twitter.com/Gv68XG2t4N
— Jeremy Grosser (@JeremyGrosser) November 10, 2021
— Jeremy Grosser (@JeremyGrosser) December 7, 2021
Finally remembered why I started messing with microcontrollers to begin with... Behold, my three timezone NTP clock. pic.twitter.com/IHoCbUhm1n
— Jeremy Grosser (@JeremyGrosser) October 19, 2021
Lookin pretty good! pic.twitter.com/HKvWuzVCGr
— Jeremy Grosser (@JeremyGrosser) December 23, 2021
Pretty happy with how my portable Pico dev kit is turning out. Still need to 3d print a mount for the battery and make some shorter wires. pic.twitter.com/a3LFRChFwn
— Jeremy Grosser (@JeremyGrosser) June 22, 2021
SPI debugging means I get to use *all the channels* pic.twitter.com/ntIMNSBKRd
— Jeremy Grosser (@JeremyGrosser) June 25, 2021
Adding a serial command line to the #RaspberryPi #Pico in #Adahttps://t.co/jxJ9FGGTjZ
— Jeremy Grosser (@JeremyGrosser) July 18, 2021
Update: I blew up my microcontroller.
— Jeremy Grosser (@JeremyGrosser) July 5, 2021
I built it on a breadboard. This is gonna work. pic.twitter.com/y3WteQgFAH
— Jeremy Grosser (@JeremyGrosser) September 26, 2021
Changelog 1.0.0
New features
DMA IRQ management
RP.DMA
can now configure interrupt masks for each DMA channel. If DMA_Configuration.Quiet = False
, the interrupt will fire when a transfer is completed.
Unit tests
We’ve begun writing tests for rp2040_hal with the AUnit Testing Framework. Currently, there are tests for Clock, UART, SPI, GPIO, and DMA. These tests have already led to several bug fixes and we will continue to work toward more complete unit test coverage.
Bugs fixed
GPIO.Mode returned incorrect values
GPIO.Mode was returning the mode of the wrong pin.
PWM divider edge cases
The minimum and maximum PWM divider values were calculated incorrectly. The calculation and constraints on RP.PWM.Divider
have been fixed.
RP.DMA.Status returned incorrect Transfers_Remaining
The DMA alias register layouts were incorrect. The only visible effect of this error was that RP.DMA.Status returned an incorrect value for Transfers_Remaining.
Some DMA triggers didn’t work
The DREQ register values did not have a representation clause specified, which caused triggers internal to the DMA peripheral (pacing timers and permanent triggers) to be nonfunctional.