|
|
void | rtc_init (void) |
| | Initialise the RTC system.
|
| bool | rtc_set_datetime (const datetime_t *t) |
| | Set the RTC to the specified time.
|
| bool | rtc_get_datetime (datetime_t *t) |
| | Get the current time from the RTC.
|
|
bool | rtc_running (void) |
| | Is the RTC running?
|
| void | rtc_set_alarm (const datetime_t *t, rtc_callback_t user_callback) |
| | Set a time in the future for the RTC to call a user provided callback.
|
|
void | rtc_enable_alarm (void) |
| | Enable the RTC alarm (if inactive).
|
|
void | rtc_disable_alarm (void) |
| | Disable the RTC alarm (if active).
|
| bool | rtc_run_from_external_source (uint32_t src_hz, uint gpio_pin) |
| | Run the RTC from an external clock source through GPIO.
|
Hardware Real Time Clock API.
The RTC keeps track of time in human readable format and generates events when the time is equal to a preset value. Think of a digital clock, not epoch time used by most computers. There are seven fields, one each for year (12 bit), month (4 bit), day (5 bit), day of the week (3 bit), hour (5 bit) minute (6 bit) and second (6 bit), storing the data in binary format.
- See also
- datetime_t
Example
int main() {
printf("Hello RTC!\n");
char datetime_buf[256];
char *datetime_str = &datetime_buf[0];
.year = 2020,
.month = 06,
.day = 05,
.dotw = 5,
.hour = 15,
.min = 45,
.sec = 00
};
while (true) {
datetime_to_str(datetime_str, sizeof(datetime_buf), &t);
printf("\r%s ", datetime_str);
}
}
bool rtc_set_datetime(const datetime_t *t)
Set the RTC to the specified time.
Definition rtc.c:54
bool rtc_get_datetime(datetime_t *t)
Get the current time from the RTC.
Definition rtc.c:87
void rtc_init(void)
Initialise the RTC system.
Definition rtc.c:22
bool stdio_init_all(void)
Initialize all of the present standard stdio types that are linked into the binary.
Definition stdio.c:207
void sleep_ms(uint32_t ms)
Wait for the given number of milliseconds before returning.
Definition time.c:516
void sleep_us(uint64_t us)
Wait for the given number of microseconds before returning.
Definition time.c:499
Structure containing date and time information.
Definition types.h:107