Loading...
Searching...
No Matches
pico_aon_timer

High Level "Always on Timer" Abstraction. More...

Macros

#define AON_TIMER_IRQ_NUM()
 Returns the irq_num_t for interrupts for the actual hardware backing the AON timer abstraction.
 

Functions

void aon_timer_start_with_timeofday (void)
 Start the AON timer running using the result from the gettimeofday() function as the current time.
 
bool aon_timer_start (const struct timespec *ts)
 Start the AON timer running using the specified timespec as the current time.
 
bool aon_timer_start_calendar (const struct tm *tm)
 Start the AON timer running using the specified calendar date/time as the current time.
 
void aon_timer_stop (void)
 Stop the AON timer.
 
bool aon_timer_set_time (const struct timespec *ts)
 Set the current time of the AON timer.
 
bool aon_timer_set_time_calendar (const struct tm *tm)
 Set the current time of the AON timer to the given calendar date/time.
 
bool aon_timer_get_time (struct timespec *ts)
 Get the current time of the AON timer.
 
bool aon_timer_get_time_calendar (struct tm *tm)
 Get the current time of the AON timer as a calendar date/time.
 
absolute_time_t aon_timer_get_absolute_time (void)
 Get the current time of the AON timer as an absolute time.
 
static absolute_time_t aon_timer_make_timeout_time_ms (uint32_t ms)
 Convenience method to get the timestamp a number of milliseconds from the current time of the AON timer.
 
void aon_timer_get_resolution (struct timespec *ts)
 Get the resolution of the AON timer.
 
aon_timer_alarm_handler_t aon_timer_enable_alarm (const struct timespec *ts, aon_timer_alarm_handler_t handler, bool wakeup_from_low_power)
 Enable an AON timer alarm for a specified time.
 
aon_timer_alarm_handler_t aon_timer_enable_alarm_calendar (const struct tm *tm, aon_timer_alarm_handler_t handler, bool wakeup_from_low_power)
 Enable an AON timer alarm for a specified calendar date/time.
 
void aon_timer_disable_alarm (void)
 Disable the currently enabled AON timer alarm if any.
 
bool aon_timer_is_running (void)
 Check if the AON timer is running.
 

Detailed Description

High Level "Always on Timer" Abstraction.

This library uses the Powman Timer on RP2350.

This library supports both aon_timer_xxx_calendar() methods which use a calendar date/time (as struct tm), and aon_timer_xxx() methods which use a linear time value relative an internal reference time (via struct timespec).

On RP2350 the 'calendar date/time' methods must convert the calendar date/time to a linear time value internally; these methods are:

This conversion is handled by the pico_mktime method. By default, this pulls in the C library mktime method which can lead to a big increase in binary size. The default implementation of pico_mktime is weak, so it can be overridden if a better/smaller alternative is available, otherwise you might consider the method variants not ending in _calendar() instead on RP2350.

Macro Definition Documentation

◆ AON_TIMER_IRQ_NUM

#define AON_TIMER_IRQ_NUM ( )

Returns the irq_num_t for interrupts for the actual hardware backing the AON timer abstraction.

Note this macro is intended to resolve at compile time, and does no parameter checking

Function Documentation

◆ aon_timer_enable_alarm()

aon_timer_alarm_handler_t aon_timer_enable_alarm ( const struct timespec *  ts,
aon_timer_alarm_handler_t  handler,
bool  wakeup_from_low_power 
)

Enable an AON timer alarm for a specified time.

On RP2350 the alarm will fire if it is in the past

Parameters
tsthe alarm time
handlera callback to call when the timer fires (can be NULL for wakeup_from_low_power = true)
wakeup_from_low_powertrue if the AON timer is to be used to wake up from a DORMANT state
Returns
on success the old handler (or NULL if there was none) or PICO_ERROR_INVALID_ARG if internal time format conversion failed
See also
pico_localtime_r

◆ aon_timer_enable_alarm_calendar()

aon_timer_alarm_handler_t aon_timer_enable_alarm_calendar ( const struct tm *  tm,
aon_timer_alarm_handler_t  handler,
bool  wakeup_from_low_power 
)

Enable an AON timer alarm for a specified calendar date/time.

On RP2350 the alarm will fire if it is in the past

See caveats for using this method on RP2350

Parameters
tmthe alarm calendar date/time
handlera callback to call when the timer fires (can be NULL for wakeup_from_low_power = true)
wakeup_from_low_powertrue if the AON timer is to be used to wake up from a DORMANT state
Returns
on success the old handler (or NULL if there was none) or PICO_ERROR_INVALID_ARG if internal time format conversion failed
See also
pico_localtime_r

◆ aon_timer_get_absolute_time()

absolute_time_t aon_timer_get_absolute_time ( void  )

Get the current time of the AON timer as an absolute time.

Returns
the current time of the AON timer as an absolute time

◆ aon_timer_get_resolution()

void aon_timer_get_resolution ( struct timespec *  ts)

Get the resolution of the AON timer.

Parameters
tsout value for the resolution of the AON timer

◆ aon_timer_get_time()

bool aon_timer_get_time ( struct timespec *  ts)

Get the current time of the AON timer.

Parameters
tsout value for the current time
Returns
true on success, false if internal time format conversion failed
See also
aon_timer_get_time_calendar

◆ aon_timer_get_time_calendar()

bool aon_timer_get_time_calendar ( struct tm *  tm)

Get the current time of the AON timer as a calendar date/time.

See caveats for using this method on RP2350

Parameters
tmout value for the current calendar date/time
Returns
true on success, false if internal time format conversion failed
See also
aon_timer_get_time

◆ aon_timer_is_running()

bool aon_timer_is_running ( void  )

Check if the AON timer is running.

Returns
true if the AON timer is running

◆ aon_timer_make_timeout_time_ms()

static absolute_time_t aon_timer_make_timeout_time_ms ( uint32_t  ms)
inlinestatic

Convenience method to get the timestamp a number of milliseconds from the current time of the AON timer.

Parameters
msthe number of milliseconds to add to the current timestamp
Returns
the future timestamp

◆ aon_timer_set_time()

bool aon_timer_set_time ( const struct timespec *  ts)

Set the current time of the AON timer.

Parameters
tsthe new current time
Returns
true on success, false if internal time format conversion failed
See also
aon_timer_set_time_calendar

◆ aon_timer_set_time_calendar()

bool aon_timer_set_time_calendar ( const struct tm *  tm)

Set the current time of the AON timer to the given calendar date/time.

See caveats for using this method on RP2350

Parameters
tmthe new current time
Returns
true on success, false if internal time format conversion failed
See also
aon_timer_set_time

◆ aon_timer_start()

bool aon_timer_start ( const struct timespec *  ts)

Start the AON timer running using the specified timespec as the current time.

Parameters
tsthe time to set as 'now'
Returns
true on success, false if internal time format conversion failed
See also
aon_timer_start_calendar

◆ aon_timer_start_calendar()

bool aon_timer_start_calendar ( const struct tm *  tm)

Start the AON timer running using the specified calendar date/time as the current time.

See caveats for using this method on RP2350

Parameters
tmthe calendar date/time to set as 'now'
Returns
true on success, false if internal time format conversion failed
See also
aon_timer_start

◆ aon_timer_start_with_timeofday()

void aon_timer_start_with_timeofday ( void  )

Start the AON timer running using the result from the gettimeofday() function as the current time.