-
Notifications
You must be signed in to change notification settings - Fork 2
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
5c7269c
commit 261b79f
Showing
6 changed files
with
475 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
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,38 @@ | ||
#![deny(unsafe_code)] | ||
#![no_std] | ||
#![no_main] | ||
|
||
use panic_halt as _; | ||
|
||
use embassy_executor::{self, Spawner}; | ||
use embassy_time::Timer; | ||
use embedded_hal::digital::OutputPin; | ||
use gd32f1x0_hal::{embassy, pac, prelude::*}; | ||
|
||
#[embassy_executor::task] | ||
async fn blink_task(mut led: impl OutputPin + 'static) { | ||
loop { | ||
Timer::after_millis(1_000).await; | ||
led.set_high().unwrap(); | ||
Timer::after_millis(1_000).await; | ||
led.set_low().unwrap(); | ||
} | ||
} | ||
|
||
#[embassy_executor::main] | ||
async fn main(spawner: Spawner) { | ||
let p = pac::Peripherals::take().unwrap(); | ||
let mut rcu = p.rcu.constrain(); | ||
let mut flash = p.fmc.constrain(); | ||
let clocks = rcu.cfgr.freeze(&mut flash.ws); | ||
|
||
embassy::init(p.timer1, &clocks, &mut rcu.apb1); | ||
|
||
let mut gpioc = p.gpioc.split(&mut rcu.ahb); | ||
let led = gpioc | ||
.pc13 | ||
.into_push_pull_output(&mut gpioc.config) | ||
.downgrade(); | ||
|
||
spawner.must_spawn(blink_task(led)); | ||
} |
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,9 @@ | ||
use time_driver::{Bus, EmbassyTimeDriver, Timer}; | ||
|
||
use crate::rcu::Clocks; | ||
|
||
mod time_driver; | ||
|
||
pub fn init(timer: Timer, clocks: &Clocks, apb: &mut Bus) { | ||
EmbassyTimeDriver::init(timer, clocks, apb) | ||
} |
Oops, something went wrong.