Skip to content

Commit aedd521

Browse files
committed
drivers: fuelgauge: Add Onsemi LC709203F driver
Add driver for the Onsemi LC709203F fuel gauge Signed-off-by: Philipp Steiner <[email protected]>
1 parent eca5790 commit aedd521

27 files changed

+1520
-23
lines changed

boards/adafruit/feather_esp32s2/doc/adafruit_feather_esp32s2.rst

+29-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Hardware
1616
- 320KB SRAM, 4MB flash + 2MB PSRAM
1717
- USB-C directly connected to the ESP32-S2 for USB
1818
- LiPo connector and built-in battery charging when powered via USB-C
19-
- LC709203 or MAX17048 fuel gauge for battery voltage and state-of-charge reporting
19+
- LC709203F or MAX17048 fuel gauge for battery voltage and state-of-charge reporting
2020
- Built-in NeoPixel indicator RGB LED
2121
- STEMMA QT connector for I2C devices, with switchable power for low-power mode
2222

@@ -28,12 +28,10 @@ Hardware
2828
overlay. All boards, except the `Adafruit ESP32-S2 Feather with BME280 Sensor`_ have a
2929
space for it, but will not be shipped with.
3030
- As of May 31, 2023 - Adafruit has changed the battery monitor chip from the
31-
now-discontinued LC709203 to the MAX17048. Check the back silkscreen of your Feather to
31+
now-discontinued LC709203F to the MAX17048. Check the back silkscreen of your Feather to
3232
see which chip you have.
33-
- For the MAX17048 a driver in zephyr exists and is supported, but needs to be added via
34-
a devicetree overlay.
35-
- For the LC709203 a driver does'nt exists yet and the fuel gauge for boards with this IC
36-
is not available.
33+
- For the MAX17048 and LC709203F a driver in zephyr exists and is supported, but needs to be
34+
added via a devicetree overlay.
3735
- For the `Adafruit ESP32-S2 Feather`_ there are two different Revisions ``rev B`` and
3836
``rev C``. The ``rev C`` board has revised the power circuitry for the NeoPixel and I2C
3937
QT port. Instead of a transistor the ``rev C`` has a LDO regulator. To enable the
@@ -311,14 +309,38 @@ There is a sample available to verify that the MAX17048 fuel gauge on the board
311309
functioning correctly with Zephyr:
312310

313311
.. note::
314-
As of May 31, 2023 Adafruit changed the battery monitor chip from the now-discontinued LC709203
312+
As of May 31, 2023 Adafruit changed the battery monitor chip from the now-discontinued LC709203F
315313
to the MAX17048.
316314

317315
.. zephyr-app-commands::
318316
:zephyr-app: samples/fuel_gauge/max17048/
319317
:board: adafruit_feather_esp32s2@C
320318
:goals: build flash
321319

320+
Testing the Fuel Gauge (LC709203F)
321+
*********************************
322+
323+
There is a sample available to verify that the LC709203F fuel gauge on the board are
324+
functioning correctly with Zephyr:
325+
326+
.. note::
327+
As of May 31, 2023 Adafruit changed the battery monitor chip from the now-discontinued LC709203F
328+
to the MAX17048.
329+
330+
**Rev B**
331+
332+
.. zephyr-app-commands::
333+
:zephyr-app: samples/fuel_gauge/lc709203f/
334+
:board: adafruit_feather_esp32s2@B
335+
:goals: build flash
336+
337+
**Rev C**
338+
339+
.. zephyr-app-commands::
340+
:zephyr-app: samples/fuel_gauge/lc709203f/
341+
:board: adafruit_feather_esp32s2@C
342+
:goals: build flash
343+
322344
Testing Wi-Fi
323345
*************
324346

boards/adafruit/feather_esp32s2/doc/adafruit_feather_esp32s2_tft.rst

+20-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Hardware
1616
- 320KB SRAM, 4MB flash + 2MB PSRAM
1717
- USB-C directly connected to the ESP32-S2 for USB
1818
- LiPo connector and built-in battery charging when powered via USB-C
19-
- LC709203 or MAX17048 fuel gauge for battery voltage and state-of-charge reporting
19+
- LC709203F or MAX17048 fuel gauge for battery voltage and state-of-charge reporting
2020
- Charging indicator LED, user LED, reset and boot buttons.
2121
- Built-in NeoPixel indicator RGB LED
2222
- STEMMA QT connector for I2C devices, with switchable power for low-power mode
@@ -26,12 +26,10 @@ Hardware
2626

2727
- The board has a space for a BME280, but will not be shipped with.
2828
- As of May 31, 2023 - Adafruit has changed the battery monitor chip from the
29-
now-discontinued LC709203 to the MAX17048. Check the back silkscreen of your Feather to
29+
now-discontinued LC709203F to the MAX17048. Check the back silkscreen of your Feather to
3030
see which chip you have.
31-
- For the MAX17048 a driver in zephyr exists and is supported, but needs to be added via
32-
a devicetree overlay.
33-
- For the LC709203 a driver does'nt exists yet and the fuel gauge for boards with this IC
34-
is not available.
31+
- For the MAX17048 and LC709203F a driver in zephyr exists and is supported, but needs to be
32+
added via a devicetree overlay.
3533

