add charger current choice

This commit is contained in:
mrninhvn 2021-10-21 13:25:26 +07:00
parent eef00512d7
commit b0462e54b6
3 changed files with 34 additions and 18 deletions

View file

@ -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
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

View file

@ -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

View file

@ -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