diff options
-rw-r--r-- | common/button.c | 8 | ||||
-rw-r--r-- | include/button.h | 14 | ||||
-rw-r--r-- | include/config.h | 6 |
3 files changed, 27 insertions, 1 deletions
diff --git a/common/button.c b/common/button.c index 1dcebae3bd..42d08c9baf 100644 --- a/common/button.c +++ b/common/button.c @@ -73,8 +73,14 @@ static int raw_button_pressed(const struct button_config *button) int physical_value = 0; int simulated_value = 0; if (!(button->flags & BUTTON_FLAG_DISABLED)) { - physical_value = (!!gpio_get_level(button->gpio) == + if (IS_ENABLED(CONFIG_ADC_BUTTONS) && + button_is_adc_detected(button->gpio)) { + physical_value = + adc_to_physical_value(button->gpio); + } else { + physical_value = (!!gpio_get_level(button->gpio) == !!(button->flags & BUTTON_FLAG_ACTIVE_HIGH)); + } #ifdef CONFIG_SIMULATED_BUTTON simulated_value = simulated_button_pressed(button); #endif diff --git a/include/button.h b/include/button.h index 381e650550..ec0a7afdc2 100644 --- a/include/button.h +++ b/include/button.h @@ -87,4 +87,18 @@ int button_disable_gpio(enum button button_type); */ void button_interrupt(enum gpio_signal signal); +/* + * determined which buttons connected ADC + * + * @param signal Signal which triggered the interrupt. + */ +int button_is_adc_detected(enum gpio_signal gpio); + +/* + * distinct which buttons determined by ADC voltage + * + * @param signal Signal which triggered the interrupt. + */ +int adc_to_physical_value(enum gpio_signal gpio); + #endif /* __CROS_EC_BUTTON_H */ diff --git a/include/config.h b/include/config.h index c80636f33d..0d5d10ac90 100644 --- a/include/config.h +++ b/include/config.h @@ -771,6 +771,12 @@ #undef CONFIG_VOLUME_BUTTONS /* + * The board has volume up and volume down buttons, that are connected to ADC + * pins which pressed and released values are determined by the analog voltage + */ +#undef CONFIG_ADC_BUTTONS + +/* * Allow runtime configuration of the buttons[] array */ #undef CONFIG_BUTTONS_RUNTIME_CONFIG |