Extend the power switch API for switches driven by a PWM signal, as used in PWM solar charge controllers: - Set and get the duty cycle - Check if the switch is currently conducting (momentary PWM state) - Generic event callback replacing the fault callback, which also reports the rising edges of the PWM signal New backends: - libresolar,stm32-pwm-power-switch: PWM signal generated by a channel of an STM32 timer. The output is driven inactive while switched off instead of disabling the channel, which left the pin floating. - libresolar,power-switch-emul: Emulated switch for tests on native_sim supporting all features of the API. Power-good failures and events can be injected by the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
35 lines
737 B
Plaintext
35 lines
737 B
Plaintext
/*
|
|
* Copyright (c) The Libre Solar Project Contributors
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/ {
|
|
fake_pwm: fake-pwm {
|
|
compatible = "zephyr,fake-pwm";
|
|
#pwm-cells = <2>;
|
|
frequency = <1000000>;
|
|
};
|
|
|
|
basic_switch: basic-switch {
|
|
compatible = "libresolar,gpio-power-switch";
|
|
gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
|
|
};
|
|
|
|
latching_switch: latching-switch {
|
|
compatible = "libresolar,gpio-power-switch";
|
|
gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
|
|
latching-pgood;
|
|
};
|
|
|
|
charge_pump_switch: charge-pump-switch {
|
|
compatible = "libresolar,gpio-power-switch";
|
|
gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>;
|
|
charge-pump-pwms = <&fake_pwm 0 200000>;
|
|
};
|
|
|
|
emul_switch: emul-switch {
|
|
compatible = "libresolar,power-switch-emul";
|
|
};
|
|
};
|