-
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 pull request 'Start adding embassy example' (#24) from add-emba…
…ssy-example into main Reviewed-on: https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/pulls/24
- Loading branch information
Showing
25 changed files
with
721 additions
and
46 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
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,25 @@ | ||
VA416xx Example Applications | ||
======== | ||
|
||
This folder contains various examples | ||
Consult the main README first for setup of the repository. | ||
|
||
## Simple examples | ||
|
||
```rs | ||
cargo run --example blinky | ||
``` | ||
|
||
You can have a look at the `simple/examples` folder to see all available simple examples | ||
|
||
## RTIC example | ||
|
||
```rs | ||
cargo run --bin rtic-example | ||
``` | ||
|
||
## Embassy example | ||
|
||
```rs | ||
cargo run --bin embassy-example | ||
``` |
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,40 @@ | ||
[package] | ||
name = "embassy-example" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
cortex-m = { version = "0.7", features = ["critical-section-single-core"] } | ||
cortex-m-rt = "0.7" | ||
embedded-hal = "1" | ||
|
||
rtt-target = { version = "0.5" } | ||
panic-rtt-target = { version = "0.1" } | ||
critical-section = "1" | ||
|
||
embassy-sync = { version = "0.6.0" } | ||
embassy-time = { version = "0.3.2" } | ||
embassy-time-driver = { version = "0.1" } | ||
|
||
[dependencies.once_cell] | ||
version = "1" | ||
default-features = false | ||
features = ["critical-section"] | ||
|
||
[dependencies.embassy-executor] | ||
version = "0.6.0" | ||
features = [ | ||
"arch-cortex-m", | ||
"executor-thread", | ||
"executor-interrupt", | ||
"integrated-timers", | ||
] | ||
|
||
[dependencies.va416xx-hal] | ||
path = "../../va416xx-hal" | ||
features = ["va41630"] | ||
|
||
[features] | ||
default = ["ticks-hz-1_000"] | ||
ticks-hz-1_000 = ["embassy-time/tick-hz-1_000"] | ||
ticks-hz-32_768 = ["embassy-time/tick-hz-32_768"] |
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,4 @@ | ||
#![no_std] | ||
pub mod time_driver; | ||
|
||
pub use time_driver::init; |
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,46 @@ | ||
#![no_std] | ||
#![no_main] | ||
use embassy_executor::Spawner; | ||
use embassy_time::{Duration, Instant, Ticker}; | ||
use embedded_hal::digital::StatefulOutputPin; | ||
use panic_rtt_target as _; | ||
use rtt_target::{rprintln, rtt_init_print}; | ||
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 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(); | ||
// Safety: Only called once here. | ||
unsafe { | ||
embassy_example::init( | ||
&mut dp.sysconfig, | ||
&dp.irq_router, | ||
dp.tim15, | ||
dp.tim14, | ||
&clocks, | ||
) | ||
}; | ||
let portg = PinsG::new(&mut dp.sysconfig, dp.portg); | ||
let mut led = portg.pg5.into_readable_push_pull_output(); | ||
let mut ticker = Ticker::every(Duration::from_secs(1)); | ||
loop { | ||
ticker.next().await; | ||
rprintln!("Current time: {}", Instant::now().as_secs()); | ||
led.toggle().ok(); | ||
} | ||
} |
Oops, something went wrong.