Commit Graph
7 Commits
Author SHA1 Message Date
Martin JägerandClaude Opus 5.5 465a7f9ef7 app: use power switch driver for PWM switch
Replace the register-level timer code in pwm_switch_driver.c by the STM32
PWM power switch driver. The duty cycle steps of the control algorithm
are kept at 100 us on-time per step, independent of the timer resolution
of the driver.

The rising edges of the PWM signal are only reported while the switch
is on. Before, the overvoltage alert of the battery voltage was also
inhibited periodically while the switch was off.

The PWM switch is now a child node of the timer with the label
pwm_switch instead of a child of the outputs node referencing a Zephyr
PWM device. The unit tests use the emulated power switch, so that the
dummy PWM binding is not needed anymore. The obsolete kconfig-flag and
latching-pgood properties are removed from the outputs binding.

Note for out-of-tree boards: The pwm_switch child of the outputs node
must be converted to a libresolar,stm32-pwm-power-switch node below the
st,stm32-timers node.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 14:20:21 +01:00
Martin JägerandClaude Opus 5.5 dc0356b41a app: use power switch driver for load and USB outputs
Replace the function pointers for the load and USB switches by power
switch devices. The register-level code for the short-circuit comparator
of the PWM 2420 LUS moved to the STM32 LPTIM power switch driver, which
reports short circuits via the fault callback. load_driver.c is removed.

The load and USB switches are now standalone devicetree nodes with the
labels load_switch and usb_switch instead of children of the outputs
node. The separate charge_pump node is replaced by the charge-pump-pwms
property of the load switch.

The comparator interrupt now only clears its own EXTI pending flag
instead of all pending flags.

Note for out-of-tree boards and overlays: The load and usb-pwr children
of the outputs node must be converted to nodes with the compatible
libresolar,gpio-power-switch and the labels load_switch and usb_switch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 13:43:57 +01:00
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
Martin Jäger b59cede24f Switch to ThingSet SDK 2026-03-09 08:18:21 +01:00
Martin Jäger 88467118be Upgrade to Zephyr v3.2 2023-01-13 20:34:38 +01:00
Martin Jäger 5bdbecf19d Add Clang-Format file and apply it
The format tries to maintain the previously used Libre Solar firmware coding
style as much as possible.

Applying the format fixed some issues and re-ordered some parts of the code.
2022-01-26 13:56:31 +01:00
Martin Jäger 8ab8ea244a Move to standard Zephyr T2 workspace structure (star topology)
https://docs.zephyrproject.org/latest/guides/west/workspaces.html

Previously, west manifest and CMake entry point were in zephyr subfolder
as required for PlatformIO. As PlatformIO support was dropped, we can
follow the default Zephyr folder structure more closely.

The application is built and flashed from app subfolder, where as unit
tests are run from tests subfolder.
2021-12-12 14:09:05 +01:00