@@ -99,21 +99,18 @@ digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(
99
99
void common_hal_digitalio_digitalinout_set_value (
100
100
digitalio_digitalinout_obj_t * self , bool value ) {
101
101
const uint8_t pin = self -> pin -> number ;
102
- if (value ) {
103
- // If true, set the direction -before- setting the pin value, to
104
- // to avoid a glitch true 3.3v on the pin before switching from output to input for open drain.
105
- if (self -> open_drain ) {
106
- gpio_set_dir (pin , GPIO_IN );
107
- }
108
- gpio_put (pin , true);
102
+ if (self -> open_drain && value ) {
103
+ // If true and open-drain, set the direction -before- setting
104
+ // the pin value, to to avoid a high glitch on the pin before
105
+ // switching from output to input for open-drain.
106
+ gpio_set_dir (pin , GPIO_IN );
107
+ gpio_put (pin , value );
109
108
} else {
110
- // If false, set the direction -after- setting the pin value,
111
- // to avoid a glitch 3.3v on the pin before switching from input to output for open drain,
112
- // when previous value was high.
113
- gpio_put (pin , false);
114
- if (self -> open_drain ) {
115
- gpio_set_dir (pin , GPIO_OUT );
116
- }
109
+ // Otherwise set the direction -after- setting the pin value,
110
+ // to avoid a glitch which might occur if the old value was
111
+ // different and the pin was previously set to input.
112
+ gpio_put (pin , value );
113
+ gpio_set_dir (pin , GPIO_OUT );
117
114
}
118
115
}
119
116
0 commit comments