Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
rtc.h File Reference

Public real time clock driver API. More...

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <errno.h>
#include <zephyr/syscalls/rtc.h>

Go to the source code of this file.

Data Structures

struct  rtc_time
 Structure for storing date and time values with sub-second precision. More...
 

Macros

RTC Alarm Time Mask

Mask for alarm time fields to enable when setting alarm time

#define RTC_ALARM_TIME_MASK_SECOND   BIT(0)
 
#define RTC_ALARM_TIME_MASK_MINUTE   BIT(1)
 
#define RTC_ALARM_TIME_MASK_HOUR   BIT(2)
 
#define RTC_ALARM_TIME_MASK_MONTHDAY   BIT(3)
 
#define RTC_ALARM_TIME_MASK_MONTH   BIT(4)
 
#define RTC_ALARM_TIME_MASK_YEAR   BIT(5)
 
#define RTC_ALARM_TIME_MASK_WEEKDAY   BIT(6)
 
#define RTC_ALARM_TIME_MASK_YEARDAY   BIT(7)
 
#define RTC_ALARM_TIME_MASK_NSEC   BIT(8)
 

Typedefs

typedef void(* rtc_update_callback) (const struct device *dev, void *user_data)
 RTC update event callback.
 
typedef void(* rtc_alarm_callback) (const struct device *dev, uint16_t id, void *user_data)
 RTC alarm triggered callback.
 

Functions

int rtc_set_time (const struct device *dev, const struct rtc_time *timeptr)
 API for setting RTC time.
 
int rtc_get_time (const struct device *dev, struct rtc_time *timeptr)
 API for getting RTC time.
 
RTC Interface Alarm
int rtc_alarm_get_supported_fields (const struct device *dev, uint16_t id, uint16_t *mask)
 API for getting the supported fields of the RTC alarm time.
 
int rtc_alarm_set_time (const struct device *dev, uint16_t id, uint16_t mask, const struct rtc_time *timeptr)
 API for setting RTC alarm time.
 
int rtc_alarm_get_time (const struct device *dev, uint16_t id, uint16_t *mask, struct rtc_time *timeptr)
 API for getting RTC alarm time.
 
int rtc_alarm_is_pending (const struct device *dev, uint16_t id)
 API for testing if RTC alarm is pending.
 
int rtc_alarm_set_callback (const struct device *dev, uint16_t id, rtc_alarm_callback callback, void *user_data)
 API for setting alarm callback.
 
RTC Interface Update
int rtc_update_set_callback (const struct device *dev, rtc_update_callback callback, void *user_data)
 API for setting update callback.
 
RTC Interface Calibration
int rtc_set_calibration (const struct device *dev, int32_t calibration)
 API for setting RTC calibration.
 
int rtc_get_calibration (const struct device *dev, int32_t *calibration)
 API for getting RTC calibration.
 
RTC Interface Helpers
static struct tmrtc_time_to_tm (struct rtc_time *timeptr)
 Convenience function for safely casting a rtc_time pointer to a tm pointer.
 
static int32_t rtc_calibration_from_frequency (uint32_t frequency)
 Determine required calibration to 1 Hertz from frequency.
 

Detailed Description

Public real time clock driver API.