Implement Kconfig and enhance error checks

This commit is contained in:
Nick 2020-10-26 16:01:57 -05:00
parent 63007fb6c1
commit a008731103
9 changed files with 20 additions and 14 deletions

View file

@ -27,4 +27,7 @@ config ZMK_BLE
config ZMK_USB config ZMK_USB
default y default y
config ZMK_BATTERY_VOLTAGE_DIVIDER
default y
endif # BOARD_BLUEMICRO840_V1 endif # BOARD_BLUEMICRO840_V1

View file

@ -10,8 +10,6 @@ CONFIG_ARM_MPU=y
# enable GPIO # enable GPIO
CONFIG_GPIO=y CONFIG_GPIO=y
CONFIG_ADC=y
CONFIG_USE_DT_CODE_PARTITION=y CONFIG_USE_DT_CODE_PARTITION=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y CONFIG_MPU_ALLOW_FLASH_WRITE=y

View file

@ -25,4 +25,7 @@ config ZMK_BLE
config ZMK_USB config ZMK_USB
default y default y
config ZMK_BATTERY_VOLTAGE_DIVIDER
default y
endif # BOARD_NICE_NANO endif # BOARD_NICE_NANO

View file

@ -10,8 +10,6 @@ CONFIG_ARM_MPU=y
# enable GPIO # enable GPIO
CONFIG_GPIO=y CONFIG_GPIO=y
CONFIG_ADC=y
CONFIG_USE_DT_CODE_PARTITION=y CONFIG_USE_DT_CODE_PARTITION=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y CONFIG_MPU_ALLOW_FLASH_WRITE=y

View file

@ -35,6 +35,9 @@ if BOARD_NRFMICRO_13
config BOARD_NRFMICRO_CHARGER config BOARD_NRFMICRO_CHARGER
default y default y
config ZMK_BATTERY_VOLTAGE_DIVIDER
default y
endif # BOARD_NRFMICRO_13 endif # BOARD_NRFMICRO_13
endif # BOARD_NRFMICRO_11 || BOARD_NRFMICRO_11_FLIPPED || BOARD_NRFMICRO_13 endif # BOARD_NRFMICRO_11 || BOARD_NRFMICRO_11_FLIPPED || BOARD_NRFMICRO_13

View file

@ -10,8 +10,6 @@ CONFIG_ARM_MPU=y
# enable GPIO # enable GPIO
CONFIG_GPIO=y CONFIG_GPIO=y
CONFIG_ADC=y
CONFIG_USE_DT_CODE_PARTITION=y CONFIG_USE_DT_CODE_PARTITION=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y CONFIG_MPU_ALLOW_FLASH_WRITE=y

View file

@ -5,9 +5,9 @@ if(CONFIG_ZMK_KSCAN_GPIO_DRIVER)
zephyr_library_sources( zephyr_library_sources(
kscan_gpio_matrix.c kscan_gpio_matrix.c
kscan_gpio_direct.c kscan_gpio_direct.c
battery_voltage_divider.c
) )
zephyr_library_sources_ifdef(CONFIG_EC11 ec11.c) zephyr_library_sources_ifdef(CONFIG_EC11 ec11.c)
zephyr_library_sources_ifdef(CONFIG_EC11_TRIGGER ec11_trigger.c) zephyr_library_sources_ifdef(CONFIG_EC11_TRIGGER ec11_trigger.c)
zephyr_library_sources_ifdef(CONFIG_ZMK_BATTERY_VOLTAGE_DIVIDER battery_voltage_divider.c)
endif() endif()

View file

@ -21,6 +21,12 @@ config ZMK_KSCAN_INIT_PRIORITY
help help
Keyboard scan device driver initialization priority. Keyboard scan device driver initialization priority.
config ZMK_BATTERY_VOLTAGE_DIVIDER
bool "ZMK battery voltage divider"
select ADC
help
Enable ZMK battery voltage divider driver for battery monitoring.
menuconfig EC11 menuconfig EC11
bool "EC11 Incremental Encoder Sensor" bool "EC11 Incremental Encoder Sensor"
depends on GPIO depends on GPIO

View file

@ -14,8 +14,6 @@
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
struct io_channel_config { struct io_channel_config {
const char *label; const char *label;
uint8_t channel; uint8_t channel;
@ -102,10 +100,11 @@ static int bvd_sample_fetch(struct device *dev, enum sensor_channel chan) {
// Disable power GPIO if present // Disable power GPIO if present
if (drv_data->gpio) { if (drv_data->gpio) {
rc = gpio_pin_set(drv_data->gpio, drv_cfg->power_gpios.pin, 0); int rc2 = gpio_pin_set(drv_data->gpio, drv_cfg->power_gpios.pin, 0);
if (rc != 0) { if (rc2 != 0) {
LOG_DBG("Failed to disable ADC power GPIO: %d", rc); LOG_DBG("Failed to disable ADC power GPIO: %d", rc2);
return rc2;
} }
} }
@ -214,5 +213,3 @@ static const struct bvd_config bvd_cfg = {
DEVICE_AND_API_INIT(bvd_dev, DT_INST_LABEL(0), &bvd_init, &bvd_data, &bvd_cfg, POST_KERNEL, DEVICE_AND_API_INIT(bvd_dev, DT_INST_LABEL(0), &bvd_init, &bvd_data, &bvd_cfg, POST_KERNEL,
CONFIG_SENSOR_INIT_PRIORITY, &bvd_api); CONFIG_SENSOR_INIT_PRIORITY, &bvd_api);
#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */