2016-08-02 07:51:44 +02:00
|
|
|
#ifndef _INTERNALS_RTC_H
|
2016-11-05 22:00:23 +01:00
|
|
|
#define _INTERNALS_RTC_H
|
2016-08-02 07:51:44 +02:00
|
|
|
|
2016-09-04 11:35:41 +02:00
|
|
|
#include <rtc.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2016-11-05 22:00:23 +01:00
|
|
|
#ifndef RTC_CB_ARRAY_SIZE
|
2016-09-04 11:35:41 +02:00
|
|
|
#define RTC_CB_ARRAY_SIZE 5
|
2016-11-05 22:00:23 +01:00
|
|
|
#endif
|
2016-09-04 11:35:41 +02:00
|
|
|
|
|
|
|
/*
|
2017-04-13 21:59:13 +02:00
|
|
|
rtc_callback_t
|
|
|
|
An RTC callback with a unique id.
|
2016-09-04 11:35:41 +02:00
|
|
|
*/
|
2017-04-13 21:59:13 +02:00
|
|
|
typedef struct
|
2016-09-04 11:35:41 +02:00
|
|
|
{
|
2017-03-01 11:07:28 +01:00
|
|
|
rtc_frequency_t freq;
|
2016-09-04 11:35:41 +02:00
|
|
|
int id;
|
|
|
|
|
|
|
|
void (*callback)(void);
|
|
|
|
int repeats;
|
2017-04-13 21:59:13 +02:00
|
|
|
|
|
|
|
} rtc_callback_t;
|
2016-09-04 11:35:41 +02:00
|
|
|
|
|
|
|
// The callback array.
|
2017-04-13 21:59:13 +02:00
|
|
|
rtc_callback_t cb_array[RTC_CB_ARRAY_SIZE];
|
2016-09-04 11:35:41 +02:00
|
|
|
|
2017-03-01 11:07:28 +01:00
|
|
|
/*
|
|
|
|
rtc_perodic_interrupt()
|
|
|
|
Handles periodic interrupts and calls the callbacks.
|
|
|
|
*/
|
|
|
|
void rtc_periodic_interrupt(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
rtc_cb_interrupt()
|
|
|
|
Calls the RTC callbacks if necessary, and updates the repeat counts.
|
|
|
|
Should only be called when RTC periodic interrupts occur.
|
|
|
|
*/
|
|
|
|
void rtc_cb_interrupt(void);
|
|
|
|
|
2016-08-02 07:51:44 +02:00
|
|
|
#endif // _INTERNALS_RTC_H
|