DCDC: Update HV output switch handling

This commit is contained in:
Martin Jäger
2021-02-24 16:45:01 +01:00
parent 01ca3b4f15
commit f8d7b25648
3 changed files with 19 additions and 14 deletions
+2 -2
View File
@@ -62,8 +62,8 @@
pwms = <&pwm8 1 200000 PWM_POLARITY_NORMAL>; /* 200 us period = 5 kHz */
};
hv-ext-sense {
label = "HV external sense and switch";
hv-out {
label = "HV output sense and enable switch";
gpios = <&gpiob 12 GPIO_ACTIVE_LOW>;
};
};
+2 -2
View File
@@ -48,8 +48,8 @@
gpios = <&gpiob 14 GPIO_ACTIVE_LOW>;
};
hv-ext-sense {
label = "HV external sense and switch";
hv-out {
label = "HV output sense and enable switch";
gpios = <&gpiob 12 GPIO_ACTIVE_LOW>;
};
};
+15 -10
View File
@@ -9,6 +9,7 @@
#include <zephyr.h>
#ifndef UNIT_TEST
#include <device.h>
#include <drivers/gpio.h>
#include <logging/log.h>
@@ -29,8 +30,8 @@ extern DeviceStatus dev_stat;
#if BOARD_HAS_DCDC
#if DT_NODE_EXISTS(DT_CHILD(DT_PATH(outputs), hv_ext_sense))
#define HV_EXT_SENSE_GPIO DT_CHILD(DT_PATH(outputs), hv_ext_sense)
#if DT_NODE_EXISTS(DT_CHILD(DT_PATH(outputs), hv_out))
#define HV_OUT_NODE DT_CHILD(DT_PATH(outputs), hv_out)
#endif
Dcdc::Dcdc(DcBus *high, DcBus *low, DcdcOperationMode op_mode)
@@ -335,19 +336,23 @@ void Dcdc::fuse_destruction()
void Dcdc::output_hvs_enable()
{
#if DT_NODE_EXISTS(DT_CHILD(DT_PATH(outputs), hv_ext_sense))
const struct device *dev_hv_ext = device_get_binding(DT_GPIO_LABEL(HV_EXT_SENSE_GPIO, gpios));
gpio_pin_configure(dev_hv_ext, DT_GPIO_PIN(HV_EXT_SENSE_GPIO, gpios),
DT_GPIO_FLAGS(HV_EXT_SENSE_GPIO, gpios) | GPIO_OUTPUT_ACTIVE);
#ifdef HV_OUT_NODE
const struct device *hv_out = DEVICE_DT_GET(DT_GPIO_CTLR(HV_OUT_NODE, gpios));
if (device_is_ready(hv_out)) {
gpio_pin_configure(hv_out, DT_GPIO_PIN(HV_OUT_NODE, gpios),
DT_GPIO_FLAGS(HV_OUT_NODE, gpios) | GPIO_OUTPUT_ACTIVE);
}
#endif
}
void Dcdc::output_hvs_disable()
{
#if DT_NODE_EXISTS(DT_CHILD(DT_PATH(outputs), hv_ext_sense))
const struct device *dev_hv_ext = device_get_binding(DT_GPIO_LABEL(HV_EXT_SENSE_GPIO, gpios));
gpio_pin_configure(dev_hv_ext, DT_GPIO_PIN(HV_EXT_SENSE_GPIO, gpios),
DT_GPIO_FLAGS(HV_EXT_SENSE_GPIO, gpios) | GPIO_OUTPUT_INACTIVE);
#ifdef HV_OUT_NODE
const struct device *hv_out = DEVICE_DT_GET(DT_GPIO_CTLR(HV_OUT_NODE, gpios));
if (device_is_ready(hv_out)) {
gpio_pin_configure(hv_out, DT_GPIO_PIN(HV_OUT_NODE, gpios),
DT_GPIO_FLAGS(HV_OUT_NODE, gpios) | GPIO_OUTPUT_INACTIVE);
}
#endif
}