Skip to content

Commit b7904b1

Browse files
committed
put back blinky
1 parent 1004efc commit b7904b1

File tree

6 files changed

+253
-112
lines changed

6 files changed

+253
-112
lines changed

platforms/allwinner-d1/boards/src/bin/lichee-rv.rs

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ extern crate alloc;
66
use core::time::Duration;
77
use mnemos_d1_core::{
88
dmac::Dmac,
9-
drivers::{spim::kernel_spim1, twi, uart::kernel_uart},
9+
drivers::{spim::kernel_spim1, twi, uart::kernel_uart, gpio},
1010
plic::Plic,
1111
timer::Timers,
1212
Ram, D1,
@@ -33,36 +33,26 @@ fn main() -> ! {
3333
let dmac = Dmac::new(p.DMAC, &mut p.CCU);
3434
let plic = Plic::new(p.PLIC);
3535

36-
p.GPIO.pc_cfg0.modify(|_r, w| {
37-
w.pc1_select().output();
38-
w
39-
});
40-
p.GPIO.pc_dat.modify(|_r, w| {
41-
w.pc_dat().variant(0b0000_0010);
42-
w
43-
});
44-
4536
let d1 = D1::initialize(timers, uart, spim, dmac, plic, i2c0, p.GPIO).unwrap();
4637

4738
d1.initialize_sharp_display();
4839

49-
// // Initialize LED loop
50-
// d1.kernel
51-
// .initialize(async move {
52-
// loop {
53-
// p.GPIO.pc_dat.modify(|_r, w| {
54-
// w.pc_dat().variant(0b0000_0010);
55-
// w
56-
// });
57-
// d1.kernel.sleep(Duration::from_millis(250)).await;
58-
// p.GPIO.pc_dat.modify(|_r, w| {
59-
// w.pc_dat().variant(0b0000_0000);
60-
// w
61-
// });
62-
// d1.kernel.sleep(Duration::from_millis(250)).await;
63-
// }
64-
// })
65-
// .unwrap();
40+
// Initialize LED loop
41+
d1.kernel
42+
.initialize(async move {
43+
let mut pin = {
44+
let mut gpio = gpio::GpioClient::from_registry(d1.kernel).await;
45+
gpio.claim_output(gpio::PinC::C1).await.expect("can't claim C1 as output!")
46+
};
47+
loop {
48+
pin.set(true);
49+
d1.kernel.sleep(Duration::from_millis(250)).await;
50+
pin.set(false);
51+
d1.kernel.sleep(Duration::from_millis(250)).await;
52+
}
53+
})
54+
.unwrap();
55+
6656

6757
d1.run()
6858
}

platforms/allwinner-d1/boards/src/bin/mq-pro.rs

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use core::time::Duration;
77
use mnemos_beepy::i2c_puppet::{HsvColor, I2cPuppetClient, I2cPuppetServer};
88
use 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

Comments
 (0)