@@ -293,6 +293,9 @@ pstate_bitset_t *low_power_persistent_pstate_get(pstate_bitset_t *pstate);
293293 * \ingroup pico_low_power
294294 * See \ref aon_timer_start for more information.
295295 *
296+ * If the AON timer is already running, this function will restart it
297+ * from the specified time.
298+ *
296299 * \param ms The time in milliseconds to start the AON timer at.
297300 * \return true on success, false on failure.
298301 */
@@ -304,14 +307,16 @@ static inline bool low_power_start_aon_timer_at_time_ms(uint64_t ms) {
304307
305308/*! \brief Start the AON timer at the current system time
306309 * \ingroup pico_low_power
310+ *
307311 * See \ref aon_timer_start for more information.
308312 *
313+ * If the AON timer is already running, this function will not restart it.
314+ *
309315 * \return true on success, false on failure.
310316 */
311317static inline bool low_power_start_aon_timer (void ) {
312- struct timespec ts ;
313- ms_to_timespec (to_ms_64_since_boot (get_absolute_time ()), & ts );
314- return aon_timer_start (& ts );
318+ if (aon_timer_is_running ()) return true;
319+ return low_power_start_aon_timer_at_time_ms (0 );
315320}
316321
317322/*! \brief Sleep for a number of microseconds
@@ -351,7 +356,7 @@ static inline int low_power_sleep_for_ms(uint32_t ms, const clock_dest_bitset_t
351356 * \return 0 on success, non-zero on error.
352357 */
353358static inline int low_power_dormant_for_ms (uint32_t ms , dormant_clock_source_t dormant_clock_source , const clock_dest_bitset_t * keep_enabled ) {
354- if (! aon_timer_is_running ()) low_power_start_aon_timer ();
359+ low_power_start_aon_timer ();
355360 return low_power_dormant_until_aon_timer (aon_timer_make_timeout_time_ms (ms ), dormant_clock_source , keep_enabled );
356361}
357362
@@ -366,7 +371,7 @@ static inline int low_power_dormant_for_ms(uint32_t ms, dormant_clock_source_t d
366371 * \return 0 on success, non-zero on error.
367372 */
368373static inline int low_power_pstate_for_ms (uint32_t ms , pstate_bitset_t * pstate , low_power_pstate_resume_func resume_func ) {
369- if (! aon_timer_is_running ()) low_power_start_aon_timer ();
374+ low_power_start_aon_timer ();
370375 return low_power_pstate_until_aon_timer (aon_timer_make_timeout_time_ms (ms ), pstate , resume_func );
371376}
372377#endif
0 commit comments