2 * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 /******************************************************************************
18 * @brief header file for rtc driver
21 ******************************************************************************/
31 #include <drv_common.h>
34 /// definition for rtc handle.
35 typedef void *rtc_handle_t;
37 /****** rtc specific error codes *****/
39 EDRV_RTC_TIME = (EDRV_SPECIFIC + 1), ///< timer data not supported
46 uint32_t active : 1; ///< rtc is running or not
49 /****** RTC Event *****/
51 RTC_EVENT_TIMER_INTRERRUPT = 0 ///< generate interrupt
54 typedef void (*rtc_event_cb_t)(rtc_event_e event); ///< Pointer to \ref rtc_event_cb_t : RTC Event call back.
57 \brief RTC Device Driver Capabilities.
60 uint32_t interrupt_mode : 1; ///< supports Interrupt mode
61 uint32_t wrap_mode : 1; ///< supports wrap mode
65 \brief get rtc instance count.
66 \return rtc instance count
68 int32_t csi_rtc_get_instance_count(void);
71 \brief Initialize RTC Interface. 1. Initializes the resources needed for the RTC interface 2.registers event callback function
72 \param[in] idx must not exceed return value of csi_rtc_get_instance_count()
73 \param[in] cb_event Pointer to \ref rtc_event_cb_t
74 \return pointer to rtc instance
76 rtc_handle_t csi_rtc_initialize(int32_t idx, rtc_event_cb_t cb_event);
79 \brief De-initialize RTC Interface. stops operation and releases the software resources used by the interface
80 \param[in] handle rtc handle to operate.
83 int32_t csi_rtc_uninitialize(rtc_handle_t handle);
86 \brief Get driver capabilities.
87 \param[in] handle rtc handle to operate.
88 \return \ref rtc_capabilities_t
90 rtc_capabilities_t csi_rtc_get_capabilities(rtc_handle_t handle);
94 \param[in] handle rtc handle to operate.
95 \param[in] rtctime pointer to rtc time
98 int32_t csi_rtc_set_time(rtc_handle_t handle, const struct tm *rtctime);
101 \brief Get RTC timer.
102 \param[in] handle rtc handle to operate.
103 \param[in] rtctime pointer to rtc time
106 int32_t csi_rtc_get_time(rtc_handle_t handle, struct tm *rtctime);
111 \brief Start RTC timer.
112 \param[in] handle rtc handle to operate.
115 int32_t csi_rtc_start(rtc_handle_t handle);
118 \brief Stop RTC timer.
119 \param[in] handle rtc handle to operate.
122 int32_t csi_rtc_stop(rtc_handle_t handle);
125 \brief config rtc mode.
126 \param[in] handle rtc handle to operate.
129 //int32_t drv_rtc_config (rtc_handle_t handle/*,rtc_mode_e mode*/);
132 \brief Get RTC status.
133 \param[in] handle rtc handle to operate.
134 \return RTC status \ref rtc_status_t
136 rtc_status_t csi_rtc_get_status(rtc_handle_t handle);
139 \brief config RTC timer.
140 \param[in] handle rtc handle to operate.
141 \param[in] rtctime time to wake up
144 int32_t csi_rtc_timer_config(rtc_handle_t handle, const struct tm *rtctime);
147 \brief disable or enable RTC timer.
148 \param[in] handle rtc handle to operate.
149 \param[in] en set 1 enable for rtc timer
152 int32_t csi_rtc_timer_enable(rtc_handle_t handle, uint8_t en);
161 #endif /* _CSI_RTC_H_ */