boards: arm: hexiwear_k64: use regulator driver for battery sensing

The battery sensing circuit can be enabled using a regulator device
instead of custom code in the board pinmux.c.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2022-03-15 19:21:39 +01:00 committed by David Leach
parent 69ff24ce97
commit 4d6d2bf429
5 changed files with 15 additions and 21 deletions

View File

@ -1,8 +0,0 @@
# Hexiwear K64 board
# Copyright (c) 2017, NXP
# SPDX-License-Identifier: Apache-2.0
config BATTERY_SENSE
bool "The battery sense circuit"
depends on BOARD_HEXIWEAR_K64

View File

@ -20,11 +20,7 @@ config MCG_VDIV0
config MCG_FCRDIV
default 1
if ADC
config BATTERY_SENSE
default y
endif # ADC
config REGULATOR
default y if ADC
endif # BOARD_HEXIWEAR_K64

View File

@ -137,6 +137,11 @@ The K64F SoC has five pairs of pinmux/gpio controllers.
| PTE25 | UART4_TX | UART BT HCI |
+-------+-----------------+---------------------------+
.. note::
To enable battery sensing, you will need to enable the ``en_bat_sens``
regulator in Devicetree.
System Clock
============

View File

@ -58,6 +58,14 @@
pwms = <&ftm3 5 15625000 PWM_POLARITY_INVERTED>;
};
};
en_bat_sens: enable-battery-sense {
compatible = "regulator-fixed-sync", "regulator-fixed";
label = "en_bat_sens";
regulator-name = "en_bat_sens";
enable-gpios = <&gpioc 14 GPIO_ACTIVE_LOW>;
regulator-boot-on;
};
};
&sim {

View File

@ -25,13 +25,6 @@ static int hexiwear_k64_pinmux_init(const struct device *dev)
gpio_pin_configure(gpioa, 29, GPIO_OUTPUT_HIGH);
#endif
#ifdef CONFIG_BATTERY_SENSE
const struct device *gpioc =
device_get_binding(DT_LABEL(DT_NODELABEL(gpioc)));
gpio_pin_configure(gpioc, 14, GPIO_OUTPUT_LOW);
#endif
return 0;
}