3634
Supported Features
3735
==================
@@ -259,14 +257,29 @@ There is a sample available to verify that the MAX17048 fuel gauge on the board
259257
functioning correctly with Zephyr:
260258

261259
.. note::
262-
As of May 31, 2023 Adafruit changed the battery monitor chip from the now-discontinued LC709203
260+
As of May 31, 2023 Adafruit changed the battery monitor chip from the now-discontinued LC709203F
263261
to the MAX17048.
264262

265263
.. zephyr-app-commands::
266264
:zephyr-app: samples/fuel_gauge/max17048/
267265
:board: adafruit_feather_esp32s2_tft
268266
:goals: build flash
269267

268+
Testing the Fuel Gauge (LC709203F)
269+
*********************************
270+
271+
There is a sample available to verify that the LC709203F fuel gauge on the board are
272+
functioning correctly with Zephyr:
273+
274+
.. note::
275+
As of May 31, 2023 Adafruit changed the battery monitor chip from the now-discontinued LC709203F
276+
to the MAX17048.
277+
278+
.. zephyr-app-commands::
279+
:zephyr-app: samples/fuel_gauge/lc709203f/
280+
:board: adafruit_feather_esp32s2_tft
281+
:goals: build flash
282+
270283
Testing Wi-Fi
271284
*************
272285

boards/adafruit/feather_esp32s2/doc/adafruit_feather_esp32s2_tft_reverse.rst

+1-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Hardware
1616
- 320KB SRAM, 4MB flash + 2MB PSRAM
1717
- USB-C directly connected to the ESP32-S2 for USB
1818
- LiPo connector and built-in battery charging when powered via USB-C
19-
- LC709203 or MAX17048 fuel gauge for battery voltage and state-of-charge reporting
19+
- MAX17048 fuel gauge for battery voltage and state-of-charge reporting
2020
- Charging indicator LED, user LED, reset and boot buttons and has 2 additional buttons.
2121
- Built-in NeoPixel indicator RGB LED
2222
- 240x135 pixel IPS TFT color display with 1.14" diagonal and ST7789 chipset.
@@ -255,10 +255,6 @@ Testing the Fuel Gauge (MAX17048)
255255
There is a sample available to verify that the MAX17048 fuel gauge on the board are
256256
functioning correctly with Zephyr:
257257

258-
.. note::
259-
As of May 31, 2023 Adafruit changed the battery monitor chip from the now-discontinued LC709203
260-
to the MAX17048.
261-
262258
.. zephyr-app-commands::
263259
:zephyr-app: samples/fuel_gauge/max17048/
264260
:board: adafruit_feather_esp32s2_tft_reverse

drivers/fuel_gauge/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ add_subdirectory_ifdef(CONFIG_SBS_GAUGE_NEW_API sbs_gauge)
66
add_subdirectory_ifdef(CONFIG_FUEL_GAUGE_COMPOSITE composite)
77
add_subdirectory_ifdef(CONFIG_MAX17048 max17048)
88
add_subdirectory_ifdef(CONFIG_BQ27Z746 bq27z746)
9+
add_subdirectory_ifdef(CONFIG_LC709203F lc709203f)
910

1011
zephyr_library_sources_ifdef(CONFIG_USERSPACE fuel_gauge_syscall_handlers.c)
1112

drivers/fuel_gauge/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ source "drivers/fuel_gauge/max17048/Kconfig"
2323
source "drivers/fuel_gauge/sbs_gauge/Kconfig"
2424
source "drivers/fuel_gauge/bq27z746/Kconfig"
2525
source "drivers/fuel_gauge/composite/Kconfig"
26+
source "drivers/fuel_gauge/lc709203f/Kconfig"
2627

2728
endif # FUEL_GAUGE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
zephyr_library()
2+
3+
zephyr_library_sources(lc709203f.c)
4+
5+
zephyr_include_directories_ifdef(CONFIG_EMUL_LC709203F .)
6+
zephyr_library_sources_ifdef(CONFIG_EMUL_LC709203F ./emul_lc709203f.c)

drivers/fuel_gauge/lc709203f/Kconfig

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2025 Philipp Steiner <[email protected]>
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
config LC709203F
6+
bool "LC709203F Fuel Gauge"
7+
default y
8+
depends on DT_HAS_ONNN_LC709203F_ENABLED
9+
select I2C
10+
help
11+
Enable I2C-based driver for LC709203F Fuel Gauge.
12+
13+
config EMUL_LC709203F
14+
bool "Emulate an LC709203F fuel gague"
15+
default y
16+
depends on EMUL
17+
depends on LC709203F
18+
help
19+
It provides readings which follow a simple sequence, thus allowing
20+
test code to check that things are working as expected.

0 commit comments

Comments
 (0)