4545
Fork of mbed-dev by
targets/TARGET_ONSEMI/TARGET_NCS36510/rtc.h@166:33361e55dd8c, 2017-08-23 (annotated)
- Committer:
- iftaziz
- Date:
- Wed Aug 23 10:32:38 2017 +0000
- Revision:
- 166:33361e55dd8c
- Parent:
- 150:02e0a0aed4ec
r1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 149:156823d33999 | 1 | /** |
<> | 149:156823d33999 | 2 | ****************************************************************************** |
<> | 149:156823d33999 | 3 | * @file rtc.h |
<> | 149:156823d33999 | 4 | * @brief (API) Public header of RTC driver |
<> | 149:156823d33999 | 5 | * @internal |
<> | 149:156823d33999 | 6 | * @author ON Semiconductor |
<> | 149:156823d33999 | 7 | * $Rev: 3485 $ |
<> | 149:156823d33999 | 8 | * $Date: 2015-07-14 15:20:11 +0530 (Tue, 14 Jul 2015) $ |
<> | 149:156823d33999 | 9 | ****************************************************************************** |
<> | 149:156823d33999 | 10 | * Copyright 2016 Semiconductor Components Industries LLC (d/b/a ON Semiconductor). |
<> | 149:156823d33999 | 11 | * All rights reserved. This software and/or documentation is licensed by ON Semiconductor |
<> | 149:156823d33999 | 12 | * under limited terms and conditions. The terms and conditions pertaining to the software |
<> | 149:156823d33999 | 13 | * and/or documentation are available at http://www.onsemi.com/site/pdf/ONSEMI_T&C.pdf |
<> | 149:156823d33999 | 14 | * (ON Semiconductor Standard Terms and Conditions of Sale, Section 8 Software) and |
<> | 149:156823d33999 | 15 | * if applicable the software license agreement. Do not use this software and/or |
<> | 149:156823d33999 | 16 | * documentation unless you have carefully read and you agree to the limited terms and |
<> | 149:156823d33999 | 17 | * conditions. By using this software and/or documentation, you agree to the limited |
<> | 149:156823d33999 | 18 | * terms and conditions. |
<> | 149:156823d33999 | 19 | * |
<> | 149:156823d33999 | 20 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED |
<> | 149:156823d33999 | 21 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF |
<> | 149:156823d33999 | 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. |
<> | 149:156823d33999 | 23 | * ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, |
<> | 149:156823d33999 | 24 | * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
<> | 149:156823d33999 | 25 | * @endinternal |
<> | 149:156823d33999 | 26 | * |
<> | 149:156823d33999 | 27 | * @ingroup rtc |
<> | 149:156823d33999 | 28 | */ |
<> | 149:156823d33999 | 29 | |
<> | 149:156823d33999 | 30 | #ifndef RTC_H_ |
<> | 149:156823d33999 | 31 | #define RTC_H_ |
<> | 149:156823d33999 | 32 | |
<> | 149:156823d33999 | 33 | #include "rtc_map.h" |
<> | 149:156823d33999 | 34 | #include "clock.h" |
<> | 149:156823d33999 | 35 | #include "memory_map.h" |
<> | 149:156823d33999 | 36 | |
<> | 149:156823d33999 | 37 | #define RTC_CLOCK_HZ 32768 |
<> | 149:156823d33999 | 38 | #define RTC_SEC_TO_US 1000000 |
<> | 149:156823d33999 | 39 | #define RTC_SUB_SEC_MASK 0x7FFF |
<> | 149:156823d33999 | 40 | #define RTC_SEC_MASK 0xFFFFFFFF |
<> | 149:156823d33999 | 41 | #define RTC_SEC_INT_STATUS_MASK 0x2 |
<> | 149:156823d33999 | 42 | |
<> | 149:156823d33999 | 43 | #define RTC_SUBSEC_INTERRUPT_BIT_VAL 0x1 |
<> | 149:156823d33999 | 44 | #define RTC_SEC_INTERRUPT_BIT_VAL 0x2 |
<> | 149:156823d33999 | 45 | #define RTC_ALL_INTERRUPT_BIT_VAL 0x3 |
<> | 149:156823d33999 | 46 | |
<> | 149:156823d33999 | 47 | #define RTC_INT_CLR_SUB_SEC_BIT_POS 0 |
<> | 149:156823d33999 | 48 | #define RTC_INT_CLR_SEC_BIT_POS 1 |
<> | 149:156823d33999 | 49 | |
<> | 149:156823d33999 | 50 | #define RTC_CONTROL_SUBSEC_CNT_START_BIT_POS 0 |
<> | 149:156823d33999 | 51 | #define RTC_CONTROL_SEC_CNT_START_BIT_POS 1 |
<> | 149:156823d33999 | 52 | #define RTC_CONTROL_SUBSEC_CNT_INT_BIT_POS 2 |
<> | 149:156823d33999 | 53 | #define RTC_CONTROL_SEC_CNT_INT_BIT_POS 3 |
<> | 149:156823d33999 | 54 | |
<> | 150:02e0a0aed4ec | 55 | #define RTC_STATUS_SUB_SEC_ALARM_WRT_BIT_POS 6 |
<> | 150:02e0a0aed4ec | 56 | #define RTC_STATUS_SEC_ALARM_WRT_BIT_POS 7 |
<> | 150:02e0a0aed4ec | 57 | #define RTC_STATUS_CONTROL_WRT_BIT_POS 8 |
<> | 149:156823d33999 | 58 | #define RTC_STATUS_SUB_SEC_INT_CLR_WRT_BIT_POS 9 |
<> | 149:156823d33999 | 59 | #define RTC_STATUS_SEC_INT_CLR_WRT_BIT_POS 10 |
<> | 149:156823d33999 | 60 | |
<> | 150:02e0a0aed4ec | 61 | #define SUB_SEC_MASK 0x7FFF |
<> | 150:02e0a0aed4ec | 62 | |
<> | 150:02e0a0aed4ec | 63 | |
<> | 149:156823d33999 | 64 | /* FUnction pointer for call back */ |
<> | 149:156823d33999 | 65 | typedef void (* fRtcCallBack)(void); |
<> | 149:156823d33999 | 66 | |
<> | 149:156823d33999 | 67 | /** |
<> | 149:156823d33999 | 68 | * @details |
<> | 149:156823d33999 | 69 | * Initializes RTC, enable RTC & register call back function |
<> | 149:156823d33999 | 70 | * |
<> | 149:156823d33999 | 71 | * @param RtcCallBack Function pointer for RTC call back funtion |
<> | 149:156823d33999 | 72 | * @return None |
<> | 149:156823d33999 | 73 | */ |
<> | 149:156823d33999 | 74 | void fRtcInit(void); |
<> | 149:156823d33999 | 75 | |
<> | 149:156823d33999 | 76 | /** |
<> | 149:156823d33999 | 77 | * @details |
<> | 149:156823d33999 | 78 | * Disable RTC |
<> | 149:156823d33999 | 79 | * |
<> | 149:156823d33999 | 80 | * @param None |
<> | 149:156823d33999 | 81 | * @return None |
<> | 149:156823d33999 | 82 | */ |
<> | 149:156823d33999 | 83 | void fRtcFree(void); |
<> | 149:156823d33999 | 84 | |
<> | 149:156823d33999 | 85 | /** |
<> | 149:156823d33999 | 86 | * @details |
<> | 149:156823d33999 | 87 | * Set up alram for RTC interrupt in micro second |
<> | 149:156823d33999 | 88 | * Pre-requisite: Both second & sub second interrupts should be cleared. |
<> | 149:156823d33999 | 89 | * @param TimeStamp in micro seconds |
<> | 149:156823d33999 | 90 | * @return None |
<> | 149:156823d33999 | 91 | */ |
<> | 149:156823d33999 | 92 | void fRtcSetInterrupt(uint32_t timestamp); |
<> | 149:156823d33999 | 93 | |
<> | 149:156823d33999 | 94 | /** |
<> | 149:156823d33999 | 95 | * @details |
<> | 149:156823d33999 | 96 | * Disable interrupt |
<> | 149:156823d33999 | 97 | * |
<> | 149:156823d33999 | 98 | * @param None |
<> | 149:156823d33999 | 99 | * @return None |
<> | 149:156823d33999 | 100 | */ |
<> | 149:156823d33999 | 101 | void fRtcDisableInterrupt(void); |
<> | 149:156823d33999 | 102 | |
<> | 149:156823d33999 | 103 | /** |
<> | 149:156823d33999 | 104 | * @details |
<> | 149:156823d33999 | 105 | * Enable interrupt |
<> | 149:156823d33999 | 106 | * |
<> | 149:156823d33999 | 107 | * @param None |
<> | 149:156823d33999 | 108 | * @return None |
<> | 149:156823d33999 | 109 | */ |
<> | 149:156823d33999 | 110 | void fRtcEnableInterrupt(void); |
<> | 149:156823d33999 | 111 | |
<> | 149:156823d33999 | 112 | /** |
<> | 149:156823d33999 | 113 | * @details |
<> | 149:156823d33999 | 114 | * Clear interrupt |
<> | 149:156823d33999 | 115 | * |
<> | 149:156823d33999 | 116 | * @param None |
<> | 149:156823d33999 | 117 | * @return None |
<> | 149:156823d33999 | 118 | */ |
<> | 149:156823d33999 | 119 | void fRtcClearInterrupt(void); |
<> | 149:156823d33999 | 120 | |
<> | 149:156823d33999 | 121 | /** |
<> | 149:156823d33999 | 122 | * @details |
<> | 149:156823d33999 | 123 | * Returns RTC time in micro seconds |
<> | 149:156823d33999 | 124 | * |
<> | 149:156823d33999 | 125 | * @param None |
<> | 149:156823d33999 | 126 | * @return RTC Time in micro second |
<> | 149:156823d33999 | 127 | */ |
<> | 149:156823d33999 | 128 | uint64_t fRtcRead(void); |
<> | 149:156823d33999 | 129 | |
<> | 149:156823d33999 | 130 | /** |
<> | 149:156823d33999 | 131 | * @details |
<> | 149:156823d33999 | 132 | * Set RTC time in micro seconds |
<> | 149:156823d33999 | 133 | * |
<> | 149:156823d33999 | 134 | * @param RtcTime in micro Seconds |
<> | 149:156823d33999 | 135 | * @return None |
<> | 149:156823d33999 | 136 | */ |
<> | 149:156823d33999 | 137 | void fRtcWrite(uint64_t RtcTimeus); |
<> | 149:156823d33999 | 138 | |
<> | 149:156823d33999 | 139 | /** |
<> | 149:156823d33999 | 140 | * @details |
<> | 149:156823d33999 | 141 | * RTC interrupt handler |
<> | 149:156823d33999 | 142 | * |
<> | 149:156823d33999 | 143 | * @param None |
<> | 149:156823d33999 | 144 | * @return None |
<> | 149:156823d33999 | 145 | */ |
<> | 149:156823d33999 | 146 | void fRtcHandler(void); |
<> | 149:156823d33999 | 147 | |
<> | 149:156823d33999 | 148 | /** |
<> | 149:156823d33999 | 149 | * @details |
<> | 149:156823d33999 | 150 | * Is RTC enabled? |
<> | 149:156823d33999 | 151 | * |
<> | 149:156823d33999 | 152 | * @param None |
<> | 149:156823d33999 | 153 | * @return RTC status |
<> | 149:156823d33999 | 154 | */ |
<> | 149:156823d33999 | 155 | boolean fIsRtcEnabled(void); |
<> | 149:156823d33999 | 156 | #endif /* RTC_H_ */ |