daniel-p-carvalho opened a new pull request, #20970:
URL: https://github.com/apache/nuttx/pull/20970
## Summary
Add a lower-half driver for the Analog Devices LTC4013 multi-chemistry
battery charger controller, on top of the battery charger interface
(`nuttx/power/battery_charger.h`).
The chip has no digital interface. The board provides callbacks to drive
`ENAB`, to set the three-state `MODE1`/`MODE2` pins and to read
`STAT0`/`STAT1`, and describes the optional limits of the charge voltage in
`ltc4013_config_s`.
- `BATIOC_OPERATE` selects one of the nine algorithms of the MODE table of
the datasheet (`LTC4013_OPRTN_ALGO`) and enables or disables the charger. The
algorithm can only change while the charger is disabled.
- `BATIOC_VOLTAGE` sets the voltage of the last stage of the algorithm (the
VFLOAT column). For the 3 and 4-stage algorithms that is the float voltage, and
the absorption voltage follows from the same divider (x2.367/2.267).
- How the feedback network is programmed is left to the board (digital pot,
DAC, fixed divider): an optional callback receives the battery voltage and the
Vfb of the selected algorithm, and may refuse a voltage it cannot reach.
Without it the divider is fixed by the hardware.
- `BATIOC_STATE`/`BATIOC_HEALTH` decode the status pins as in the datasheet.
- The charger is left disabled at registration, and cannot be enabled until
a voltage has been set when the board sets it.
- A documentation page is added to the power-related drivers.
## Impact
- New option `CONFIG_LTC4013`, default `n`, depends on
`CONFIG_BATTERY_CHARGER`. Existing configurations are not affected.
- No board in the tree uses the driver yet. It runs on an out-of-tree board
(STM32G474, feedback divider with a MCP4561), which is not part of this PR.
- Documentation:
`Documentation/os/drivers/special/power/battery/ltc4013.rst` and one line in
the index.
## Testing
Hardware: custom STM32G474 board with an LTC4013 (feedback divider set by a
MCP4561), 24 V input, a bidirectional bench supply (EA PSB 10200-50) in place
of the battery. No battery was connected.
Li-Ion wide spread (`chargerctl algo 1`, `voltage 13800`, wiper 189), supply
following a battery model, sink limit 3 A. Voltage at the supply terminals:
```
nsh> chargerctl enable
nsh> chargerctl status
state charging health good enabled 1 voltage 13800 mV
16.0 s 13.470 V -2.450 A
23.1 s 13.670 V -2.220 A
29.1 s 13.740 V -1.580 A
35.1 s 13.790 V -0.990 A
41.1 s 13.820 V -0.560 A
61.2 s 13.850 V -0.150 A
73.2 s 13.860 V -0.130 A
nsh> chargerctl disable
nsh> chargerctl status
state idle health good enabled 0 voltage 13800 mV
```
Constant current at 2.45 A, then constant voltage at 13.86 V for 13.8 V
requested (+0.4%, with the supply measuring at its own terminals).
3-stage normal (`algo 4`, `voltage 13200`, wiper 184), sink limited to 1 A:
absorption at 13.76 V / 1.01 A, 13.78 V expected (13.2 V x 2.367/2.267).
Not tested on the board: the float stage and the `BATTERY_FULL` state, the
time termination and the recharge, a real battery.
Host: `checkpatch.sh -c -u -m -g` passes. With a host program that stubs the
upper half and the callbacks: voltage limits and refusal by the board, the new
Vfb when the algorithm changes (including the restore when the mode pins fail),
the decoding of the status pins for each kind of algorithm, a fixed divider
with and without resistors and the validation of the configuration. The
documentation builds with Sphinx 6.2.1 without warnings in the new page.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]