From b0462e54b6d170ebb07a8c454fd89583223f9e46 Mon Sep 17 00:00:00 2001 From: mrninhvn Date: Thu, 21 Oct 2021 13:25:26 +0700 Subject: [PATCH] add charger current choice --- app/boards/arm/mikoto/Kconfig | 21 ++++++++++++++++---- app/boards/arm/mikoto/Kconfig.defconfig | 5 +++-- app/boards/arm/mikoto/pinmux.c | 26 +++++++++++++------------ 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/app/boards/arm/mikoto/Kconfig b/app/boards/arm/mikoto/Kconfig index eecb74a0..129866cd 100644 --- a/app/boards/arm/mikoto/Kconfig +++ b/app/boards/arm/mikoto/Kconfig @@ -4,7 +4,20 @@ config BOARD_ENABLE_DCDC default y depends on (BOARD_MIKOTO_520) -config BOARD_MIKOTO_CHARGER - bool "Enable battery charger" - default y - depends on (BOARD_MIKOTO_520) +choice BOARD_MIKOTO_CHARGER_CURRENT + prompt "Charge current to supply to attached batteries" + depends on (BOARD_MIKOTO_520) + +config BOARD_MIKOTO_CHARGER_CURRENT_100MA + bool "100mA charge current" + +config BOARD_MIKOTO_CHARGER_CURRENT_250MA + bool "250mA charge current" + +config BOARD_MIKOTO_CHARGER_CURRENT_350MA + bool "350mA charge current" + +config BOARD_MIKOTO_CHARGER_CURRENT_NONE + bool "Disable charge current" + +endchoice \ No newline at end of file diff --git a/app/boards/arm/mikoto/Kconfig.defconfig b/app/boards/arm/mikoto/Kconfig.defconfig index 4a2ed0b8..2ca77b9e 100644 --- a/app/boards/arm/mikoto/Kconfig.defconfig +++ b/app/boards/arm/mikoto/Kconfig.defconfig @@ -30,8 +30,9 @@ config ZMK_USB config PINMUX default y -config BOARD_MIKOTO_CHARGER - default y +choice BOARD_MIKOTO_CHARGER_CURRENT + default BOARD_MIKOTO_CHARGER_CURRENT_100MA +endchoice config ZMK_BATTERY_VOLTAGE_DIVIDER default y diff --git a/app/boards/arm/mikoto/pinmux.c b/app/boards/arm/mikoto/pinmux.c index 79af1ba0..6b632aa4 100644 --- a/app/boards/arm/mikoto/pinmux.c +++ b/app/boards/arm/mikoto/pinmux.c @@ -17,21 +17,23 @@ static int pinmux_mikoto_init(const struct device *port) { #if CONFIG_BOARD_MIKOTO_520 const struct device *p0 = device_get_binding("GPIO_0"); const struct device *p1 = device_get_binding("GPIO_1"); -#if CONFIG_BOARD_MIKOTO_CHARGER - // 100mA +#if CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_100MA gpio_pin_configure(p0, 26, GPIO_OUTPUT); gpio_pin_set(p0, 26, 0); gpio_pin_configure(p1, 15, GPIO_INPUT); - // 250mA - // gpio_pin_configure(p0, 26, GPIO_INPUT); - // gpio_pin_configure(p1, 15, GPIO_OUTPUT); - // gpio_pin_set(p1, 15, 0); - // 250mA - // gpio_pin_configure(p0, 26, GPIO_OUTPUT); - // gpio_pin_set(p0, 26, 0); - // gpio_pin_configure(p1, 15, GPIO_OUTPUT); - // gpio_pin_set(p1, 15, 0); -#else +#endif +#if CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_250MA + gpio_pin_configure(p0, 26, GPIO_INPUT); + gpio_pin_configure(p1, 15, GPIO_OUTPUT); + gpio_pin_set(p1, 15, 0); +#endif +#if CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_350MA + gpio_pin_configure(p0, 26, GPIO_OUTPUT); + gpio_pin_set(p0, 26, 0); + gpio_pin_configure(p1, 15, GPIO_OUTPUT); + gpio_pin_set(p1, 15, 0); +#endif +#if CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_NONE gpio_pin_configure(p0, 26, GPIO_INPUT); gpio_pin_configure(p1, 15, GPIO_INPUT); #endif