aboutsummaryrefslogtreecommitdiffstats
path: root/src/led.rs
diff options
context:
space:
mode:
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 {