@@ -43,6 +43,7 @@ digitalinout_result_t common_hal_digitalio_digitalinout_construct(
43
43
self -> output = false;
44
44
self -> open_drain = false;
45
45
46
+ // Set to input. No output value.
46
47
gpio_init (pin -> number );
47
48
return DIGITALINOUT_OK ;
48
49
}
@@ -75,10 +76,15 @@ digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output(
75
76
digitalio_digitalinout_obj_t * self , bool value ,
76
77
digitalio_drive_mode_t drive_mode ) {
77
78
const uint8_t pin = self -> pin -> number ;
78
- gpio_set_dir (pin , GPIO_OUT );
79
- // TODO: Turn on "strong" pin driving (more current available).
79
+ gpio_disable_pulls (pin );
80
+
81
+ // Turn on "strong" pin driving (more current available).
82
+ hw_write_masked (& padsbank0_hw -> io [pin ],
83
+ PADS_BANK0_GPIO0_DRIVE_VALUE_12MA << PADS_BANK0_GPIO0_DRIVE_LSB ,
84
+ PADS_BANK0_GPIO0_DRIVE_BITS );
80
85
81
86
self -> output = true;
87
+ // Pin direction is ultimately set in set_value. We don't need to do it here.
82
88
common_hal_digitalio_digitalinout_set_drive_mode (self , drive_mode );
83
89
common_hal_digitalio_digitalinout_set_value (self , value );
84
90
return DIGITALINOUT_OK ;
@@ -110,9 +116,6 @@ digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode(
110
116
const uint8_t pin = self -> pin -> number ;
111
117
bool value = common_hal_digitalio_digitalinout_get_value (self );
112
118
self -> open_drain = drive_mode == DRIVE_MODE_OPEN_DRAIN ;
113
- if (self -> open_drain ) {
114
- gpio_put (pin , false);
115
- }
116
119
// True is implemented differently between modes so reset the value to make
117
120
// sure it's correct for the new mode.
118
121
if (value ) {
0 commit comments