Skip to content

Commit

Permalink
Merge pull request #5866 from dhalbert/espressif-open-drain
Browse files Browse the repository at this point in the history
fix espressif DigitalInOut open-drain
  • Loading branch information
jepler authored Jan 17, 2022
2 parents 7a3bcf7 + 11848b1 commit 895a8a9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions ports/espressif/common-hal/digitalio/DigitalInOut.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self
void common_hal_digitalio_digitalinout_switch_to_input(
digitalio_digitalinout_obj_t *self, digitalio_pull_t pull) {
common_hal_digitalio_digitalinout_set_pull(self, pull);
gpio_set_direction(self->pin->number, GPIO_MODE_DEF_INPUT);
gpio_set_direction(self->pin->number, GPIO_MODE_INPUT);
}

digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output(
Expand Down Expand Up @@ -108,11 +108,9 @@ digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode(
digitalio_digitalinout_obj_t *self,
digitalio_drive_mode_t drive_mode) {
gpio_num_t number = self->pin->number;
gpio_mode_t mode;
gpio_mode_t mode = GPIO_MODE_OUTPUT;
if (drive_mode == DRIVE_MODE_OPEN_DRAIN) {
mode = GPIO_MODE_DEF_OD;
} else {
mode = GPIO_MODE_DEF_OUTPUT;
mode |= GPIO_MODE_OUTPUT_OD;
}
esp_err_t result = gpio_set_direction(number, mode);
if (result != ESP_OK) {
Expand Down

0 comments on commit 895a8a9

Please sign in to comment.