aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rwxr-xr-xsrc/main.rs36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 6cb4139..19f2b7a 100755
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,15 +4,17 @@
mod blink;
mod led;
mod log;
+mod usb;
use gd32vf103xx_hal::{
afio::AfioExt,
eclic::{self, EclicExt},
+ exti::Exti,
gpio::GpioExt,
pac::{self, Peripherals},
rcu::RcuExt,
serial::Serial,
- time::Hertz,
+ time::{Hertz, MegaHertz},
timer::Timer,
};
use riscv::{
@@ -29,10 +31,11 @@ use led::LED;
fn main(_hartid: usize) -> ! {
let p = Peripherals::take().expect("couldn't take peripherals");
+ pac::ECLIC::reset();
pac::ECLIC::set_threshold_level(eclic::Level::L0);
pac::ECLIC::set_level_priority_bits(eclic::LevelPriorityBits::L3P1);
- let mut rcu = p.RCU.configure().freeze();
+ let mut rcu = p.RCU.configure().sysclk(MegaHertz(48)).freeze();
let mut afio = p.AFIO.constrain(&mut rcu);
let gpioa = p.GPIOA.split(&mut rcu);
@@ -49,22 +52,45 @@ fn main(_hartid: usize) -> ! {
let (tx, _rx) = serial.split();
log::init(tx);
- let timer = Timer::<pac::TIMER6>::timer6(p.TIMER6, Hertz(1), &mut rcu);
+ let timer = Timer::<pac::TIMER6>::timer6(p.TIMER6, Hertz(5), &mut rcu);
let led = LED::new(gpioa.pa7);
let mut blink = blink::Task::new(timer, Hertz(5), led);
+ logln!("+++ busabus");
+ let mut exti = Exti::new(p.EXTI);
+ let bus = usb::Bus::new(p.USBFS_GLOBAL, p.USBFS_DEVICE, p.USBFS_PWRCLK, &mut rcu, &mut exti);
+ bus.init();
+ // let bus_alloc = UsbBusAllocator::new(bus);
+ // logln!("+++ devadev");
+ // let mut usb_dev = UsbDeviceBuilder::new(&bus_alloc, UsbVidPid(0xdead, 0xbeef))
+ // .manufacturer("luchie")
+ // .product("pad")
+ // .serial_number("test")
+ // .build();
+ // logln!("+++ superserious");
+ //let mut serial = SerialPort::new(&bus_alloc);
+
+ unsafe { interrupt::enable() };
+
loop {
let mut can_sleep = true;
+ log!("yo");
if let Ok(_) = blink.poll() {
can_sleep = false;
}
- log!("yo!");
- logln!(" mtv raps");
+ log!(" mtv");
+ // was: usb_dev.poll(&mut [&mut serial])
+ // if usb_dev.poll(&mut []) {
+ // can_sleep = false;
+ // }
+ log!(" raps");
if can_sleep {
+ log!("!");
unsafe { wfi() };
}
+ logln!("");
}
}