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

pm: Use new MPSL PM API #19361

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions subsys/mpsl/pm/mpsl_pm_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static void m_update_latency_request(uint32_t lat_value_us)
}
}

void mpsl_pm_utils_work_handler(void)
void m_register_event(void)
{
mpsl_pm_params_t params = {0};
bool pm_param_valid = mpsl_pm_params_get(&params);
Expand All @@ -58,8 +58,6 @@ void mpsl_pm_utils_work_handler(void)
switch (params.event_state) {
case MPSL_PM_EVENT_STATE_NO_EVENTS_LEFT:
{
/* No event scheduled, so set latency to restrict deepest sleep states*/
m_update_latency_request(PM_MAX_LATENCY_HCI_COMMANDS_US);
if (m_pm_event_is_registered) {
pm_policy_event_unregister(&m_evt);
m_pm_event_is_registered = false;
Expand All @@ -68,9 +66,6 @@ void mpsl_pm_utils_work_handler(void)
}
case MPSL_PM_EVENT_STATE_BEFORE_EVENT:
{
/* In case we missed a state and are in zero-latency, set low-latency.*/
m_update_latency_request(PM_MAX_LATENCY_HCI_COMMANDS_US);

/* Note: Considering an overflow could only happen if the system runs many years,
* it needen't be considered here.
*/
Expand Down Expand Up @@ -107,15 +102,37 @@ void mpsl_pm_utils_work_handler(void)
}
break;
}
case MPSL_PM_EVENT_STATE_IN_EVENT:
{
m_update_latency_request(0);
break;
}
default:
__ASSERT(false, "MPSL PM is in an undefined state.");
}
m_pm_prev_flag_value = params.cnt_flag;
mpsl_pm_event_registered_ack(params.cnt_flag);
}

static void m_register_latency(void)
{
switch (mpsl_pm_low_latency_state_get()) {
case MPSL_PM_LOW_LATENCY_STATE_OFF:
if (mpsl_pm_low_latency_requested()) {
m_update_latency_request(0);
mpsl_pm_low_latency_state_set(MPSL_PM_LOW_LATENCY_STATE_ON);
}
break;
case MPSL_PM_LOW_LATENCY_STATE_ON:
if (!mpsl_pm_low_latency_requested()) {
m_update_latency_request(PM_MAX_LATENCY_HCI_COMMANDS_US);
mpsl_pm_low_latency_state_set(MPSL_PM_LOW_LATENCY_STATE_OFF);
}
break;
default:
break;
}
}

void mpsl_pm_utils_work_handler(void)
{
m_register_event();
m_register_latency();
}

static void m_work_handler(struct k_work *work)
Expand Down
Loading
Loading