FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[drivers][pm] Resume devices with their suspend mode by manyangshen · Pull Request #11821 · RT-Thread/rt-thread · GitHub

Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
18 changes: 11 additions & 7 deletions components/drivers/pm/pm.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ static void _pm_change_sleep_mode(struct rt_pm *pm)
rt_tick_t timeout_tick = 0, delta_tick = 0;
rt_base_t level = 0;
uint8_t sleep_mode = PM_SLEEP_MODE_DEEP;
rt_uint8_t suspend_mode;

level = rt_pm_enter_critical(pm->sleep_mode);

Expand All @@ -414,21 +415,24 @@ static void _pm_change_sleep_mode(struct rt_pm *pm)
}
else
{
/* Tickless selection may change the mode after devices are suspended. */
suspend_mode = pm->sleep_mode;

/* Notify app will enter sleep mode */
if (_pm_notify.notify)
{
_pm_notify.notify(RT_PM_ENTER_SLEEP, pm->sleep_mode, _pm_notify.data);
_pm_notify.notify(RT_PM_ENTER_SLEEP, suspend_mode, _pm_notify.data);
}

/* Suspend all peripheral device */
#ifdef PM_ENABLE_SUSPEND_SLEEP_MODE
rt_err_t ret = _pm_device_suspend(pm->sleep_mode);
rt_err_t ret = _pm_device_suspend(suspend_mode);
if (ret != RT_EOK)
{
_pm_device_resume(pm->sleep_mode);
_pm_device_resume(suspend_mode);
if (_pm_notify.notify)
{
_pm_notify.notify(RT_PM_EXIT_SLEEP, pm->sleep_mode, _pm_notify.data);
_pm_notify.notify(RT_PM_EXIT_SLEEP, suspend_mode, _pm_notify.data);
}
if (pm->sleep_mode > PM_SUSPEND_SLEEP_MODE)
{
Expand All @@ -439,7 +443,7 @@ static void _pm_change_sleep_mode(struct rt_pm *pm)
return;
}
#else
_pm_device_suspend(pm->sleep_mode);
_pm_device_suspend(suspend_mode);
#endif
/* Tickless*/
if (pm->timer_mask & (0x01 << pm->sleep_mode))
Expand Down Expand Up @@ -473,10 +477,10 @@ static void _pm_change_sleep_mode(struct rt_pm *pm)
}

/* resume all device */
_pm_device_resume(pm->sleep_mode);
_pm_device_resume(suspend_mode);

if (_pm_notify.notify)
_pm_notify.notify(RT_PM_EXIT_SLEEP, pm->sleep_mode, _pm_notify.data);
_pm_notify.notify(RT_PM_EXIT_SLEEP, suspend_mode, _pm_notify.data);

rt_pm_exit_critical(level, pm->sleep_mode);
}
Expand Down
Loading

Back | FazBrowse Home | New Git URL