@@ -7,7 +7,7 @@ use core::time::Duration;
77use mnemos_beepy:: i2c_puppet:: { HsvColor , I2cPuppetClient , I2cPuppetServer } ;
88use mnemos_d1_core:: {
99 dmac:: Dmac ,
10- drivers:: { spim:: kernel_spim1, twi, uart:: kernel_uart} ,
10+ drivers:: { spim:: kernel_spim1, twi, uart:: kernel_uart, gpio } ,
1111 plic:: Plic ,
1212 timer:: Timers ,
1313 Ram , D1 ,
@@ -33,35 +33,23 @@ fn main() -> ! {
3333 let timers = Timers :: new ( p. TIMER ) ;
3434 let dmac = Dmac :: new ( p. DMAC , & mut p. CCU ) ;
3535 let plic = Plic :: new ( p. PLIC ) ;
36-
37- p. GPIO . pd_cfg2 . modify ( |_r, w| {
38- w. pd18_select ( ) . output ( ) ;
39- w
40- } ) ;
41- p. GPIO . pd_dat . modify ( |_r, w| {
42- w. pd_dat ( ) . variant ( 1 << 18 ) ;
43- w
44- } ) ;
45-
4636 let d1 = D1 :: initialize ( timers, uart, spim, dmac, plic, i2c0, p. GPIO ) . unwrap ( ) ;
4737
48- // // Initialize LED loop
49- // d1.kernel
50- // .initialize(async move {
51- // loop {
52- // p.GPIO.pd_dat.modify(|_r, w| {
53- // w.pd_dat().variant(1 << 18);
54- // w
55- // });
56- // d1.kernel.sleep(Duration::from_millis(250)).await;
57- // p.GPIO.pd_dat.modify(|_r, w| {
58- // w.pd_dat().variant(0);
59- // w
60- // });
61- // d1.kernel.sleep(Duration::from_millis(250)).await;
62- // }
63- // })
64- // .unwrap();
38+ // Initialize LED loop
39+ d1. kernel
40+ . initialize ( async move {
41+ let mut pin = {
42+ let mut gpio = gpio:: GpioClient :: from_registry ( d1. kernel ) . await ;
43+ gpio. claim_output ( gpio:: PinD :: D18 ) . await . expect ( "can't claim D18 as output!" )
44+ } ;
45+ loop {
46+ pin. set ( true ) ;
47+ d1. kernel . sleep ( Duration :: from_millis ( 250 ) ) . await ;
48+ pin. set ( false ) ;
49+ d1. kernel . sleep ( Duration :: from_millis ( 250 ) ) . await ;
50+ }
51+ } )
52+ . unwrap ( ) ;
6553
6654 d1. initialize_sharp_display ( ) ;
6755
0 commit comments