diff options
| author | Nathan Perry <np@nathanperry.dev> | 2024-09-22 09:14:21 -0400 |
|---|---|---|
| committer | Nathan Perry <np@nathanperry.dev> | 2024-09-22 09:14:31 -0400 |
| commit | 945052f34bb1f01f0ba0cb861350a885d8d82f43 (patch) | |
| tree | 1d818cd9dd13875df4043a8270331364e71f32fb /src/main.rs | |
| parent | ff3606c0d2d3f510ee6bca040e77de92ca5be529 (diff) | |
theoretically working firmware
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 102 |
1 files changed, 93 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs index ead8e00..3811101 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,16 +2,100 @@ #![no_main] #![feature(impl_trait_in_assoc_type)] -use molybdos::genlog::defmt; -use molybdos::reexports::*; +use molybdos::{ + embassy_embedded_hal::shared_bus::asynch::spi::SpiDevice, + embassy_rp::{ + i2c::{ + self, + I2c, + }, + peripherals::{ + I2C0, + SPI0, + SPI1, + }, + spi::{ + self, + Spi, + }, + }, + embassy_sync::{ + blocking_mutex::raw::CriticalSectionRawMutex, + pubsub, + }, + embedded_sdmmc_async::{ + VolumeIdx, + VolumeManager, + }, + genlog, + genlog::defmt, + pal::StaticOutput, +}; -#[defmt::panic_handler] -fn panic() -> ! { - panic_probe::hard_fault(); -} +mod bringup; +mod usb; + +pub type BMESpi = Spi<'static, SPI1, spi::Async>; +pub type BMESpiDev = SpiDevice<'static, CriticalSectionRawMutex, BMESpi, StaticOutput>; +pub type SdSpi = Spi<'static, SPI0, spi::Async>; +pub type SdSpiDev = SpiDevice<'static, CriticalSectionRawMutex, SdSpi, StaticOutput>; + +pub type SensorI2c = I2c<'static, I2C0, i2c::Async>; #[embassy_executor::main] -async fn main(_spawner: embassy_executor::Spawner) { - genlog::info!("hello"); - molybdos::heap::init(); +async fn main(spawner: embassy_executor::Spawner) { + molybdos::pal::heap::init(); + + genlog::info!("boot"); + + let bringup::Split { + sd_spi, + sd_cs, + bme_spi, + bme_cs, + wdt, + usb, + .. + } = bringup::split(Default::default()); + + // spawner.must_spawn(molybdos::pal::watchdog(wdt)); + + let (acm,) = molybdos::lib::usb::bringup!( + spawn, + usb, + molybdos::pal::UsbDriver, + molybdos::lib::usb::config("npry", "ocularium", 0x8888, 0x0011), + endpoints = { + acm => |builder| molybdos::lib::usb::acm!(builder), + } + ); + + molybdos::lib::usb::start!(molybdos::pal::UsbDriver, acm, &usb::UPLINK, &usb::DOWNLINK); + + molybdos::lib::util::cobs::start!( + ocularium::Uplink, + &usb::UPLINK, + &usb::COBS_UPLINK, + ocularium::Downlink, + &usb::DOWNLINK, + &usb::COBS_DOWNLINK + ); + + #[cfg(not(feature = "disable_sd"))] + { + let vm = molybdos::rt::sd::bringup!(sd_spi, SdSpi, sd_cs); + + { + let vol = VolumeManager::open_volume(vm, VolumeIdx(0)).await.expect("opening volume"); + } + + // spawner.must_spawn(sd::run_sd(vm, pubsub::LED.sender().into())); + } + + panic!() +} + +#[defmt::panic_handler] +fn panic() -> ! { + molybdos::panic_probe::hard_fault(); } |
