make the HAL sleep function obey the chip documentation
the sleep mode doesn't get set immediately, and needs to be waited upon.
This commit is contained in:
parent
d10fa223b2
commit
d96d6f9c91
@ -70,6 +70,16 @@ extern "C" {
|
||||
*/
|
||||
int32_t _set_sleep_mode(const uint8_t mode);
|
||||
|
||||
/**
|
||||
* \brief Get the sleep mode for the device
|
||||
*
|
||||
* This function gets the sleep mode for the device.
|
||||
*
|
||||
* \return the current value of the sleep mode configuration bits
|
||||
*/
|
||||
int32_t _get_sleep_mode(void);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Reset MCU
|
||||
*/
|
||||
|
@ -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;
|
||||
|
@ -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()
|
||||
{
|
||||
return hri_pm_read_SLEEPCFG_SLEEPMODE_bf(PM);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set performance level
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user