RTC
- group RTC
Enums
-
enum pi_rtc_mode_e
RTC working mode.
Values:
-
enumerator PI_RTC_MODE_CALENDAR = 0x1
RTC calendar mode.
-
enumerator PI_RTC_MODE_ALARM = 0x2
RTC alarm mode.
-
enumerator PI_RTC_MODE_TIMER = 0x4
RTC countdown mode.
-
enumerator PI_RTC_MODE_CALIBRATION = 0x8
RTC calibration mode.
-
enumerator PI_RTC_MODE_CALENDAR = 0x1
-
enum pi_rtc_alarm_repeat_e
RTC alarm repeat mode.
Values:
-
enumerator PI_RTC_ALARM_RPT_NONE = 0x0
Alarm not repeated.
-
enumerator PI_RTC_ALARM_RPT_SEC = 0x3
Alarm repeated every seconds.
-
enumerator PI_RTC_ALARM_RPT_MIN = 0x4
Alarm repeated every minutes.
-
enumerator PI_RTC_ALARM_RPT_HOUR = 0x5
Alarm repeated every hours.
-
enumerator PI_RTC_ALARM_RPT_DAY = 0x6
Alarm repeated every days.
-
enumerator PI_RTC_ALARM_RPT_MON = 0x7
Alarm repeated every months.
-
enumerator PI_RTC_ALARM_RPT_YEAR = 0x8
Alarm repeated every years.
-
enumerator PI_RTC_ALARM_RPT_NONE = 0x0
-
enum pi_rtc_ioctl_cmd_e
RTC ioctl commands.
Values:
-
enumerator PI_RTC_CALENDAR_START = 0
Start RTC device.
-
enumerator PI_RTC_CALENDAR_STOP = 1
Stop RTC device.
-
enumerator PI_RTC_ALARM_START = 2
Start alarm function.
-
enumerator PI_RTC_ALARM_STOP = 3
Stop alarm function.
-
enumerator PI_RTC_TIMER_START = 4
Start countdown.
-
enumerator PI_RTC_TIMER_STOP = 5
Stop countdown.
-
enumerator PI_RTC_ALARM_ATTACH_TASK = 6
Attach task to be enqueued when alarm is reached.
-
enumerator PI_RTC_TIMER_ATTACH_TASK = 7
Attach task to be enqueued when timer is reached.
-
enumerator PI_RTC_CALENDAR_START = 0
Functions
-
void pi_rtc_conf_init(struct pi_rtc_conf *conf)
Initialize a RTC configuration structure.
This function initializes a RTC configuration structure with default values.
- Parameters:
conf – RTC configuration structure.
-
int pi_rtc_open(struct pi_device *device)
Open a RTC device.
This function opens a RTC device.
- Parameters:
device – Device structure.
- Return values:
0 – If operation is successful.
ERRNO – An error code otherwise.
-
void pi_rtc_close(struct pi_device *device)
Close a RTC device.
This function closes a RTC device.
- Parameters:
device – Device structure.
-
int pi_rtc_datetime_set(struct pi_device *device, struct tm *time)
Set date and time.
This function is used to set current date and current time.
Note
Standard is not used to set the struct tm here.
Ex: 20/12/2019 15:20:45
time->tm_year = 2019;
time->tm_mon = 12;
time->tm_date = 20;
time->tm_hour = 15;
time->tm_min = 20;
time->tm_sec = 45;
If this struct needs to be used with standarg functions, copy this struct into a new one, adjust members according to standards.- Parameters:
device – Device structure.
time – Current date and time to set.
- Return values:
0 – If operation is successful.
ERRNO – An error code otherwise.
-
int pi_rtc_datetime_get(struct pi_device *device, struct tm *time)
Get current date ans time.
This function retrieves current date and time.
- Parameters:
device – Device structure.
time – Current date and time to store.
- Return values:
0 – If operation is successful.
ERRNO – An error code otherwise.
-
int pi_rtc_alarm_set(struct pi_device *device, struct tm *alarm)
Set alaram.
This function is used to set alarm. The alarm can be one shot or rearmed. An IRQ is triggered when the alarm date and time are reached.
- Parameters:
device – Device structure.
alarm – Date and time to set alarm.
- Return values:
0 – If operation is successful.
ERRNO – An error code otherwise.
-
int pi_rtc_alarm_get(struct pi_device *device, struct tm *alarm)
Get current alaram.
This function retrieves alarm date and time, if set.
- Parameters:
device – Device structure.
alarm – Curremt alarm date and time to store.
- Return values:
0 – If operation is successful.
ERRNO – An error code otherwise.
-
int pi_rtc_timer_set(struct pi_device *device, uint32_t countdown)
Set counter.
This function is used to set counter. The timer counts down from the given till 0, and triggers an IRQ.
- Parameters:
device – Device structure.
countdown – Countdown value.
- Return values:
0 – If operation is successful.
ERRNO – An error code otherwise.
-
uint32_t pi_rtc_timer_get(struct pi_device *device)
Get current counter value.
This function returns current timer value.
- Parameters:
device – Device structure.
- Returns:
Value Current timer value..
-
int pi_rtc_ioctl(struct pi_device *device, uint32_t cmd, void *arg)
Ioctl command.
This function allows to send different commands to RTC device. The commands are listed above in pi_rtc_ioctl_cmd_e.
- Parameters:
device – Device structure.
cmd – Ioctl command.
arg – Ioctl command args.
- Return values:
-1 – If wrong ioctl command.
Value – Otherwise return value depending on ioctl command.
-
struct pi_rtc_conf
- #include <rtc.h>
RTC configuration structure.
-
enum pi_rtc_mode_e