Skip to content

Instantly share code, notes, and snippets.

synack@polar ~/src/ravenscar_full_rp2040((HEAD detached at 4176e8f)) $ ls -al links/ | head -n 30
total 60
drwxr-xr-x 2 synack synack 53248 May 1 12:04 .
drwxr-xr-x 15 synack synack 4096 May 1 12:04 ..
lrwxrwxrwx 1 synack synack 15 May 1 12:04 ada.ads -> ../gnat/ada.ads
lrwxrwxrwx 1 synack synack 20 May 1 12:04 ada-assertions.adb -> ../gnat/a-assert.adb
lrwxrwxrwx 1 synack synack 20 May 1 12:04 ada-assertions.ads -> ../gnat/a-assert.ads
lrwxrwxrwx 1 synack synack 20 May 1 12:04 ada-calendar.adb -> ../gnat/a-calend.adb
lrwxrwxrwx 1 synack synack 20 May 1 12:04 ada-calendar.ads -> ../gnat/a-calend.ads
lrwxrwxrwx 1 synack synack 20 May 1 12:04 ada-calendar-control.adb -> ../gnat/a-calcon.adb
@JeremyGrosser
JeremyGrosser / _arp.ads
Created November 2, 2022 23:48
ARP Packet Parser
with HAL; use HAL;
package ARP is
type Packet
(HLEN, PLEN : Natural)
is record
HTYPE : UInt16;
PTYPE : UInt16;
OPER : UInt16;
@JeremyGrosser
JeremyGrosser / ada-on-the-raspberrypi-rp2040.md
Created July 24, 2022 01:49
Ada on the Raspberry Pi RP2040

Ada on the Raspberry Pi RP2040

Jeremy Grosser: This is Ada on the Raspberry Pi RP 2040. So this is a Raspberry Pi Pico it's a development board fits nicely on a breadboard, got a USB port, L E D that sort of thing. This talk's mostly about the RP 2040, which is that chip in the middle there. It's Raspberry Pi's is first inhouse silicon. It's got all the sort of serial peripherals and things you expect. It's got some fancy stuff like the PIO we'll talk about in a bit.

So let's say you wanna program this chip. Most people would just go and use their C SDK or maybe micro Python. I like doing things the hard way. So I'm gonna program it in Ada and that means starting from scratch. So you go to the data sheet and you find a page like this, and you know, you've got a base address at the top there, and these are a bunch of offsets.

These are all memory locations, you know, reading and writing from them has different side effects. So for example, this register writing to it will set an output high or low dep

with Ada.Text_IO; use Ada.Text_IO;
procedure Test is
type UInt16 is mod 2 ** 16
with Size => 16;
type UInt32 is mod 2 ** 32
with Size => 32;
type Words is array (Positive range <>) of UInt16
with Component_Size => 16;
synack@polar ~/build/hal(master) $ cat hal.gpr
project HAL is
for Source_Dirs use ("src");
for Library_Name use "hal";
for Object_Dir use "obj";
for Library_Dir use "lib";
for Library_Kind use "static";
@JeremyGrosser
JeremyGrosser / printer-ultimaker-original-1.5.6.cfg
Created January 24, 2022 00:19
Klipper config for Ultimaker Original 1.5.6
# This file contains common pin mappings for Ultimaker Original with the v1.5.6
# board. To use this config, the firmware should be compiled for the AVR
# atmega2560.
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
step_pin: PA3
dir_pin: !PA1
enable_pin: !PA5
with "config/hello_pico_config.gpr";
with "pico_bsp.gpr";
project Hello_Pico is
for Target use "arm-eabi";
for Runtime ("Ada") use "zfp-cortex-m0p";
package Linker is
for Switches ("Ada") use Pico_BSP.Linker_Switches;
end Linker;
Linux version 5.10.0-7-cloud-arm64 (debian-kernel@lists.debian.org) (gcc-10 (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2) #
1 SMP Debian 5.10.40-1 (2021-05-28)
root@ip-10-0-1-183:/home/admin# kexec -l /boot/vmlinuz-5.10.0-8-cloud-arm64 --initrd=/boot/initrd.img-5.10.0-8-cloud-arm64 --append="$(cat /proc/cmdline)"
root@ip-10-0-1-183:/home/admin# kexec -e
@JeremyGrosser
JeremyGrosser / main.adb
Created May 25, 2021 23:54
Nested generic procedures in Ada
procedure Main is
generic
type A_Type is private;
procedure Outer (A : A_Type);
procedure Outer (A : A_Type) is
generic
type B_Type is private;
procedure Inner (A : A_Type; B : B_Type);