Skip to content
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

power: Handle signals in separate functions #386

Draft
wants to merge 6 commits into
base: power-leds
Choose a base branch
from

Conversation

crawfxrd
Copy link
Member

@crawfxrd crawfxrd commented Jul 24, 2023

Break up power_event into functions for handling each signal.

This reduces complexity of the power_event function itself and brings it down to <100 LoC.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
Signed-off-by: Tim Crawford <tcrawford@system76.com>
Signed-off-by: Tim Crawford <tcrawford@system76.com>
Signed-off-by: Tim Crawford <tcrawford@system76.com>
Signed-off-by: Tim Crawford <tcrawford@system76.com>
Signed-off-by: Tim Crawford <tcrawford@system76.com>

void power_event(void) {
const bool ac_new = power_handle_acin_n();
gpio_set(&AC_PRESENT, !ac_new);
Copy link
Member Author

Choose a reason for hiding this comment

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

Does it need to be set on every cycle, or can it be set only when ACIN# changes?

// Read power switch state
const bool ps_new = power_handle_pwr_sw_n();
// Send power signal to PCH
gpio_set(&PWR_BTN_N, ps_new);
Copy link
Member Author

Choose a reason for hiding this comment

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

Does it need to be set on every cycle, or can it be set only when PWR_SW# changes?

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.

None yet

1 participant