From 7a1a1b02b5fb54ca5a373c3bf5e66d34a6981955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20J=C3=A4ger?= Date: Wed, 21 Oct 2026 20:22:39 +0200 Subject: [PATCH] docs: describe hardware loop-back tests Co-Authored-By: Claude Opus 5.5 --- docs/src/dev/unit_tests.rst | 41 ++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/docs/src/dev/unit_tests.rst b/docs/src/dev/unit_tests.rst index d8a21d7..07294c8 100644 --- a/docs/src/dev/unit_tests.rst +++ b/docs/src/dev/unit_tests.rst @@ -16,7 +16,46 @@ All tests are run on ``native_sim`` with emulated drivers using twister: The driver tests are additionally built (but not run) for some of the boards to ensure that the drivers compile for all supported MCUs. -The firmware can be built for all boards and board revisions in the same way: +Hardware tests +-------------- + +The half-bridge drivers configure timers which drive the MOSFETs of the power stage. A wrong +configuration (e.g. missing dead time) could destroy the hardware. So the drivers are tested on a +Nucleo-G474RE board instead of an actual charge controller. The outputs of the half bridge are +wired to input capture channels of another timer (loop-back), which measures the frequency, duty +cycle, dead time and overlap of the signals at the pins. + +The test is located in ``tests/drivers/half_bridge_loopback`` and covers the drivers for +advanced-control timers (TIM1), general-purpose timers (TIM3) and the HRTIM. The required wiring +is described in ``boards/nucleo_g474re.overlay`` of the test. + +Twister only runs the test on boards providing the ``half_bridge_loopback`` fixture, which has to +be specified in a hardware map file (e.g. ``map.yaml``) together with the ID of the ST-LINK probe: + +.. code-block:: yaml + + - connected: true + id: 00180012544B500420343637 + platform: nucleo_g474re + product: STLINK-V3 + runner: pyocd + serial: /dev/ttyACM0 + fixtures: + - half_bridge_loopback + +A hardware map with the IDs of the connected probes can be generated with +``west twister --generate-hardware-map map.yaml``. Afterwards, run the tests with: + +.. code-block:: bash + + west twister -T tests/drivers/half_bridge_loopback --device-testing --hardware-map map.yaml + +Without a hardware map (e.g. in CI), the test is only built. + +Firmware builds +--------------- + +The firmware can be built for all boards and board revisions in the same way as the tests: .. code-block:: bash