From 3a7bd3a3efbfb290778b4648ea2e239c86ad7bfd Mon Sep 17 00:00:00 2001 From: Benjamin Koch <bbbsnowball@gmail.com> Date: Tue, 16 May 2023 04:59:36 +0200 Subject: [PATCH] use auto-push to reduce size of PIO program --- firmware/rust1/src/bin/heizung.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/firmware/rust1/src/bin/heizung.rs b/firmware/rust1/src/bin/heizung.rs index 6934c33..4248da4 100644 --- a/firmware/rust1/src/bin/heizung.rs +++ b/firmware/rust1/src/bin/heizung.rs @@ -316,9 +316,7 @@ async fn autobaud_task(pio0: embassy_rp::peripherals::PIO0, rx_pin: embassy_rp:: // Send zero to RX FIFO to signal start of next measurement. ".wrap_target", "timeout:", - "set x, 0", - "mov isr, x", - "push", + "in null, 32", // Wait for pin to be high for a longer time (UART is idle), copy waiting time to X // and decrement until done, start again when pin changes. @@ -350,8 +348,7 @@ async fn autobaud_task(pio0: embassy_rp::peripherals::PIO0, rx_pin: embassy_rp:: "jmp x-- measure_low", "jmp timeout", "changed_to_one:", - "mov isr, x" - "push", + "in x, 32" // Start counting, again, but for a high pulse. "mov x, osr", @@ -362,8 +359,7 @@ async fn autobaud_task(pio0: embassy_rp::peripherals::PIO0, rx_pin: embassy_rp:: "jmp x-- measure_high", "jmp timeout", "changed_to_low:", - "mov isr, x" - "push", + "in x, 32", "jmp y-- measure_next", // We are done. @@ -378,7 +374,7 @@ async fn autobaud_task(pio0: embassy_rp::peripherals::PIO0, rx_pin: embassy_rp:: const SM_FREQ: u32 = 125_000_000; cfg.clock_divider = (U56F8!(125_000_000) / U56F8!(125_000_000 /* SM_FREQ */)).to_fixed(); cfg.shift_in = ShiftConfig { - auto_fill: false, + auto_fill: true, threshold: 32, direction: ShiftDirection::Left, }; @@ -404,7 +400,8 @@ async fn autobaud_task(pio0: embassy_rp::peripherals::PIO0, rx_pin: embassy_rp:: unsafe { common.free_instr(loaded_program.used_memory); }; sm.set_enable(false); let relocated = RelocatedProgram::new(&prg.program); - cfg.use_program(&common.load_program(&relocated), &[]); + let loaded_program = common.load_program(&relocated); + cfg.use_program(&loaded_program, &[]); cfg.fifo_join = FifoJoin::RxOnly; sm.set_config(&cfg); sm.set_enable(true); @@ -415,6 +412,8 @@ async fn autobaud_task(pio0: embassy_rp::peripherals::PIO0, rx_pin: embassy_rp:: pin_io(&rx_pin).ctrl().write(|w| w.set_funcsel(embassy_rp::pac::io::vals::Gpio17ctrlFuncsel::UART0_RX.0)); } + info!("Program size for auto-baud: {}", prg.program.code.len()); + let mut dma_in_ref = dma_channel.into_ref(); let mut din = [42u32; 9]; let mut bit_index = 0; -- GitLab