Skip to content

drivers: fuelgauge: Add Onsemi LC709203F driver #89000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

DBS06
Copy link
Contributor

@DBS06 DBS06 commented Apr 24, 2025

Add driver for the Onsemi LC709203F fuel gauge

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an Onsemi LC709203F fuel gauge driver along with samples, DTS binding, header updates, and an emulator implementation.

  • Introduces main sample application to demonstrate fuel gauge usage.
  • Updates fuel gauge header definitions and DTS binding to support new properties.
  • Provides an emulator implementation for testing.

Reviewed Changes

Copilot reviewed 13 out of 27 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
samples/fuel_gauge/lc709203f/src/main.c Implements sample app; contains a redundant dev check.
samples/fuel_gauge/lc709203f/sample.yaml Provides sample configuration for the fuel gauge.
include/zephyr/drivers/fuel_gauge.h Adds new fuel gauge properties.
dts/bindings/fuel-gauge/onnn,lc709203f.yaml Adds DTS binding for the LC709203F fuel gauge.
drivers/fuel_gauge/lc709203f/lc709203f.h Declares registers and APIs for the new driver.
drivers/fuel_gauge/lc709203f/emul_lc709203f.c Implements an emulator for the LC709203F fuel gauge.
Files not reviewed (14)
  • boards/adafruit/feather_esp32s2/doc/adafruit_feather_esp32s2.rst: Language not supported
  • boards/adafruit/feather_esp32s2/doc/adafruit_feather_esp32s2_tft.rst: Language not supported
  • boards/adafruit/feather_esp32s2/doc/adafruit_feather_esp32s2_tft_reverse.rst: Language not supported
  • drivers/fuel_gauge/CMakeLists.txt: Language not supported
  • drivers/fuel_gauge/Kconfig: Language not supported
  • drivers/fuel_gauge/lc709203f/CMakeLists.txt: Language not supported
  • drivers/fuel_gauge/lc709203f/Kconfig: Language not supported
  • samples/fuel_gauge/lc709203f/CMakeLists.txt: Language not supported
  • samples/fuel_gauge/lc709203f/README.rst: Language not supported
  • samples/fuel_gauge/lc709203f/boards/adafruit_feather_esp32s2.conf: Language not supported
  • samples/fuel_gauge/lc709203f/boards/adafruit_feather_esp32s2.overlay: Language not supported
  • samples/fuel_gauge/lc709203f/boards/adafruit_feather_esp32s2_tft.conf: Language not supported
  • samples/fuel_gauge/lc709203f/boards/adafruit_feather_esp32s2_tft.overlay: Language not supported
  • samples/fuel_gauge/lc709203f/prj.conf: Language not supported

@DBS06 DBS06 force-pushed the add_LC709203F_fuel_gauge_driver branch from b168287 to aedd521 Compare April 24, 2025 06:33
Copy link
Collaborator

@kartben kartben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some early feedback

Copy link
Collaborator

@kartben kartben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please separate in multiple commits as it is doing more than just adding a new driver (i.e. adding new fuel gauge property typed)

@DBS06
Copy link
Contributor Author

DBS06 commented Apr 24, 2025

