-
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.
Merge branch 'add-embassy-example' of egit.irs.uni-stuttgart.de:rust/…
…va416xx-rs into add-embassy-example
- Loading branch information
Showing
5 changed files
with
194 additions
and
63 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
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 |
---|---|---|
@@ -1,23 +1,36 @@ | ||
#![no_std] | ||
#![no_main] | ||
use cortex_m::asm; | ||
use embassy_executor::Spawner; | ||
use embassy_time::Timer; | ||
use embedded_hal::digital::StatefulOutputPin; | ||
use panic_rtt_target as _; | ||
use rtt_target::{rprintln, rtt_init_print}; | ||
use va416xx_hal::{gpio::PinsG, pac}; | ||
use va416xx_hal::{gpio::PinsG, pac, prelude::*, time::Hertz}; | ||
|
||
const EXTCLK_FREQ: u32 = 40_000_000; | ||
|
||
// main is itself an async function. | ||
#[embassy_executor::main] | ||
async fn main(_spawner: Spawner) { | ||
rtt_init_print!(); | ||
rprintln!("VA416xx RTT Demo"); | ||
rprintln!("VA416xx Embassy Demo"); | ||
|
||
let mut dp = pac::Peripherals::take().unwrap(); | ||
|
||
// Initialize the systick interrupt & obtain the token to prove that we did | ||
// Use the external clock connected to XTAL_N. | ||
let clocks = dp | ||
.clkgen | ||
.constrain() | ||
.xtal_n_clk_with_src_freq(Hertz::from_raw(EXTCLK_FREQ)) | ||
.freeze(&mut dp.sysconfig) | ||
.unwrap(); | ||
embassy_example::init(&mut dp.sysconfig, dp.tim15, dp.tim14, &clocks); | ||
let portg = PinsG::new(&mut dp.sysconfig, dp.portg); | ||
let mut led = portg.pg5.into_readable_push_pull_output(); | ||
loop { | ||
Timer::after_millis(200).await; | ||
Timer::after_millis(2000).await; | ||
led.toggle().ok(); | ||
} | ||
} |
Oops, something went wrong.