Skip to content

Test: deepsleep() API replacement #5147

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

Merged
merged 1 commit into from
Oct 13, 2017
Merged
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
7 changes: 6 additions & 1 deletion TESTS/mbed_drivers/lp_timeout/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ void lp_timeout_1s_deepsleep(void)
*/
timer.start();
lpt.attach(&cb_done, 1);
deepsleep();
/* Make sure deepsleep is allowed, to go to deepsleep */
bool deep_sleep_allowed = sleep_manager_can_deep_sleep();
TEST_ASSERT_TRUE_MESSAGE(deep_sleep_allowed, "Deep sleep should be allowed");
sleep();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is assuming that using LowPower object does allow deepsleep, and using sleep() should go into deepsleep, but would it? :-) As this test is for drivers, this looks fine, what about the below test for hal? Same? no direct deepsleep hal call ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was speaking about lp_timeout_1s_sleep function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was speaking about lp_timeout_1s_sleep function.

Should have lock there.

while (!complete);

/* It takes longer to wake up from deep sleep */
Expand All @@ -75,6 +78,8 @@ void lp_timeout_1s_sleep(void)

sleep_manager_lock_deep_sleep();
lpt.attach(&cb_done, 1);
bool deep_sleep_allowed = sleep_manager_can_deep_sleep();
TEST_ASSERT_FALSE_MESSAGE(deep_sleep_allowed, "Deep sleep should be disallowed");
sleep();
while (!complete);
sleep_manager_unlock_deep_sleep();
Expand Down
7 changes: 6 additions & 1 deletion TESTS/mbed_hal/lp_ticker/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ void lp_ticker_1s_deepsleep()
lp_timer.reset();
lp_timer.start();
ticker_insert_event(lp_ticker_data, &delay_event, delay_ts, (uint32_t)&delay_event);
deepsleep();
/* Make sure deepsleep is allowed, to go to deepsleep */
bool deep_sleep_allowed = sleep_manager_can_deep_sleep();
TEST_ASSERT_TRUE_MESSAGE(deep_sleep_allowed, "Deep sleep should be allowed");
sleep();
while (!complete);
lp_timer.stop();

Expand All @@ -124,6 +127,8 @@ void lp_ticker_1s_sleep()
sleep_manager_lock_deep_sleep();
timer.reset();
timer.start();
bool deep_sleep_allowed = sleep_manager_can_deep_sleep();
TEST_ASSERT_FALSE_MESSAGE(deep_sleep_allowed, "Deep sleep should be disallowed");
ticker_insert_event(lp_ticker_data, &delay_event, delay_ts, (uint32_t)&delay_event);
sleep();
while (!complete);
Expand Down