rp: move pio pin configs after set_config

This is needed for the program to work correctly on rp235xb when using
the higher pin numbers.
This commit is contained in:
Adrian Wowk 2025-08-20 13:40:14 -05:00 committed by Dario Nieuwenhuis
parent 451625ff55
commit 5137306575

View File

@ -121,10 +121,6 @@ impl<'d, PIO: Instance, const SM: usize, M: Mode> Spi<'d, PIO, SM, M> {
clk_pin.set_output_inversion(false);
}
sm.set_pins(Level::Low, &[&clk_pin, &mosi_pin]);
sm.set_pin_dirs(Direction::Out, &[&clk_pin, &mosi_pin]);
sm.set_pin_dirs(Direction::In, &[&miso_pin]);
let mut cfg = crate::pio::Config::default();
cfg.use_program(&program.prg, &[&clk_pin]);
@ -142,6 +138,11 @@ impl<'d, PIO: Instance, const SM: usize, M: Mode> Spi<'d, PIO, SM, M> {
cfg.clock_divider = calculate_clock_divider(config.frequency);
sm.set_config(&cfg);
sm.set_pins(Level::Low, &[&clk_pin, &mosi_pin]);
sm.set_pin_dirs(Direction::Out, &[&clk_pin, &mosi_pin]);
sm.set_pin_dirs(Direction::In, &[&miso_pin]);
sm.set_enable(true);
Self {