GPIO descriptor fixes (#578)
This commit is contained in:
committed by
GitHub
parent
a3fda9ad8f
commit
8b92aa8e5a
@@ -68,7 +68,3 @@ properties:
|
||||
type: phandles
|
||||
default: GPIO_PIN_SPEC_NONE
|
||||
description: Optional reset GPIO pin, pulsed once at start (20 ms assert, 60 ms settle)
|
||||
reset-active-high:
|
||||
type: boolean
|
||||
default: false
|
||||
description: Whether the reset pin is active high
|
||||
|
||||
@@ -27,7 +27,6 @@ struct Tca8418Config {
|
||||
uint8_t sym_row;
|
||||
uint8_t sym_col;
|
||||
struct GpioPinSpec pin_reset;
|
||||
bool reset_active_high;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#include <drivers/tca8418.h>
|
||||
|
||||
#include <tca8418_module.h>
|
||||
|
||||
#include <tactility/check.h>
|
||||
#include <tactility/delay.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/driver.h>
|
||||
#include <tactility/drivers/gpio.h>
|
||||
#include <tactility/drivers/gpio_controller.h>
|
||||
#include <tactility/drivers/i2c_controller.h>
|
||||
#include <tactility/drivers/keyboard.h>
|
||||
@@ -116,15 +118,18 @@ static void perform_hardware_reset(const Tca8418Config* config) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* rst = gpio_descriptor_acquire(config->pin_reset.gpio_controller, config->pin_reset.pin, GPIO_OWNER_GPIO);
|
||||
// Not requesting GPIO_FLAG_ACTIVE_LOW here: some GPIO expanders (e.g. xl9555/tca95xx/
|
||||
// tca9534) can only invert what's read back from an input, not what's driven on an
|
||||
// output, so they reject ACTIVE_LOW combined with OUTPUT. Drive the raw physical level
|
||||
// instead: this pin's reset line is active-low, so low asserts and high releases.
|
||||
auto* rst = gpio_descriptor_acquire(config->pin_reset.gpio_controller, config->pin_reset.pin, GPIO_FLAG_DIRECTION_OUTPUT, GPIO_OWNER_GPIO);
|
||||
if (rst == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
gpio_descriptor_set_flags(rst, GPIO_FLAG_DIRECTION_OUTPUT);
|
||||
gpio_descriptor_set_level(rst, config->reset_active_high);
|
||||
gpio_descriptor_set_level(rst, false);
|
||||
delay_millis(20);
|
||||
gpio_descriptor_set_level(rst, !config->reset_active_high);
|
||||
gpio_descriptor_set_level(rst, true);
|
||||
gpio_descriptor_release(rst);
|
||||
delay_millis(60);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user