MT2523 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 
405 #ifdef HAL_RTC_FEATURE_TIME_CALLBACK
406 
407 typedef enum {
416 #endif
417 
425 #ifdef HAL_RTC_FEATURE_TIME_CALLBACK
426 
427 typedef struct {
428  uint8_t rtc_sec;
429  uint8_t rtc_min;
430  uint8_t rtc_hour;
431  uint8_t rtc_day;
432  uint8_t rtc_mon;
433  uint8_t rtc_week;
434  uint8_t rtc_year;
436 #else
437 
438 typedef struct {
439  uint8_t rtc_sec;
440  uint8_t rtc_min;
441  uint8_t rtc_hour;
442  uint8_t rtc_day;
443  uint8_t rtc_mon;
444  uint8_t rtc_week;
445  uint8_t rtc_year;
447 #endif
448 
456 #ifdef HAL_RTC_FEATURE_TIME_CALLBACK
457 
460 typedef void (*hal_rtc_time_callback_t)(void *user_data);
461 #endif
462 
466 typedef void (*hal_rtc_alarm_callback_t)(void *user_data);
467 
477 
483 
493 
502 
503 #ifdef HAL_RTC_FEATURE_TIME_CALLBACK
504 
518 #endif
519 
529 
538 
546 
552 
553 #ifdef HAL_RTC_FEATURE_TIME_CALLBACK
554 
563 hal_rtc_status_t hal_rtc_set_time_callback(hal_rtc_time_callback_t callback_function, void *user_data);
564 #endif
565 
566 #ifdef HAL_RTC_FEATURE_SLEEP
567 
576 hal_rtc_status_t hal_rtc_sleep(uint32_t magic);
577 #endif
578 
588 hal_rtc_status_t hal_rtc_set_alarm_callback(const hal_rtc_alarm_callback_t callback_function, void *user_data);
589 
590 #ifdef HAL_RTC_FEATURE_CALIBRATION
591 
598 
606 
613 hal_rtc_status_t hal_rtc_set_repeat_calibration(int16_t ticks_per_8_seconds);
614 
621 hal_rtc_status_t hal_rtc_get_repeat_calibration(int16_t *ticks_per_8_seconds);
622 #endif
623 
642 hal_rtc_status_t hal_rtc_set_data(uint16_t offset, const char *buf, uint16_t len);
643 
662 hal_rtc_status_t hal_rtc_get_data(uint16_t offset, char *buf, uint16_t len);
663 
681 hal_rtc_status_t hal_rtc_clear_data(uint16_t offset, uint16_t len);
682 
688 hal_rtc_status_t hal_rtc_get_f32k_frequency(uint32_t *frequency);
689 
690 #ifdef HAL_RTC_FEATURE_RETENTION_SRAM
691 
711 hal_rtc_status_t hal_rtc_retention_sram_config(uint32_t mask, hal_rtc_sram_mode_t mode);
712 
718 hal_rtc_status_t hal_rtc_enter_retention_mode(void);
719 
724 void hal_rtc_exit_retention_mode(void);
725 #endif
726 
727 #ifdef __cplusplus
728 }
729 #endif
730 
736 #endif /*HAL_RTC_MODULE_ENABLED*/
737 #endif /*__HAL_RTC_H__*/
738 
hal_rtc_status_t hal_rtc_set_time_callback(hal_rtc_time_callback_t callback_function, void *user_data)
This function sets the RTC time notification callback, and the callback execution period is set by ha...
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.
Execute a callback function set by hal_rtc_set_time_notification_period() for every second...
Definition: hal_rtc.h:409
uint8_t rtc_sec
Seconds after minutes - [0,59].
Definition: hal_rtc.h:428
uint8_t rtc_week
Days in a week - [0,6].
Definition: hal_rtc.h:433
hal_rtc_status_t
RTC status.
Definition: hal_rtc.h:399
uint8_t rtc_year
Years - [0,127].
Definition: hal_rtc.h:434
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_set_repeat_calibration(int16_t ticks_per_8_seconds)
This function sets the ticks that are periodically adjusted to the RTC current time per 8 seconds...
No need for a time notification.
Definition: hal_rtc.h:408
hal_rtc_status_t hal_rtc_get_repeat_calibration(int16_t *ticks_per_8_seconds)
This function gets the ticks that are periodically adjusted to the RTC current time per 8 seconds...
void(* hal_rtc_time_callback_t)(void *user_data)
Callback function definition to handle the RTC current time change.
Definition: hal_rtc.h:460
hal_rtc_status_t hal_rtc_get_alarm(hal_rtc_time_t *time)
This function gets the RTC alarm time.
Execute a callback function set by hal_rtc_set_time_notification_period() for every year...
Definition: hal_rtc.h:414
uint8_t rtc_day
Day of the month - [1,31].
Definition: hal_rtc.h:431
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:466
uint8_t rtc_hour
Hours after midnight - [0,23].
Definition: hal_rtc.h:430
RTC time structure definition.
Definition: hal_rtc.h:427
hal_rtc_status_t hal_rtc_set_one_shot_calibration(int16_t ticks)
This function sets the tick value that will be adjusted to the RTC current time.
hal_rtc_time_notification_period_t
RTC current time change notification period selections.
Definition: hal_rtc.h:407
uint8_t rtc_min
Minutes after the hour - [0,59].
Definition: hal_rtc.h:429
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.
Execute a callback function set by hal_rtc_set_time_notification_period() for every day...
Definition: hal_rtc.h:412
hal_rtc_status_t hal_rtc_init(void)
This function initializes the RTC module.
hal_rtc_status_t hal_rtc_set_time_notification_period(hal_rtc_time_notification_period_t period)
This function sets the RTC current time change notification period.
hal_rtc_status_t hal_rtc_enable_alarm(void)
This function enables an alarm.
hal_rtc_status_t hal_rtc_get_one_shot_calibration(int16_t *ticks)
This function gets the tick value that will be adjusted to the RTC current time.
Execute a callback function set by hal_rtc_set_time_notification_period() for every minute...
Definition: hal_rtc.h:410
uint8_t rtc_mon
Months - [1,12].
Definition: hal_rtc.h:432
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...
Execute a callback function set by hal_rtc_set_time_notification_period() for every month...
Definition: hal_rtc.h:413
Execute a callback function set by hal_rtc_set_time_notification_period() for every hour...
Definition: hal_rtc.h:411