diff options
Diffstat (limited to 'src/led.rs')
-rw-r--r-- | src/led.rs | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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 { |