Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

aliases {
backlight = &led1;
fuel-gauge0 = &max17048;
};

leds {
Expand Down
67 changes: 55 additions & 12 deletions boards/adafruit/feather_esp32s2/doc/adafruit_feather_esp32s2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Hardware
- 320KB SRAM, 4MB flash + 2MB PSRAM
- USB-C directly connected to the ESP32-S2 for USB
- LiPo connector and built-in battery charging when powered via USB-C
- LC709203 or MAX17048 fuel gauge for battery voltage and state-of-charge reporting
- LC709203F or MAX17048 fuel gauge for battery voltage and state-of-charge reporting
- Built-in NeoPixel indicator RGB LED
- STEMMA QT connector for I2C devices, with switchable power for low-power mode

Expand All @@ -28,12 +28,10 @@ Hardware
overlay. All boards, except the `Adafruit ESP32-S2 Feather with BME280 Sensor`_ have a
space for it, but will not be shipped with.
- As of May 31, 2023 - Adafruit has changed the battery monitor chip from the
now-discontinued LC709203 to the MAX17048. Check the back silkscreen of your Feather to
now-discontinued LC709203F to the MAX17048. Check the back silkscreen of your Feather to
see which chip you have.
- For the MAX17048 a driver in zephyr exists and is supported, but needs to be added via
a devicetree overlay.
- For the LC709203 a driver does'nt exists yet and the fuel gauge for boards with this IC
is not available.
- For the MAX17048 and LC709203F a driver in zephyr exists and is supported, but needs to be
added via a devicetree overlay.
- For the `Adafruit ESP32-S2 Feather`_ there are two different Revisions ``rev B`` and
``rev C``. The ``rev C`` board has revised the power circuitry for the NeoPixel and I2C
QT port. Instead of a transistor the ``rev C`` has a LDO regulator. To enable the
Expand Down Expand Up @@ -304,19 +302,64 @@ functioning correctly with Zephyr:
:board: adafruit_feather_esp32s2@C
:goals: build flash

Testing the Fuel Gauge (MAX17048)
*********************************
Testing the Fuel Gauge
**********************

There is a sample available to verify that the MAX17048 fuel gauge on the board are
functioning correctly with Zephyr:
There is a sample available to verify that the MAX17048 or LC709203F fuel gauge on the board are
functioning correctly with Zephyr

.. note::
As of May 31, 2023 Adafruit changed the battery monitor chip from the now-discontinued LC709203
As of May 31, 2023 Adafruit changed the battery monitor chip from the now-discontinued LC709203F
to the MAX17048.

**Rev B**

For the Rev B a devicetree overlay for the LC709203F fuel gauge already exists in the
``samples/drivers/fuel_gauge/boards`` folder.

.. zephyr-app-commands::
:zephyr-app: samples/drivers/fuel_gauge
:board: adafruit_feather_esp32s2@B
:goals: build flash

**Rev C**

For the Rev C a devicetree overlay for the MAX17048 fuel gauge already exists in the
``samples/drivers/fuel_gauge/boards`` folder.

.. zephyr-app-commands::
:zephyr-app: samples/drivers/fuel_gauge
:board: adafruit_feather_esp32s2@C
:goals: build flash

For the LC709203F a devicetree overlay needs to be added to the build.
The overlay can be added via the ``--extra-dtc-overlay`` argument and should most likely includes
the following:

.. code-block:: devicetree

/ {
aliases {
fuel-gauge0 = &lc709203f;
};
};

&i2c0 {
lc709203f: lc709203f@0b {
compatible = "onnn,lc709203f";
status = "okay";
reg = <0x0b>;
power-domains = <&i2c_reg>;
apa = "500mAh";
battery-profile = <0x01>;
};
};


.. zephyr-app-commands::
:zephyr-app: samples/fuel_gauge/max17048/
:zephyr-app: samples/drivers/fuel_gauge
:board: adafruit_feather_esp32s2@C
:west-args: --extra-dtc-overlay="boards/name_of_your.overlay"
:goals: build flash

Testing Wi-Fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Hardware
- 320KB SRAM, 4MB flash + 2MB PSRAM
- USB-C directly connected to the ESP32-S2 for USB
- LiPo connector and built-in battery charging when powered via USB-C
- LC709203 or MAX17048 fuel gauge for battery voltage and state-of-charge reporting
- LC709203F or MAX17048 fuel gauge for battery voltage and state-of-charge reporting
- Charging indicator LED, user LED, reset and boot buttons.
- Built-in NeoPixel indicator RGB LED
- STEMMA QT connector for I2C devices, with switchable power for low-power mode
Expand All @@ -26,12 +26,10 @@ Hardware

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

Supported Features
==================
Expand Down Expand Up @@ -252,19 +250,52 @@ Testing the TFT
:board: adafruit_feather_esp32s2_tft
:goals: build flash

Testing the Fuel Gauge (MAX17048)
*********************************
Testing the Fuel Gauge
**********************

There is a sample available to verify that the MAX17048 fuel gauge on the board are
functioning correctly with Zephyr:
There is a sample available to verify that the MAX17048 or LC709203F fuel gauge on the board are
functioning correctly with Zephyr.

.. note::
As of May 31, 2023 Adafruit changed the battery monitor chip from the now-discontinued LC709203
As of May 31, 2023 Adafruit changed the battery monitor chip from the now-discontinued LC709203F
to the MAX17048.

**LC709203F Fuel Gauge**

For the LC709203F a devicetree overlay already exists in the ``samples/drivers/fuel_gauge/boards`` folder.

.. zephyr-app-commands::
:zephyr-app: samples/drivers/fuel_gauge
:board: adafruit_feather_esp32s2_tft
:goals: build flash

**MAX17048 Fuel Gauge**

For the MAX17048 a devicetree overlay needs to be added to the build.
The overlay can be added via the ``--extra-dtc-overlay`` argument and should most likely includes
the following:

.. code-block:: devicetree

/ {
aliases {
fuel-gauge0 = &max17048;
};
};

&i2c0 {
max17048: max17048@36 {
compatible = "maxim,max17048";
status = "okay";
reg = <0x36 >;
power-domains = <&i2c_reg>;
};
};

.. zephyr-app-commands::
:zephyr-app: samples/fuel_gauge/max17048/
:zephyr-app: samples/drivers/fuel_gauge
:board: adafruit_feather_esp32s2_tft
:west-args: --extra-dtc-overlay="boards/name_of_your.overlay"
:goals: build flash

Testing Wi-Fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Hardware
- 320KB SRAM, 4MB flash + 2MB PSRAM
- USB-C directly connected to the ESP32-S2 for USB
- LiPo connector and built-in battery charging when powered via USB-C
- LC709203 or MAX17048 fuel gauge for battery voltage and state-of-charge reporting
- MAX17048 fuel gauge for battery voltage and state-of-charge reporting
- Charging indicator LED, user LED, reset and boot buttons and has 2 additional buttons.
- Built-in NeoPixel indicator RGB LED
- 240x135 pixel IPS TFT color display with 1.14" diagonal and ST7789 chipset.
Expand Down Expand Up @@ -249,18 +249,14 @@ functioning correctly with Zephyr:
:board: adafruit_feather_esp32s2_tft_reverse
:goals: build flash

Testing the Fuel Gauge (MAX17048)
*********************************
Testing the Fuel Gauge
**********************

There is a sample available to verify that the MAX17048 fuel gauge on the board are
functioning correctly with Zephyr:

.. note::
As of May 31, 2023 Adafruit changed the battery monitor chip from the now-discontinued LC709203
to the MAX17048.

.. zephyr-app-commands::
:zephyr-app: samples/fuel_gauge/max17048/
:zephyr-app: samples/drivers/fuel_gauge
:board: adafruit_feather_esp32s2_tft_reverse
:goals: build flash

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
sw0 = &button0;
led0 = &led0;
led-strip = &led_strip;
fuel-gauge0 = &max17048;
};