Also please separate in multiple commits as it is doing more than just adding a new driver (i.e. adding new fuel gauge property typed

I will split the commits asap

@DBS06
Copy link
Contributor Author

DBS06 commented Apr 24, 2025

Some early feedback

Thanks a lot for this fast reply!

@DBS06 DBS06 force-pushed the add_LC709203F_fuel_gauge_driver branch 3 times, most recently from b1096dd to 7569d0a Compare April 24, 2025 12:17
@DBS06
Copy link
Contributor Author

DBS06 commented Apr 24, 2025

Also please separate in multiple commits as it is doing more than just adding a new driver (i.e. adding new fuel gauge property typed)

I split up the commit into multiple commits in a way which I think makes sense

@DBS06
Copy link
Contributor Author

DBS06 commented Apr 24, 2025

overview which is still missing or needs/should/wished to be changed

  • Made changes suggested by Copilot Review
  • Made changes suggested by kartbens early Review
  • Change CRC calculation to Zephyr CRC
  • Add explanation for dts/bindings default values
  • Split up the commits
  • Add most basic fuelgauge sample
  • Adapt Docu for Adafruit_ESP32S2_feather boards
  • Extend fuelgauge sample as discussed here: drivers: fuelgauge: Add Onsemi LC709203F driver #89000 (comment)

@DBS06 DBS06 force-pushed the add_LC709203F_fuel_gauge_driver branch 10 times, most recently from ddebd24 to d9af45c Compare April 29, 2025 09:57
@DBS06 DBS06 requested a review from kartben April 29, 2025 10:54
@DBS06 DBS06 force-pushed the add_LC709203F_fuel_gauge_driver branch from d9af45c to 5ffc6da Compare April 29, 2025 11:11
@DBS06
Copy link
Contributor Author

DBS06 commented Apr 29, 2025

@kartben @aaronemassey @teburd I have one questiong regarding the doc/hardware/peripherals/fuel_gauge.rst
Imho I think this doc-file is partially outdated. Should I update it? Will the maintainers do it?
I think I am already doing a lot of changes with the PR and to update this file is somehow part of the job.. If wished I could also open a new PR for this, but I think this is not necessary.

@teburd
Copy link
Collaborator

teburd commented Apr 29, 2025

@kartben @aaronemassey @teburd I have one questiong regarding the doc/hardware/peripherals/fuel_gauge.rst Imho I think this doc-file is partially outdated. Should I update it? Will the maintainers do it? I think I am already doing a lot of changes with the PR and to update this file is somehow part of the job.. If wished I could also open a new PR for this, but I think this is not necessary.

If you find missing/out of date docs then yes please send a separate PR updating them.

@teburd
Copy link
Collaborator

teburd commented Apr 29, 2025

Please review your commits and messages. The very first commit has added properties but the commit title is "drivers: fuelgauge: Add Onsemi LC709203F driver". This should be more like...

fuelgauge: Add additional properties

Adds properties for charge and voltage alarms

Signed-off-by: ...

This commit should have no formatting changes and only the changes needed to add the attributes. Basically the commits need to be cleaned up before I'll take a look again

Copy link
Collaborator

@teburd teburd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this looks really nice, please fix the commit message titles and messages, ensure format changes are separate, +1 from me on doing so

@DBS06 DBS06 force-pushed the add_LC709203F_fuel_gauge_driver branch 2 times, most recently from fe82d2d to 6dedf2e Compare April 29, 2025 19:35
@DBS06
Copy link
Contributor Author

DBS06 commented Apr 29, 2025

Most of this looks really nice, please fix the commit message titles and messages, ensure format changes are separate, +1 from me on doing so

Thanks a lot for your feedback, I really appreciate that!

@DBS06 DBS06 force-pushed the add_LC709203F_fuel_gauge_driver branch 2 times, most recently from 9014ef3 to 241bae7 Compare April 30, 2025 04:17
DBS06 added 4 commits April 30, 2025 06:20
Adds properties for current direction, charge and voltage alarms

Signed-off-by: Philipp Steiner <[email protected]>
format fuel_gauge.h according to the clang-format settings

Signed-off-by: Philipp Steiner <[email protected]>
Add driver for the Onsemi LC709203F fuel gauge

Signed-off-by: Philipp Steiner <[email protected]>
Add test for the Onsemi LC709203F fuel gauge

Signed-off-by: Philipp Steiner <[email protected]>
@DBS06 DBS06 force-pushed the add_LC709203F_fuel_gauge_driver branch from 241bae7 to 5bfe438 Compare April 30, 2025 04:20
update because of LC709203F driver was added

Signed-off-by: Philipp Steiner <[email protected]>
@DBS06 DBS06 force-pushed the add_LC709203F_fuel_gauge_driver branch 3 times, most recently from 9f8ea2a to 3f523fe Compare April 30, 2025 04:32
DBS06 added 2 commits April 30, 2025 06:59
Adds missing property values for battery connect and present state

Signed-off-by: Philipp Steiner <[email protected]>
Replace IC specific fuel gauge example with a generic fuel gauge example

Signed-off-by: Philipp Steiner <[email protected]>
@DBS06 DBS06 force-pushed the add_LC709203F_fuel_gauge_driver branch from 3f523fe to 03c4e8a Compare April 30, 2025 05:00
@DBS06
Copy link
Contributor Author

DBS06 commented Apr 30, 2025

@teburd

@kartben @aaronemassey @teburd I have one questiong regarding the doc/hardware/peripherals/fuel_gauge.rst Imho I think this doc-file is partially outdated. Should I update it? Will the maintainers do it? I think I am already doing a lot of changes with the PR and to update this file is somehow part of the job.. If wished I could also open a new PR for this, but I think this is not necessary.

If you find missing/out of date docs then yes please send a separate PR updating them.

I added a PR for this issue #89301

@DBS06
Copy link
Contributor Author

DBS06 commented Apr 30, 2025

Most of this looks really nice, please fix the commit message titles and messages, ensure format changes are separate, +1 from me on doing so

I changed the commit messages, split the commits and reordered them. So far I think/hope I did this in the way as it was intended by you.

@DBS06 DBS06 requested a review from teburd April 30, 2025 06:50
@kartben kartben requested a review from Copilot May 7, 2025 21:10
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for the Onsemi LC709203F fuel gauge by introducing a new driver along with the necessary device tree bindings, emulator support, Kconfig integration, and documentation updates.

  • Added new LC709203F driver source files, header, and emulator implementation.
  • Introduced a new device tree binding and updated board overlay files for fuel gauge selection.
  • Updated CMake configurations, Kconfig, and documentation to clearly differentiate between the LC709203F and the existing MAX17048.

Reviewed Changes

Copilot reviewed 42 out of 42 changed files in this pull request and generated no comments.

Show a summary per file
File Description
samples/fuel_gauge/boards/adafruit_feather_esp32s2_B.overlay Added LC709203F overlay with new compatible string and configuration.
include/zephyr/drivers/fuel_gauge.h Extended fuel gauge property enum and union to include new LC709203F properties.
dts/bindings/fuel-gauge/onnn,lc709203f.yaml Introduced DT binding YAML for the LC709203F.
drivers/fuel_gauge/lc709203f/ (all files) Added driver source, header, emulator, Kconfig, and CMake integration for LC709203F.
drivers/fuel_gauge/Kconfig and CMakeLists.txt Updated to integrate the new LC709203F driver.
Boards overlays and documentation files Revised overlays and docs to clarify support for LC709203F versus MAX17048.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants