generated from sivakov512/rp2040-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c459db3
commit f1c1d94
Showing
3 changed files
with
64 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#![no_main] | ||
#![no_std] | ||
|
||
use rp_pico as bsp; | ||
|
||
use bsp::entry; | ||
use defmt_rtt as _; | ||
use panic_probe as _; | ||
|
||
use bsp::hal::{ | ||
clocks::{init_clocks_and_plls, Clock}, | ||
pac, | ||
sio::Sio, | ||
watchdog::Watchdog, | ||
}; | ||
use defmt::info; | ||
use embedded_hal::digital::v2::OutputPin; | ||
|
||
const DELAY_MS: u32 = 2_000; | ||
|
||
#[entry] | ||
fn main() -> ! { | ||
info!("Running toggle_pin program"); | ||
|
||
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); | ||
|
||
let clocks = init_clocks_and_plls( | ||
bsp::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().to_Hz()); | ||
|
||
let pins = bsp::Pins::new( | ||
pac.IO_BANK0, | ||
pac.PADS_BANK0, | ||
sio.gpio_bank0, | ||
&mut pac.RESETS, | ||
); | ||
|
||
let mut pin = pins.gpio15.into_push_pull_output(); | ||
|
||
let mut state = false; | ||
loop { | ||
info!("Toogle pin"); | ||
|
||
state = !state; | ||
pin.set_state(state.into()).unwrap(); | ||
|
||
delay.delay_ms(DELAY_MS); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters