1 /* 2 * Copyright (c) 2023 Intel Corporation 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef _SEDI_DRIVER_RTC_H_ 8 #define _SEDI_DRIVER_RTC_H_ 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 #include "sedi_driver_common.h" 15 16 /*! 17 * \defgroup sedi_driver_rtc RTC 18 * \ingroup sedi_driver 19 */ 20 21 #define SEDI_RTC_API_VERSION SEDI_DRIVER_VERSION_MAJOR_MINOR(0, 1) 22 23 /*! 24 * \struct sedi_rtc_capabilities_t 25 * \brief RTC Driver Capabilities. 26 * \ingroup sedi_driver_rtc 27 */ 28 typedef struct { 29 uint32_t support_alarm : 1; /**< interrupt supports timestamp */ 30 uint32_t support_callback : 1; /**< RTC support interrupt callback feature*/ 31 uint32_t reserved : 30; 32 } sedi_rtc_capabilities_t; 33 34 /*! 35 * \struct sedi_rtc_time 36 * \brief RTC time. 37 * \ingroup sedi_driver_rtc 38 */ 39 typedef struct { 40 uint32_t year; /**< Year of the time */ 41 uint8_t month; /**< Month*/ 42 uint8_t day; /**< Day */ 43 uint8_t hour; /**< Time hour */ 44 uint8_t minute; /**< Time minute */ 45 uint8_t seconds; /**< Time second */ 46 } sedi_rtc_time_t; 47 48 /*! 49 * \defgroup rtc_event_handler RTC Event Handler Callback 50 * \ingroup sedi_driver_rtc 51 * \{ 52 */ 53 /*! 54 * \typedef sedi_rtc_event_cb_t 55 * \brief Callback function type for signal rtc event. 56 * \param[in] event_flag: Event flags for the callback. 57 * \param[in] param: User callback parameter pointer. 58 * \return void 59 */ 60 typedef void (*sedi_rtc_event_cb_t)(IN uint32_t event_flag, INOUT void *param); 61 62 /*! 63 * \} 64 */ 65 66 /*! 67 * \brief Get rtc driver's API versions 68 * \return the version of current rtc driver 69 */ 70 sedi_driver_version_t sedi_rtc_get_version(void); 71 72 /*! 73 * \brief Get rtc device's capabilities. 74 * \param[out] cap: RTC device capabilities pointer 75 * \return \ref return_status 76 */ 77 int sedi_rtc_get_capabilities(sedi_rtc_capabilities_t *cap); 78 79 /*! 80 * \brief Init rtc module 81 * \return \ref return_status 82 */ 83 int sedi_rtc_init(void); 84 85 /*! 86 * \brief Uninit rtc module. 87 * \return \ref return_status 88 */ 89 int sedi_rtc_uninit(void); 90 91 /*! 92 * \brief Set rtc module power state. 93 * \param[IN] state: Power state. 94 * \return \ref return_status. 95 */ 96 int sedi_rtc_set_power(IN sedi_power_state_t state); 97 98 /*! 99 * \brief Get rtc timer. 100 * \return Timer of rtc in clock cycle 101 */ 102 uint64_t sedi_rtc_get(void); 103 104 /*! 105 * \brief Get rtc time in microsecond 106 * \return RTC time in microsecond 107 */ 108 uint64_t sedi_rtc_get_us(void); 109 110 #ifdef __cplusplus 111 } 112 #endif 113 114 #endif /*_SEDI_DRIVER_RTC_H_*/ 115