Your First Program
The simplest useful Flint program on current hardware support is an RP2040 LED blink.
This version uses the HAL-facing modules instead of raw register writes:
use micro/gpio
use time/delay
fn main() {
let builtin_led = gpio.builtin_led()
if builtin_led.is_none() {
return
}
if let Option.Some(led) = builtin_led {
loop {
led.toggle()
delay.millis(500)
}
}
}
What To Notice
useimports modules with explicit paths.fn main()is a normal function. There is no hidden runtime wrapper in the language syntax.letis immutable by default.is_none()makes the missing-hardware guard obvious up front.loopis the simplest infinite loop form.- Method calls such as
led.toggle()are ordinary Flint syntax, not macros.
About builtin_led()
Flint also exposes gpio.builtin_led() as a convenience API, but it returns Option<gpio.OutputPin> because not every board has a direct GPIO-backed onboard LED.
Use it when you want a helper and are prepared to handle the missing case:
let builtin_led = gpio.builtin_led()
if builtin_led.is_none() {
return
}
if let Option.Some(led) = builtin_led {
led.toggle()
}
This keeps the missing-hardware case explicit in the source without pushing the main path deeper to the right.
A Slightly Lower-Level Version
Flint can also target the hardware more directly when needed. The repository includes examples that use unsafe and volatile_write to configure GPIO on the RP2040 without going through a higher-level HAL abstraction.
That is an important part of Flint’s design: higher-level APIs should exist, but they should not block you from reaching the machine when necessary.