new blinky example, cargo.toml update
This commit is contained in:
parent
87b0180e6f
commit
0bc7e0f341
@ -36,10 +36,15 @@ debug = true
|
|||||||
lto = false
|
lto = false
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
# Problematic because RTT won't work
|
||||||
|
lto = false
|
||||||
debug = true
|
debug = true
|
||||||
opt-level = "s"
|
opt-level = "s"
|
||||||
|
|
||||||
|
[profile.release-lto]
|
||||||
|
inherits = "release"
|
||||||
|
lto = true
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "timer-ticks"
|
name = "timer-ticks"
|
||||||
required-features = ["rt"]
|
required-features = ["rt"]
|
||||||
|
48
examples/blinky-pac.rs
Normal file
48
examples/blinky-pac.rs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
//! Blinky examples using only the PAC
|
||||||
|
//!
|
||||||
|
//! Additional note on LEDs:
|
||||||
|
//! Pulling the GPIOs low makes the LEDs blink. See REB1
|
||||||
|
//! schematic for more details.
|
||||||
|
#![no_main]
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
|
use cortex_m_rt::entry;
|
||||||
|
use panic_halt as _;
|
||||||
|
use va108xx as pac;
|
||||||
|
|
||||||
|
// REB LED pin definitions. All on port A
|
||||||
|
const LED_D2: u32 = 1 << 10;
|
||||||
|
const LED_D3: u32 = 1 << 7;
|
||||||
|
const LED_D4: u32 = 1 << 6;
|
||||||
|
|
||||||
|
#[entry]
|
||||||
|
fn main() -> ! {
|
||||||
|
let dp = pac::Peripherals::take().unwrap();
|
||||||
|
// Enable all peripheral clocks
|
||||||
|
dp.SYSCONFIG
|
||||||
|
.peripheral_clk_enable
|
||||||
|
.modify(|_, w| unsafe { w.bits(0xffffffff) });
|
||||||
|
dp.PORTA
|
||||||
|
.dir()
|
||||||
|
.modify(|_, w| unsafe { w.bits(LED_D2 | LED_D3 | LED_D4) });
|
||||||
|
dp.PORTA
|
||||||
|
.datamask()
|
||||||
|
.modify(|_, w| unsafe { w.bits(LED_D2 | LED_D3 | LED_D4) });
|
||||||
|
for _ in 0..10 {
|
||||||
|
dp.PORTA
|
||||||
|
.clrout()
|
||||||
|
.write(|w| unsafe { w.bits(LED_D2 | LED_D3 | LED_D4) });
|
||||||
|
cortex_m::asm::delay(5_000_000);
|
||||||
|
dp.PORTA
|
||||||
|
.setout()
|
||||||
|
.write(|w| unsafe { w.bits(LED_D2 | LED_D3 | LED_D4) });
|
||||||
|
cortex_m::asm::delay(5_000_000);
|
||||||
|
}
|
||||||
|
loop {
|
||||||
|
dp.PORTA
|
||||||
|
.togout()
|
||||||
|
.write(|w| unsafe { w.bits(LED_D2 | LED_D3 | LED_D4) });
|
||||||
|
cortex_m::asm::delay(25_000_000);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user