98 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			98 lines
		
	
	
		
			3.7 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_RTC_EXT_DRIVER_H_
 | |
| #define _IOT_RTC_EXT_DRIVER_H_
 | |
| 
 | |
| /* iot common header files */
 | |
| #include "iot_config_api.h"
 | |
| #include "iot_rtc_api.h"
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| extern "C" {
 | |
| #endif
 | |
| 
 | |
| #if IOT_RTC_EXT_ENABLE
 | |
| 
 | |
| #if HW_PLATFORM != HW_PLATFORM_SIMU
 | |
| /* define whether the chip is enabled */
 | |
| #define  IOT_EXT_RTC_M41T0_ENABLE           1
 | |
| #define  IOT_EXT_RTC_BL8025T_ENABLE         1
 | |
| #define  IOT_EXT_RTC_RX8010_ENABLE          1
 | |
| #endif /* HW_PLATFORM != HW_PLATFORM_SIMU */
 | |
| 
 | |
| /* define maximum number of drivers in the table */
 | |
| #define IOT_EXT_RTC_DRV_TABLE_SIZE          4
 | |
| 
 | |
| /* function callback to prode external RTC chip.
 | |
|  * @retval:  ERR_OK - chip prode successfully, otherwise - error code
 | |
|  */
 | |
| typedef uint32_t (*iot_rtc_drv_prode_func)(void);
 | |
| 
 | |
| /* function callback to initialize external RTC chip.
 | |
|  * @tm:      set the initial time infor of the external RTC, if the chip is
 | |
|  *           powerup. otherwise return the external RTC time info.
 | |
|  * @done:    1 - ext RTC chip has been started, 0 - not started
 | |
|  * @retval:  ERR_OK - set successfully, otherwise - error code
 | |
|  */
 | |
| typedef uint32_t (*iot_rtc_drv_init_func)(iot_time_tm_t *tm, uint32_t *done);
 | |
| 
 | |
| /* function callback to deinit external RTC chip.
 | |
|  */
 | |
| typedef void (*iot_rtc_drv_deinit_func)(void);
 | |
| 
 | |
| /* function callback get time from external RTC chip.
 | |
|  * @tm:     return the time info of the external RTC chip
 | |
|  * @retval: ERR_OK - set successfully, otherwise - error code
 | |
|  */
 | |
| typedef uint32_t (*iot_rtc_drv_get_time_func)(iot_time_tm_t *tm);
 | |
| 
 | |
| /* function callback to set time to external RTC chip.
 | |
|  * @tm:     pointer to the time to be set
 | |
|  * @week:   week to be set, 0 - sunday, 1 ~ 6 - monday ~ saturday
 | |
|  * @retval: ERR_OK - set successfully, otherwise - error code
 | |
|  */
 | |
| typedef uint32_t (*iot_rtc_drv_set_time_func)(iot_time_tm_t *tm, uint8_t week);
 | |
| 
 | |
| /* callback functions to check whether external RTC chips startup
 | |
|  * @tm:     if started, return the time info of the external RTC chip
 | |
|  * @retval: 1 - started,  0   - not startup
 | |
|  */
 | |
| typedef uint32_t (*iot_rtc_drv_is_starup_func)(iot_time_tm_t *tm);
 | |
| 
 | |
| /* extern RTC callback function descriptor */
 | |
| typedef struct _iot_ext_rtc_drv {
 | |
|     /* external RTC chip prode callback function */
 | |
|     iot_rtc_drv_prode_func drv_prode;
 | |
|     /* external RTC chip init callback function */
 | |
|     iot_rtc_drv_init_func drv_init;
 | |
|     /* external RTC chip deinit callback function */
 | |
|     iot_rtc_drv_deinit_func drv_deinit;
 | |
|     /* external RTC chip get time callback function */
 | |
|     iot_rtc_drv_get_time_func drv_get_time;
 | |
|     /* external RTC chip set time callback function */
 | |
|     iot_rtc_drv_set_time_func drv_set_time;
 | |
|     /* external RTC chip checks start-up callback function */
 | |
|     iot_rtc_drv_is_starup_func drv_is_startup;
 | |
|     /* local time of the latest update */
 | |
| } iot_ext_rtc_drv_t;
 | |
| 
 | |
| #endif /* IOT_RTC_EXT_ENABLE */
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| }
 | |
| #endif
 | |
| 
 | |
| #endif /*_IOT_RTC_EXT_DRIVER_H_ */ |