132 lines
4.0 KiB
C
132 lines
4.0 KiB
C
|
/****************************************************************************
|
||
|
|
||
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
||
|
|
||
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
||
|
be copied by any method or incorporated into another program without
|
||
|
the express written consent of Aerospace C.Power. This Information or any portion
|
||
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
||
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
||
|
liability for its use in any way and conveys no license or title under
|
||
|
any patent or copyright and makes no representation or warranty that this
|
||
|
Information is free from patent or copyright infringement.
|
||
|
|
||
|
****************************************************************************/
|
||
|
#ifndef IOT_BRM_RTC_H
|
||
|
#define IOT_BRM_RTC_H
|
||
|
|
||
|
/* os shim includes */
|
||
|
#include "os_types_api.h"
|
||
|
|
||
|
/* iot common includes */
|
||
|
#include "iot_task_api.h"
|
||
|
#include "iot_rtc_api.h"
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
#if (IOT_BRM_ENABLE && PLC_SUPPORT_STA_ROLE)
|
||
|
|
||
|
/* alarm clock enabling bit definition */
|
||
|
#define IOT_BRM_RTC_ALARM_SEC_EN 0x01
|
||
|
#define IOT_BRM_RTC_ALARM_MIN_EN 0x02
|
||
|
#define IOT_BRM_RTC_ALARM_HOUR_EN 0x04
|
||
|
#define IOT_BRM_RTC_ALARM_DAY_EN 0x08
|
||
|
|
||
|
/* alarm clock notification callback function */
|
||
|
typedef void (*iot_brm_rtc_alarm_func_t)(void);
|
||
|
|
||
|
/* rtc clock sec update callback function */
|
||
|
typedef void (*iot_brm_rtc_sec_update_func_t)(void);
|
||
|
|
||
|
/* rtc alarm config descriptor */
|
||
|
typedef struct _iot_brm_rtc_alarm_config {
|
||
|
/* the alarm sec to be matched */
|
||
|
uint8_t sec;
|
||
|
/* the alarm min to be matched */
|
||
|
uint8_t min;
|
||
|
/* the alarm hour to be matched */
|
||
|
uint8_t hour;
|
||
|
/* the alarm day to be matched */
|
||
|
uint8_t day;
|
||
|
/* match enable flag, bit 0, 1, 2, 3 corresponds to second, minute,
|
||
|
* hour, day.
|
||
|
*/
|
||
|
uint8_t en;
|
||
|
/* alarm clock notification callback function */
|
||
|
iot_brm_rtc_alarm_func_t nodify_func;
|
||
|
} iot_brm_rtc_alarm_config_t;
|
||
|
|
||
|
/**
|
||
|
* @brief iot_brm_rtctime_to_time() - convert RTC time to integer timestamp.
|
||
|
* @param tm: pointer to the rtc time
|
||
|
* @retval: integer timestamp relative to 1970-1-1 00:00:00
|
||
|
*/
|
||
|
uint32_t iot_brm_rtctime_to_time(iot_time_tm_t *tm);
|
||
|
|
||
|
/**
|
||
|
* @brief iot_brm_time_to_rtctime() - convert integer timestamp to RTC time.
|
||
|
* @param time: integer timestamp relative to 1970-1-1 00:00:00
|
||
|
* @param tm: return RTC time
|
||
|
*/
|
||
|
void iot_brm_time_to_rtctime(uint32_t time, iot_time_tm_t *tm);
|
||
|
|
||
|
/**
|
||
|
* @brief iot_brm_send_mr_cmd() - set calendar time.
|
||
|
* @param tm: pointer to the calendar time to be set
|
||
|
* @retval: ERR_OK - successfully, otherwise - error code
|
||
|
*/
|
||
|
uint32_t iot_brm_rtc_set_time(iot_time_tm_t *tm);
|
||
|
|
||
|
/**
|
||
|
* @brief iot_brm_rtc_get_time() - get calendar time.
|
||
|
* @param tm: return the calendar time
|
||
|
* @param week: return week, 0 - sunday, 1 ~ 6 - monday ~ saturday.
|
||
|
*/
|
||
|
void iot_brm_rtc_get_time(iot_time_tm_t *tm, uint8_t *week);
|
||
|
|
||
|
/**
|
||
|
* @brief iot_brm_rtc_set_alarm() - set alarm clock.
|
||
|
* @param config: alarm clock config info.
|
||
|
* @retval: ERR_OK - successfully, otherwise - error code
|
||
|
*/
|
||
|
uint8_t iot_brm_rtc_set_alarm(iot_brm_rtc_alarm_config_t *config);
|
||
|
|
||
|
/**
|
||
|
* @brief iot_brm_rtc_set_sec_update() - set sec update clock.
|
||
|
* @param fun: sec update clock fun.
|
||
|
* @retval: ERR_OK - successfully, otherwise - error code
|
||
|
*/
|
||
|
uint8_t iot_brm_rtc_set_sec_update(iot_brm_rtc_sec_update_func_t fun);
|
||
|
|
||
|
/**
|
||
|
* @brief iot_brm_rtc_init() - initialize RTC module
|
||
|
* @retval: ERR_OK - successfully, otherwise - error code
|
||
|
*/
|
||
|
uint32_t iot_brm_rtc_init(void);
|
||
|
|
||
|
/**
|
||
|
* @brief iot_brm_rtc_timeout() - RTC module period handle
|
||
|
*/
|
||
|
void iot_brm_rtc_timeout(void);
|
||
|
|
||
|
/**
|
||
|
* @brief iot_brm_rtc_deinit() - deinit RTC module
|
||
|
*/
|
||
|
void iot_brm_rtc_deinit(void);
|
||
|
|
||
|
/**
|
||
|
* @brief iot_brm_rtc_is_abnormal() - check whether RTC is abnormal.
|
||
|
* @retval: 1 - abnormal, 0 - normal
|
||
|
*/
|
||
|
uint8_t iot_brm_rtc_is_abnormal(void);
|
||
|
|
||
|
#endif /* IOT_BRM_ENABLE && PLC_SUPPORT_STA_ROLE */
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#endif /* IOT_BRM_RTC_H */
|