Introduce generic "outputs" DTS binding

Replaces previous "switch" and "pwm-out" bindings and allows to reference
either gpio or pwm handle and specify maximum current.

Also replacing CONFIG_HAS_LOAD and CONFIG_HAS_USB_PWR with DT_ variants.
This commit is contained in:
Martin Jäger
2020-05-06 12:53:26 +02:00
parent 90c1e7fcf5
commit ce7f63b888
29 changed files with 142 additions and 160 deletions
@@ -6,12 +6,6 @@ if BOARD_MPPT_1210_HUS
config BOARD
default "mppt_1210_hus"
config HAS_LOAD_OUTPUT
default y
config HAS_USB_PWR_OUTPUT
default y
if UART_CONSOLE
config UART_2
-2
View File
@@ -7,8 +7,6 @@
#ifndef MPPT_1210_HUS_H
#define MPPT_1210_HUS_H
#define LOAD_CURRENT_MAX 10 // PCB maximum load switch current
#define PIN_UEXT_TX PA_2
#define PIN_UEXT_RX PA_3
#define PIN_UEXT_SCL PB_6
+7 -6
View File
@@ -52,23 +52,24 @@
};
};
switches {
compatible = "switch";
outputs {
compatible = "outputs";
load {
label = "Load output";
gpios = <&gpioc 13 GPIO_ACTIVE_HIGH>;
label = "Load enable";
current-max = <10>;
};
usb-pwr {
gpios = <&gpiob 10 GPIO_ACTIVE_HIGH>;
label = "USB charging port enable";
gpios = <&gpiob 10 GPIO_ACTIVE_HIGH>;
};
v-solar {
gpios = <&gpioc 14 GPIO_ACTIVE_HIGH>;
label = "Solar voltage measurement enable";
gpios = <&gpioc 14 GPIO_ACTIVE_HIGH>;
};
boot0 {
gpios = <&gpiob 12 GPIO_ACTIVE_HIGH>;
label = "BOOT0 pin trigger";
gpios = <&gpiob 12 GPIO_ACTIVE_HIGH>;
};
};
@@ -6,9 +6,6 @@ if BOARD_MPPT_2420_HPX
config BOARD
default "mppt_2420_hpx"
config HAS_LOAD_OUTPUT
default y
if UART_CONSOLE
config UART_1
-2
View File
@@ -9,8 +9,6 @@
#include <zephyr.h>
#define LOAD_CURRENT_MAX 20 // PCB maximum load switch current
#define PIN_UEXT_TX PA_2
#define PIN_UEXT_RX PA_3
#define PIN_UEXT_SCL PB_6
+13 -18
View File
@@ -50,22 +50,16 @@
};
};
pwmouts {
compatible = "pwm-out";
charge_pump: charge_pump {
pwms = <&{/soc/timers@40000400/pwm} 1 4>; /* TIM3 */
/* originally planned TIM8 not working with current Zephyr driver */
/* pwms = <&{/soc/timers@40013400/pwm} 1 4>; */
label = "Charge pump for HS MOSFET drivers";
};
};
switches {
compatible = "switch";
outputs {
compatible = "outputs";
load {
label = "Load output";
gpios = <&gpiob 15 GPIO_ACTIVE_LOW>;
label = "Load disable";
current-max = <20>;
};
charge_pump {
label = "Charge pump for HS MOSFET drivers";
pwms = <&pwm3 1 200000>; /* 200 us period = 5 kHz */
};
};
@@ -74,7 +68,6 @@
uext-uart = &usart3;
spi-uext = &spi1;
i2c-uext = &i2c1;
pwm-cp = &charge_pump;
};
};
@@ -126,11 +119,13 @@
status = "okay";
};
/* for charge pump and PWM solar input */
/*
* TIM3 used for charge pump (CH1) and PWM power switch (CH2)
* (originally planned TIM8 for charge pump not working with current Zephyr driver)
*/
&timers3 {
status = "okay";
pwm {
pwm3: pwm {
status = "okay";
};
};
@@ -6,9 +6,6 @@ if BOARD_MPPT_2420_LC
config BOARD
default "mppt_2420_lc"
config HAS_LOAD_OUTPUT
default y
if UART_CONSOLE
config UART_2
-2
View File
@@ -7,8 +7,6 @@
#ifndef MPPT_2420_LC_H
#define MPPT_2420_LC_H
#define LOAD_CURRENT_MAX 20 // PCB maximum load switch current
#define PIN_UEXT_DIS PC_14 // starting from rev. 0.10
#define PIN_UEXT_TX PA_2
#define PIN_UEXT_RX PA_3
+8 -7
View File
@@ -48,19 +48,20 @@
};
};
switches {
compatible = "switch";
outputs {
compatible = "outputs";
load {
label = "Load output";
gpios = <&gpiob 2 GPIO_ACTIVE_LOW>;
label = "Load disable";
current-max = <20>;
};
uext {
uext_en {
label = "UEXT enable";
gpios = <&gpioc 14 GPIO_ACTIVE_LOW>;
label = "UEXT disable";
};
can {
gpios = <&gpioa 15 GPIO_ACTIVE_LOW>;
can_en {
label = "CAN disable / standby";
gpios = <&gpioa 15 GPIO_ACTIVE_LOW>;
};
};
@@ -6,12 +6,6 @@ if BOARD_PWM_2420_LUS
config BOARD
default "pwm_2420_lus"
config HAS_LOAD_OUTPUT
default y
config HAS_USB_PWR_OUTPUT
default y
if UART_CONSOLE
config UART_2
-2
View File
@@ -7,8 +7,6 @@
#ifndef PWM_2420_LUS_H
#define PWM_2420_LUS_H
#define LOAD_CURRENT_MAX 15 // PCB maximum load switch current
#define PIN_UEXT_TX PA_2
#define PIN_UEXT_RX PA_3
#define PIN_UEXT_SCL PB_6
+6 -5
View File
@@ -58,19 +58,20 @@
};
};
switches {
compatible = "switch";
outputs {
compatible = "outputs";
load {
label = "Load output";
gpios = <&gpiob 2 GPIO_ACTIVE_LOW>;
label = "Load disable";
current-max = <20>;
};
usb-pwr {
gpios = <&gpiob 5 GPIO_ACTIVE_LOW>;
label = "USB charging port disable";
gpios = <&gpiob 5 GPIO_ACTIVE_LOW>;
};
boot0 {
gpios = <&gpiob 12 GPIO_ACTIVE_HIGH>;
label = "BOOT0 pin trigger";
gpios = <&gpiob 12 GPIO_ACTIVE_HIGH>;
};
};
+13 -5
View File
@@ -6,6 +6,10 @@
#include "bat_charger.h"
#ifndef UNIT_TEST
#include <zephyr.h>
#endif
#include <math.h> // for fabs function
#include <stdio.h>
@@ -46,7 +50,7 @@ void battery_conf_init(BatConf *bat, int type, int num_cells, float nominal_capa
bat->voltage_load_reconnect = num_cells * 2.10;
// assumption: Battery selection matching charge controller
bat->internal_resistance = num_cells * (1.95 - 1.80) / LOAD_CURRENT_MAX;
bat->internal_resistance = num_cells * (1.95 - 1.80) / DT_OUTPUTS_LOAD_CURRENT_MAX;
bat->voltage_absolute_min = num_cells * 1.6;
@@ -84,7 +88,8 @@ void battery_conf_init(BatConf *bat, int type, int num_cells, float nominal_capa
bat->voltage_load_reconnect = num_cells * 3.15;
// 5% voltage drop at max current
bat->internal_resistance = bat->voltage_load_disconnect * 0.05 / LOAD_CURRENT_MAX;
bat->internal_resistance = bat->voltage_load_disconnect * 0.05 /
DT_OUTPUTS_LOAD_CURRENT_MAX;
bat->voltage_absolute_min = num_cells * 2.0;
bat->ocv_full = num_cells * 3.4; // will give really nonlinear SOC calculation
@@ -109,7 +114,8 @@ void battery_conf_init(BatConf *bat, int type, int num_cells, float nominal_capa
bat->voltage_load_reconnect = num_cells * 3.6;
// 5% voltage drop at max current
bat->internal_resistance = bat->voltage_load_disconnect * 0.05 / LOAD_CURRENT_MAX;
bat->internal_resistance = bat->voltage_load_disconnect * 0.05 /
DT_OUTPUTS_LOAD_CURRENT_MAX;
bat->voltage_absolute_min = num_cells * 2.5;
@@ -158,9 +164,11 @@ bool battery_conf_check(BatConf *bat_conf)
bat_conf->voltage_recharge > (bat_conf->voltage_load_disconnect + 1) &&
bat_conf->voltage_load_disconnect > (bat_conf->voltage_absolute_min + 0.4) &&
// max. 10% drop
bat_conf->internal_resistance < bat_conf->voltage_load_disconnect * 0.1 / LOAD_CURRENT_MAX &&
bat_conf->internal_resistance < bat_conf->voltage_load_disconnect * 0.1 /
DT_OUTPUTS_LOAD_CURRENT_MAX &&
// max. 3% loss
bat_conf->wire_resistance < bat_conf->topping_voltage * 0.03 / LOAD_CURRENT_MAX &&
bat_conf->wire_resistance < bat_conf->topping_voltage * 0.03 /
DT_OUTPUTS_LOAD_CURRENT_MAX &&
// C/10 or lower current cutoff allowed
bat_conf->topping_current_cutoff < (bat_conf->nominal_capacity / 10.0) &&
bat_conf->topping_current_cutoff > 0.01 &&
+4 -4
View File
@@ -185,10 +185,10 @@ static void adc_init(ADC_TypeDef *adc)
static void adc_setup()
{
#ifdef DT_SWITCH_V_SOLAR_GPIOS_CONTROLLER
struct device *dev = device_get_binding(DT_SWITCH_V_SOLAR_GPIOS_CONTROLLER);
gpio_pin_configure(dev, DT_SWITCH_V_SOLAR_GPIOS_PIN,
DT_SWITCH_V_SOLAR_GPIOS_FLAGS | GPIO_OUTPUT_ACTIVE);
#ifdef DT_OUTPUTS_V_SOLAR_PRESENT
struct device *dev = device_get_binding(DT_OUTPUTS_V_SOLAR_GPIOS_CONTROLLER);
gpio_pin_configure(dev, DT_OUTPUTS_V_SOLAR_GPIOS_PIN,
DT_OUTPUTS_V_SOLAR_GPIOS_FLAGS | GPIO_OUTPUT_ACTIVE);
#endif
adc_init(ADC1);
+4 -4
View File
@@ -155,7 +155,7 @@ const data_object_t data_objects[] = {
TS_DATA_OBJ_BOOL(0x40, "LoadEnDefault", &load.enable,
TS_CONF, TS_READ_ALL | TS_WRITE_ALL),
#if CONFIG_HAS_USB_PWR_OUTPUT
#if DT_OUTPUTS_USB_PWR_PRESENT
TS_DATA_OBJ_BOOL(0x41, "UsbEnDefault", &usb_pwr.enable,
TS_CONF, TS_READ_ALL | TS_WRITE_ALL),
#endif
@@ -178,7 +178,7 @@ const data_object_t data_objects[] = {
TS_DATA_OBJ_INT32(0x47, "LoadUVRecovery_s", &load.lvd_recovery_delay,
TS_CONF, TS_READ_ALL | TS_WRITE_ALL),
#if CONFIG_HAS_USB_PWR_OUTPUT
#if DT_OUTPUTS_USB_PWR_PRESENT
TS_DATA_OBJ_INT32(0x48, "UsbUVRecovery_s", &usb_pwr.lvd_recovery_delay,
TS_CONF, TS_READ_ALL | TS_WRITE_ALL),
#endif
@@ -189,7 +189,7 @@ const data_object_t data_objects[] = {
TS_DATA_OBJ_BOOL(0x60, "LoadEn", &load.enable,
TS_INPUT, TS_READ_ALL | TS_WRITE_ALL),
#if CONFIG_HAS_USB_PWR_OUTPUT
#if DT_OUTPUTS_USB_PWR_PRESENT
TS_DATA_OBJ_BOOL(0x61, "UsbEn", &usb_pwr.enable,
TS_INPUT, TS_READ_ALL | TS_WRITE_ALL),
#endif
@@ -219,7 +219,7 @@ const data_object_t data_objects[] = {
TS_DATA_OBJ_INT32(0x04, "LoadInfo", &load.info,
TS_OUTPUT, TS_READ_ALL),
#if CONFIG_HAS_USB_PWR_OUTPUT
#if DT_OUTPUTS_USB_PWR_PRESENT
TS_DATA_OBJ_INT32(0x05, "UsbInfo", &usb_pwr.info,
TS_OUTPUT, TS_READ_ALL),
#endif
+4 -4
View File
@@ -128,16 +128,16 @@ ThingSetCAN::ThingSetCAN(uint8_t can_node_id, const unsigned int c):
node_id(can_node_id),
channel(c)
{
can_en_dev = device_get_binding(DT_SWITCH_CAN_GPIOS_CONTROLLER);
gpio_pin_configure(can_en_dev, DT_SWITCH_CAN_GPIOS_PIN,
DT_SWITCH_CAN_GPIOS_FLAGS | GPIO_OUTPUT_INACTIVE);
can_en_dev = device_get_binding(DT_OUTPUTS_CAN_EN_GPIOS_CONTROLLER);
gpio_pin_configure(can_en_dev, DT_OUTPUTS_CAN_EN_GPIOS_PIN,
DT_OUTPUTS_CAN_EN_GPIOS_FLAGS | GPIO_OUTPUT_INACTIVE);
can_dev = device_get_binding("CAN_1");
}
void ThingSetCAN::enable()
{
gpio_pin_set(can_en_dev, DT_SWITCH_CAN_GPIOS_PIN, 1);
gpio_pin_set(can_en_dev, DT_OUTPUTS_CAN_EN_GPIOS_PIN, 1);
}
#endif
+4 -4
View File
@@ -57,10 +57,10 @@ OledSSD1306 oled(i2c_dev);
void ExtOled::enable()
{
#ifdef DT_SWITCH_UEXT_GPIOS_CONTROLLER
struct device *dev_uext_dis = device_get_binding(DT_SWITCH_UEXT_GPIOS_CONTROLLER);
gpio_pin_configure(dev_uext_dis, DT_SWITCH_UEXT_GPIOS_PIN,
DT_SWITCH_UEXT_GPIOS_FLAGS | GPIO_OUTPUT_ACTIVE);
#ifdef DT_OUTPUTS_UEXT_EN_PRESENT
struct device *dev_uext_en = device_get_binding(DT_OUTPUTS_UEXT_EN_GPIOS_CONTROLLER);
gpio_pin_configure(dev_uext_en, DT_OUTPUTS_UEXT_EN_GPIOS_PIN,
DT_OUTPUTS_UEXT_EN_GPIOS_FLAGS | GPIO_OUTPUT_ACTIVE);
#endif
oled.init(CONFIG_EXT_OLED_BRIGHTNESS);
+4 -4
View File
@@ -65,11 +65,11 @@ void watchdog_feed(int channel_id)
void start_stm32_bootloader()
{
#ifdef DT_SWITCH_BOOT0_GPIOS_CONTROLLER
#ifdef DT_OUTPUTS_BOOT0_PRESENT
// pin is connected to BOOT0 via resistor and capacitor
struct device *dev = device_get_binding(DT_SWITCH_BOOT0_GPIOS_CONTROLLER);
gpio_pin_configure(dev, DT_SWITCH_BOOT0_GPIOS_PIN,
DT_SWITCH_BOOT0_GPIOS_FLAGS | GPIO_OUTPUT_ACTIVE);
struct device *dev = device_get_binding(DT_OUTPUTS_BOOT0_GPIOS_CONTROLLER);
gpio_pin_configure(dev, DT_OUTPUTS_BOOT0_GPIOS_PIN,
DT_OUTPUTS_BOOT0_GPIOS_FLAGS | GPIO_OUTPUT_ACTIVE);
k_sleep(100); // wait for capacitor at BOOT0 pin to charge up
reset_device();
+2 -2
View File
@@ -44,12 +44,12 @@ void LoadOutput::control()
// junction temperature calculation model for overcurrent detection
junction_temperature = junction_temperature + (
dev_stat.internal_temp - junction_temperature + current * current /
(LOAD_CURRENT_MAX * LOAD_CURRENT_MAX) *
(DT_OUTPUTS_LOAD_CURRENT_MAX * DT_OUTPUTS_LOAD_CURRENT_MAX) *
(DT_CHARGE_CONTROLLER_PCB_MOSFETS_TJ_MAX - DT_CHARGE_CONTROLLER_PCB_INTERNAL_TREF_MAX)
) / (DT_CHARGE_CONTROLLER_PCB_MOSFETS_TAU_JA * CONFIG_CONTROL_FREQUENCY);
if (junction_temperature > DT_CHARGE_CONTROLLER_PCB_MOSFETS_TJ_MAX ||
current > LOAD_CURRENT_MAX * 2)
current > DT_OUTPUTS_LOAD_CURRENT_MAX * 2)
{
flags_set(&error_flags, ERR_LOAD_OVERCURRENT);
oc_timestamp = uptime();
+33 -23
View File
@@ -6,10 +6,10 @@
#include "load.h"
#include <inttypes.h> // for PRIu32 in printf statements
#ifndef UNIT_TEST
#include <inttypes.h> // for PRIu32 in printf statements
#include <zephyr.h>
#include <device.h>
#include <drivers/gpio.h>
@@ -23,12 +23,10 @@
static struct device *dev_load;
#ifdef DT_SWITCH_USB_PWR_GPIOS_CONTROLLER
#ifdef DT_OUTPUTS_USB_PWR_PRESENT
static struct device *dev_usb;
#endif
#endif // UNIT_TEST
#include "board.h"
#include "hardware.h"
#include "leds.h"
@@ -158,53 +156,55 @@ void load_out_set(bool status)
leds_set(LED_LOAD, status);
#endif
#ifdef DT_SWITCH_LOAD_GPIOS_CONTROLLER
gpio_pin_configure(dev_load, DT_SWITCH_LOAD_GPIOS_PIN,
DT_SWITCH_LOAD_GPIOS_FLAGS | GPIO_OUTPUT_INACTIVE);
#ifdef DT_OUTPUTS_LOAD_PRESENT
gpio_pin_configure(dev_load, DT_OUTPUTS_LOAD_GPIOS_PIN,
DT_OUTPUTS_LOAD_GPIOS_FLAGS | GPIO_OUTPUT_INACTIVE);
if (status == true) {
#ifdef PIN_I_LOAD_COMP
lptim_init();
#else
gpio_pin_set(dev_load, DT_SWITCH_LOAD_GPIOS_PIN, 1);
gpio_pin_set(dev_load, DT_OUTPUTS_LOAD_GPIOS_PIN, 1);
#endif
}
else {
gpio_pin_set(dev_load, DT_SWITCH_LOAD_GPIOS_PIN, 0);
gpio_pin_set(dev_load, DT_OUTPUTS_LOAD_GPIOS_PIN, 0);
}
#endif
}
void usb_out_set(bool status)
{
#ifdef DT_SWITCH_USB_PWR_GPIOS_CONTROLLER
gpio_pin_configure(dev_usb, DT_SWITCH_USB_PWR_GPIOS_PIN,
DT_SWITCH_USB_PWR_GPIOS_FLAGS | GPIO_OUTPUT_INACTIVE);
#ifdef DT_OUTPUTS_USB_PWR_PRESENT
gpio_pin_configure(dev_usb, DT_OUTPUTS_USB_PWR_GPIOS_PIN,
DT_OUTPUTS_USB_PWR_GPIOS_FLAGS | GPIO_OUTPUT_INACTIVE);
if (status == true) {
gpio_pin_set(dev_usb, DT_SWITCH_USB_PWR_GPIOS_PIN, 1);
gpio_pin_set(dev_usb, DT_OUTPUTS_USB_PWR_GPIOS_PIN, 1);
}
else {
gpio_pin_set(dev_usb, DT_SWITCH_USB_PWR_GPIOS_PIN, 0);
gpio_pin_set(dev_usb, DT_OUTPUTS_USB_PWR_GPIOS_PIN, 0);
}
#endif
}
void load_cp_enable()
{
#ifdef DT_PWM_OUT_CHARGE_PUMP_PWMS_CONTROLLER
#ifdef DT_OUTPUTS_CHARGE_PUMP_PRESENT
struct device *pwm_dev;
pwm_dev = device_get_binding(DT_PWM_OUT_CHARGE_PUMP_PWMS_CONTROLLER);
pwm_dev = device_get_binding(DT_OUTPUTS_CHARGE_PUMP_PWMS_CONTROLLER);
if (!pwm_dev) {
print_error("Cannot find %s!\n", DT_PWM_OUT_CHARGE_PUMP_PWMS_CONTROLLER);
print_error("Cannot find %s!\n", DT_OUTPUTS_CHARGE_PUMP_PWMS_CONTROLLER);
return;
}
pwm_pin_set_usec(pwm_dev, DT_PWM_OUT_CHARGE_PUMP_PWMS_CHANNEL, 200, 100, 0);
// set to 50% duty cycle
pwm_pin_set_nsec(pwm_dev, DT_OUTPUTS_CHARGE_PUMP_PWMS_CHANNEL,
DT_OUTPUTS_CHARGE_PUMP_PWMS_PERIOD, DT_OUTPUTS_CHARGE_PUMP_PWMS_PERIOD / 2, 0);
#endif
}
void load_out_init()
{
#ifdef DT_SWITCH_LOAD_GPIOS_CONTROLLER
dev_load = device_get_binding(DT_SWITCH_LOAD_GPIOS_CONTROLLER);
#ifdef DT_OUTPUTS_LOAD_PRESENT
dev_load = device_get_binding(DT_OUTPUTS_LOAD_GPIOS_CONTROLLER);
#endif
// analog comparator to detect short circuits and trigger immediate load switch-off
@@ -220,7 +220,17 @@ void load_out_init()
void usb_out_init()
{
#ifdef DT_SWITCH_USB_PWR_GPIOS_CONTROLLER
dev_usb = device_get_binding(DT_SWITCH_USB_PWR_GPIOS_CONTROLLER);
#ifdef DT_OUTPUTS_USB_PWR_PRESENT
dev_usb = device_get_binding(DT_OUTPUTS_USB_PWR_GPIOS_CONTROLLER);
#endif
}
#else // UNIT_TEST
void load_out_init() {;}
void usb_out_init() {;}
void load_out_set(bool) {;}
void usb_out_set(bool) {;}
#endif
+3 -3
View File
@@ -68,7 +68,7 @@ void main(void)
load.set_voltage_limits(bat_conf.voltage_load_disconnect, bat_conf.voltage_load_reconnect,
bat_conf.voltage_absolute_max);
#if CONFIG_HAS_USB_PWR_OUTPUT
#if DT_OUTPUTS_USB_PWR_PRESENT
usb_pwr.set_voltage_limits(bat_conf.voltage_load_disconnect - 0.1, // keep on longer than load
bat_conf.voltage_load_reconnect, bat_conf.voltage_absolute_max);
#endif
@@ -117,11 +117,11 @@ void control_thread()
leds_set_charging(half_bridge_enabled());
#endif
#if CONFIG_HAS_LOAD_OUTPUT
#if DT_OUTPUTS_LOAD_PRESENT
load.control();
#endif
#if CONFIG_HAS_USB_PWR_OUTPUT
#if DT_OUTPUTS_USB_PWR_PRESENT
usb_pwr.control();
#endif
+2 -2
View File
@@ -49,11 +49,11 @@ Dcdc dcdc(&hv_terminal, &dcdc_lv_port, MODE_MPPT_BUCK);
PwmSwitch pwm_switch(&lv_bus);
#endif
#if CONFIG_HAS_LOAD_OUTPUT
#if DT_OUTPUTS_LOAD_PRESENT
LoadOutput load(&lv_bus, &load_out_set, &load_out_init);
#endif
#if CONFIG_HAS_USB_PWR_OUTPUT
#if DT_OUTPUTS_USB_PWR_PRESENT
LoadOutput usb_pwr(&lv_bus, &usb_out_set, &usb_out_init);
#endif
+2 -2
View File
@@ -41,11 +41,11 @@ extern Charger charger;
extern BatConf bat_conf;
extern BatConf bat_conf_user;
#if CONFIG_HAS_LOAD_OUTPUT
#if DT_OUTPUTS_LOAD_PRESENT
extern LoadOutput load;
#endif
#if CONFIG_HAS_USB_PWR_OUTPUT
#if DT_OUTPUTS_USB_PWR_PRESENT
extern LoadOutput usb_pwr;
#endif
+4 -4
View File
@@ -37,8 +37,10 @@
#define DT_INST_0_PWM_SWITCH_PWM_FREQUENCY 50 // Hz
#define DT_INST_0_PWM_SWITCH_CURRENT_MAX 20 // A
#define CONFIG_HAS_LOAD_OUTPUT 1
#define CONFIG_HAS_USB_PWR_OUTPUT 1
#define DT_OUTPUTS_LOAD_PRESENT 1
#define DT_OUTPUTS_LOAD_CURRENT_MAX 20 // PCB maximum load switch current
#define DT_OUTPUTS_USB_PWR_PRESENT 1
// Values that are otherwise defined by Kconfig
#define CONFIG_CONTROL_FREQUENCY 10 // Hz
@@ -46,8 +48,6 @@
#define DT_CHARGE_CONTROLLER_PCB_INTERNAL_TREF_MAX 50
#define DT_CHARGE_CONTROLLER_PCB_MOSFETS_TAU_JA 5
#define LOAD_CURRENT_MAX 20 // PCB maximum load switch current
#define DT_CHARGE_CONTROLLER_PCB_LS_VOLTAGE_MAX 32 // Maximum voltage at battery port (V)
#define DT_CHARGE_CONTROLLER_PCB_HS_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
+1 -1
View File
@@ -101,7 +101,7 @@ void control_on_to_off_overcurrent()
LoadOutput load_out(&bus, &load_drv_set, &load_drv_init);
load_init(&load_out, true);
load_out.current = LOAD_CURRENT_MAX * 1.9; // with factor 2 it is switched off immediately
load_out.current = DT_OUTPUTS_LOAD_CURRENT_MAX * 1.9; // with factor 2 it is switched off immediately
load_out.control();
TEST_ASSERT_EQUAL(LOAD_STATE_ON, load_out.state);
+26
View File
@@ -0,0 +1,26 @@
# Copyright (c) 2020 Martin Jäger / Libre Solar
# SPDX-License-Identifier: Apache-2.0
description: GPIOs used for digital output (either on/off type or PWM signal)
compatible: "outputs"
child-binding:
description: GPIO digital outputs child node
properties:
gpios:
type: phandle-array
description: GPIO handle for on/off type output
pwms:
type: phandle-array
description: PWM handle for PWM type output
current-max:
type: int
description: Maximum current of driven power switch (A)
label:
type: string
required: true
description: Human readable string describing the device (used by Zephyr for API name)
present:
type: int
default: 1
-17
View File
@@ -1,17 +0,0 @@
# Copyright (c) 2020 Martin Jäger / Libre Solar
# SPDX-License-Identifier: Apache-2.0
description: GPIO pins to generate a PWM signal
compatible: "pwm-out"
child-binding:
description: PWM output child node
properties:
pwms:
type: phandle-array
required: true
label:
type: string
required: true
description: Human readable string describing the device (used by Zephyr for API name)
-17
View File
@@ -1,17 +0,0 @@
# Copyright (c) 2020 Martin Jäger / Libre Solar
# SPDX-License-Identifier: Apache-2.0
description: GPIO pins to switch something on or off
compatible: "switch"
child-binding:
description: GPIO switch child node
properties:
gpios:
type: phandle-array
required: true
label:
type: string
required: true
description: Human readable string describing the device (used by Zephyr for API name)
+2 -2
View File
@@ -37,8 +37,8 @@
/delete-node/ c;
};
switches {
compatible = "switch";
outputs {
compatible = "outputs";
load {
gpios = <&gpioc 13 GPIO_ACTIVE_HIGH>;
label = "Load enable";