// src/software_uart/debug.rs
use defmt::info;

pub fn dump_tim6_regs() {
    use embassy_stm32::pac::timer::TimBasic;
    let tim = unsafe { TimBasic::from_ptr(0x4000_1000usize as _) };
    let sr = tim.sr().read();
    let dier = tim.dier().read();
    let cr1 = tim.cr1().read();
    let arr = tim.arr().read().arr();
    let psc = tim.psc().read();
    info!(
        "TIM6: CR1.CEN={} DIER.UDE={} SR.UIF={} PSC={} ARR={}",
        cr1.cen(),
        dier.ude(),
        sr.uif(),
        psc,
        arr
    );
}

pub fn dump_dma_ch0_regs() {
    use embassy_stm32::pac::gpdma::Gpdma;
    let dma = unsafe { Gpdma::from_ptr(0x4002_0000usize as _) };
    let ch = dma.ch(0);
    let cr = ch.cr().read();
    let tr1 = ch.tr1().read();
    let tr2 = ch.tr2().read();
    let br1 = ch.br1().read();
    info!(
        "GPDMA1_CH0: EN={} PRIO={} SDW={} DDW={} SINC={} DINC={} REQSEL={} SWREQ={} DREQ={} BNDT={}",
        cr.en(),
        cr.prio(),
        tr1.sdw(),
        tr1.ddw(),
        tr1.sinc(),
        tr1.dinc(),
        tr2.reqsel(),
        tr2.swreq(),
        tr2.dreq(),
        br1.bndt()
    );
}
