rp2/mphalport: Change order of pin operations to prevent glitches.

When switching from a special function like SPI to an input or output,
there was a brief period after the function was disabled but before the
pin's I/O state was configured, in which the state would be poorly defined.
This fixes the problem by switching off the special function after fully
configuring the I/O state.

Fixes #10226.

Signed-off-by: Paul Grayson <pdg@alum.mit.edu>
pull/10337/head
Paul Grayson 2022-12-24 09:55:12 -08:00 zatwierdzone przez Damien George
rodzic f0f5c6568d
commit b208cf23e2
1 zmienionych plików z 3 dodań i 3 usunięć

Wyświetl plik

@ -91,22 +91,22 @@ static inline unsigned int mp_hal_pin_name(mp_hal_pin_obj_t pin) {
}
static inline void mp_hal_pin_input(mp_hal_pin_obj_t pin) {
gpio_set_function(pin, GPIO_FUNC_SIO);
gpio_set_dir(pin, GPIO_IN);
machine_pin_open_drain_mask &= ~(1 << pin);
gpio_set_function(pin, GPIO_FUNC_SIO);
}
static inline void mp_hal_pin_output(mp_hal_pin_obj_t pin) {
gpio_set_function(pin, GPIO_FUNC_SIO);
gpio_set_dir(pin, GPIO_OUT);
machine_pin_open_drain_mask &= ~(1 << pin);
gpio_set_function(pin, GPIO_FUNC_SIO);
}
static inline void mp_hal_pin_open_drain(mp_hal_pin_obj_t pin) {
gpio_set_function(pin, GPIO_FUNC_SIO);
gpio_set_dir(pin, GPIO_IN);
gpio_put(pin, 0);
machine_pin_open_drain_mask |= 1 << pin;
gpio_set_function(pin, GPIO_FUNC_SIO);
}
static inline void mp_hal_pin_config(mp_hal_pin_obj_t pin, uint32_t mode, uint32_t pull, uint32_t alt) {