pico-blinky/alt/simple-blink.rs

48 lines
1.1 KiB
Rust
Raw Permalink Normal View History

#![no_std]
#![no_main]
use cortex_m::delay::Delay;
use embedded_hal::digital::OutputPin;
use panic_halt as _;
use rp_pico::entry;
use rp_pico::hal::{clocks::init_clocks_and_plls, pac, watchdog::Watchdog, Clock, Sio};
#[entry]
fn main() -> ! {
let mut pac = pac::Peripherals::take().unwrap();
let core = pac::CorePeripherals::take().unwrap();
let mut watchdog = Watchdog::new(pac.WATCHDOG);
let clocks = init_clocks_and_plls(
rp_pico::XOSC_CRYSTAL_FREQ,
pac.XOSC,
pac.CLOCKS,
pac.PLL_SYS,
pac.PLL_USB,
&mut pac.RESETS,
&mut watchdog,
)
.ok()
.unwrap();
let mut delay = Delay::new(core.SYST, clocks.system_clock.freq().to_Hz());
let sio = Sio::new(pac.SIO);
let pins = rp_pico::Pins::new(
pac.IO_BANK0,
pac.PADS_BANK0,
sio.gpio_bank0,
&mut pac.RESETS,
);
let mut led = pins.led.into_push_pull_output();
loop {
led.set_high().unwrap();
delay.delay_ms(250);
led.set_low().unwrap();
delay.delay_ms(250);
}
}