Skip to content

adding stable conditions for HVC state machine#247

Open
angelasrsh wants to merge 1 commit into
mainfrom
angela-hvc
Open

adding stable conditions for HVC state machine#247
angelasrsh wants to merge 1 commit into
mainfrom
angela-hvc

Conversation

@angelasrsh
Copy link
Copy Markdown
Contributor

No description provided.

@angelasrsh angelasrsh requested a review from a team as a code owner May 25, 2026 14:04
@angelasrsh angelasrsh requested review from alicedimauro and sebzafa and removed request for a team May 25, 2026 14:04
@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

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

Project Deployment Actions Updated (UTC)
lhre-2026 Ready Ready Preview, Comment May 25, 2026 2:04pm

Copy link
Copy Markdown
Contributor

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

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 updates the HVC state machine to ensure the shutdown circuit is closed before entering or remaining in charging states. Feedback highlights that the is_shutdown_closed() function contains stateful debouncing logic; calling it multiple times per cycle, as introduced in these changes, will incorrectly accelerate the debounce period and increase noise sensitivity. It is recommended to capture the state in a local variable at the start of the function to ensure consistency and correct debouncing.

precharge_start_time = current_time;
current_state = HVC_STATE_PRECHARGING;
} else if (is_charge_enable_active()) {
} else if (is_shutdown_closed() && is_charge_enable_active()) {
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.

high

The function is_shutdown_closed() contains stateful debouncing logic (lines 193-212) that increments a counter on every call if the input differs from the current state. By adding this call here, it is now called twice within the HVC_STATE_NOT_ENERGIZED case (once at line 69 and once at line 73). This causes the debounce logic to process multiple times per task cycle, effectively reducing the debounce period and making the system more susceptible to noise.

Furthermore, the logic is redundant as is_shutdown_closed() is checked in both branches. It is highly recommended to capture the result of is_shutdown_closed() into a local variable at the start of update_state_machine() and use that variable throughout the function to ensure a consistent state snapshot and correct debouncing behavior.

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.

1 participant