Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards: Seeeduino XIAO BLE charge current select. #10

Open
wants to merge 1 commit into
base: v3.0.0+zmk-fixes
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions boards/arm/seeeduino_xiao_ble/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if(CONFIG_BOARD_CHARGE_RATE_100MA)
zephyr_library()
zephyr_library_sources(board.c)
endif()
12 changes: 12 additions & 0 deletions boards/arm/seeeduino_xiao_ble/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
42 changes: 42 additions & 0 deletions boards/arm/seeeduino_xiao_ble/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <init.h>
#include <hal/nrf_gpio.h>
#include <nrfx.h>
#include <device.h>
#include <drivers/gpio.h>

#include <logging/log.h>
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);