mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2024-12-26 05:51:30 +11:00
58 lines
1.3 KiB
Rust
58 lines
1.3 KiB
Rust
|
//! Blinks the LED on a VCC-GND Studio YD-RP2040 board
|
||
|
//!
|
||
|
//! This will blink on-board LED.
|
||
|
#![no_std]
|
||
|
#![no_main]
|
||
|
|
||
|
use embedded_hal::digital::v2::OutputPin;
|
||
|
use embedded_time::rate::*;
|
||
|
use panic_halt as _;
|
||
|
use vcc_gnd_yd_rp2040::entry;
|
||
|
use vcc_gnd_yd_rp2040::{
|
||
|
hal::{
|
||
|
clocks::{init_clocks_and_plls, Clock},
|
||
|
pac,
|
||
|
watchdog::Watchdog,
|
||
|
Sio,
|
||
|
},
|
||
|
Pins, XOSC_CRYSTAL_FREQ,
|
||
|
};
|
||
|
|
||
|
#[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(
|
||
|
XOSC_CRYSTAL_FREQ,
|
||
|
pac.XOSC,
|
||
|
pac.CLOCKS,
|
||
|
pac.PLL_SYS,
|
||
|
pac.PLL_USB,
|
||
|
&mut pac.RESETS,
|
||
|
&mut watchdog,
|
||
|
)
|
||
|
.ok()
|
||
|
.unwrap();
|
||
|
|
||
|
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().integer());
|
||
|
|
||
|
let sio = Sio::new(pac.SIO);
|
||
|
let pins = Pins::new(
|
||
|
pac.IO_BANK0,
|
||
|
pac.PADS_BANK0,
|
||
|
sio.gpio_bank0,
|
||
|
&mut pac.RESETS,
|
||
|
);
|
||
|
let mut led_pin = pins.led.into_push_pull_output();
|
||
|
|
||
|
loop {
|
||
|
led_pin.set_high().unwrap();
|
||
|
delay.delay_ms(1500);
|
||
|
led_pin.set_low().unwrap();
|
||
|
delay.delay_ms(1500);
|
||
|
}
|
||
|
}
|