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