MT7687 API Reference  LinkIt SDK v4
hal_rtc.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2017 MediaTek Inc. All rights reserved.
4  *
5  * This software/firmware and related documentation ("MediaTek Software") are
6  * protected under relevant copyright laws. The information contained herein
7  * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
8  * Without the prior written permission of MediaTek and/or its licensors,
9  * any reproduction, modification, use or disclosure of MediaTek Software,
10  * and information contained herein, in whole or in part, shall be strictly prohibited.
11  * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
12  * if you have agreed to and been bound by the applicable license agreement with
13  * MediaTek ("License Agreement") and been granted explicit permission to do so within
14  * the License Agreement ("Permitted User"). If you are not a Permitted User,
15  * please cease any access or use of MediaTek Software immediately.
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
18  * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
19  * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
21  * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
22  * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
23  * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
24  * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
25  * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
26  * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
27  * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
28  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
29  * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
30  * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
31  * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
32  * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
33  */
34 
35 #ifndef __HAL_RTC_H__
36 #define __HAL_RTC_H__
37 #include "hal_platform.h"
38 
39 #ifdef HAL_RTC_MODULE_ENABLED
40 
59 #ifdef HAL_RTC_FEATURE_TIME_CALLBACK
60 
78 #else
79 
89 #endif
90 
109 #ifdef HAL_RTC_FEATURE_TIME_CALLBACK
110 
124 #else
125 
138 #endif
139 
210 #ifdef HAL_RTC_FEATURE_TIME_CALLBACK
211 
253 #endif
254 
354 #ifdef HAL_RTC_FEATURE_SLEEP
355 
371 #endif
372 
373 
374 
375 #ifdef __cplusplus
376 extern "C" {
377 #endif
378 
383 #ifdef HAL_RTC_FEATURE_SLEEP
384 
387 #define HAL_RTC_SLEEP_MAGIC (0xBABEBABE)
388 #endif
389 
399 typedef enum {
404 
413 #ifdef HAL_RTC_FEATURE_TIME_CALLBACK
414 
417 typedef void (*hal_rtc_time_callback_t)(void *user_data);
418 #endif
419 
423 typedef void (*hal_rtc_alarm_callback_t)(void *user_data);
424 
434 
440 
450 
459 
460 #ifdef HAL_RTC_FEATURE_TIME_CALLBACK
461 
474 hal_rtc_status_t hal_rtc_set_time_notification_period(hal_rtc_time_notification_period_t period);
475 #endif
476 
486 
495 
503 
509 
510 #ifdef HAL_RTC_FEATURE_TIME_CALLBACK
511 
520 hal_rtc_status_t hal_rtc_set_time_callback(hal_rtc_time_callback_t callback_function, void *user_data);
521 #endif
522 
523 #ifdef HAL_RTC_FEATURE_SLEEP
524 
533 hal_rtc_status_t hal_rtc_sleep(uint32_t magic);
534 #endif
535 
545 hal_rtc_status_t hal_rtc_set_alarm_callback(const hal_rtc_alarm_callback_t callback_function, void *user_data);
546 
547 #ifdef HAL_RTC_FEATURE_CALIBRATION
548 
554 hal_rtc_status_t hal_rtc_set_one_shot_calibration(int16_t ticks);
555 
562 hal_rtc_status_t hal_rtc_get_one_shot_calibration(int16_t *ticks);
563 
570 hal_rtc_status_t hal_rtc_set_repeat_calibration(int16_t ticks_per_8_seconds);
571 
578 hal_rtc_status_t hal_rtc_get_repeat_calibration(int16_t *ticks_per_8_seconds);
579 #endif
580 
599 hal_rtc_status_t hal_rtc_set_data(uint16_t offset, const char *buf, uint16_t len);
600 
619 hal_rtc_status_t hal_rtc_get_data(uint16_t offset, char *buf, uint16_t len);
620 
638 hal_rtc_status_t hal_rtc_clear_data(uint16_t offset, uint16_t len);
639 
645 hal_rtc_status_t hal_rtc_get_f32k_frequency(uint32_t *frequency);
646 
647 #ifdef HAL_RTC_FEATURE_RETENTION_SRAM
648 
668 hal_rtc_status_t hal_rtc_retention_sram_config(uint32_t mask, hal_rtc_sram_mode_t mode);
669 
675 hal_rtc_status_t hal_rtc_enter_retention_mode(void);
676 
682 void hal_rtc_exit_retention_mode(void);
683 #endif
684 
685 #ifdef HAL_RTC_FEATURE_ELAPSED_TICK
686 
719 hal_rtc_status_t hal_rtc_get_elapsed_tick(bool is_after_sleep, uint32_t *elapsed_tick);
720 #endif
721 
722 #ifdef __cplusplus
723 }
724 #endif
725 
731 #endif /*HAL_RTC_MODULE_ENABLED*/
732 #endif /*__HAL_RTC_H__*/
733 
hal_rtc_status_t hal_rtc_set_alarm(const hal_rtc_time_t *time)
This function sets the RTC alarm time.
hal_rtc_status_t hal_rtc_get_data(uint16_t offset, char *buf, uint16_t len)
This function reads data from the RTC registers that won't be cleared even if the system power is off...
hal_rtc_status_t hal_rtc_set_alarm_callback(const hal_rtc_alarm_callback_t callback_function, void *user_data)
This function sets the alarm callback.
hal_rtc_status_t
RTC status.
Definition: hal_rtc.h:399
hal_rtc_status_t hal_rtc_deinit(void)
This function deinitializes the RTC module.
hal_rtc_status_t hal_rtc_set_time(const hal_rtc_time_t *time)
This function sets the RTC current time.
The operation completed successfully.
Definition: hal_rtc.h:402
hal_rtc_status_t hal_rtc_disable_alarm(void)
This function disables an alarm.
hal_rtc_status_t hal_rtc_get_time(hal_rtc_time_t *time)
This function gets the RTC current time.
hal_rtc_status_t hal_rtc_sleep(uint32_t magic)
This function sets the system into sleep mode.
hal_rtc_status_t hal_rtc_get_alarm(hal_rtc_time_t *time)
This function gets the RTC alarm time.
hal_rtc_status_t hal_rtc_set_data(uint16_t offset, const char *buf, uint16_t len)
This function stores data to the RTC registers that won't be cleared even if the system power is off...
void(* hal_rtc_alarm_callback_t)(void *user_data)
Callback function definition to handle the RTC alarm.
Definition: hal_rtc.h:423
RTC time structure definition.
Definition: hal_platform.h:571
hal_rtc_status_t hal_rtc_get_f32k_frequency(uint32_t *frequency)
This function gets the frequency value of 32.768kHz clock source, unit is in Hz.
hal_rtc_status_t hal_rtc_init(void)
This function initializes the RTC module.
hal_rtc_status_t hal_rtc_enable_alarm(void)
This function enables an alarm.
An error occurred.
Definition: hal_rtc.h:400
Invalid parameter is given.
Definition: hal_rtc.h:401
hal_rtc_status_t hal_rtc_clear_data(uint16_t offset, uint16_t len)
This function stores zero to the RTC registers that won't be cleared even if the system power is off...