@web-font-path: "roboto-debian.css";
Loading...
Searching...
No Matches
aon_timer.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Raspberry Pi (Trading) Ltd.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef _PICO_AON_TIMER_H
8#define _PICO_AON_TIMER_H
9
10#include "pico.h"
11#include <time.h>
12#include "pico/util/datetime.h"
13#include "hardware/regs/intctrl.h"
14
60#ifdef __cplusplus
61extern "C" {
62#endif
63
72#ifndef AON_TIMER_IRQ_NUM
73#if HAS_RP2040_RTC
74#define AON_TIMER_IRQ_NUM() RTC_IRQ
75#elif HAS_POWMAN_TIMER
76#define AON_TIMER_IRQ_NUM() POWMAN_IRQ_TIMER
77#endif
78#endif
79
80typedef void (*aon_timer_alarm_handler_t)(void);
81
92
105bool aon_timer_start(const struct timespec *ts);
106
119bool aon_timer_start_calendar(const struct tm *tm);
120
125void aon_timer_stop(void);
126
139bool aon_timer_set_time(const struct timespec *ts);
140
153bool aon_timer_set_time_calendar(const struct tm *tm);
154
167bool aon_timer_get_time(struct timespec *ts);
168
181bool aon_timer_get_time_calendar(struct tm *tm);
182
188void aon_timer_get_resolution(struct timespec *ts);
189
210aon_timer_alarm_handler_t aon_timer_enable_alarm(const struct timespec *ts, aon_timer_alarm_handler_t handler, bool wakeup_from_low_power);
211
233aon_timer_alarm_handler_t aon_timer_enable_alarm_calendar(const struct tm *tm, aon_timer_alarm_handler_t handler, bool wakeup_from_low_power);
234
239void aon_timer_disable_alarm(void);
240
246bool aon_timer_is_running(void);
247
248static inline uint aon_timer_get_irq_num(void) {
249 return AON_TIMER_IRQ_NUM();
250}
251
252#ifdef __cplusplus
253}
254#endif
255
256#endif
bool aon_timer_is_running(void)
Check if the AON timer is running.
Definition aon_timer.c:245
bool aon_timer_start(const struct timespec *ts)
Start the AON timer running using the specified timespec as the current time.
Definition aon_timer.c:188
void aon_timer_disable_alarm(void)
Disable the currently enabled AON timer alarm if any.
Definition aon_timer.c:168
bool aon_timer_start_calendar(const struct tm *tm)
Start the AON timer running using the specified calendar date/time as the current time.
Definition aon_timer.c:206
void aon_timer_start_with_timeofday(void)
Start the AON timer running using the result from the gettimeofday() function as the current time.
Definition aon_timer.c:179
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.
Definition aon_timer.c:105
bool aon_timer_get_time(struct timespec *ts)
Get the current time of the AON timer.
Definition aon_timer.c:77
bool aon_timer_get_time_calendar(struct tm *tm)
Get the current time of the AON timer as a calendar date/time.
Definition aon_timer.c:90
void aon_timer_get_resolution(struct timespec *ts)
Get the resolution of the AON timer.
Definition aon_timer.c:233
bool aon_timer_set_time(const struct timespec *ts)
Set the current time of the AON timer.
Definition aon_timer.c:42
void aon_timer_stop(void)
Stop the AON timer.
Definition aon_timer.c:223
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.
Definition aon_timer.c:146
bool aon_timer_set_time_calendar(const struct tm *tm)
Set the current time of the AON timer to the given calendar date/time.
Definition aon_timer.c:56