Skip to content
Snippets Groups Projects
Commit 3a7bd3a3 authored by Benjamin Koch's avatar Benjamin Koch
Browse files

use auto-push to reduce size of PIO program

parent 2a5a0a73
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment