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