aboutsummaryrefslogtreecommitdiffstats
path: root/src-riscv/main.rs
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2022-10-29 21:48:07 -0400
committerBrian Cully <bjc@kublai.com>2022-10-29 21:48:07 -0400
commitfc0d9fe0e73348e5599bbc232c7dbf4f98d65ea5 (patch)
treeb80eb240bd430ed5213ba0536508a68b2757cccf /src-riscv/main.rs
parent06fa7f990885ec17220df66094cbe6663719a4da (diff)
downloadluchie-fc0d9fe0e73348e5599bbc232c7dbf4f98d65ea5.tar.gz
luchie-fc0d9fe0e73348e5599bbc232c7dbf4f98d65ea5.zip
riscv: remove code
all previous functionality has been replicated, and the code lives in a branch anyway.
Diffstat (limited to 'src-riscv/main.rs')
-rwxr-xr-xsrc-riscv/main.rs215
1 files changed, 0 insertions, 215 deletions
diff --git a/src-riscv/main.rs b/src-riscv/main.rs
deleted file mode 100755
index 68fa8da..0000000
--- a/src-riscv/main.rs
+++ /dev/null
@@ -1,215 +0,0 @@
-#![no_std]
-#![no_main]
-
-mod blink;
-mod led;
-mod log;
-mod usb;
-
-// use gd32vf103xx_hal as hal;
-use stm32f30x_hal as hal;
-
-use hal::{
- afio::AfioExt,
- eclic::{self, EclicExt},
- gpio::GpioExt,
- pac::{self, Peripherals},
- rcu::RcuExt,
- serial::Serial,
- time::{Hertz, MegaHertz},
- timer::Timer,
-};
-use riscv::{
- asm::wfi,
- interrupt,
-};
-use riscv_rt::entry;
-use usb_device::prelude::*;
-
-use led::LED;
-use usb::{USB, UsbBus};
-
-static mut EP_MEMORY: [u32; 1024] = [0; 1024];
-
-#[entry]
-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()
- .ext_hf_clock(MegaHertz(8))
- .sysclk(MegaHertz(96))
- .freeze();
- let mut afio = p.AFIO.constrain(&mut rcu);
- let gpioa = p.GPIOA.split(&mut rcu);
-
- // TODO: figure out how to use the usb serial on the start board.
- //
- // this version has to be wired up physically.
- let serial = Serial::new(
- p.USART1,
- (gpioa.pa2, gpioa.pa3),
- Default::default(),
- &mut afio,
- &mut rcu,
- );
- let (tx, _rx) = serial.split();
- log::init(tx);
- logln!("luchie starting");
-
- 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);
-
- let usb = USB {
- usb_global: p.USBFS_GLOBAL,
- usb_device: p.USBFS_DEVICE,
- usb_pwrclk: p.USBFS_PWRCLK,
- pin_dm: gpioa.pa11,
- pin_dp: gpioa.pa12,
- hclk: rcu.clocks.hclk()
- };
- logln!("hclk: {:?}", rcu.clocks.hclk().0);
-
- let usb_bus = UsbBus::new(usb, unsafe { &mut EP_MEMORY });
-
- let mut usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(0x16c0, 0x27dd))
- .manufacturer("Fake company")
- .product("Enumeration test")
- .serial_number("TEST")
- .device_class(0)
- .build();
-
- //let mut serial = SerialPort::new(&bus_alloc);
-
- unsafe { interrupt::enable() };
-
- loop {
- let mut can_sleep = true;
-
- if let Ok(_) = blink.poll() {
- can_sleep = false;
- }
- if usb_dev.poll(&mut []) {
- logln!("usb");
- can_sleep = false;
- }
-
- if can_sleep && false {
- log!("!");
- unsafe { wfi() };
- }
- }
-}
-#[export_name="ExceptionHandler"]
-fn exception_handler(_frame: &riscv_rt::TrapFrame) -> ! {
- spin();
-}
-
-#[export_name="DefaultHandler"]
-fn default_handler() -> ! {
- spin();
-}
-
-#[export_name="MachineTimer"]
-fn machine_timer() {
- spin();
-}
-
-#[panic_handler]
-fn panic(info: &core::panic::PanicInfo) -> ! {
- interrupt::free(|_cs| {
- log!("!!! panic ");
- if let Some(loc) = info.location() {
- log!("in {}:{} ", loc.file(), loc.line());
- }
- if let Some(msg) = info.payload().downcast_ref::<&str>() {
- log!("⇒ {} ", msg);
- }
- logln!("!!!");
- });
- spin();
-}
-
-fn spin() -> ! {
- loop { unsafe { wfi() } };
-}
-
-/*
-#![no_std]
-#![no_main]
-
-mod usb;
-
-use riscv::asm::wfi;
-use riscv_rt::entry;
-use gd32vf103xx_hal::prelude::*;
-use gd32vf103xx_hal::pac;
-
-use usb::{USB, UsbBus};
-use usb_device::prelude::*;
-use usbd_serial::SerialPort;
-
-static mut EP_MEMORY: [u32; 1024] = [0; 1024];
-
-#[entry]
-fn main() -> ! {
- let dp = pac::Peripherals::take().unwrap();
-
- // Configure clocks
- let mut rcu = dp.RCU.configure()
- .ext_hf_clock(8.mhz())
- .sysclk(96.mhz())
- .freeze();
-
- assert!(rcu.clocks.usbclk_valid());
-
- let gpioa = dp.GPIOA.split(&mut rcu);
- let usb = USB {
- usb_global: dp.USBFS_GLOBAL,
- usb_device: dp.USBFS_DEVICE,
- usb_pwrclk: dp.USBFS_PWRCLK,
- pin_dm: gpioa.pa11,
- pin_dp: gpioa.pa12,
- hclk: rcu.clocks.hclk()
- };
-
- let usb_bus = UsbBus::new(usb, unsafe { &mut EP_MEMORY });
-
- let mut serial = SerialPort::new(&usb_bus);
- let mut usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(0x16c0, 0x27dd))
- .manufacturer("Fake company")
- .product("Enumeration test")
- .serial_number("TEST")
- .device_class(0)
- .build();
-
- loop {
- if usb_dev.poll(&mut [&mut serial]) {
- }
- }
-}
-
-#[panic_handler]
-fn panic(info: &core::panic::PanicInfo) -> ! {
-// interrupt::free(|_cs| {
-// log!("!!! panic ");
- if let Some(loc) = info.location() {
-// log!("in {}:{} ", loc.file(), loc.line());
- }
- if let Some(msg) = info.payload().downcast_ref::<&str>() {
-// log!("⇒ {} ", msg);
- }
-// logln!("!!!");
-// });
- spin();
-}
-
-fn spin() -> ! {
- loop { unsafe { wfi() } };
-}
-*/