summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick <nick.win999@gmail.com>2020-10-26 16:01:57 -0500
committerNick <nick.win999@gmail.com>2020-10-26 16:01:57 -0500
commita0087311038e9b21c2a45499e669d1300af16f83 (patch)
treebe02b819a1c2784d3ce963da818ce42c919df402
parent63007fb6c136b8475894a6315f12eabeea952ca4 (diff)
Implement Kconfig and enhance error checks
-rw-r--r--app/boards/arm/bluemicro840/Kconfig.defconfig3
-rw-r--r--app/boards/arm/bluemicro840/bluemicro840_v1_defconfig2
-rw-r--r--app/boards/arm/nice_nano/Kconfig.defconfig3
-rw-r--r--app/boards/arm/nice_nano/nice_nano_defconfig2
-rw-r--r--app/boards/arm/nrfmicro/Kconfig.defconfig3
-rw-r--r--app/boards/arm/nrfmicro/nrfmicro_13_defconfig2
-rw-r--r--app/drivers/zephyr/CMakeLists.txt2
-rw-r--r--app/drivers/zephyr/Kconfig6
-rw-r--r--app/drivers/zephyr/battery_voltage_divider.c11
9 files changed, 20 insertions, 14 deletions
diff --git a/app/boards/arm/bluemicro840/Kconfig.defconfig b/app/boards/arm/bluemicro840/Kconfig.defconfig
index 566b5a4..2b55e17 100644
--- a/app/boards/arm/bluemicro840/Kconfig.defconfig
+++ b/app/boards/arm/bluemicro840/Kconfig.defconfig
@@ -27,4 +27,7 @@ config ZMK_BLE
config ZMK_USB
default y
+config ZMK_BATTERY_VOLTAGE_DIVIDER
+ default y
+
endif # BOARD_BLUEMICRO840_V1
diff --git a/app/boards/arm/bluemicro840/bluemicro840_v1_defconfig b/app/boards/arm/bluemicro840/bluemicro840_v1_defconfig
index 00d5661..96f03ca 100644
--- a/app/boards/arm/bluemicro840/bluemicro840_v1_defconfig
+++ b/app/boards/arm/bluemicro840/bluemicro840_v1_defconfig
@@ -10,8 +10,6 @@ CONFIG_ARM_MPU=y
# enable GPIO
CONFIG_GPIO=y
-CONFIG_ADC=y
-
CONFIG_USE_DT_CODE_PARTITION=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
diff --git a/app/boards/arm/nice_nano/Kconfig.defconfig b/app/boards/arm/nice_nano/Kconfig.defconfig
index 0961ddd..205050a 100644
--- a/app/boards/arm/nice_nano/Kconfig.defconfig
+++ b/app/boards/arm/nice_nano/Kconfig.defconfig
@@ -25,4 +25,7 @@ config ZMK_BLE
config ZMK_USB
default y
+config ZMK_BATTERY_VOLTAGE_DIVIDER
+ default y
+
endif # BOARD_NICE_NANO
diff --git a/app/boards/arm/nice_nano/nice_nano_defconfig b/app/boards/arm/nice_nano/nice_nano_defconfig
index a888cb3..393d61f 100644
--- a/app/boards/arm/nice_nano/nice_nano_defconfig
+++ b/app/boards/arm/nice_nano/nice_nano_defconfig
@@ -10,8 +10,6 @@ CONFIG_ARM_MPU=y
# enable GPIO
CONFIG_GPIO=y
-CONFIG_ADC=y
-
CONFIG_USE_DT_CODE_PARTITION=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
diff --git a/app/boards/arm/nrfmicro/Kconfig.defconfig b/app/boards/arm/nrfmicro/Kconfig.defconfig
index 7957b4a..a3c02c2 100644
--- a/app/boards/arm/nrfmicro/Kconfig.defconfig
+++ b/app/boards/arm/nrfmicro/Kconfig.defconfig
@@ -35,6 +35,9 @@ if BOARD_NRFMICRO_13
config BOARD_NRFMICRO_CHARGER
default y
+config ZMK_BATTERY_VOLTAGE_DIVIDER
+ default y
+
endif # BOARD_NRFMICRO_13
endif # BOARD_NRFMICRO_11 || BOARD_NRFMICRO_11_FLIPPED || BOARD_NRFMICRO_13
diff --git a/app/boards/arm/nrfmicro/nrfmicro_13_defconfig b/app/boards/arm/nrfmicro/nrfmicro_13_defconfig
index 4e44ea3..cac1164 100644
--- a/app/boards/arm/nrfmicro/nrfmicro_13_defconfig
+++ b/app/boards/arm/nrfmicro/nrfmicro_13_defconfig
@@ -10,8 +10,6 @@ CONFIG_ARM_MPU=y
# enable GPIO
CONFIG_GPIO=y
-CONFIG_ADC=y
-
CONFIG_USE_DT_CODE_PARTITION=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
diff --git a/app/drivers/zephyr/CMakeLists.txt b/app/drivers/zephyr/CMakeLists.txt
index 0b1d18f..fc43fb8 100644
--- a/app/drivers/zephyr/CMakeLists.txt
+++ b/app/drivers/zephyr/CMakeLists.txt
@@ -5,9 +5,9 @@ if(CONFIG_ZMK_KSCAN_GPIO_DRIVER)
zephyr_library_sources(
kscan_gpio_matrix.c
kscan_gpio_direct.c
- battery_voltage_divider.c
)
zephyr_library_sources_ifdef(CONFIG_EC11 ec11.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()
diff --git a/app/drivers/zephyr/Kconfig b/app/drivers/zephyr/Kconfig
index 0534cab..6b177fb 100644
--- a/app/drivers/zephyr/Kconfig
+++ b/app/drivers/zephyr/Kconfig
@@ -21,6 +21,12 @@ config ZMK_KSCAN_INIT_PRIORITY
help
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
bool "EC11 Incremental Encoder Sensor"
depends on GPIO
diff --git a/app/drivers/zephyr/battery_voltage_divider.c b/app/drivers/zephyr/battery_voltage_divider.c
index 09a353a..37ac024 100644
--- a/app/drivers/zephyr/battery_voltage_divider.c
+++ b/app/drivers/zephyr/battery_voltage_divider.c
@@ -14,8 +14,6 @@
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
-#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
-
struct io_channel_config {
const char *label;
uint8_t channel;
@@ -102,10 +100,11 @@ static int bvd_sample_fetch(struct device *dev, enum sensor_channel chan) {
// Disable power GPIO if present
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) {
- LOG_DBG("Failed to disable ADC power GPIO: %d", rc);
+ if (rc2 != 0) {
+ 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,
CONFIG_SENSOR_INIT_PRIORITY, &bvd_api);
-
-#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */