Skip to content

Commit b1096dd

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 b1096dd

39 files changed

+1488
-178
lines changed

boards/adafruit/feather_esp32s2/adafruit_feather_esp32s2_tft_reverse.dts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
aliases {
2121
backlight = &led1;
22+
fuel-gauge0 = &max17048;
2223
};
2324

2425
leds {

boards/adafruit/feather_esp32s2/doc/adafruit_feather_esp32s2.rst

+22-13
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
@@ -304,19 +302,30 @@ functioning correctly with Zephyr:
304302
:board: adafruit_feather_esp32s2@C
305303
:goals: build flash
306304

307-
Testing the Fuel Gauge (MAX17048)
308-
*********************************
305+
Testing the Fuel Gauge
306+
**********************
309307

310-
There is a sample available to verify that the MAX17048 fuel gauge on the board are
311-
functioning correctly with Zephyr:
308+
There are samples available to verify that the MAX17048 or LC709203F fuel gauge on the board are
309+
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

315+
**MAX17048 Fuel Gauge**
316+
317317
.. zephyr-app-commands::
318-
:zephyr-app: samples/fuel_gauge/max17048/
319-
:board: adafruit_feather_esp32s2@C
318+
:zephyr-app: samples/fuel_gauge
319+
:board: adafruit_feather_esp32s2
320+
:west-args: --extra-dtc-overlay="boards/adafruit_feather_esp32s2_max17048.overlay"
321+
:goals: build flash
322+
323+
**LC709203F Fuel Gauge**
324+
325+
.. zephyr-app-commands::
326+
:zephyr-app: samples/fuel_gauge
327+
:board: adafruit_feather_esp32s2
328+
:west-args: --extra-dtc-overlay="boards/adafruit_feather_esp32s2_lc709203f.overlay"
320329
:goals: build flash
321330

322331
Testing Wi-Fi

boards/adafruit/feather_esp32s2/doc/adafruit_feather_esp32s2_tft.rst

+21-12
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
==================
@@ -252,19 +250,30 @@ Testing the TFT
252250
:board: adafruit_feather_esp32s2_tft
253251
:goals: build flash
254252

255-
Testing the Fuel Gauge (MAX17048)
256-
*********************************
253+
Testing the Fuel Gauge
254+
**********************
257255

258-
There is a sample available to verify that the MAX17048 fuel gauge on the board are
259-
functioning correctly with Zephyr:
256+
There are samples available to verify that the MAX17048 or LC709203F fuel gauge on the board are
257+
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

263+
**MAX17048 Fuel Gauge**
264+
265+
.. zephyr-app-commands::
266+
:zephyr-app: samples/fuel_gauge
267+
:board: adafruit_feather_esp32s2_tft
268+
:west-args: --extra-dtc-overlay="boards/adafruit_feather_esp32s2_max17048.overlay"
269+
:goals: build flash
270+
271+
**LC709203F Fuel Gauge**
272+
265273
.. zephyr-app-commands::
266-
:zephyr-app: samples/fuel_gauge/max17048/
274+
:zephyr-app: samples/fuel_gauge
267275
:board: adafruit_feather_esp32s2_tft
276+
:west-args: --extra-dtc-overlay="boards/adafruit_feather_esp32s2_max17048.overlay"
268277
:goals: build flash
269278

270279
Testing Wi-Fi

boards/adafruit/feather_esp32s2/doc/adafruit_feather_esp32s2_tft_reverse.rst

+4-8
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.
@@ -249,18 +249,14 @@ functioning correctly with Zephyr:
249249
:board: adafruit_feather_esp32s2_tft_reverse
250250
:goals: build flash
251251

252-
Testing the Fuel Gauge (MAX17048)
253-
*********************************
252+
Testing the Fuel Gauge
253+
**********************
254254

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::
263-
:zephyr-app: samples/fuel_gauge/max17048/
259+
:zephyr-app: samples/fuel_gauge
264260
:board: adafruit_feather_esp32s2_tft_reverse
265261
:goals: build flash
266262

boards/adafruit/feather_esp32s3/adafruit_feather_esp32s3_procpu.dts

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
sw0 = &button0;
3939
led0 = &led0;
4040
led-strip = &led_strip;
41+
fuel-gauge0 = &max17048;
4142
};
4243

4344
buttons {

boards/adafruit/feather_esp32s3_tft/adafruit_feather_esp32s3_tft_procpu.dts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
aliases {
2323
i2c-0 = &i2c0;
2424
watchdog0 = &wdt0;
25+
fuel-gauge0 = &max17048;
2526
};
2627

2728
chosen {

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)