RTC API Reference
RTC
-
enum wm_rtc_alarm_mask_e
RTC alarm mask enum.
Values:
-
enumerator WM_RTC_ALARM_TIME_MASK_SECOND
alarm trigger ignore seconds
-
enumerator WM_RTC_ALARM_TIME_MASK_MINUTE
alarm trigger ignore minutes
-
enumerator WM_RTC_ALARM_TIME_MASK_HOUR
alarm trigger ignore hours
-
enumerator WM_RTC_ALARM_TIME_MASK_MONTHDAY
alarm trigger ignore day of the month
-
enumerator WM_RTC_ALARM_TIME_MASK_MONTH
alarm trigger ignore month
-
enumerator WM_RTC_ALARM_TIME_MASK_YEAR
alarm trigger ignore year
-
enumerator WM_RTC_ALARM_TIME_MASK_WEEKDAY
alarm trigger ignore weekday
-
enumerator WM_RTC_ALARM_TIME_MASK_YEARDAY
alarm trigger ignore day of the year
-
enumerator WM_RTC_ALARM_TIME_MASK_NSEC
alarm trigger ignore nanosecond
-
enumerator WM_RTC_ALARM_TIME_MASK_SECOND
-
typedef wm_hal_rtc_time_t wm_drv_rtc_time_t
RTC driver time structure.
-
typedef void (*wm_rtc_callback_t)(void *user_data)
Prototype of RTC driver callback function.
-
wm_device_t *wm_drv_rtc_init(const char *dev_name)
Initialize RTC driver.
Note
This API must be called before all other RTC API can be called
- Parameters:
dev_name – RTC device name
- Returns:
NULL: failed
others: succeed
-
int wm_drv_rtc_deinit(wm_device_t *dev)
Deinitialization RTC driver.
- Parameters:
dev – RTC driver device
- Returns:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_drv_rtc_set_time(wm_device_t *dev, struct tm *tm)
Set RTC calendar.
Note
W800 calendar time input Range 2000.01.01 0:0:0 ~ 2127:12.31 23:59:59
Note
Set RTC calendar will cancel RTC alarm
- Parameters:
dev – RTC driver device
tm – Calendar time
- Returns:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_drv_rtc_get_time(wm_device_t *dev, struct tm *tm)
Get RTC calendar.
- Parameters:
dev – RTC driver device
tm – [out] Calendar time write back address
- Returns:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_drv_rtc_get_alarm_supported_mask(wm_device_t *dev, int id, int *mask)
Get RTC alarm supported mask.
- Parameters:
dev – RTC driver device
id – RTC alarm index number, range is 0 ~ WM_DRV_RTC_ALARM_NUMBER
mask – [out] RTC alarm supported mask @ wm_rtc_alarm_mask_e
- Returns:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_drv_rtc_get_alarm_available_id(wm_device_t *dev, int *id)
Get available RTC alarm ID, mean this alarm is in idle state.
- Parameters:
dev – RTC driver device
id – [out] available RTC alarm ID
- Returns:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_drv_rtc_set_alarm(wm_device_t *dev, int id, int mask, struct tm *tm)
Set RTC alarm time.
Note
Set calendar time will clear alarm
Note
The alarm time must be later than the current time
Note
W800 alarm time input Range 2000.01.01 0:0:0 ~ 2127:12.31 23:59:59
- Parameters:
dev – RTC driver device
id – RTC alarm index number, range is 0 ~ WM_DRV_RTC_ALARM_NUMBER
mask – RTC alarm mask @ wm_rtc_alarm_mask_e
tm – RTC alarm time
- Returns:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_drv_rtc_get_alarm(wm_device_t *dev, int id, int *mask, struct tm *tm)
Get RTC alarm time.
- Parameters:
dev – RTC driver device
id – RTC alarm index number, range is 0 ~ WM_DRV_RTC_ALARM_NUMBER
mask – [out] RTC alarm mask write back address
tm – [out] RTC alarm time write back address
- Returns:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_drv_rtc_abort_alarm(wm_device_t *dev, int id)
Abort RTC alarm.
- Parameters:
dev – RTC driver device
id – RTC alarm index number, range is 0 ~ WM_DRV_RTC_ALARM_NUMBER
- Returns:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed
-
int wm_drv_rtc_register_alarm_callback(wm_device_t *dev, int id, wm_rtc_callback_t callback, void *user_data)
Register RTC alarm callback function.
- Attention
As the callback is invoked in the ISR handler, it is not suitable to use any blocking operation or logic that will take more time in the callback, to avoid other ISRs from not being triggered in time. It is suggested to send an event to the user application task in this callback if there is any blocking operation.
- Parameters:
dev – RTC driver device
id – RTC alarm index number, range is 0 ~ WM_DRV_RTC_ALARM_NUMBER
callback – RTC alarm callback function
user_data – User data for RTC alarm callback function
- Returns:
WM_ERR_SUCCESS: succeed
WM_ERR_INVALID_PARAM: invalid argument
others: failed