buttons {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
aliases {
i2c-0 = &i2c0;
watchdog0 = &wdt0;
fuel-gauge0 = &max17048;
};

chosen {
Expand Down
1 change: 1 addition & 0 deletions drivers/fuel_gauge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ add_subdirectory_ifdef(CONFIG_FUEL_GAUGE_COMPOSITE composite)
add_subdirectory_ifdef(CONFIG_MAX17048 max17048)
add_subdirectory_ifdef(CONFIG_BQ27Z746 bq27z746)
add_subdirectory_ifdef(CONFIG_FUEL_GAUGE_AXP2101 axp2101)
add_subdirectory_ifdef(CONFIG_LC709203F lc709203f)

zephyr_library_sources_ifdef(CONFIG_USERSPACE fuel_gauge_syscall_handlers.c)

Expand Down
1 change: 1 addition & 0 deletions drivers/fuel_gauge/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ source "drivers/fuel_gauge/sbs_gauge/Kconfig"
source "drivers/fuel_gauge/bq27z746/Kconfig"
source "drivers/fuel_gauge/composite/Kconfig"
source "drivers/fuel_gauge/axp2101/Kconfig"
source "drivers/fuel_gauge/lc709203f/Kconfig"

endif # FUEL_GAUGE
6 changes: 6 additions & 0 deletions drivers/fuel_gauge/lc709203f/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
zephyr_library()

zephyr_library_sources(lc709203f.c)

zephyr_include_directories_ifdef(CONFIG_EMUL_LC709203F .)
zephyr_library_sources_ifdef(CONFIG_EMUL_LC709203F ./emul_lc709203f.c)
21 changes: 21 additions & 0 deletions drivers/fuel_gauge/lc709203f/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2025 Philipp Steiner <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0

config LC709203F
bool "LC709203F Fuel Gauge"
default y
depends on DT_HAS_ONNN_LC709203F_ENABLED
select CRC
select I2C
help
Enable I2C-based driver for LC709203F Fuel Gauge.

config EMUL_LC709203F
bool "Emulate an LC709203F fuel gauge"
default y
depends on EMUL
depends on LC709203F
help
It provides readings which follow a simple sequence, thus allowing
test code to check that things are working as expected.
Loading