Skip to content

cell balancing fix for always on after unpowered#310

Closed
Rolandw31 wants to merge 2 commits into
mainfrom
rw/cell-balancing-fix
Closed

cell balancing fix for always on after unpowered#310
Rolandw31 wants to merge 2 commits into
mainfrom
rw/cell-balancing-fix

Conversation

@Rolandw31

Copy link
Copy Markdown
Contributor

No description provided.

@Rolandw31 Rolandw31 requested a review from a team as a code owner June 15, 2026 03:45
@Rolandw31 Rolandw31 requested review from KaitlynWChang and sebzafa and removed request for a team June 15, 2026 03:45
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lhre-2026 Ready Ready Preview, Comment Jun 15, 2026 3:45am

@Rolandw31 Rolandw31 requested review from a team and matt-mekha June 15, 2026 03:45

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a periodic refresh mechanism for the BMS discharge timeout during cell balancing. It defines update periods and refresh cycles, adds helper functions to set and refresh a short discharge timeout, and integrates this logic into the main BMS update loop. Additionally, it cleans up hardcoded timing values and adds a missing GPIO header include. The reviewer suggested optimizing the discharge timeout refresh function to write only Configuration Register Group B instead of both groups, which avoids redundant SPI bus traffic and transaction overhead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +149 to +153
static void bms_refresh_discharge_timeout(void)
{
bms_set_short_discharge_timeout();
bms_write_config();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Writing both Configuration Register Group A and B is redundant here since only Config B (tx_cfgb) is modified by bms_set_short_discharge_timeout(). Writing Config A unnecessarily increases SPI bus traffic and transaction overhead. Consider writing only Config B directly using adBmsWriteData.

Suggested change
static void bms_refresh_discharge_timeout(void)
{
bms_set_short_discharge_timeout();
bms_write_config();
}
static void bms_refresh_discharge_timeout(void)
{
bms_set_short_discharge_timeout();
adBmsWakeupIc(TOTAL_IC);
adBmsWriteData(TOTAL_IC, IC, WRCFGB, Config, B);
}

@matt-mekha matt-mekha closed this Jun 15, 2026
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.

2 participants