diff --git a/rp2040-hal/src/pio.rs b/rp2040-hal/src/pio.rs index 37e6559..a8f04f4 100644 --- a/rp2040-hal/src/pio.rs +++ b/rp2040-hal/src/pio.rs @@ -598,6 +598,7 @@ impl StateMachine { // `UninitStateMachine` byt adding a program. pub fn set_pins(&mut self, pins: impl IntoIterator) { let saved_ctrl = self.sm.sm().sm_pinctrl.read(); + let saved_execctrl = self.sm.sm().sm_execctrl.read(); for (pin_num, pin_state) in pins { self.sm .sm() @@ -611,10 +612,11 @@ impl StateMachine { .encode(), ); } - self.sm - .sm() - .sm_pinctrl + let sm = self.sm.sm(); + sm.sm_pinctrl .write(|w| unsafe { w.bits(saved_ctrl.bits()) }); + sm.sm_execctrl + .write(|w| unsafe { w.bits(saved_execctrl.bits()) }) } /// Set pin directions. @@ -645,13 +647,10 @@ impl StateMachine { .encode(), ); } - self.sm - .sm() - .sm_pinctrl + let sm = self.sm.sm(); + sm.sm_pinctrl .write(|w| unsafe { w.bits(saved_ctrl.bits()) }); - self.sm - .sm() - .sm_execctrl + sm.sm_execctrl .write(|w| unsafe { w.bits(saved_execctrl.bits()) }); } }