Files
charge-controller-firmware/tests/boards/native_sim.overlay
T
Martin JägerandClaude Opus 5.5 6c2251e2c8 app: use half-bridge driver for DC/DC converter
Replace the register-level half_bridge.c module by the new half-bridge
drivers. The Dcdc class gets the half-bridge device injected via its
constructor, so that the emulated driver can be used in unit tests.

Board devicetrees are migrated to the new compatibles:

- TIM1 boards use libresolar,stm32-half-bridge with complementary
  outputs on channel 1. The ADC trigger via OC6/TRGO2 is enabled for
  the STM32G4 boards as before.
- MPPT 1210 HUS uses libresolar,stm32-half-bridge with TIM3 channel 3
  (high side) and channel 4 (low side).
- Nucleo G474RE uses libresolar,stm32-hrtim-half-bridge. The HRTIM
  node gets the timer clock source as second clock.

Instead of the half-bridge compatible, the halfbridge node label is now
used to detect if the board has a DC/DC converter.

The half-bridge unit tests are removed, as they are superseded by the
driver test suite in tests/drivers/half_bridge.

Note for out-of-tree boards: Nodes with "half-bridge" compatible must be
migrated to one of the new compatibles, and the deadtime property was
renamed to deadtime-ns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 21:02:57 +02:00

156 lines
2.8 KiB
Plaintext

/*
* Copyright (c) The Libre Solar Project Contributors
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
/* delete conflicting nodes from Zephyr native_sim board */
/delete-node/ leds;
/delete-node/ aliases;
pcb {
compatible = "charge-controller";
type = "Native POSIX dummy";
version-str = "v0.1";
version-num = <1>;
hs-voltage-max = <80>;
ls-voltage-max = <32>;
dcdc-current-max = <20>;
};
chosen {
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,flash = &flash0;
};
leds {
compatible = "charlieplexing-leds";
gpios = <&gpio0 6 GPIO_ACTIVE_LOW>, /* chg red */
<&gpio0 14 GPIO_ACTIVE_LOW>, /* chg green */
<&gpio0 9 GPIO_ACTIVE_LOW>, /* dis red */
<&gpio0 15 GPIO_ACTIVE_LOW>; /* dis green */
pwr {
states = <0 1 0 0>;
};
load {
states = <0 0 0 1>;
};
};
outputs {
compatible = "outputs";
pwm_switch {
pwms = <&pwm3 2 (20*1000*1000) 0>; /* 20 ms period = 50 Hz */
current-max = <20>;
kconfig-flag; /* make node visible in Kconfig */
};
load {
gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
current-max = <20>;
kconfig-flag; /* make node visible in Kconfig */
};
can_en {
gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
};
};
adc1: adc1 {
compatible = "zephyr,dummy-adc";
#io-channel-cells = <1>;
};
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>;
};
v-pwm {
io-channels = <&adc1 4>;
multiplier = <25224>; // (12*8.2 + 120*8.2 + 120*12) * 10
divider = <984>; // (8.2*12) * 10
offset = <37414>; // 65536 / (1 + 8.2/120 + 8.2/12)
};
temp-fets {
io-channels = <&adc1 11>;
multiplier = <10000>; // 10k NTC series resistor
divider = <1>;
};
vref-mcu {
io-channels = <&adc1 18>;
multiplier = <1>;
divider = <1>;
};
temp-mcu {
io-channels = <&adc1 16>;
multiplier = <1>;
divider = <1>;
};
i-dcdc {
io-channels = <&adc1 1>;
// amp gain: 25, resistor: 2 mOhm
multiplier = <1000>; // 1000
divider = <50>; // 2*25
};
i-load {
io-channels = <&adc1 2>;
// amp gain: 25, resistor: 2 mOhm
multiplier = <1000>; // 1000
divider = <50>; // 2*25
};
i-pwm {
io-channels = <&adc1 5>;
// amp gain: 68/2.2, resistor: 2 mOhm
multiplier = <2200>; // 1000*2.2
divider = <136>; // 2*68
};
};
halfbridge: halfbridge {
compatible = "libresolar,half-bridge-emul";
clock-frequency = <24000000>;
frequency = <70000>;
deadtime-ns = <300>;
};
timers3: timers {
status = "okay";
pwm3: pwm3 {
compatible = "zephyr,dummy-pwm";
#pwm-cells = <3>;
};
};
aliases {
uart-dbg = &uart0;
uart-uext = &uart0;
// spi-uext = &spi1;
// i2c-uext = &i2c1;
};
};