这是最新(主)开发分支的文档。如果您正在查找以前版本的文档,使用左侧的下拉菜单选择所需的版本。

RTC API 参考

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

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.

备注

This API must be called before all other RTC API can be called

参数:

dev_name – RTC device name

返回:

  • NULL: failed

  • others: succeed

int wm_drv_rtc_deinit(wm_device_t *dev)

Deinitialization RTC driver.

参数:

dev – RTC driver device

返回:

  • 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.

备注

W800 calendar time input Range 2000.01.01 0:0:0 ~ 2127:12.31 23:59:59

备注

Set RTC calendar will cancel RTC alarm

参数:
  • dev – RTC driver device

  • tm – Calendar time

返回:

  • 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.

参数:
  • dev – RTC driver device

  • tm[out] Calendar time write back address

返回:

  • 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.

参数:
  • 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

返回:

  • 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.

参数:
  • dev – RTC driver device

  • id[out] available RTC alarm ID

返回:

  • 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.

备注

Set calendar time will clear alarm

备注

The alarm time must be later than the current time

备注

W800 alarm time input Range 2000.01.01 0:0:0 ~ 2127:12.31 23:59:59

参数:
  • 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

返回:

  • 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.

参数:
  • 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

返回:

  • 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.

参数:
  • dev – RTC driver device

  • id – RTC alarm index number, range is 0 ~ WM_DRV_RTC_ALARM_NUMBER

返回:

  • 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.

参数:
  • 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

返回:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed