Replace the register-level ADC, DAC and DMA handling in daq_driver.c by the new DAQ driver. The application only maps the measurements to the power ports and DC buses and handles the alerts. The factory calibration values are removed from mcu.h, as they are provided by the driver now. All boards are migrated to the new libresolar,stm32-daq compatible. The unit tests use the emulated DAQ. The high-side overvoltage limit is now set after the DAQ setup. Before, the limit was calculated before any reading of the internal reference voltage was available, so that the alert never triggered on boards without fixed reference voltage (STM32F0 and STM32L0). Note for out-of-tree boards: The adc-inputs node must use the compatible libresolar,stm32-daq instead of adc-inputs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
156 lines
2.8 KiB
Plaintext
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 = "libresolar,daq-emul";
|
|
|
|
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;
|
|
};
|
|
};
|