Upgrade to Zephyr v4.3 and migrate boards
Also use new Zephyr CI environment and compile all boards. Board migration script example: python ../zephyr/scripts/utils/board_v1_to_v2.py --board-root . \ -v libresolar -g libresolar -b pwm_2420_lus -s stm32l072xx
This commit is contained in:
@@ -1,45 +1,54 @@
|
|||||||
name: Build with Zephyr toolchain
|
name: Build firmware
|
||||||
|
|
||||||
on: [push, pull_request]
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
# Avoid running twice if pushing to a PR branch in the base repo
|
||||||
|
if: >
|
||||||
|
github.event_name != 'pull_request' ||
|
||||||
|
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: zephyrprojectrtos/ci:latest
|
defaults:
|
||||||
env:
|
run:
|
||||||
CMAKE_PREFIX_PATH: /opt/toolchains
|
working-directory: firmware
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
path: charge-controller-firmware
|
path: firmware
|
||||||
fetch-depth: 0
|
fetch-depth: 0 # necessary to get tags
|
||||||
|
|
||||||
- name: Initialize
|
- name: Python setup
|
||||||
working-directory: charge-controller-firmware
|
uses: actions/setup-python@v6
|
||||||
run: |
|
with:
|
||||||
west init -l .
|
python-version: 3.12
|
||||||
west update --narrow
|
|
||||||
|
- name: Zephyr project setup
|
||||||
|
uses: zephyrproject-rtos/action-zephyr-setup@v1
|
||||||
|
with:
|
||||||
|
app-path: firmware
|
||||||
|
toolchains: arm-zephyr-eabi
|
||||||
|
|
||||||
- name: Coding style check
|
- name: Coding style check
|
||||||
working-directory: charge-controller-firmware
|
|
||||||
run: |
|
run: |
|
||||||
apt-get update
|
sudo apt-get update
|
||||||
apt-get install -y clang-format-12 colordiff
|
sudo apt-get install -y clang-format-15 colordiff
|
||||||
git status
|
git status
|
||||||
bash scripts/check-style.sh
|
bash scripts/check-style.sh
|
||||||
|
|
||||||
- name: Build firmware
|
- name: Build firmware
|
||||||
working-directory: charge-controller-firmware
|
|
||||||
run: |
|
run: |
|
||||||
cd app
|
west build -b mppt_1210_hus app -p
|
||||||
west build -b mppt_2420_hc@0.2 -p
|
west build -b mppt_2420_hc app -p
|
||||||
west build -b mppt_2420_lc -p
|
west build -b mppt_2420_hpx app -p
|
||||||
west build -b mppt_1210_hus@0.7 -p
|
west build -b mppt_2420_lc app -p
|
||||||
west build -b pwm_2420_lus@0.3 -p
|
west build -b mppt_2420_rc app -p
|
||||||
|
west build -b nucleo_g474re app -p
|
||||||
|
west build -b pwm_2420_lus app -p
|
||||||
|
|
||||||
- name: Run unit-tests
|
- name: Run tests
|
||||||
working-directory: charge-controller-firmware
|
|
||||||
run: |
|
run: |
|
||||||
cd tests
|
west build -b native_sim -t run tests -p
|
||||||
west build -b native_posix -t run
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ build
|
|||||||
*~
|
*~
|
||||||
|
|
||||||
# others
|
# others
|
||||||
|
.cache
|
||||||
.clang_complete
|
.clang_complete
|
||||||
.gcc-flags.json
|
.gcc-flags.json
|
||||||
.pio
|
.pio
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# Copyright (c) The Libre Solar Project Contributors
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
zephyr_include_directories(include)
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
|
|
||||||
# custom DTS overlays
|
|
||||||
*.overlay
|
|
||||||
|
|
||||||
# custom project configuration per board
|
|
||||||
prj_*.conf
|
|
||||||
|
|
||||||
# alternative location for custom DTS overlays or conf files
|
|
||||||
boards*
|
|
||||||
|
|
||||||
# folders generated by west
|
|
||||||
build
|
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
# Copyright (c) The Libre Solar Project Contributors
|
# Copyright (c) The Libre Solar Project Contributors
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
set(BOARD_ROOT ${CMAKE_SOURCE_DIR}/..)
|
|
||||||
set(DTS_ROOT ${CMAKE_SOURCE_DIR}/..)
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.13.1)
|
cmake_minimum_required(VERSION 3.13.1)
|
||||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,159 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019 STMicroelectronics.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is a dummy charge controller board for testing new features using the STM32G474 MCU
|
||||||
|
*
|
||||||
|
* IMPORTANT: You have to remove the VREF jumper on the Nucleo board to make it work. Otherwise
|
||||||
|
* the MCU will get stuck while trying to generate a reference voltage at VREF+ pin.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/ {
|
||||||
|
/* delete conflicting nodes from Zephyr board */
|
||||||
|
/delete-node/ leds;
|
||||||
|
/delete-node/ aliases;
|
||||||
|
|
||||||
|
pcb {
|
||||||
|
compatible = "charge-controller";
|
||||||
|
|
||||||
|
type = "Nucleo G474 dummy charge controller";
|
||||||
|
version-str = "v0.1";
|
||||||
|
version-num = <1>;
|
||||||
|
|
||||||
|
hs-voltage-max = <80>;
|
||||||
|
ls-voltage-max = <32>;
|
||||||
|
dcdc-current-max = <20>;
|
||||||
|
};
|
||||||
|
|
||||||
|
chosen {
|
||||||
|
zephyr,console = &lpuart1;
|
||||||
|
zephyr,shell-uart = &lpuart1;
|
||||||
|
zephyr,sram = &sram0;
|
||||||
|
zephyr,flash = &flash0;
|
||||||
|
zephyr,canbus = &fdcan1;
|
||||||
|
};
|
||||||
|
|
||||||
|
leds {
|
||||||
|
compatible = "charlieplexing-leds";
|
||||||
|
gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>;
|
||||||
|
|
||||||
|
pwr {
|
||||||
|
states = <1>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs {
|
||||||
|
compatible = "outputs";
|
||||||
|
|
||||||
|
can_en {
|
||||||
|
gpios = <&gpiob 11 GPIO_ACTIVE_LOW>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
adc-inputs {
|
||||||
|
compatible = "adc-inputs";
|
||||||
|
|
||||||
|
v-low {
|
||||||
|
io-channels = <&adc1 12>;
|
||||||
|
multiplier = <105600>;
|
||||||
|
divider = <5600>;
|
||||||
|
};
|
||||||
|
|
||||||
|
v-high {
|
||||||
|
io-channels = <&adc1 15>;
|
||||||
|
multiplier = <102200>;
|
||||||
|
divider = <2200>;
|
||||||
|
};
|
||||||
|
|
||||||
|
vref-mcu {
|
||||||
|
io-channels = <&adc1 18>;
|
||||||
|
multiplier = <1>;
|
||||||
|
divider = <1>;
|
||||||
|
};
|
||||||
|
|
||||||
|
temp-mcu {
|
||||||
|
io-channels = <&adc1 16>;
|
||||||
|
multiplier = <1>;
|
||||||
|
divider = <1>;
|
||||||
|
};
|
||||||
|
|
||||||
|
i-dcdc {
|
||||||
|
io-channels = <&adc2 1>;
|
||||||
|
// amp gain: 25, resistor: 2 mOhm
|
||||||
|
multiplier = <1000>; // 1000
|
||||||
|
divider = <50>; // 2*25
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
gpio_keys {
|
||||||
|
compatible = "gpio-keys";
|
||||||
|
user_button: button {
|
||||||
|
gpios = <&gpioc 13 GPIO_ACTIVE_LOW>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
aliases {
|
||||||
|
sw0 = &user_button;
|
||||||
|
uart-dbg = &lpuart1;
|
||||||
|
uart-uext = &usart1;
|
||||||
|
spi-uext = &spi1;
|
||||||
|
i2c-uext = &i2c1;
|
||||||
|
};
|
||||||
|
|
||||||
|
soc {
|
||||||
|
hrtim1: timers@40016800 {
|
||||||
|
compatible = "st,stm32-timers";
|
||||||
|
reg = <0x40016800 0x400>;
|
||||||
|
clocks = <&rcc STM32_CLOCK(APB2, 26)>;
|
||||||
|
resets = <&rctl STM32_RESET(APB2, 26)>;
|
||||||
|
interrupts = <67 0>, <68 0>, <69 0>, <70 0>,
|
||||||
|
<71 0>, <72 0>, <73 0>, <74 0>;
|
||||||
|
interrupt-names = "master", "tima", "timb", "timc",
|
||||||
|
"timd", "time", "flt", "timf";
|
||||||
|
st,prescaler = <0>;
|
||||||
|
status = "disabled";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
&hrtim1 {
|
||||||
|
status = "okay";
|
||||||
|
|
||||||
|
halfbridge: halfbridge {
|
||||||
|
compatible = "half-bridge";
|
||||||
|
pinctrl-0 = <&hrtim1_cha1_pa8 &hrtim1_cha2_pa9>;
|
||||||
|
pinctrl-names = "default";
|
||||||
|
frequency = <70000>;
|
||||||
|
deadtime = <300>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
// alternative to HRTIM
|
||||||
|
&timers1 {
|
||||||
|
status = "okay";
|
||||||
|
|
||||||
|
halfbridge: halfbridge {
|
||||||
|
compatible = "half-bridge";
|
||||||
|
pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pb13>;
|
||||||
|
pinctrl-names = "default";
|
||||||
|
frequency = <70000>;
|
||||||
|
deadtime = <300>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
&adc1 {
|
||||||
|
pinctrl-0 = <&adc1_in1_pa0>;
|
||||||
|
pinctrl-names = "default";
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
||||||
|
&fdcan1 {
|
||||||
|
bitrate = <500000>;
|
||||||
|
bitrate-data = <2000000>;
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
@@ -19,6 +19,8 @@ CONFIG_REBOOT=y
|
|||||||
|
|
||||||
CONFIG_HWINFO=y
|
CONFIG_HWINFO=y
|
||||||
|
|
||||||
|
CONFIG_CRC=y
|
||||||
|
|
||||||
CONFIG_CONSOLE_SUBSYS=y
|
CONFIG_CONSOLE_SUBSYS=y
|
||||||
CONFIG_CONSOLE_GETCHAR=y
|
CONFIG_CONSOLE_GETCHAR=y
|
||||||
|
|
||||||
|
|||||||
+16
-13
@@ -226,12 +226,12 @@ bool battery_conf_check(BatConf *bat_conf)
|
|||||||
{ .func =
|
{ .func =
|
||||||
[bat_conf]() {
|
[bat_conf]() {
|
||||||
return bat_conf->load_reconnect_voltage
|
return bat_conf->load_reconnect_voltage
|
||||||
> (bat_conf->load_disconnect_voltage + 0.4);
|
> (bat_conf->load_disconnect_voltage + 0.4f);
|
||||||
},
|
},
|
||||||
.text = "Load Reconnect Voltage must be higher than Load Disconnect Voltage + 0.4" },
|
.text = "Load Reconnect Voltage must be higher than Load Disconnect Voltage + 0.4" },
|
||||||
{ .func =
|
{ .func =
|
||||||
[bat_conf]() {
|
[bat_conf]() {
|
||||||
return bat_conf->recharge_voltage < (bat_conf->topping_voltage - 0.4);
|
return bat_conf->recharge_voltage < (bat_conf->topping_voltage - 0.4f);
|
||||||
},
|
},
|
||||||
.text = "Recharge Voltage must be lower than Topping Voltage - 0.4" },
|
.text = "Recharge Voltage must be lower than Topping Voltage - 0.4" },
|
||||||
{ .func =
|
{ .func =
|
||||||
@@ -241,28 +241,29 @@ bool battery_conf_check(BatConf *bat_conf)
|
|||||||
.text = "Recharge Voltage must be higher than Load Disconnect Voltage + 1.0" },
|
.text = "Recharge Voltage must be higher than Load Disconnect Voltage + 1.0" },
|
||||||
{ .func =
|
{ .func =
|
||||||
[bat_conf]() {
|
[bat_conf]() {
|
||||||
return bat_conf->load_disconnect_voltage > (bat_conf->absolute_min_voltage + 0.4);
|
return bat_conf->load_disconnect_voltage
|
||||||
|
> (bat_conf->absolute_min_voltage + 0.4f);
|
||||||
},
|
},
|
||||||
.text = "Load Disconnecct Voltage must be higher than Absolute Min Voltage + 0.4" },
|
.text = "Load Disconnecct Voltage must be higher than Absolute Min Voltage + 0.4" },
|
||||||
{ .func =
|
{ .func =
|
||||||
[bat_conf]() {
|
[bat_conf]() {
|
||||||
return bat_conf->internal_resistance
|
return bat_conf->internal_resistance
|
||||||
< bat_conf->load_disconnect_voltage * 0.1 / DISCHARGE_CURRENT_MAX;
|
< bat_conf->load_disconnect_voltage * 0.1f / DISCHARGE_CURRENT_MAX;
|
||||||
},
|
},
|
||||||
.text = "Internal Battery Resistance must not cause more than 10% drop at Max Discharge "
|
.text = "Internal Battery Resistance must not cause more than 10% drop at Max Discharge "
|
||||||
"Current" },
|
"Current" },
|
||||||
{ .func =
|
{ .func =
|
||||||
[bat_conf]() {
|
[bat_conf]() {
|
||||||
return bat_conf->wire_resistance
|
return bat_conf->wire_resistance
|
||||||
< bat_conf->topping_voltage * 0.03 / DISCHARGE_CURRENT_MAX;
|
< bat_conf->topping_voltage * 0.03f / DISCHARGE_CURRENT_MAX;
|
||||||
},
|
},
|
||||||
.text = "Wire Resistances must not cause more than 3% drop at Max Discharge Current" },
|
.text = "Wire Resistances must not cause more than 3% drop at Max Discharge Current" },
|
||||||
{ .func =
|
{ .func =
|
||||||
[bat_conf]() {
|
[bat_conf]() {
|
||||||
return bat_conf->topping_cutoff_current < (bat_conf->nominal_capacity / 10.0);
|
return bat_conf->topping_cutoff_current < (bat_conf->nominal_capacity / 10.0f);
|
||||||
},
|
},
|
||||||
.text = "Topping Cutoff Current must be less than 10% of Nominal Capacity (C/10)" },
|
.text = "Topping Cutoff Current must be less than 10% of Nominal Capacity (C/10)" },
|
||||||
{ .func = [bat_conf]() { return bat_conf->topping_cutoff_current > 0.01; },
|
{ .func = [bat_conf]() { return bat_conf->topping_cutoff_current > 0.01f; },
|
||||||
.text = "Topping Cutoff Current must be higher than 0.01A" },
|
.text = "Topping Cutoff Current must be higher than 0.01A" },
|
||||||
{ .func =
|
{ .func =
|
||||||
[bat_conf]() {
|
[bat_conf]() {
|
||||||
@@ -355,10 +356,10 @@ void Charger::detect_num_batteries(BatConf *bat) const
|
|||||||
&& port->bus->voltage < bat->absolute_max_voltage * 2)
|
&& port->bus->voltage < bat->absolute_max_voltage * 2)
|
||||||
{
|
{
|
||||||
port->bus->series_multiplier = 2;
|
port->bus->series_multiplier = 2;
|
||||||
printf("Detected two batteries (total %.2f V max)\n", bat->topping_voltage * 2);
|
printf("Detected two batteries (total %.2f V max)\n", (double)bat->topping_voltage * 2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Detected single battery (%.2f V max)\n", bat->topping_voltage);
|
printf("Detected single battery (%.2f V max)\n", (double)bat->topping_voltage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,9 +367,9 @@ void Charger::update_soc(BatConf *bat_conf)
|
|||||||
{
|
{
|
||||||
static int soc_filtered = 0; // SOC / 100 for better filtering
|
static int soc_filtered = 0; // SOC / 100 for better filtering
|
||||||
|
|
||||||
if (fabs(port->current) < 0.2) {
|
if (fabs(port->current) < 0.2f) {
|
||||||
int soc_new = (int)((port->bus->voltage - bat_conf->ocv_empty)
|
int soc_new = (int)((port->bus->voltage - bat_conf->ocv_empty)
|
||||||
/ (bat_conf->ocv_full - bat_conf->ocv_empty) * 10000.0);
|
/ (bat_conf->ocv_full - bat_conf->ocv_empty) * 10000.0f);
|
||||||
|
|
||||||
if (soc_new > 500 && soc_filtered == 0) {
|
if (soc_new > 500 && soc_filtered == 0) {
|
||||||
// bypass filter during initialization
|
// bypass filter during initialization
|
||||||
@@ -452,7 +453,8 @@ void Charger::discharge_control(BatConf *bat_conf)
|
|||||||
// discharging currently not allowed. should we allow it?
|
// discharging currently not allowed. should we allow it?
|
||||||
|
|
||||||
if (port->bus->voltage
|
if (port->bus->voltage
|
||||||
>= port->bus->src_control_voltage(bat_conf->absolute_min_voltage + 0.1F)) {
|
>= port->bus->src_control_voltage(bat_conf->absolute_min_voltage + 0.1F))
|
||||||
|
{
|
||||||
dev_stat.clear_error(ERR_BAT_UNDERVOLTAGE);
|
dev_stat.clear_error(ERR_BAT_UNDERVOLTAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,7 +465,8 @@ void Charger::discharge_control(BatConf *bat_conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!dev_stat.has_error(ERR_BAT_UNDERVOLTAGE | ERR_BAT_DIS_OVERTEMP
|
if (!dev_stat.has_error(ERR_BAT_UNDERVOLTAGE | ERR_BAT_DIS_OVERTEMP
|
||||||
| ERR_BAT_DIS_UNDERTEMP)) {
|
| ERR_BAT_DIS_UNDERTEMP))
|
||||||
|
{
|
||||||
// discharge current is stored as absolute value in bat_conf, but defined
|
// discharge current is stored as absolute value in bat_conf, but defined
|
||||||
// as negative current for power port
|
// as negative current for power port
|
||||||
port->neg_current_limit = -bat_conf->discharge_current_max;
|
port->neg_current_limit = -bat_conf->discharge_current_max;
|
||||||
|
|||||||
+6
-5
@@ -91,7 +91,8 @@ static inline float ntc_temp(uint32_t channel, int32_t vref, float ntc_series_re
|
|||||||
// resistance of NTC (Ohm)
|
// resistance of NTC (Ohm)
|
||||||
float rts = ntc_series_resistor * v_temp / (vref - v_temp);
|
float rts = ntc_series_resistor * v_temp / (vref - v_temp);
|
||||||
|
|
||||||
return 1.0 / (1.0 / (273.15 + 25) + 1.0 / NTC_BETA_VALUE * log(rts / 10000.0)) - 273.15; // °C
|
return 1.0f / (1.0f / (273.15f + 25.0f) + 1.0f / (float)NTC_BETA_VALUE * logf(rts / 10000.0f))
|
||||||
|
- 273.15f; // °C
|
||||||
}
|
}
|
||||||
|
|
||||||
void calibrate_current_sensors()
|
void calibrate_current_sensors()
|
||||||
@@ -369,13 +370,13 @@ void prepare_adc_readings(AdcValues values)
|
|||||||
{
|
{
|
||||||
adc_readings[ADC_POS(vref_mcu)] = (uint16_t)(1.224 / 3.3 * 4096) << 4;
|
adc_readings[ADC_POS(vref_mcu)] = (uint16_t)(1.224 / 3.3 * 4096) << 4;
|
||||||
adc_readings[ADC_POS(v_high)] =
|
adc_readings[ADC_POS(v_high)] =
|
||||||
(uint16_t)((values.solar_voltage / ADC_GAIN(v_high)) / 3.3 * 4096) << 4;
|
(uint16_t)((values.solar_voltage / ADC_GAIN(v_high)) / 3.3f * 4096) << 4;
|
||||||
adc_readings[ADC_POS(v_low)] =
|
adc_readings[ADC_POS(v_low)] =
|
||||||
(uint16_t)((values.battery_voltage / ADC_GAIN(v_low)) / 3.3 * 4096) << 4;
|
(uint16_t)((values.battery_voltage / ADC_GAIN(v_low)) / 3.3f * 4096) << 4;
|
||||||
adc_readings[ADC_POS(i_dcdc)] =
|
adc_readings[ADC_POS(i_dcdc)] =
|
||||||
(uint16_t)((values.dcdc_current / ADC_GAIN(i_dcdc)) / 3.3 * 4096) << 4;
|
(uint16_t)((values.dcdc_current / ADC_GAIN(i_dcdc)) / 3.3f * 4096) << 4;
|
||||||
adc_readings[ADC_POS(i_load)] =
|
adc_readings[ADC_POS(i_load)] =
|
||||||
(uint16_t)((values.load_current / ADC_GAIN(i_load)) / 3.3 * 4096) << 4;
|
(uint16_t)((values.load_current / ADC_GAIN(i_load)) / 3.3f * 4096) << 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepare_adc_filtered()
|
void prepare_adc_filtered()
|
||||||
|
|||||||
@@ -1175,7 +1175,9 @@ void data_objects_init()
|
|||||||
hwinfo_get_device_id(buf, sizeof(buf));
|
hwinfo_get_device_id(buf, sizeof(buf));
|
||||||
|
|
||||||
uint64_t id64 = crc32_ieee(buf, sizeof(buf));
|
uint64_t id64 = crc32_ieee(buf, sizeof(buf));
|
||||||
|
#ifdef CONFIG_LIBRE_SOLAR_TYPE_ID
|
||||||
id64 += ((uint64_t)CONFIG_LIBRE_SOLAR_TYPE_ID) << 32;
|
id64 += ((uint64_t)CONFIG_LIBRE_SOLAR_TYPE_ID) << 32;
|
||||||
|
#endif
|
||||||
|
|
||||||
uint64_to_base32(id64, device_id, sizeof(device_id), alphabet_crockford);
|
uint64_to_base32(id64, device_id, sizeof(device_id), alphabet_crockford);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
#include "mcu.h"
|
#include "mcu.h"
|
||||||
#include "thingset.h"
|
#include "thingset.h"
|
||||||
|
#include "zephyr/toolchain.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ LOG_MODULE_REGISTER(nvs, CONFIG_DATA_STORAGE_LOG_LEVEL);
|
|||||||
K_MUTEX_DEFINE(data_buf_lock);
|
K_MUTEX_DEFINE(data_buf_lock);
|
||||||
|
|
||||||
// Buffer used by store and restore functions (must be word-aligned for hardware CRC calculation)
|
// Buffer used by store and restore functions (must be word-aligned for hardware CRC calculation)
|
||||||
static uint8_t buf[512] __aligned(sizeof(uint32_t));
|
__maybe_unused static uint8_t buf[512] __aligned(sizeof(uint32_t));
|
||||||
|
|
||||||
extern ThingSet ts;
|
extern ThingSet ts;
|
||||||
|
|
||||||
|
|||||||
+16
-12
@@ -69,7 +69,7 @@ void Dcdc::perturb_observe_buck()
|
|||||||
power_good_timestamp = uptime();
|
power_good_timestamp = uptime();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((uptime() - power_good_timestamp > 10 || power < -10.0) && mode != DCDC_MODE_AUTO) {
|
if ((uptime() - power_good_timestamp > 10 || power < -10.0f) && mode != DCDC_MODE_AUTO) {
|
||||||
// switch off after 10s low power or negative power (if not in nanogrid mode)
|
// switch off after 10s low power or negative power (if not in nanogrid mode)
|
||||||
pwm_direction = 0;
|
pwm_direction = 0;
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ void Dcdc::perturb_observe_boost()
|
|||||||
power_good_timestamp = uptime();
|
power_good_timestamp = uptime();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((uptime() - power_good_timestamp > 10 || -power < -10.0) && mode != DCDC_MODE_AUTO) {
|
if ((uptime() - power_good_timestamp > 10 || -power < -10.0f) && mode != DCDC_MODE_AUTO) {
|
||||||
// switch off after 10s low power or negative power (if not in nanogrid mode)
|
// switch off after 10s low power or negative power (if not in nanogrid mode)
|
||||||
pwm_direction = 0;
|
pwm_direction = 0;
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ __weak DcdcOperationMode Dcdc::check_start_conditions()
|
|||||||
|
|
||||||
if (lvb->sink_current_margin > 0 && lvb->voltage < lvb->sink_control_voltage()
|
if (lvb->sink_current_margin > 0 && lvb->voltage < lvb->sink_control_voltage()
|
||||||
&& hvb->src_current_margin < 0 && hvb->voltage > hvb->src_control_voltage()
|
&& hvb->src_current_margin < 0 && hvb->voltage > hvb->src_control_voltage()
|
||||||
&& hvb->voltage * 0.85 > lvb->voltage)
|
&& hvb->voltage * 0.85f > lvb->voltage)
|
||||||
{
|
{
|
||||||
return DCDC_MODE_BUCK;
|
return DCDC_MODE_BUCK;
|
||||||
}
|
}
|
||||||
@@ -259,7 +259,8 @@ __weak void Dcdc::control()
|
|||||||
half_bridge_start();
|
half_bridge_start();
|
||||||
power_good_timestamp = uptime();
|
power_good_timestamp = uptime();
|
||||||
printf("DC/DC %s mode start (HV: %.2fV, LV: %.2fV, PWM: %.1f).\n", mode_name,
|
printf("DC/DC %s mode start (HV: %.2fV, LV: %.2fV, PWM: %.1f).\n", mode_name,
|
||||||
hvb->voltage, lvb->voltage, half_bridge_get_duty_cycle() * 100);
|
(double)hvb->voltage, (double)lvb->voltage,
|
||||||
|
(double)half_bridge_get_duty_cycle() * 100.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
startup_inhibit(true); // reset inhibit counter
|
startup_inhibit(true); // reset inhibit counter
|
||||||
@@ -275,7 +276,7 @@ __weak void Dcdc::control()
|
|||||||
stop_reason = "disabled";
|
stop_reason = "disabled";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (mode == DCDC_MODE_BUCK || (mode == DCDC_MODE_AUTO && inductor_current > 0.1)) {
|
if (mode == DCDC_MODE_BUCK || (mode == DCDC_MODE_AUTO && inductor_current > 0.1f)) {
|
||||||
perturb_observe_buck();
|
perturb_observe_buck();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -289,9 +290,10 @@ __weak void Dcdc::control()
|
|||||||
LOG_DBG("P %.2fW, inductor %.2fA, HS: %.2fV, %.2fA margin, "
|
LOG_DBG("P %.2fW, inductor %.2fA, HS: %.2fV, %.2fA margin, "
|
||||||
"LS: %.2fV (target %.2fV), %.2fA margin, "
|
"LS: %.2fV (target %.2fV), %.2fA margin, "
|
||||||
"PWM: %.1f, dcdc_state: %d, pwm_direction: %d",
|
"PWM: %.1f, dcdc_state: %d, pwm_direction: %d",
|
||||||
power, inductor_current, hvb->voltage, hvb->src_current_margin,
|
(double)power, (double)inductor_current, (double)hvb->voltage,
|
||||||
lvb->voltage, lvb->sink_voltage_intercept, lvb->sink_current_margin,
|
(double)hvb->src_current_margin, (double)lvb->voltage,
|
||||||
half_bridge_get_duty_cycle() * 100.0, state, pwm_direction);
|
(double)lvb->sink_voltage_intercept, (double)lvb->sink_current_margin,
|
||||||
|
(double)half_bridge_get_duty_cycle() * 100.0, state, pwm_direction);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stop_reason = "low power";
|
stop_reason = "low power";
|
||||||
@@ -316,7 +318,7 @@ void Dcdc::test()
|
|||||||
stop_reason = "disabled";
|
stop_reason = "disabled";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (half_bridge_get_duty_cycle() > 0.50) {
|
if (half_bridge_get_duty_cycle() > 0.50f) {
|
||||||
half_bridge_set_ccr(half_bridge_get_ccr() - 1);
|
half_bridge_set_ccr(half_bridge_get_ccr() - 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -337,8 +339,9 @@ void Dcdc::test()
|
|||||||
|
|
||||||
half_bridge_set_duty_cycle(lvb->voltage / hvb->voltage);
|
half_bridge_set_duty_cycle(lvb->voltage / hvb->voltage);
|
||||||
half_bridge_start();
|
half_bridge_start();
|
||||||
printf("DC/DC test mode start (HV: %.2fV, LV: %.2fV, PWM: %.1f).\n", hvb->voltage,
|
printf("DC/DC test mode start (HV: %.2fV, LV: %.2fV, PWM: %.1f).\n",
|
||||||
lvb->voltage, half_bridge_get_duty_cycle() * 100);
|
(double)hvb->voltage, (double)lvb->voltage,
|
||||||
|
(double)half_bridge_get_duty_cycle() * 100.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
startup_inhibit(true); // reset inhibit counter
|
startup_inhibit(true); // reset inhibit counter
|
||||||
@@ -394,6 +397,7 @@ void Dcdc::output_hvs_disable()
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
Dcdc::Dcdc(DcBus *high, DcBus *low, DcdcOperationMode op_mode) {}
|
Dcdc::Dcdc(DcBus *high, DcBus *low, DcdcOperationMode op_mode)
|
||||||
|
{}
|
||||||
|
|
||||||
#endif /* BOARD_HAS_DCDC */
|
#endif /* BOARD_HAS_DCDC */
|
||||||
|
|||||||
+11
-12
@@ -33,7 +33,11 @@ extern ThingSet ts;
|
|||||||
extern uint16_t can_node_addr;
|
extern uint16_t can_node_addr;
|
||||||
extern Charger charger;
|
extern Charger charger;
|
||||||
|
|
||||||
|
#if DT_NODE_EXISTS(DT_NODELABEL(can1))
|
||||||
static const struct device *can_dev = DEVICE_DT_GET(DT_NODELABEL(can1));
|
static const struct device *can_dev = DEVICE_DT_GET(DT_NODELABEL(can1));
|
||||||
|
#elif DT_NODE_EXISTS(DT_NODELABEL(fdcan1))
|
||||||
|
static const struct device *can_dev = DEVICE_DT_GET(DT_NODELABEL(fdcan1));
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_ISOTP
|
#ifdef CONFIG_ISOTP
|
||||||
|
|
||||||
@@ -46,15 +50,13 @@ const struct isotp_fc_opts fc_opts = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct isotp_msg_id rx_addr = {
|
struct isotp_msg_id rx_addr = {
|
||||||
.id_type = CAN_EXTENDED_IDENTIFIER,
|
// enable SAE J1939 compatible addressing
|
||||||
.use_ext_addr = 0, // Normal ISO-TP addressing (using only CAN ID)
|
.flags = ISOTP_MSG_FIXED_ADDR | ISOTP_MSG_IDE,
|
||||||
.use_fixed_addr = 1, // enable SAE J1939 compatible addressing
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct isotp_msg_id tx_addr = {
|
struct isotp_msg_id tx_addr = {
|
||||||
.id_type = CAN_EXTENDED_IDENTIFIER,
|
// enable SAE J1939 compatible addressing
|
||||||
.use_ext_addr = 0, // Normal ISO-TP addressing (using only CAN ID)
|
.flags = ISOTP_MSG_FIXED_ADDR | ISOTP_MSG_IDE,
|
||||||
.use_fixed_addr = 1, // enable SAE J1939 compatible addressing
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct isotp_recv_ctx recv_ctx;
|
static struct isotp_recv_ctx recv_ctx;
|
||||||
@@ -146,10 +148,8 @@ CAN_MSGQ_DEFINE(sub_msgq, 10);
|
|||||||
|
|
||||||
const struct can_filter ctrl_filter = {
|
const struct can_filter ctrl_filter = {
|
||||||
.id = TS_CAN_TYPE_PUBSUB,
|
.id = TS_CAN_TYPE_PUBSUB,
|
||||||
.rtr = CAN_DATAFRAME,
|
.mask = TS_CAN_TYPE_MASK,
|
||||||
.id_type = CAN_EXTENDED_IDENTIFIER,
|
.flags = CAN_FILTER_IDE,
|
||||||
.id_mask = TS_CAN_TYPE_MASK,
|
|
||||||
.rtr_mask = 1,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void can_pub_isr(const struct device *dev, int error, void *user_data)
|
void can_pub_isr(const struct device *dev, int error, void *user_data)
|
||||||
@@ -160,9 +160,8 @@ void can_pub_isr(const struct device *dev, int error, void *user_data)
|
|||||||
void can_pub_send(uint32_t can_id, uint8_t can_data[8], uint8_t data_len)
|
void can_pub_send(uint32_t can_id, uint8_t can_data[8], uint8_t data_len)
|
||||||
{
|
{
|
||||||
struct can_frame frame = { 0 };
|
struct can_frame frame = { 0 };
|
||||||
frame.id_type = CAN_EXTENDED_IDENTIFIER;
|
|
||||||
frame.rtr = CAN_DATAFRAME;
|
|
||||||
frame.id = can_id;
|
frame.id = can_id;
|
||||||
|
frame.flags = CAN_FRAME_IDE;
|
||||||
memcpy(frame.data, can_data, 8);
|
memcpy(frame.data, can_data, 8);
|
||||||
|
|
||||||
if (data_len >= 0) {
|
if (data_len >= 0) {
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ void half_bridge_init(int freq_kHz, int deadtime_ns, float min_duty, float max_d
|
|||||||
|
|
||||||
void half_bridge_set_duty_cycle(float duty)
|
void half_bridge_set_duty_cycle(float duty)
|
||||||
{
|
{
|
||||||
if (duty >= 0.0 && duty <= 1.0) {
|
if (duty >= 0.0f && duty <= 1.0f) {
|
||||||
half_bridge_set_ccr(half_bridge_get_arr() * duty);
|
half_bridge_set_ccr(half_bridge_get_arr() * duty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ int main(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BOARD_HAS_USB_OUTPUT
|
#if BOARD_HAS_USB_OUTPUT
|
||||||
usb_pwr.set_voltage_limits(bat_conf.load_disconnect_voltage - 0.1, // keep on longer than load
|
usb_pwr.set_voltage_limits(bat_conf.load_disconnect_voltage - 0.1f, // keep on longer than load
|
||||||
bat_conf.load_reconnect_voltage, bat_conf.absolute_max_voltage);
|
bat_conf.load_reconnect_voltage, bat_conf.absolute_max_voltage);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
board_check_revision(
|
|
||||||
FORMAT MAJOR.MINOR.PATCH
|
|
||||||
DEFAULT_REVISION 0.7.1
|
|
||||||
)
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
board_check_revision(FORMAT MAJOR.MINOR.PATCH)
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
# STM32G474RE Nucleo board configuration
|
|
||||||
|
|
||||||
# Copyright (c) 2019 STMicroelectronics.
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
config BOARD_NUCLEO_G474RE
|
|
||||||
bool "Nucleo G474RE Development Board"
|
|
||||||
depends on SOC_STM32G474XX
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# STM32G474RE Nucleo board configuration
|
|
||||||
|
|
||||||
# Copyright (c) 2019 STMicroelectronics.
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
if BOARD_NUCLEO_G474RE
|
|
||||||
|
|
||||||
config BOARD
|
|
||||||
default "nucleo_g474re"
|
|
||||||
|
|
||||||
config LIBRE_SOLAR_TYPE_ID
|
|
||||||
default 0
|
|
||||||
|
|
||||||
endif # BOARD_NUCLEO_G431RB
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
# use target=stm32g474rbtx instead of stm32g474retx
|
|
||||||
# to allow board re-flashing (see PR #23230)
|
|
||||||
board_runner_args(pyocd "--target=stm32g474rbtx")
|
|
||||||
|
|
||||||
board_runner_args(jlink "--device=STM32G474RE" "--speed=4000" "--reset-after-load")
|
|
||||||
|
|
||||||
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
|
|
||||||
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
|
|
||||||
@@ -1,290 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 STMicroelectronics.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is a dummy charge controller board for testing new features using the STM32G474 MCU
|
|
||||||
*
|
|
||||||
* IMPORTANT: You have to remove the VREF jumper on the Nucleo board to make it work. Otherwise
|
|
||||||
* the MCU will get stuck while trying to generate a reference voltage at VREF+ pin.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/dts-v1/;
|
|
||||||
#include <st/g4/stm32g474Xe.dtsi>
|
|
||||||
#include <st/g4/stm32g474r(b-c-e)tx-pinctrl.dtsi>
|
|
||||||
|
|
||||||
/ {
|
|
||||||
model = "STMicroelectronics STM32G474RE-NUCLEO board";
|
|
||||||
compatible = "st,stm32g474re-nucleo";
|
|
||||||
|
|
||||||
pcb {
|
|
||||||
compatible = "charge-controller";
|
|
||||||
|
|
||||||
type = "Nucleo G474 dummy charge controller";
|
|
||||||
version-str = "v0.1";
|
|
||||||
version-num = <1>;
|
|
||||||
|
|
||||||
hs-voltage-max = <80>;
|
|
||||||
ls-voltage-max = <32>;
|
|
||||||
dcdc-current-max = <20>;
|
|
||||||
};
|
|
||||||
|
|
||||||
chosen {
|
|
||||||
zephyr,console = &lpuart1;
|
|
||||||
zephyr,shell-uart = &lpuart1;
|
|
||||||
zephyr,sram = &sram0;
|
|
||||||
zephyr,flash = &flash0;
|
|
||||||
zephyr,can-primary = &can1;
|
|
||||||
};
|
|
||||||
|
|
||||||
leds {
|
|
||||||
compatible = "charlieplexing-leds";
|
|
||||||
gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>;
|
|
||||||
|
|
||||||
pwr {
|
|
||||||
states = <1>;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs {
|
|
||||||
compatible = "outputs";
|
|
||||||
|
|
||||||
can_en {
|
|
||||||
gpios = <&gpiob 11 GPIO_ACTIVE_LOW>;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
adc-inputs {
|
|
||||||
compatible = "adc-inputs";
|
|
||||||
|
|
||||||
v-low {
|
|
||||||
io-channels = <&adc1 12>;
|
|
||||||
multiplier = <105600>;
|
|
||||||
divider = <5600>;
|
|
||||||
};
|
|
||||||
|
|
||||||
v-high {
|
|
||||||
io-channels = <&adc1 15>;
|
|
||||||
multiplier = <102200>;
|
|
||||||
divider = <2200>;
|
|
||||||
};
|
|
||||||
|
|
||||||
vref-mcu {
|
|
||||||
io-channels = <&adc1 18>;
|
|
||||||
multiplier = <1>;
|
|
||||||
divider = <1>;
|
|
||||||
};
|
|
||||||
|
|
||||||
temp-mcu {
|
|
||||||
io-channels = <&adc1 16>;
|
|
||||||
multiplier = <1>;
|
|
||||||
divider = <1>;
|
|
||||||
};
|
|
||||||
|
|
||||||
i-dcdc {
|
|
||||||
io-channels = <&adc2 1>;
|
|
||||||
// amp gain: 25, resistor: 2 mOhm
|
|
||||||
multiplier = <1000>; // 1000
|
|
||||||
divider = <50>; // 2*25
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
gpio_keys {
|
|
||||||
compatible = "gpio-keys";
|
|
||||||
user_button: button {
|
|
||||||
gpios = <&gpioc 13 GPIO_ACTIVE_LOW>;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
aliases {
|
|
||||||
sw0 = &user_button;
|
|
||||||
uart-dbg = &lpuart1;
|
|
||||||
uart-uext = &usart1;
|
|
||||||
spi-uext = &spi1;
|
|
||||||
i2c-uext = &i2c1;
|
|
||||||
};
|
|
||||||
|
|
||||||
soc {
|
|
||||||
hrtim1: timers@40016800 {
|
|
||||||
compatible = "st,stm32-timers";
|
|
||||||
reg = <0x40016800 0x400>;
|
|
||||||
clocks = <&rcc STM32_CLOCK_BUS_APB2 0x04000000>;
|
|
||||||
interrupts = <67 0>, <68 0>, <69 0>, <70 0>,
|
|
||||||
<71 0>, <72 0>, <73 0>, <74 0>;
|
|
||||||
interrupt-names = "master", "tima", "timb", "timc",
|
|
||||||
"timd", "time", "flt", "timf";
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
|
|
||||||
/* below nodes are required until following PR is merged:
|
|
||||||
* https://github.com/zephyrproject-rtos/hal_stm32/pull/87
|
|
||||||
*/
|
|
||||||
pinctrl: pin-controller@48000000 {
|
|
||||||
hrtim1_cha1_pa8: hrtim1_cha1_pa8 {
|
|
||||||
pinmux = <STM32_PINMUX('A', 8, AF13)>;
|
|
||||||
};
|
|
||||||
|
|
||||||
hrtim1_cha2_pa9: hrtim1_cha2_pa9 {
|
|
||||||
pinmux = <STM32_PINMUX('A', 9, AF13)>;
|
|
||||||
};
|
|
||||||
|
|
||||||
hrtim1_chb1_pa10: hrtim1_chb1_pa10 {
|
|
||||||
pinmux = <STM32_PINMUX('A', 10, AF13)>;
|
|
||||||
};
|
|
||||||
|
|
||||||
hrtim1_chb2_pa11: hrtim1_chb2_pa11 {
|
|
||||||
pinmux = <STM32_PINMUX('A', 11, AF13)>;
|
|
||||||
};
|
|
||||||
|
|
||||||
hrtim1_chc1_pb12: hrtim1_chc1_pb12 {
|
|
||||||
pinmux = <STM32_PINMUX('B', 12, AF13)>;
|
|
||||||
};
|
|
||||||
|
|
||||||
hrtim1_chc2_pb13: hrtim1_chc2_pb13 {
|
|
||||||
pinmux = <STM32_PINMUX('B', 13, AF13)>;
|
|
||||||
};
|
|
||||||
|
|
||||||
hrtim1_chd1_pb14: hrtim1_chd1_pb14 {
|
|
||||||
pinmux = <STM32_PINMUX('B', 14, AF13)>;
|
|
||||||
};
|
|
||||||
|
|
||||||
hrtim1_chd2_pb15: hrtim1_chd2_pb15 {
|
|
||||||
pinmux = <STM32_PINMUX('B', 15, AF13)>;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
&clk_hse {
|
|
||||||
clock-frequency = <DT_FREQ_M(24)>;
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
|
|
||||||
&pll {
|
|
||||||
div-m = <6>;
|
|
||||||
mul-n = <85>;
|
|
||||||
div-p = <7>;
|
|
||||||
div-q = <2>;
|
|
||||||
div-r = <2>;
|
|
||||||
clocks = <&clk_hse>;
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
|
|
||||||
&rcc {
|
|
||||||
clocks = <&pll>;
|
|
||||||
clock-frequency = <DT_FREQ_M(170)>;
|
|
||||||
ahb-prescaler = <1>;
|
|
||||||
apb1-prescaler = <1>;
|
|
||||||
apb2-prescaler = <1>;
|
|
||||||
};
|
|
||||||
|
|
||||||
&usart1 {
|
|
||||||
pinctrl-0 = <&usart1_tx_pc4 &usart1_rx_pc5>;
|
|
||||||
pinctrl-names = "default";
|
|
||||||
current-speed = <115200>;
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
|
|
||||||
&usart1_rx_pc5 {
|
|
||||||
bias-pull-up; // avoid junk characters if pin is left floating
|
|
||||||
};
|
|
||||||
|
|
||||||
&lpuart1 {
|
|
||||||
pinctrl-0 = <&lpuart1_tx_pa2 &lpuart1_rx_pa3>;
|
|
||||||
pinctrl-names = "default";
|
|
||||||
current-speed = <115200>;
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
|
|
||||||
&lpuart1_rx_pa3 {
|
|
||||||
bias-pull-up; // avoid junk characters if pin is left floating
|
|
||||||
};
|
|
||||||
|
|
||||||
&i2c1 {
|
|
||||||
pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9>;
|
|
||||||
pinctrl-names = "default";
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
|
|
||||||
&spi1 {
|
|
||||||
pinctrl-0 = <&spi1_nss_pa4 &spi1_sck_pb3
|
|
||||||
&spi1_miso_pa6 &spi1_mosi_pa7>;
|
|
||||||
pinctrl-names = "default";
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
|
|
||||||
&hrtim1 {
|
|
||||||
status = "okay";
|
|
||||||
|
|
||||||
halfbridge: halfbridge {
|
|
||||||
compatible = "half-bridge";
|
|
||||||
pinctrl-0 = <&hrtim1_cha1_pa8 &hrtim1_cha2_pa9>;
|
|
||||||
pinctrl-names = "default";
|
|
||||||
frequency = <70000>;
|
|
||||||
deadtime = <300>;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
// alternative to HRTIM
|
|
||||||
&timers1 {
|
|
||||||
status = "okay";
|
|
||||||
|
|
||||||
halfbridge: halfbridge {
|
|
||||||
compatible = "half-bridge";
|
|
||||||
pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pb13>;
|
|
||||||
pinctrl-names = "default";
|
|
||||||
frequency = <70000>;
|
|
||||||
deadtime = <300>;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
&rtc {
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
|
|
||||||
&flash0 {
|
|
||||||
/*
|
|
||||||
* For more information, see:
|
|
||||||
* http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions
|
|
||||||
*/
|
|
||||||
partitions {
|
|
||||||
compatible = "fixed-partitions";
|
|
||||||
#address-cells = <1>;
|
|
||||||
#size-cells = <1>;
|
|
||||||
|
|
||||||
/* Set 2Kb of storage at the end of the 128Kb of flash */
|
|
||||||
storage_partition: partition@1f800 {
|
|
||||||
reg = <0x0001f800 0x00000800>;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
&iwdg {
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
|
|
||||||
&rng {
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
|
|
||||||
&adc1 {
|
|
||||||
pinctrl-0 = <&adc1_in1_pa0>;
|
|
||||||
pinctrl-names = "default";
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
|
|
||||||
&can1 {
|
|
||||||
pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>;
|
|
||||||
pinctrl-names = "default";
|
|
||||||
bus-speed = <500000>;
|
|
||||||
bus-speed-data = <500000>;
|
|
||||||
sjw = <1>;
|
|
||||||
sjw-data = <1>;
|
|
||||||
sample-point = <875>;
|
|
||||||
sample-point-data = <875>;
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
identifier: nucleo_g474re
|
|
||||||
name: ST Nucleo G474RE
|
|
||||||
type: mcu
|
|
||||||
arch: arm
|
|
||||||
toolchain:
|
|
||||||
- zephyr
|
|
||||||
- gnuarmemb
|
|
||||||
- xtools
|
|
||||||
ram: 128
|
|
||||||
flash: 512
|
|
||||||
supported:
|
|
||||||
- nvs
|
|
||||||
- pwm
|
|
||||||
- i2c
|
|
||||||
- gpio
|
|
||||||
- usb device
|
|
||||||
- counter
|
|
||||||
- spi
|
|
||||||
- watchdog
|
|
||||||
- adc
|
|
||||||
- can
|
|
||||||
- canfd
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
CONFIG_SOC_SERIES_STM32G4X=y
|
|
||||||
CONFIG_SOC_STM32G474XX=y
|
|
||||||
|
|
||||||
# enable uart driver
|
|
||||||
CONFIG_SERIAL=y
|
|
||||||
|
|
||||||
# enable pinmux
|
|
||||||
CONFIG_PINCTRL=y
|
|
||||||
|
|
||||||
# enable GPIO
|
|
||||||
CONFIG_GPIO=y
|
|
||||||
|
|
||||||
# Enable Clocks
|
|
||||||
CONFIG_CLOCK_CONTROL=y
|
|
||||||
|
|
||||||
# Console
|
|
||||||
CONFIG_CONSOLE=y
|
|
||||||
CONFIG_UART_CONSOLE=y
|
|
||||||
|
|
||||||
# Enable MPU
|
|
||||||
CONFIG_ARM_MPU=y
|
|
||||||
|
|
||||||
# Enable HW stack protection
|
|
||||||
CONFIG_HW_STACK_PROTECTION=y
|
|
||||||
|
|
||||||
CONFIG_CAN=y
|
|
||||||
CONFIG_THINGSET_CAN=y
|
|
||||||
|
|
||||||
CONFIG_ISOTP=y
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
source [find interface/stlink.cfg]
|
|
||||||
|
|
||||||
transport select hla_swd
|
|
||||||
|
|
||||||
source [find target/stm32g4x.cfg]
|
|
||||||
|
|
||||||
reset_config srst_only
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
board_check_revision(
|
|
||||||
FORMAT MAJOR.MINOR.PATCH
|
|
||||||
DEFAULT_REVISION 0.3
|
|
||||||
)
|
|
||||||
-3
@@ -3,9 +3,6 @@
|
|||||||
|
|
||||||
if BOARD_MPPT_1210_HUS
|
if BOARD_MPPT_1210_HUS
|
||||||
|
|
||||||
config BOARD
|
|
||||||
default "mppt_1210_hus"
|
|
||||||
|
|
||||||
config LIBRE_SOLAR_TYPE_ID
|
config LIBRE_SOLAR_TYPE_ID
|
||||||
default 4
|
default 4
|
||||||
|
|
||||||
+1
-2
@@ -2,5 +2,4 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
config BOARD_MPPT_1210_HUS
|
config BOARD_MPPT_1210_HUS
|
||||||
bool "Libre Solar MPPT 1210 HUS"
|
select SOC_STM32L072XX
|
||||||
depends on SOC_STM32L072XX
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
board:
|
||||||
|
name: mppt_1210_hus
|
||||||
|
vendor: libresolar
|
||||||
|
socs:
|
||||||
|
- name: stm32l072xx
|
||||||
|
revision:
|
||||||
|
format: major.minor.patch
|
||||||
|
default: "0.7.0"
|
||||||
|
revisions:
|
||||||
|
- name: "0.4.0"
|
||||||
|
- name: "0.7.0"
|
||||||
-3
@@ -1,8 +1,5 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
CONFIG_SOC_SERIES_STM32L0X=y
|
|
||||||
CONFIG_SOC_STM32L072XX=y
|
|
||||||
|
|
||||||
CONFIG_CLOCK_CONTROL=y
|
CONFIG_CLOCK_CONTROL=y
|
||||||
|
|
||||||
CONFIG_PINCTRL=y
|
CONFIG_PINCTRL=y
|
||||||
-3
@@ -3,9 +3,6 @@
|
|||||||
|
|
||||||
if BOARD_MPPT_2420_HC
|
if BOARD_MPPT_2420_HC
|
||||||
|
|
||||||
config BOARD
|
|
||||||
default "mppt_2420_hc"
|
|
||||||
|
|
||||||
config LIBRE_SOLAR_TYPE_ID
|
config LIBRE_SOLAR_TYPE_ID
|
||||||
default 8
|
default 8
|
||||||
|
|
||||||
+1
-2
@@ -2,5 +2,4 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
config BOARD_MPPT_2420_HC
|
config BOARD_MPPT_2420_HC
|
||||||
bool "Libre Solar MPPT 2420 HC"
|
select SOC_STM32G431XX
|
||||||
depends on SOC_STM32G431XX
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
board:
|
||||||
|
name: mppt_2420_hc
|
||||||
|
vendor: libresolar
|
||||||
|
socs:
|
||||||
|
- name: stm32g431xx
|
||||||
|
revision:
|
||||||
|
format: major.minor.patch
|
||||||
|
default: "0.2.0"
|
||||||
|
revisions:
|
||||||
|
- name: "0.1.0"
|
||||||
|
- name: "0.2.0"
|
||||||
+3
-7
@@ -212,14 +212,10 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
&can1 {
|
&fdcan1 {
|
||||||
pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>;
|
pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>;
|
||||||
pinctrl-names = "default";
|
pinctrl-names = "default";
|
||||||
bus-speed = <500000>;
|
bitrate = <500000>;
|
||||||
bus-speed-data = <500000>;
|
bitrate-data = <2000000>;
|
||||||
sjw = <1>;
|
|
||||||
sjw-data = <1>;
|
|
||||||
sample-point = <875>;
|
|
||||||
sample-point-data = <875>;
|
|
||||||
status = "okay";
|
status = "okay";
|
||||||
};
|
};
|
||||||
-3
@@ -1,8 +1,5 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
CONFIG_SOC_SERIES_STM32G4X=y
|
|
||||||
CONFIG_SOC_STM32G431XX=y
|
|
||||||
|
|
||||||
CONFIG_ARM_MPU=y
|
CONFIG_ARM_MPU=y
|
||||||
CONFIG_HW_STACK_PROTECTION=y
|
CONFIG_HW_STACK_PROTECTION=y
|
||||||
CONFIG_MPU_ALLOW_FLASH_WRITE=y
|
CONFIG_MPU_ALLOW_FLASH_WRITE=y
|
||||||
-3
@@ -3,9 +3,6 @@
|
|||||||
|
|
||||||
if BOARD_MPPT_2420_HPX
|
if BOARD_MPPT_2420_HPX
|
||||||
|
|
||||||
config BOARD
|
|
||||||
default "mppt_2420_hpx"
|
|
||||||
|
|
||||||
config LIBRE_SOLAR_TYPE_ID
|
config LIBRE_SOLAR_TYPE_ID
|
||||||
default 7
|
default 7
|
||||||
|
|
||||||
+1
-2
@@ -2,5 +2,4 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
config BOARD_MPPT_2420_HPX
|
config BOARD_MPPT_2420_HPX
|
||||||
bool "Libre Solar MPPT 2420 HPX"
|
select SOC_STM32G431XX
|
||||||
depends on SOC_STM32G431XX
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
board:
|
||||||
|
name: mppt_2420_hpx
|
||||||
|
vendor: libresolar
|
||||||
|
socs:
|
||||||
|
- name: stm32g431xx
|
||||||
-3
@@ -1,8 +1,5 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
CONFIG_SOC_SERIES_STM32G4X=y
|
|
||||||
CONFIG_SOC_STM32G431XX=y
|
|
||||||
|
|
||||||
CONFIG_ARM_MPU=y
|
CONFIG_ARM_MPU=y
|
||||||
CONFIG_HW_STACK_PROTECTION=y
|
CONFIG_HW_STACK_PROTECTION=y
|
||||||
|
|
||||||
-3
@@ -3,9 +3,6 @@
|
|||||||
|
|
||||||
if BOARD_MPPT_2420_LC
|
if BOARD_MPPT_2420_LC
|
||||||
|
|
||||||
config BOARD
|
|
||||||
default "mppt_2420_lc"
|
|
||||||
|
|
||||||
config LIBRE_SOLAR_TYPE_ID
|
config LIBRE_SOLAR_TYPE_ID
|
||||||
default 1
|
default 1
|
||||||
|
|
||||||
+1
-2
@@ -2,5 +2,4 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
config BOARD_MPPT_2420_LC
|
config BOARD_MPPT_2420_LC
|
||||||
bool "Libre Solar MPPT 2420 LC"
|
select SOC_STM32F072XB
|
||||||
depends on SOC_STM32F072XB
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
board:
|
||||||
|
name: mppt_2420_lc
|
||||||
|
vendor: libresolar
|
||||||
|
socs:
|
||||||
|
- name: stm32f072xb
|
||||||
-3
@@ -1,8 +1,5 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
CONFIG_SOC_SERIES_STM32F0X=y
|
|
||||||
CONFIG_SOC_STM32F072XB=y
|
|
||||||
|
|
||||||
CONFIG_CLOCK_CONTROL=y
|
CONFIG_CLOCK_CONTROL=y
|
||||||
|
|
||||||
CONFIG_PINCTRL=y
|
CONFIG_PINCTRL=y
|
||||||
-3
@@ -3,9 +3,6 @@
|
|||||||
|
|
||||||
if BOARD_MPPT_2420_RC
|
if BOARD_MPPT_2420_RC
|
||||||
|
|
||||||
config BOARD
|
|
||||||
default "mppt_2420_rc"
|
|
||||||
|
|
||||||
config LIBRE_SOLAR_TYPE_ID
|
config LIBRE_SOLAR_TYPE_ID
|
||||||
default 0
|
default 0
|
||||||
|
|
||||||
+1
-2
@@ -2,5 +2,4 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
config BOARD_MPPT_2420_RC
|
config BOARD_MPPT_2420_RC
|
||||||
bool "Libre Solar MPPT 2420 RC"
|
select SOC_STM32G431XX
|
||||||
depends on SOC_STM32G431XX
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
board:
|
||||||
|
name: mppt_2420_rc
|
||||||
|
vendor: libresolar
|
||||||
|
socs:
|
||||||
|
- name: stm32f072xb
|
||||||
+3
-7
@@ -219,14 +219,10 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
&can1 {
|
&fdcan1 {
|
||||||
pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>;
|
pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>;
|
||||||
pinctrl-names = "default";
|
pinctrl-names = "default";
|
||||||
bus-speed = <500000>;
|
bitrate = <500000>;
|
||||||
bus-speed-data = <500000>;
|
bitrate-data = <2000000>;
|
||||||
sjw = <1>;
|
|
||||||
sjw-data = <1>;
|
|
||||||
sample-point = <875>;
|
|
||||||
sample-point-data = <875>;
|
|
||||||
status = "okay";
|
status = "okay";
|
||||||
};
|
};
|
||||||
-3
@@ -1,8 +1,5 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
CONFIG_SOC_SERIES_STM32G4X=y
|
|
||||||
CONFIG_SOC_STM32G431XX=y
|
|
||||||
|
|
||||||
CONFIG_ARM_MPU=y
|
CONFIG_ARM_MPU=y
|
||||||
CONFIG_HW_STACK_PROTECTION=y
|
CONFIG_HW_STACK_PROTECTION=y
|
||||||
|
|
||||||
-3
@@ -3,9 +3,6 @@
|
|||||||
|
|
||||||
if BOARD_PWM_2420_LUS
|
if BOARD_PWM_2420_LUS
|
||||||
|
|
||||||
config BOARD
|
|
||||||
default "pwm_2420_lus"
|
|
||||||
|
|
||||||
config LIBRE_SOLAR_TYPE_ID
|
config LIBRE_SOLAR_TYPE_ID
|
||||||
default 5
|
default 5
|
||||||
|
|
||||||
+1
-2
@@ -2,5 +2,4 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
config BOARD_PWM_2420_LUS
|
config BOARD_PWM_2420_LUS
|
||||||
bool "Libre Solar PWM 2420 LUS"
|
select SOC_STM32L072XX
|
||||||
depends on SOC_STM32L072XX
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
board:
|
||||||
|
name: pwm_2420_lus
|
||||||
|
vendor: libresolar
|
||||||
|
socs:
|
||||||
|
- name: stm32l072xx
|
||||||
|
revision:
|
||||||
|
format: major.minor.patch
|
||||||
|
default: "0.3.0"
|
||||||
|
revisions:
|
||||||
|
- name: "0.2.0"
|
||||||
|
- name: "0.3.0"
|
||||||
-3
@@ -1,8 +1,5 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
CONFIG_SOC_SERIES_STM32L0X=y
|
|
||||||
CONFIG_SOC_STM32L072XX=y
|
|
||||||
|
|
||||||
CONFIG_CLOCK_CONTROL=y
|
CONFIG_CLOCK_CONTROL=y
|
||||||
|
|
||||||
CONFIG_PINCTRL=y
|
CONFIG_PINCTRL=y
|
||||||
Regular → Executable
+2
-2
@@ -7,8 +7,8 @@ DEFAULT_BRANCH="origin/main"
|
|||||||
|
|
||||||
if [ -x "$(command -v clang-format-diff)" ]; then
|
if [ -x "$(command -v clang-format-diff)" ]; then
|
||||||
CLANG_FORMAT_DIFF="clang-format-diff"
|
CLANG_FORMAT_DIFF="clang-format-diff"
|
||||||
elif [ -x "$(command -v clang-format-diff-12)" ]; then
|
elif [ -x "$(command -v clang-format-diff-15)" ]; then
|
||||||
CLANG_FORMAT_DIFF="clang-format-diff-12"
|
CLANG_FORMAT_DIFF="clang-format-diff-15"
|
||||||
elif [ -x "$(command -v /usr/share/clang/clang-format-diff.py)" ]; then
|
elif [ -x "$(command -v /usr/share/clang/clang-format-diff.py)" ]; then
|
||||||
CLANG_FORMAT_DIFF="/usr/share/clang/clang-format-diff.py -v"
|
CLANG_FORMAT_DIFF="/usr/share/clang/clang-format-diff.py -v"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/ {
|
/ {
|
||||||
/* delete conflicting nodes from Zephyr native_posix board */
|
/* delete conflicting nodes from Zephyr native_sim board */
|
||||||
/delete-node/ leds;
|
/delete-node/ leds;
|
||||||
/delete-node/ aliases;
|
/delete-node/ aliases;
|
||||||
|
|
||||||
+3
-1
@@ -23,7 +23,7 @@ void tearDown(void) {}
|
|||||||
|
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|
||||||
void main()
|
int main()
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
@@ -42,4 +42,6 @@ void main()
|
|||||||
#ifdef CONFIG_ARCH_POSIX
|
#ifdef CONFIG_ARCH_POSIX
|
||||||
posix_exit(err);
|
posix_exit(err);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ static void init_structs()
|
|||||||
void no_start_at_high_voltage()
|
void no_start_at_high_voltage()
|
||||||
{
|
{
|
||||||
init_structs();
|
init_structs();
|
||||||
bat_terminal.bus->voltage = bat_conf.recharge_voltage + 0.1;
|
bat_terminal.bus->voltage = bat_conf.recharge_voltage + 0.1f;
|
||||||
charger.charge_control(&bat_conf);
|
charger.charge_control(&bat_conf);
|
||||||
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ void no_start_after_short_rest()
|
|||||||
{
|
{
|
||||||
init_structs();
|
init_structs();
|
||||||
charger.time_state_changed = time(NULL) - bat_conf.time_limit_recharge + 1;
|
charger.time_state_changed = time(NULL) - bat_conf.time_limit_recharge + 1;
|
||||||
bat_terminal.bus->voltage = bat_conf.recharge_voltage - 0.1;
|
bat_terminal.bus->voltage = bat_conf.recharge_voltage - 0.1f;
|
||||||
charger.charge_control(&bat_conf);
|
charger.charge_control(&bat_conf);
|
||||||
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ void no_start_outside_temperature_limits()
|
|||||||
{
|
{
|
||||||
init_structs();
|
init_structs();
|
||||||
charger.bat_temperature = bat_conf.charge_temp_max + 1;
|
charger.bat_temperature = bat_conf.charge_temp_max + 1;
|
||||||
bat_terminal.bus->voltage = bat_conf.recharge_voltage - 0.1;
|
bat_terminal.bus->voltage = bat_conf.recharge_voltage - 0.1f;
|
||||||
charger.charge_control(&bat_conf);
|
charger.charge_control(&bat_conf);
|
||||||
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ void start_if_everything_just_fine()
|
|||||||
{
|
{
|
||||||
init_structs();
|
init_structs();
|
||||||
charger.time_state_changed = time(NULL) - bat_conf.time_limit_recharge - 1;
|
charger.time_state_changed = time(NULL) - bat_conf.time_limit_recharge - 1;
|
||||||
bat_terminal.bus->voltage = bat_conf.recharge_voltage - 0.1;
|
bat_terminal.bus->voltage = bat_conf.recharge_voltage - 0.1f;
|
||||||
charger.charge_control(&bat_conf);
|
charger.charge_control(&bat_conf);
|
||||||
TEST_ASSERT_EQUAL(CHG_STATE_BULK, charger.state);
|
TEST_ASSERT_EQUAL(CHG_STATE_BULK, charger.state);
|
||||||
}
|
}
|
||||||
@@ -65,11 +65,11 @@ void enter_topping_at_voltage_setpoint()
|
|||||||
{
|
{
|
||||||
init_structs();
|
init_structs();
|
||||||
charger.time_state_changed = time(NULL) - bat_conf.time_limit_recharge - 1;
|
charger.time_state_changed = time(NULL) - bat_conf.time_limit_recharge - 1;
|
||||||
bat_terminal.bus->voltage = bat_conf.recharge_voltage - 0.1;
|
bat_terminal.bus->voltage = bat_conf.recharge_voltage - 0.1f;
|
||||||
bat_terminal.bus->voltage_filtered = bat_terminal.bus->voltage;
|
bat_terminal.bus->voltage_filtered = bat_terminal.bus->voltage;
|
||||||
charger.charge_control(&bat_conf);
|
charger.charge_control(&bat_conf);
|
||||||
TEST_ASSERT_EQUAL(CHG_STATE_BULK, charger.state);
|
TEST_ASSERT_EQUAL(CHG_STATE_BULK, charger.state);
|
||||||
bat_terminal.bus->voltage = bat_conf.topping_voltage + 0.1;
|
bat_terminal.bus->voltage = bat_conf.topping_voltage + 0.1f;
|
||||||
bat_terminal.bus->voltage_filtered = bat_terminal.bus->voltage;
|
bat_terminal.bus->voltage_filtered = bat_terminal.bus->voltage;
|
||||||
charger.charge_control(&bat_conf);
|
charger.charge_control(&bat_conf);
|
||||||
TEST_ASSERT_EQUAL(CHG_STATE_TOPPING, charger.state);
|
TEST_ASSERT_EQUAL(CHG_STATE_TOPPING, charger.state);
|
||||||
@@ -80,9 +80,9 @@ void topping_to_bulk_after_8h_low_power()
|
|||||||
enter_topping_at_voltage_setpoint();
|
enter_topping_at_voltage_setpoint();
|
||||||
|
|
||||||
charger.time_state_changed = time(NULL) - 8 * 60 * 60 + 1;
|
charger.time_state_changed = time(NULL) - 8 * 60 * 60 + 1;
|
||||||
bat_terminal.bus->voltage = bat_conf.topping_voltage - 0.1;
|
bat_terminal.bus->voltage = bat_conf.topping_voltage - 0.1f;
|
||||||
bat_terminal.bus->voltage_filtered = bat_terminal.bus->voltage;
|
bat_terminal.bus->voltage_filtered = bat_terminal.bus->voltage;
|
||||||
bat_terminal.current = bat_conf.topping_cutoff_current + 0.1;
|
bat_terminal.current = bat_conf.topping_cutoff_current + 0.1f;
|
||||||
bat_terminal.current_filtered = bat_terminal.current;
|
bat_terminal.current_filtered = bat_terminal.current;
|
||||||
|
|
||||||
charger.charge_control(&bat_conf);
|
charger.charge_control(&bat_conf);
|
||||||
@@ -98,10 +98,10 @@ void stop_topping_after_time_limit()
|
|||||||
enter_topping_at_voltage_setpoint();
|
enter_topping_at_voltage_setpoint();
|
||||||
|
|
||||||
charger.target_voltage_timer = bat_conf.topping_duration - 1;
|
charger.target_voltage_timer = bat_conf.topping_duration - 1;
|
||||||
bat_terminal.current = bat_conf.topping_cutoff_current + 0.1;
|
bat_terminal.current = bat_conf.topping_cutoff_current + 0.1f;
|
||||||
bat_terminal.current_filtered = bat_terminal.current;
|
bat_terminal.current_filtered = bat_terminal.current;
|
||||||
bat_terminal.bus->voltage =
|
bat_terminal.bus->voltage =
|
||||||
bat_conf.topping_voltage - bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
bat_conf.topping_voltage - bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1f;
|
||||||
bat_terminal.bus->voltage_filtered = bat_terminal.bus->voltage;
|
bat_terminal.bus->voltage_filtered = bat_terminal.bus->voltage;
|
||||||
|
|
||||||
charger.charge_control(&bat_conf);
|
charger.charge_control(&bat_conf);
|
||||||
@@ -117,10 +117,10 @@ void stop_topping_at_cutoff_current()
|
|||||||
enter_topping_at_voltage_setpoint();
|
enter_topping_at_voltage_setpoint();
|
||||||
|
|
||||||
charger.target_voltage_timer = 0;
|
charger.target_voltage_timer = 0;
|
||||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1f;
|
||||||
bat_terminal.current_filtered = bat_terminal.current;
|
bat_terminal.current_filtered = bat_terminal.current;
|
||||||
bat_terminal.bus->voltage =
|
bat_terminal.bus->voltage =
|
||||||
bat_conf.topping_voltage - bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
bat_conf.topping_voltage - bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1f;
|
||||||
bat_terminal.bus->voltage_filtered = bat_terminal.bus->voltage;
|
bat_terminal.bus->voltage_filtered = bat_terminal.bus->voltage;
|
||||||
charger.charge_control(&bat_conf);
|
charger.charge_control(&bat_conf);
|
||||||
TEST_ASSERT_EQUAL(CHG_STATE_FLOAT, charger.state);
|
TEST_ASSERT_EQUAL(CHG_STATE_FLOAT, charger.state);
|
||||||
@@ -132,9 +132,9 @@ void float_to_idle_for_li_ion()
|
|||||||
battery_conf_init(&bat_conf, BAT_TYPE_LFP, 4, 100);
|
battery_conf_init(&bat_conf, BAT_TYPE_LFP, 4, 100);
|
||||||
|
|
||||||
charger.time_state_changed = time(NULL) - 1;
|
charger.time_state_changed = time(NULL) - 1;
|
||||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1f;
|
||||||
bat_terminal.bus->voltage =
|
bat_terminal.bus->voltage =
|
||||||
bat_conf.topping_voltage - bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
bat_conf.topping_voltage - bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1f;
|
||||||
charger.charge_control(&bat_conf);
|
charger.charge_control(&bat_conf);
|
||||||
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
||||||
}
|
}
|
||||||
@@ -150,8 +150,8 @@ void no_equalization_if_disabled()
|
|||||||
charger.time_last_equalization = time(NULL) - bat_conf.equalization_trigger_days * 24 * 60 * 60;
|
charger.time_last_equalization = time(NULL) - bat_conf.equalization_trigger_days * 24 * 60 * 60;
|
||||||
|
|
||||||
charger.time_state_changed = time(NULL) - 1;
|
charger.time_state_changed = time(NULL) - 1;
|
||||||
bat_terminal.bus->voltage = bat_conf.topping_voltage + 0.1;
|
bat_terminal.bus->voltage = bat_conf.topping_voltage + 0.1f;
|
||||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1f;
|
||||||
charger.charge_control(&bat_conf);
|
charger.charge_control(&bat_conf);
|
||||||
TEST_ASSERT_NOT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
TEST_ASSERT_NOT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
||||||
}
|
}
|
||||||
@@ -168,8 +168,8 @@ void no_equalization_if_limits_not_reached()
|
|||||||
time(NULL) - (bat_conf.equalization_trigger_days - 1) * 24 * 60 * 60;
|
time(NULL) - (bat_conf.equalization_trigger_days - 1) * 24 * 60 * 60;
|
||||||
|
|
||||||
charger.time_state_changed = time(NULL) - 1;
|
charger.time_state_changed = time(NULL) - 1;
|
||||||
bat_terminal.bus->voltage = bat_conf.topping_voltage + 0.1;
|
bat_terminal.bus->voltage = bat_conf.topping_voltage + 0.1f;
|
||||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1f;
|
||||||
charger.charge_control(&bat_conf);
|
charger.charge_control(&bat_conf);
|
||||||
TEST_ASSERT_NOT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
TEST_ASSERT_NOT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
||||||
}
|
}
|
||||||
@@ -181,9 +181,9 @@ void float_to_equalization_if_enabled_and_time_limit_reached()
|
|||||||
charger.time_last_equalization = time(NULL) - bat_conf.equalization_trigger_days * 24 * 60 * 60;
|
charger.time_last_equalization = time(NULL) - bat_conf.equalization_trigger_days * 24 * 60 * 60;
|
||||||
|
|
||||||
charger.time_state_changed = time(NULL) - 1;
|
charger.time_state_changed = time(NULL) - 1;
|
||||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1f;
|
||||||
bat_terminal.bus->voltage =
|
bat_terminal.bus->voltage =
|
||||||
bat_conf.topping_voltage - bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
bat_conf.topping_voltage - bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1f;
|
||||||
charger.charge_control(&bat_conf);
|
charger.charge_control(&bat_conf);
|
||||||
TEST_ASSERT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
TEST_ASSERT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
||||||
}
|
}
|
||||||
@@ -196,9 +196,9 @@ void float_to_equalization_if_enabled_and_deep_dis_limit_reached()
|
|||||||
charger.num_deep_discharges - bat_conf.equalization_trigger_deep_cycles;
|
charger.num_deep_discharges - bat_conf.equalization_trigger_deep_cycles;
|
||||||
|
|
||||||
charger.time_state_changed = time(NULL) - 1;
|
charger.time_state_changed = time(NULL) - 1;
|
||||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1f;
|
||||||
bat_terminal.bus->voltage =
|
bat_terminal.bus->voltage =
|
||||||
bat_conf.topping_voltage - bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
bat_conf.topping_voltage - bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1f;
|
||||||
charger.charge_control(&bat_conf);
|
charger.charge_control(&bat_conf);
|
||||||
TEST_ASSERT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
TEST_ASSERT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
||||||
}
|
}
|
||||||
@@ -209,7 +209,7 @@ void stop_equalization_after_time_limit()
|
|||||||
|
|
||||||
charger.time_state_changed = time(NULL) - bat_conf.equalization_duration + 1;
|
charger.time_state_changed = time(NULL) - bat_conf.equalization_duration + 1;
|
||||||
bat_terminal.bus->voltage = bat_conf.equalization_voltage
|
bat_terminal.bus->voltage = bat_conf.equalization_voltage
|
||||||
- bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
- bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1f;
|
||||||
|
|
||||||
charger.charge_control(&bat_conf);
|
charger.charge_control(&bat_conf);
|
||||||
TEST_ASSERT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
TEST_ASSERT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
||||||
@@ -232,7 +232,7 @@ void stop_discharge_at_low_voltage()
|
|||||||
charger.discharge_control(&bat_conf);
|
charger.discharge_control(&bat_conf);
|
||||||
TEST_ASSERT_LESS_THAN(0, bat_terminal.neg_current_limit);
|
TEST_ASSERT_LESS_THAN(0, bat_terminal.neg_current_limit);
|
||||||
|
|
||||||
bat_terminal.bus->voltage = bat_conf.absolute_min_voltage - 0.1;
|
bat_terminal.bus->voltage = bat_conf.absolute_min_voltage - 0.1f;
|
||||||
charger.discharge_control(&bat_conf);
|
charger.discharge_control(&bat_conf);
|
||||||
TEST_ASSERT_EQUAL(0, bat_terminal.neg_current_limit);
|
TEST_ASSERT_EQUAL(0, bat_terminal.neg_current_limit);
|
||||||
}
|
}
|
||||||
@@ -262,17 +262,17 @@ void restart_discharge_if_allowed()
|
|||||||
init_structs();
|
init_structs();
|
||||||
|
|
||||||
// stop because of undervoltage
|
// stop because of undervoltage
|
||||||
bat_terminal.bus->voltage = bat_conf.absolute_min_voltage - 0.1;
|
bat_terminal.bus->voltage = bat_conf.absolute_min_voltage - 0.1f;
|
||||||
charger.discharge_control(&bat_conf);
|
charger.discharge_control(&bat_conf);
|
||||||
TEST_ASSERT_EQUAL(0, bat_terminal.neg_current_limit);
|
TEST_ASSERT_EQUAL(0, bat_terminal.neg_current_limit);
|
||||||
|
|
||||||
// increase voltage slightly above absolute minimum
|
// increase voltage slightly above absolute minimum
|
||||||
bat_terminal.bus->voltage = bat_conf.absolute_min_voltage + 0.05;
|
bat_terminal.bus->voltage = bat_conf.absolute_min_voltage + 0.05f;
|
||||||
charger.discharge_control(&bat_conf);
|
charger.discharge_control(&bat_conf);
|
||||||
TEST_ASSERT_EQUAL(0, bat_terminal.neg_current_limit);
|
TEST_ASSERT_EQUAL(0, bat_terminal.neg_current_limit);
|
||||||
|
|
||||||
// increase voltage above hysteresis voltage
|
// increase voltage above hysteresis voltage
|
||||||
bat_terminal.bus->voltage = bat_conf.absolute_min_voltage + 0.15;
|
bat_terminal.bus->voltage = bat_conf.absolute_min_voltage + 0.15f;
|
||||||
charger.discharge_control(&bat_conf);
|
charger.discharge_control(&bat_conf);
|
||||||
TEST_ASSERT_LESS_THAN(0, bat_terminal.neg_current_limit);
|
TEST_ASSERT_LESS_THAN(0, bat_terminal.neg_current_limit);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ void adc_alert_lv_undervoltage_triggering()
|
|||||||
adc_update_value(ADC_POS(v_low));
|
adc_update_value(ADC_POS(v_low));
|
||||||
|
|
||||||
// undervoltage test
|
// undervoltage test
|
||||||
adcval.battery_voltage = bat_conf.absolute_min_voltage - 0.1;
|
adcval.battery_voltage = bat_conf.absolute_min_voltage - 0.1f;
|
||||||
prepare_adc_readings(adcval);
|
prepare_adc_readings(adcval);
|
||||||
adc_update_value(ADC_POS(v_low));
|
adc_update_value(ADC_POS(v_low));
|
||||||
TEST_ASSERT_EQUAL(false, dev_stat.has_error(ERR_LOAD_VOLTAGE_DIP));
|
TEST_ASSERT_EQUAL(false, dev_stat.has_error(ERR_LOAD_VOLTAGE_DIP));
|
||||||
@@ -130,7 +130,7 @@ void adc_alert_lv_overvoltage_triggering()
|
|||||||
dcdc.state = DCDC_CONTROL_MPPT;
|
dcdc.state = DCDC_CONTROL_MPPT;
|
||||||
|
|
||||||
// overvoltage test
|
// overvoltage test
|
||||||
adcval.battery_voltage = bat_conf.absolute_max_voltage + 0.1;
|
adcval.battery_voltage = bat_conf.absolute_max_voltage + 0.1f;
|
||||||
prepare_adc_readings(adcval);
|
prepare_adc_readings(adcval);
|
||||||
adc_update_value(ADC_POS(v_low));
|
adc_update_value(ADC_POS(v_low));
|
||||||
TEST_ASSERT_EQUAL(false, dev_stat.has_error(ERR_BAT_OVERVOLTAGE));
|
TEST_ASSERT_EQUAL(false, dev_stat.has_error(ERR_BAT_OVERVOLTAGE));
|
||||||
|
|||||||
+16
-16
@@ -136,7 +136,7 @@ void no_start_if_dcdc_disabled()
|
|||||||
void no_start_if_dcdc_lv_voltage_low()
|
void no_start_if_dcdc_lv_voltage_low()
|
||||||
{
|
{
|
||||||
init_structs_buck();
|
init_structs_buck();
|
||||||
lv_terminal.bus->voltage = dcdc.ls_voltage_min - 0.5;
|
lv_terminal.bus->voltage = dcdc.ls_voltage_min - 0.5f;
|
||||||
TEST_ASSERT_EQUAL(DCDC_MODE_OFF, dcdc.check_start_conditions());
|
TEST_ASSERT_EQUAL(DCDC_MODE_OFF, dcdc.check_start_conditions());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ void no_start_if_dcdc_lv_voltage_low()
|
|||||||
void no_buck_start_if_bat_voltage_high()
|
void no_buck_start_if_bat_voltage_high()
|
||||||
{
|
{
|
||||||
init_structs_buck();
|
init_structs_buck();
|
||||||
lv_terminal.bus->voltage = bat_conf.topping_voltage + 0.1;
|
lv_terminal.bus->voltage = bat_conf.topping_voltage + 0.1f;
|
||||||
TEST_ASSERT_EQUAL(DCDC_MODE_OFF, dcdc.check_start_conditions());
|
TEST_ASSERT_EQUAL(DCDC_MODE_OFF, dcdc.check_start_conditions());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ void no_buck_start_if_solar_voltage_low()
|
|||||||
void no_boost_start_if_bat_voltage_high()
|
void no_boost_start_if_bat_voltage_high()
|
||||||
{
|
{
|
||||||
init_structs_boost();
|
init_structs_boost();
|
||||||
hv_terminal.bus->voltage = bat_conf.topping_voltage + 0.1;
|
hv_terminal.bus->voltage = bat_conf.topping_voltage + 0.1f;
|
||||||
TEST_ASSERT_EQUAL(DCDC_MODE_OFF, dcdc.check_start_conditions());
|
TEST_ASSERT_EQUAL(DCDC_MODE_OFF, dcdc.check_start_conditions());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ void buck_derating_output_voltage_too_high()
|
|||||||
{
|
{
|
||||||
start_buck();
|
start_buck();
|
||||||
float pwm_before = half_bridge_get_duty_cycle();
|
float pwm_before = half_bridge_get_duty_cycle();
|
||||||
lv_terminal.bus->voltage = lv_terminal.bus->sink_voltage_intercept + 0.1;
|
lv_terminal.bus->voltage = lv_terminal.bus->sink_voltage_intercept + 0.1f;
|
||||||
dcdc.control();
|
dcdc.control();
|
||||||
float pwm_after = half_bridge_get_duty_cycle();
|
float pwm_after = half_bridge_get_duty_cycle();
|
||||||
TEST_ASSERT(pwm_after < pwm_before); // less duty cycle = higher voltage
|
TEST_ASSERT(pwm_after < pwm_before); // less duty cycle = higher voltage
|
||||||
@@ -226,7 +226,7 @@ void buck_derating_output_current_too_high()
|
|||||||
{
|
{
|
||||||
start_buck();
|
start_buck();
|
||||||
float pwm_before = half_bridge_get_duty_cycle();
|
float pwm_before = half_bridge_get_duty_cycle();
|
||||||
lv_terminal.current = lv_terminal.pos_current_limit + 0.1;
|
lv_terminal.current = lv_terminal.pos_current_limit + 0.1f;
|
||||||
lv_terminal.update_bus_current_margins();
|
lv_terminal.update_bus_current_margins();
|
||||||
dcdc.control();
|
dcdc.control();
|
||||||
float pwm_after = half_bridge_get_duty_cycle();
|
float pwm_after = half_bridge_get_duty_cycle();
|
||||||
@@ -238,7 +238,7 @@ void buck_derating_inductor_current_too_high()
|
|||||||
{
|
{
|
||||||
start_buck();
|
start_buck();
|
||||||
float pwm_before = half_bridge_get_duty_cycle();
|
float pwm_before = half_bridge_get_duty_cycle();
|
||||||
dcdc.inductor_current = dcdc.inductor_current_max + 0.1;
|
dcdc.inductor_current = dcdc.inductor_current_max + 0.1f;
|
||||||
dcdc.control();
|
dcdc.control();
|
||||||
float pwm_after = half_bridge_get_duty_cycle();
|
float pwm_after = half_bridge_get_duty_cycle();
|
||||||
TEST_ASSERT(pwm_after < pwm_before);
|
TEST_ASSERT(pwm_after < pwm_before);
|
||||||
@@ -249,8 +249,8 @@ void buck_derating_input_voltage_too_low()
|
|||||||
{
|
{
|
||||||
start_buck();
|
start_buck();
|
||||||
float pwm_before = half_bridge_get_duty_cycle();
|
float pwm_before = half_bridge_get_duty_cycle();
|
||||||
hv_terminal.bus->voltage = hv_terminal.bus->src_voltage_intercept - 0.1;
|
hv_terminal.bus->voltage = hv_terminal.bus->src_voltage_intercept - 0.1f;
|
||||||
dcdc.power = 1.2;
|
dcdc.power = 1.2f;
|
||||||
dcdc.control();
|
dcdc.control();
|
||||||
float pwm_after = half_bridge_get_duty_cycle();
|
float pwm_after = half_bridge_get_duty_cycle();
|
||||||
TEST_ASSERT(pwm_after < pwm_before);
|
TEST_ASSERT(pwm_after < pwm_before);
|
||||||
@@ -261,7 +261,7 @@ void buck_derating_input_current_too_high()
|
|||||||
{
|
{
|
||||||
start_buck();
|
start_buck();
|
||||||
float pwm_before = half_bridge_get_duty_cycle();
|
float pwm_before = half_bridge_get_duty_cycle();
|
||||||
hv_terminal.current = hv_terminal.neg_current_limit - 0.1;
|
hv_terminal.current = hv_terminal.neg_current_limit - 0.1f;
|
||||||
hv_terminal.update_bus_current_margins();
|
hv_terminal.update_bus_current_margins();
|
||||||
dcdc.control();
|
dcdc.control();
|
||||||
float pwm_after = half_bridge_get_duty_cycle();
|
float pwm_after = half_bridge_get_duty_cycle();
|
||||||
@@ -290,7 +290,7 @@ void buck_stop_input_power_too_low()
|
|||||||
void buck_stop_high_voltage_emergency()
|
void buck_stop_high_voltage_emergency()
|
||||||
{
|
{
|
||||||
start_buck();
|
start_buck();
|
||||||
lv_terminal.bus->voltage = dcdc.ls_voltage_max + 0.1;
|
lv_terminal.bus->voltage = dcdc.ls_voltage_max + 0.1f;
|
||||||
dcdc.control();
|
dcdc.control();
|
||||||
TEST_ASSERT(half_bridge_enabled() == false);
|
TEST_ASSERT(half_bridge_enabled() == false);
|
||||||
}
|
}
|
||||||
@@ -329,7 +329,7 @@ void boost_derating_output_voltage_too_high()
|
|||||||
{
|
{
|
||||||
start_boost();
|
start_boost();
|
||||||
float pwm_before = half_bridge_get_duty_cycle();
|
float pwm_before = half_bridge_get_duty_cycle();
|
||||||
hv_terminal.bus->voltage = hv_terminal.bus->sink_voltage_intercept + 0.5;
|
hv_terminal.bus->voltage = hv_terminal.bus->sink_voltage_intercept + 0.5f;
|
||||||
dcdc.control();
|
dcdc.control();
|
||||||
float pwm_after = half_bridge_get_duty_cycle();
|
float pwm_after = half_bridge_get_duty_cycle();
|
||||||
TEST_ASSERT(pwm_after > pwm_before); // higher duty cycle = less power
|
TEST_ASSERT(pwm_after > pwm_before); // higher duty cycle = less power
|
||||||
@@ -339,7 +339,7 @@ void boost_derating_output_current_too_high()
|
|||||||
{
|
{
|
||||||
start_boost();
|
start_boost();
|
||||||
float pwm_before = half_bridge_get_duty_cycle();
|
float pwm_before = half_bridge_get_duty_cycle();
|
||||||
hv_terminal.current = hv_terminal.pos_current_limit + 0.1;
|
hv_terminal.current = hv_terminal.pos_current_limit + 0.1f;
|
||||||
hv_terminal.update_bus_current_margins();
|
hv_terminal.update_bus_current_margins();
|
||||||
dcdc.control();
|
dcdc.control();
|
||||||
float pwm_after = half_bridge_get_duty_cycle();
|
float pwm_after = half_bridge_get_duty_cycle();
|
||||||
@@ -350,8 +350,8 @@ void boost_derating_input_voltage_too_low()
|
|||||||
{
|
{
|
||||||
start_boost();
|
start_boost();
|
||||||
float pwm_before = half_bridge_get_duty_cycle();
|
float pwm_before = half_bridge_get_duty_cycle();
|
||||||
lv_terminal.bus->voltage = lv_terminal.bus->src_voltage_intercept - 0.1;
|
lv_terminal.bus->voltage = lv_terminal.bus->src_voltage_intercept - 0.1f;
|
||||||
dcdc.power = -1.2;
|
dcdc.power = -1.2f;
|
||||||
hv_terminal.update_bus_current_margins();
|
hv_terminal.update_bus_current_margins();
|
||||||
dcdc.control();
|
dcdc.control();
|
||||||
float pwm_after = half_bridge_get_duty_cycle();
|
float pwm_after = half_bridge_get_duty_cycle();
|
||||||
@@ -363,7 +363,7 @@ void boost_derating_input_current_too_high()
|
|||||||
{
|
{
|
||||||
start_boost();
|
start_boost();
|
||||||
float pwm_before = half_bridge_get_duty_cycle();
|
float pwm_before = half_bridge_get_duty_cycle();
|
||||||
dcdc.inductor_current = lv_terminal.neg_current_limit - 0.1;
|
dcdc.inductor_current = lv_terminal.neg_current_limit - 0.1f;
|
||||||
dcdc.control();
|
dcdc.control();
|
||||||
float pwm_after = half_bridge_get_duty_cycle();
|
float pwm_after = half_bridge_get_duty_cycle();
|
||||||
TEST_ASSERT(pwm_after > pwm_before);
|
TEST_ASSERT(pwm_after > pwm_before);
|
||||||
@@ -390,7 +390,7 @@ void boost_stop_input_power_too_low()
|
|||||||
void boost_stop_high_voltage_emergency()
|
void boost_stop_high_voltage_emergency()
|
||||||
{
|
{
|
||||||
start_boost();
|
start_boost();
|
||||||
hv_terminal.bus->voltage = dcdc.hs_voltage_max + 0.1;
|
hv_terminal.bus->voltage = dcdc.hs_voltage_max + 0.1f;
|
||||||
dcdc.control();
|
dcdc.control();
|
||||||
TEST_ASSERT(half_bridge_enabled() == false);
|
TEST_ASSERT(half_bridge_enabled() == false);
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -81,7 +81,7 @@ static void control_on_to_off_shedding()
|
|||||||
LoadOutput load_out(&bus, &load_drv_set, &load_drv_init, NULL);
|
LoadOutput load_out(&bus, &load_drv_set, &load_drv_init, NULL);
|
||||||
load_init(&load_out, true);
|
load_init(&load_out, true);
|
||||||
|
|
||||||
bus.voltage = load_out.disconnect_voltage - 0.1;
|
bus.voltage = load_out.disconnect_voltage - 0.1f;
|
||||||
load_out.control();
|
load_out.control();
|
||||||
TEST_ASSERT_EQUAL(ERR_LOAD_SHEDDING, load_out.error_flags);
|
TEST_ASSERT_EQUAL(ERR_LOAD_SHEDDING, load_out.error_flags);
|
||||||
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
||||||
@@ -93,7 +93,7 @@ void control_on_to_off_overvoltage()
|
|||||||
LoadOutput load_out(&bus, &load_drv_set, &load_drv_init, NULL);
|
LoadOutput load_out(&bus, &load_drv_set, &load_drv_init, NULL);
|
||||||
load_init(&load_out, true);
|
load_init(&load_out, true);
|
||||||
|
|
||||||
bus.voltage = bus.sink_voltage_intercept + 0.6;
|
bus.voltage = bus.sink_voltage_intercept + 0.6f;
|
||||||
|
|
||||||
// increase debounce counter to 1 before limit
|
// increase debounce counter to 1 before limit
|
||||||
for (int i = 0; i < CONFIG_CONTROL_FREQUENCY; i++) {
|
for (int i = 0; i < CONFIG_CONTROL_FREQUENCY; i++) {
|
||||||
@@ -114,7 +114,7 @@ void control_on_to_off_overvoltage_dual_battery()
|
|||||||
LoadOutput load_out(&bus, &load_drv_set, &load_drv_init, NULL);
|
LoadOutput load_out(&bus, &load_drv_set, &load_drv_init, NULL);
|
||||||
load_init(&load_out, true, 2);
|
load_init(&load_out, true, 2);
|
||||||
|
|
||||||
bus.voltage = (bus.sink_voltage_intercept + 0.6) * bus.series_multiplier;
|
bus.voltage = (bus.sink_voltage_intercept + 0.6f) * bus.series_multiplier;
|
||||||
|
|
||||||
// increase debounce counter to 1 before limit
|
// increase debounce counter to 1 before limit
|
||||||
for (int i = 0; i < CONFIG_CONTROL_FREQUENCY; i++) {
|
for (int i = 0; i < CONFIG_CONTROL_FREQUENCY; i++) {
|
||||||
@@ -136,7 +136,7 @@ void control_on_to_off_overcurrent()
|
|||||||
load_init(&load_out, true);
|
load_init(&load_out, true);
|
||||||
|
|
||||||
// current slightly below factor 2 so that it is not switched off immediately
|
// current slightly below factor 2 so that it is not switched off immediately
|
||||||
load_out.current = DT_PROP(DT_CHILD(DT_PATH(outputs), load), current_max) * 1.9;
|
load_out.current = DT_PROP(DT_CHILD(DT_PATH(outputs), load), current_max) * 1.9f;
|
||||||
load_out.control();
|
load_out.control();
|
||||||
TEST_ASSERT_EQUAL(LOAD_STATE_ON, load_out.state);
|
TEST_ASSERT_EQUAL(LOAD_STATE_ON, load_out.state);
|
||||||
|
|
||||||
@@ -227,19 +227,19 @@ void control_off_overvoltage_to_on_at_lower_voltage()
|
|||||||
DcBus bus = {};
|
DcBus bus = {};
|
||||||
LoadOutput load_out(&bus, &load_drv_set, &load_drv_init, NULL);
|
LoadOutput load_out(&bus, &load_drv_set, &load_drv_init, NULL);
|
||||||
load_init(&load_out);
|
load_init(&load_out);
|
||||||
bus.voltage = load_out.overvoltage + 0.1;
|
bus.voltage = load_out.overvoltage + 0.1f;
|
||||||
load_out.error_flags = ERR_LOAD_OVERVOLTAGE;
|
load_out.error_flags = ERR_LOAD_OVERVOLTAGE;
|
||||||
|
|
||||||
load_out.control();
|
load_out.control();
|
||||||
TEST_ASSERT_EQUAL(ERR_LOAD_OVERVOLTAGE, load_out.error_flags);
|
TEST_ASSERT_EQUAL(ERR_LOAD_OVERVOLTAGE, load_out.error_flags);
|
||||||
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
||||||
|
|
||||||
bus.voltage = load_out.overvoltage - 0.1; // test hysteresis
|
bus.voltage = load_out.overvoltage - 0.1f; // test hysteresis
|
||||||
load_out.control();
|
load_out.control();
|
||||||
TEST_ASSERT_EQUAL(ERR_LOAD_OVERVOLTAGE, load_out.error_flags);
|
TEST_ASSERT_EQUAL(ERR_LOAD_OVERVOLTAGE, load_out.error_flags);
|
||||||
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
||||||
|
|
||||||
bus.voltage = load_out.overvoltage - load_out.ov_hysteresis - 0.1;
|
bus.voltage = load_out.overvoltage - load_out.ov_hysteresis - 0.1f;
|
||||||
load_out.control();
|
load_out.control();
|
||||||
TEST_ASSERT_EQUAL(0, load_out.error_flags);
|
TEST_ASSERT_EQUAL(0, load_out.error_flags);
|
||||||
TEST_ASSERT_EQUAL(LOAD_STATE_ON, load_out.state);
|
TEST_ASSERT_EQUAL(LOAD_STATE_ON, load_out.state);
|
||||||
@@ -250,19 +250,19 @@ void control_off_overvoltage_to_on_at_lower_voltage_dual_battery()
|
|||||||
DcBus bus = {};
|
DcBus bus = {};
|
||||||
LoadOutput load_out(&bus, &load_drv_set, &load_drv_init, NULL);
|
LoadOutput load_out(&bus, &load_drv_set, &load_drv_init, NULL);
|
||||||
load_init(&load_out, false, 2);
|
load_init(&load_out, false, 2);
|
||||||
bus.voltage = (load_out.overvoltage + 0.1) * bus.series_multiplier;
|
bus.voltage = (load_out.overvoltage + 0.1f) * bus.series_multiplier;
|
||||||
load_out.error_flags = ERR_LOAD_OVERVOLTAGE;
|
load_out.error_flags = ERR_LOAD_OVERVOLTAGE;
|
||||||
|
|
||||||
load_out.control();
|
load_out.control();
|
||||||
TEST_ASSERT_EQUAL(ERR_LOAD_OVERVOLTAGE, load_out.error_flags);
|
TEST_ASSERT_EQUAL(ERR_LOAD_OVERVOLTAGE, load_out.error_flags);
|
||||||
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
||||||
|
|
||||||
bus.voltage = (load_out.overvoltage - 0.1) * bus.series_multiplier; // test hysteresis
|
bus.voltage = (load_out.overvoltage - 0.1f) * bus.series_multiplier; // test hysteresis
|
||||||
load_out.control();
|
load_out.control();
|
||||||
TEST_ASSERT_EQUAL(ERR_LOAD_OVERVOLTAGE, load_out.error_flags);
|
TEST_ASSERT_EQUAL(ERR_LOAD_OVERVOLTAGE, load_out.error_flags);
|
||||||
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
||||||
|
|
||||||
bus.voltage = (load_out.overvoltage - load_out.ov_hysteresis - 0.1) * bus.series_multiplier;
|
bus.voltage = (load_out.overvoltage - load_out.ov_hysteresis - 0.1f) * bus.series_multiplier;
|
||||||
load_out.control();
|
load_out.control();
|
||||||
TEST_ASSERT_EQUAL(0, load_out.error_flags);
|
TEST_ASSERT_EQUAL(0, load_out.error_flags);
|
||||||
TEST_ASSERT_EQUAL(LOAD_STATE_ON, load_out.state);
|
TEST_ASSERT_EQUAL(LOAD_STATE_ON, load_out.state);
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ manifest:
|
|||||||
projects:
|
projects:
|
||||||
- name: zephyr
|
- name: zephyr
|
||||||
remote: zephyrproject
|
remote: zephyrproject
|
||||||
revision: v3.4-branch
|
revision: v4.3-branch
|
||||||
import:
|
import:
|
||||||
name-allowlist:
|
name-allowlist:
|
||||||
- cmsis
|
- cmsis_6
|
||||||
- edtt
|
- edtt
|
||||||
- hal_stm32
|
- hal_stm32
|
||||||
- name: oled-display-library
|
- name: oled-display-library
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Copyright (c) The Libre Solar Project Contributors
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
build:
|
||||||
|
kconfig: Kconfig
|
||||||
|
cmake: .
|
||||||
|
settings:
|
||||||
|
board_root: .
|
||||||
|
dts_root: .
|
||||||
Reference in New Issue
Block a user