Skip to content

Instantly share code, notes, and snippets.

@9names
Created January 15, 2026 09:41
Show Gist options
  • Select an option

  • Save 9names/473347c99bb63f005d1c6aaa8011210b to your computer and use it in GitHub Desktop.

Select an option

Save 9names/473347c99bb63f005d1c6aaa8011210b to your computer and use it in GitHub Desktop.
GPOUT on gpio25 on pico
#![no_std]
#![no_main]
use defmt::*;
use defmt_rtt as _;
use panic_probe as _;
use rp2040_hal::{
clocks::{init_clocks_and_plls, Clock},
entry,
gpio::FunctionClock,
pac,
sio::Sio,
timer::Timer,
watchdog::Watchdog,
};
use embedded_hal::delay::DelayNs;
use rp2040_hal as hal;
use rp2040_hal::fugit::RateExtU32;
#[link_section = ".boot2"]
#[used]
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GENERIC_03H;
#[entry]
fn main() -> ! {
info!("Program start");
let mut pac = pac::Peripherals::take().unwrap();
let _core = pac::CorePeripherals::take().unwrap();
let mut watchdog = Watchdog::new(pac.WATCHDOG);
let sio = Sio::new(pac.SIO);
// External high-speed crystal on the pico board is 12Mhz
let external_xtal_freq_hz = 12_000_000u32;
let mut clocks = init_clocks_and_plls(
external_xtal_freq_hz,
pac.XOSC,
pac.CLOCKS,
pac.PLL_SYS,
pac.PLL_USB,
&mut pac.RESETS,
&mut watchdog,
)
.ok()
.unwrap();
let pins = hal::gpio::Pins::new(
pac.IO_BANK0,
pac.PADS_BANK0,
sio.gpio_bank0,
&mut pac.RESETS,
);
let mut delay = Timer::new(pac.TIMER, &mut pac.RESETS, &clocks);
clocks
.gpio_output3_clock
.configure_clock(&clocks.system_clock, 8.Hz())
.unwrap();
let _led = pins
.gpio25
.into_push_pull_output()
.into_function::<FunctionClock>();
info!("all important logic is done, now we just output a square wave all day");
loop {
delay.delay_ms(500);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment