Skip to content

Commit

Permalink
make the HAL sleep function obey the chip documentation
Browse files Browse the repository at this point in the history
the sleep mode doesn't get set immediately, and needs to be waited upon.
  • Loading branch information
Alex Maestas committed Dec 18, 2023
1 parent d10fa22 commit 78cd763
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions watch-library/hardware/hal/src/hal_sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ int sleep(const uint8_t mode)
if (ERR_NONE != _set_sleep_mode(mode))
return ERR_INVALID_ARG;

// wait for the mode set to actually take, per chip doc.
while(_get_sleep_mode() != mode);

_go_to_sleep();

return ERR_NONE;
Expand Down
8 changes: 8 additions & 0 deletions watch-library/hardware/hpl/pm/hpl_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ int32_t _set_sleep_mode(const uint8_t mode)
return ERR_NONE;
}

/**
* \brief Get the sleep mode for the device
*/
int32_t _get_sleep_mode(const uint8_t mode)
{
return hri_pm_read_SLEEPCFG_SLEEPMODE_bf(PM);
}

/**
* \brief Set performance level
*/
Expand Down

0 comments on commit 78cd763

Please sign in to comment.