From ff2c51595555ff3d9531ab9e52fb3e77ba2f392b Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Wed, 28 Sep 2022 23:18:48 -0400 Subject: [PATCH] boards: Seeeduino XIAO BLE charge current select. Add board Kconfig option to allow selecting a fixed charge current, either 50mA or 100mA, at startup. Signed-off-by: Peter Johanson --- boards/arm/seeeduino_xiao_ble/CMakeLists.txt | 4 ++ boards/arm/seeeduino_xiao_ble/Kconfig | 12 ++++++ boards/arm/seeeduino_xiao_ble/board.c | 42 ++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 boards/arm/seeeduino_xiao_ble/CMakeLists.txt create mode 100644 boards/arm/seeeduino_xiao_ble/board.c diff --git a/boards/arm/seeeduino_xiao_ble/CMakeLists.txt b/boards/arm/seeeduino_xiao_ble/CMakeLists.txt new file mode 100644 index 00000000000000..eaa996423c01c7 --- /dev/null +++ b/boards/arm/seeeduino_xiao_ble/CMakeLists.txt @@ -0,0 +1,4 @@ +if(CONFIG_BOARD_CHARGE_RATE_100MA) +zephyr_library() +zephyr_library_sources(board.c) +endif() diff --git a/boards/arm/seeeduino_xiao_ble/Kconfig b/boards/arm/seeeduino_xiao_ble/Kconfig index 4c7f1902f9cc0b..a2e6b891a2332c 100644 --- a/boards/arm/seeeduino_xiao_ble/Kconfig +++ b/boards/arm/seeeduino_xiao_ble/Kconfig @@ -8,3 +8,15 @@ config BOARD_ENABLE_DCDC select SOC_DCDC_NRF52X default y depends on BOARD_SEEEDUINO_XIAO_BLE + +choice BOARD_CHARGE_RATE + prompt "LiPo Charge Rate" + depends on BOARD_SEEEDUINO_XIAO_BLE + +config BOARD_CHARGE_RATE_50MA + bool "50mA" + +config BOARD_CHARGE_RATE_100MA + bool "100mA" + +endchoice diff --git a/boards/arm/seeeduino_xiao_ble/board.c b/boards/arm/seeeduino_xiao_ble/board.c new file mode 100644 index 00000000000000..79143a9c5f8492 --- /dev/null +++ b/boards/arm/seeeduino_xiao_ble/board.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include + +#include +LOG_MODULE_REGISTER(seeeduino_xiao_ble_board_init); + +#define XIAO_BLE_CHARGE_CTRL_PORT DT_LABEL(DT_NODELABEL(gpio0)) +#define XIAO_BLE_CHARGE_CTRL_PIN 13 + +static int setup(const struct device *dev) +{ + ARG_UNUSED(dev); + + const struct device *gpio; + int err; + + gpio = device_get_binding(XIAO_BLE_CHARGE_CTRL_PORT); + if (!gpio) { + LOG_ERR("Could not bind device \"%s\"", XIAO_BLE_CHARGE_CTRL_PORT); + return -ENODEV; + } + + err = gpio_pin_configure(gpio, XIAO_BLE_CHARGE_CTRL_PIN, GPIO_OUTPUT_LOW); + + if (err < 0) { + LOG_ERR("Failed to set charge pin low for high charge rate"); + return err; + } + + return 0; +} + +SYS_INIT(setup, POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY);