aboutsummaryrefslogtreecommitdiffstats
path: root/src/led.rs
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2022-08-06 12:12:37 -0400
committerBrian Cully <bjc@kublai.com>2022-08-06 12:12:37 -0400
commit35248b205cd56633e52b9e634a942e7fd987db0b (patch)
tree37c9fd21e52e7cb0a7c547065a52d73d19d925b9 /src/led.rs
parent8f9bc49bb40e2972cf0c0bf1b61eb8127a9397df (diff)
downloadluchie-35248b205cd56633e52b9e634a942e7fd987db0b.tar.gz
luchie-35248b205cd56633e52b9e634a942e7fd987db0b.zip
Blinky on a hardware timer, with ‘wfi’ in between.
Diffstat (limited to 'src/led.rs')
-rw-r--r--src/led.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/led.rs b/src/led.rs
index d8d9912..951a32e 100644
--- a/src/led.rs
+++ b/src/led.rs
@@ -1,21 +1,23 @@
use gd32vf103_pac::Peripherals;
+#[derive(Clone, Copy)]
pub struct LED();
impl LED {
- pub fn new(peripherals: &Peripherals) -> Self {
- peripherals.RCU.apb2en.write(|w| {
+ pub fn new() -> Self {
+ let peripherals = unsafe { Peripherals::steal() };
+ peripherals.RCU.apb2en.modify(|_, w| {
w.paen().set_bit()
});
- peripherals.GPIOA.ctl0.write(|w| unsafe {
+ peripherals.GPIOA.ctl0.modify(|_, w| unsafe {
// output mode, push-pull
w.ctl7().bits(0b00);
// 50 mhz output rate
w.md7().bits(0b11);
w
});
- Self {}
+ Self()
}
pub fn is_on(&self) -> bool {