mod chips; mod dma; mod docs; mod gpio_af; mod header; mod interrupts; mod memory; mod rcc; mod registers; #[macro_export] macro_rules! regex { ($re:literal) => {{ ::ref_thread_local::ref_thread_local! { static managed REGEX: ::regex::Regex = ::regex::Regex::new($re).unwrap(); } >::borrow(®EX) }}; } struct Stopwatch { start: std::time::Instant, section_start: Option, } impl Stopwatch { fn new() -> Self { eprintln!("Starting timer"); let start = std::time::Instant::now(); Self { start, section_start: None, } } fn section(&mut self, status: &str) { let now = std::time::Instant::now(); self.print_done(now); eprintln!(" {status}"); self.section_start = Some(now); } fn stop(self) { let now = std::time::Instant::now(); self.print_done(now); let total_elapsed = now - self.start; eprintln!("Total time: {:.2} seconds", total_elapsed.as_secs_f32()); } fn print_done(&self, now: std::time::Instant) { if let Some(section_start) = self.section_start { let elapsed = now - section_start; eprintln!(" done in {:.2} seconds", elapsed.as_secs_f32()); } } } fn main() -> anyhow::Result<()> { let mut stopwatch = Stopwatch::new(); stopwatch.section("Parsing headers"); let headers = header::Headers::parse()?; stopwatch.section("Parsing other stuff"); // stopwatch.section("Parsing registers"); let registers = registers::Registers::parse()?; registers.write()?; // stopwatch.section("Parsing memories"); let memories = memory::Memories::parse()?; // stopwatch.section("Parsing interrupts"); let chip_interrupts = interrupts::ChipInterrupts::parse()?; // stopwatch.section("Parsing RCC registers"); let peripheral_to_clock = rcc::PeripheralToClock::parse(®isters)?; // stopwatch.section("Parsing docs"); let docs = docs::Docs::parse()?; // stopwatch.section("Parsing DMA"); let dma_channels = dma::DmaChannels::parse()?; // stopwatch.section("Parsing GPIO AF"); let af = gpio_af::Af::parse()?; stopwatch.section("Parsing chip groups"); let (chips, chip_groups) = chips::parse_groups()?; stopwatch.section("Processing chips"); chips::dump_all_chips( chip_groups, headers, af, chip_interrupts, peripheral_to_clock, dma_channels, chips, memories, docs, )?; stopwatch.stop(); Ok(()) }