gpio: stellaris: implement gpio_pin_get_config
Implement `gpio_pin_get_config` for the stellaris platform, and by extension `qemu_cortex_m3`. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
parent
927dda06fa
commit
86050556c0
1 changed files with 31 additions and 0 deletions
|
@ -107,6 +107,34 @@ static int gpio_stellaris_configure(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_GPIO_GET_CONFIG
|
||||
static int gpio_stellaris_get_config(const struct device *dev,
|
||||
gpio_pin_t pin,
|
||||
gpio_flags_t *out_flags)
|
||||
{
|
||||
const struct gpio_stellaris_config *cfg = dev->config;
|
||||
uint32_t base = cfg->base;
|
||||
gpio_flags_t flags = 0;
|
||||
mm_reg_t mask_addr;
|
||||
|
||||
if (sys_test_bit(GPIO_REG_ADDR(base, GPIO_DEN_OFFSET), pin) == 0) {
|
||||
flags = GPIO_DISCONNECTED;
|
||||
} else if (sys_test_bit(GPIO_REG_ADDR(base, GPIO_DIR_OFFSET), pin)) {
|
||||
mask_addr = GPIO_RW_MASK_ADDR(base, GPIO_DATA_OFFSET, BIT(pin));
|
||||
|
||||
if (sys_test_bit(mask_addr, pin)) {
|
||||
flags |= GPIO_OUTPUT_HIGH;
|
||||
} else {
|
||||
flags |= GPIO_OUTPUT_LOW;
|
||||
}
|
||||
} else {
|
||||
flags = GPIO_INPUT;
|
||||
}
|
||||
*out_flags = flags;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int gpio_stellaris_port_get_raw(const struct device *dev,
|
||||
uint32_t *value)
|
||||
{
|
||||
|
@ -221,6 +249,9 @@ static int gpio_stellaris_manage_callback(const struct device *dev,
|
|||
|
||||
static const struct gpio_driver_api gpio_stellaris_driver_api = {
|
||||
.pin_configure = gpio_stellaris_configure,
|
||||
#ifdef CONFIG_GPIO_GET_CONFIG
|
||||
.pin_get_config = gpio_stellaris_get_config,
|
||||
#endif
|
||||
.port_get_raw = gpio_stellaris_port_get_raw,
|
||||
.port_set_masked_raw = gpio_stellaris_port_set_masked_raw,
|
||||
.port_set_bits_raw = gpio_stellaris_port_set_bits_raw,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue