Skip to content

Fix MAX17048 HIBRT register address and shifted default-value comments - #1

Open
Bunton33 wants to merge 1 commit into
mainfrom
fix/max17048-hibrt-register-address
Open

Fix MAX17048 HIBRT register address and shifted default-value comments#1
Bunton33 wants to merge 1 commit into
mainfrom
fix/max17048-hibrt-register-address

Conversation

@Bunton33

@Bunton33 Bunton33 commented Aug 7, 2026

Copy link
Copy Markdown

Summary

  • REG_HIBRT was 0x0B; the MAX17048 datasheet register map puts HIBRT at 0x0A (0x0B is HIBRT's ActThr low byte).
  • The default-value comments were shifted one row: HIBRT's POR default is 0x8030 (not 0x971C, which belongs to CONFIG), and CONFIG's is 0x971C (not 0x00FF, which belongs to VALRT).
  • Added a note that the datasheet requires all register accesses to be 16-bit word operations.

Why it matters

Dormant today because nothing writes HIBRT yet — but the word-access requirement means a future hibernate-tuning write through 0x0B would span HIBRT's ActThr byte and CONFIG's RCOMP byte, silently corrupting the SOC-model compensation on every unit. Hibernate/ActThr tuning is the most likely future edit to this component (it controls charge-detection latency), so the misaligned constant is a trap worth removing now.

No functional change to current behavior: the constant is unused at runtime today, and the read paths (VCELL/SOC/CRATE) are untouched.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Corrected MAX17048 register address definitions to align with the documented 16-bit register map.
    • Updated register descriptions for improved accuracy.
    • Added guidance about required 16-bit access and the risks of misaligned writes spanning multiple registers.

REG_HIBRT was 0x0B; the datasheet register map puts HIBRT at 0x0A
(0x0B is HIBRT's ActThr low byte). The default-value comments were also
shifted one row: HIBRT's POR default is 0x8030 (not 0x971C, which is
CONFIG's default), and CONFIG's is 0x971C (not 0x00FF, which is VALRT's).

Dormant today because nothing writes HIBRT yet, but the datasheet
requires all accesses to be 16-bit word operations, so a future
hibernate-tuning write through 0x0B would span HIBRT's ActThr byte and
CONFIG's RCOMP byte, silently corrupting the SOC-model compensation on
every unit. Added a note about the word-access requirement above the
register table.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The MAX17048 register definitions now use the documented 16-bit address for REG_HIBRT. Comments document the required 16-bit word access and clarify REG_CONFIG defaults.

Changes

MAX17048 register definition update

Layer / File(s) Summary
Correct register definitions and access notes
components/max17048/max17048.cpp
Documents 16-bit register access, corrects REG_HIBRT from 0x0B to 0x0A, and updates the register descriptions and REG_CONFIG default-value comment.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A rabbit checks each register byte,
Sixteen bits must travel right.
HIBRT finds its proper place,
CONFIG comments match the case.
Hop, hop—clean addresses shine!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the corrected MAX17048 HIBRT register address and shifted default-value comments.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/max17048-hibrt-register-address

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
components/max17048/max17048.cpp (1)

16-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use uint8_t for MAX17048 register addresses.

MAX17048 uses word-sized values, but I2C register addresses fit in one byte. Make the REG_* constants uint8_t, matching the 16-bit value reads/writes and register values that need uint16_t.

Proposed fix
-constexpr uint16_t REG_VCELL = 0x02;
+constexpr uint8_t REG_VCELL = 0x02;
...
-constexpr uint16_t REG_CONFIG = 0x0C;
+constexpr uint8_t REG_CONFIG = 0x0C;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@components/max17048/max17048.cpp` around lines 16 - 21, Change the REG_VCELL,
REG_SOC, REG_MODE, REG_VERSION, REG_HIBRT, and REG_CONFIG constants to use
uint8_t while keeping the register values and existing 16-bit read/write data
types unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@components/max17048/max17048.cpp`:
- Around line 16-21: Change the REG_VCELL, REG_SOC, REG_MODE, REG_VERSION,
REG_HIBRT, and REG_CONFIG constants to use uint8_t while keeping the register
values and existing 16-bit read/write data types unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3c911819-750b-4c88-90ba-ec5e1da17ba5

📥 Commits

Reviewing files that changed from the base of the PR and between 2f24e89 and 6627dee.

📒 Files selected for processing (1)
  • components/max17048/max17048.cpp

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant