helpfor studient
Dependents: STM32_F103-C8T6basecanblink_led
Fork of mbed-dev by
targets/hal/TARGET_ONSEMI/TARGET_NCS36510/rtc.h@144:ef7eb2e8f9f7, 2016-09-02 (annotated)
- Committer:
- <>
- Date:
- Fri Sep 02 15:07:44 2016 +0100
- Revision:
- 144:ef7eb2e8f9f7
- Child:
- 147:30b64687e01f
This updates the lib to the mbed lib v125
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 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 10 | * @copyright (c) 2012 ON Semiconductor. All rights reserved. |
<> | 144:ef7eb2e8f9f7 | 11 | * ON Semiconductor is supplying this software for use with ON Semiconductor |
<> | 144:ef7eb2e8f9f7 | 12 | * processor based microcontrollers only. |
<> | 144:ef7eb2e8f9f7 | 13 | * |
<> | 144:ef7eb2e8f9f7 | 14 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED |
<> | 144:ef7eb2e8f9f7 | 15 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF |
<> | 144:ef7eb2e8f9f7 | 16 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. |
<> | 144:ef7eb2e8f9f7 | 17 | * ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, |
<> | 144:ef7eb2e8f9f7 | 18 | * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
<> | 144:ef7eb2e8f9f7 | 19 | * @endinternal |
<> | 144:ef7eb2e8f9f7 | 20 | * |
<> | 144:ef7eb2e8f9f7 | 21 | * @ingroup rtc |
<> | 144:ef7eb2e8f9f7 | 22 | */ |
<> | 144:ef7eb2e8f9f7 | 23 | |
<> | 144:ef7eb2e8f9f7 | 24 | #ifndef RTC_H_ |
<> | 144:ef7eb2e8f9f7 | 25 | #define RTC_H_ |
<> | 144:ef7eb2e8f9f7 | 26 | |
<> | 144:ef7eb2e8f9f7 | 27 | #include "rtc_map.h" |
<> | 144:ef7eb2e8f9f7 | 28 | #include "clock.h" |
<> | 144:ef7eb2e8f9f7 | 29 | #include "memory_map.h" |
<> | 144:ef7eb2e8f9f7 | 30 | |
<> | 144:ef7eb2e8f9f7 | 31 | #define RTC_CLOCK_HZ 32768 |
<> | 144:ef7eb2e8f9f7 | 32 | #define RTC_SEC_TO_US 1000000 |
<> | 144:ef7eb2e8f9f7 | 33 | #define RTC_SUB_SEC_MASK 0x7FFF |
<> | 144:ef7eb2e8f9f7 | 34 | #define RTC_SEC_MASK 0xFFFFFFFF |
<> | 144:ef7eb2e8f9f7 | 35 | #define RTC_SEC_INT_STATUS_MASK 0x2 |
<> | 144:ef7eb2e8f9f7 | 36 | |
<> | 144:ef7eb2e8f9f7 | 37 | #define RTC_SUBSEC_INTERRUPT_BIT_VAL 0x1 |
<> | 144:ef7eb2e8f9f7 | 38 | #define RTC_SEC_INTERRUPT_BIT_VAL 0x2 |
<> | 144:ef7eb2e8f9f7 | 39 | #define RTC_ALL_INTERRUPT_BIT_VAL 0x3 |
<> | 144:ef7eb2e8f9f7 | 40 | |
<> | 144:ef7eb2e8f9f7 | 41 | #define RTC_INT_CLR_SUB_SEC_BIT_POS 0 |
<> | 144:ef7eb2e8f9f7 | 42 | #define RTC_INT_CLR_SEC_BIT_POS 1 |
<> | 144:ef7eb2e8f9f7 | 43 | |
<> | 144:ef7eb2e8f9f7 | 44 | #define RTC_CONTROL_SUBSEC_CNT_START_BIT_POS 0 |
<> | 144:ef7eb2e8f9f7 | 45 | #define RTC_CONTROL_SEC_CNT_START_BIT_POS 1 |
<> | 144:ef7eb2e8f9f7 | 46 | #define RTC_CONTROL_SUBSEC_CNT_INT_BIT_POS 2 |
<> | 144:ef7eb2e8f9f7 | 47 | #define RTC_CONTROL_SEC_CNT_INT_BIT_POS 3 |
<> | 144:ef7eb2e8f9f7 | 48 | |
<> | 144:ef7eb2e8f9f7 | 49 | #define RTC_STATUS_SUB_SEC_INT_CLR_WRT_BIT_POS 9 |
<> | 144:ef7eb2e8f9f7 | 50 | #define RTC_STATUS_SEC_INT_CLR_WRT_BIT_POS 10 |
<> | 144:ef7eb2e8f9f7 | 51 | |
<> | 144:ef7eb2e8f9f7 | 52 | /* FUnction pointer for call back */ |
<> | 144:ef7eb2e8f9f7 | 53 | typedef void (* fRtcCallBack)(void); |
<> | 144:ef7eb2e8f9f7 | 54 | |
<> | 144:ef7eb2e8f9f7 | 55 | /** |
<> | 144:ef7eb2e8f9f7 | 56 | * @details |
<> | 144:ef7eb2e8f9f7 | 57 | * Initializes RTC, enable RTC & register call back function |
<> | 144:ef7eb2e8f9f7 | 58 | * |
<> | 144:ef7eb2e8f9f7 | 59 | * @param RtcCallBack Function pointer for RTC call back funtion |
<> | 144:ef7eb2e8f9f7 | 60 | * @return None |
<> | 144:ef7eb2e8f9f7 | 61 | */ |
<> | 144:ef7eb2e8f9f7 | 62 | void fRtcInit(void); |
<> | 144:ef7eb2e8f9f7 | 63 | |
<> | 144:ef7eb2e8f9f7 | 64 | /** |
<> | 144:ef7eb2e8f9f7 | 65 | * @details |
<> | 144:ef7eb2e8f9f7 | 66 | * Disable RTC |
<> | 144:ef7eb2e8f9f7 | 67 | * |
<> | 144:ef7eb2e8f9f7 | 68 | * @param None |
<> | 144:ef7eb2e8f9f7 | 69 | * @return None |
<> | 144:ef7eb2e8f9f7 | 70 | */ |
<> | 144:ef7eb2e8f9f7 | 71 | void fRtcFree(void); |
<> | 144:ef7eb2e8f9f7 | 72 | |
<> | 144:ef7eb2e8f9f7 | 73 | /** |
<> | 144:ef7eb2e8f9f7 | 74 | * @details |
<> | 144:ef7eb2e8f9f7 | 75 | * Set up alram for RTC interrupt in micro second |
<> | 144:ef7eb2e8f9f7 | 76 | * Pre-requisite: Both second & sub second interrupts should be cleared. |
<> | 144:ef7eb2e8f9f7 | 77 | * @param TimeStamp in micro seconds |
<> | 144:ef7eb2e8f9f7 | 78 | * @return None |
<> | 144:ef7eb2e8f9f7 | 79 | */ |
<> | 144:ef7eb2e8f9f7 | 80 | void fRtcSetInterrupt(uint32_t timestamp); |
<> | 144:ef7eb2e8f9f7 | 81 | |
<> | 144:ef7eb2e8f9f7 | 82 | /** |
<> | 144:ef7eb2e8f9f7 | 83 | * @details |
<> | 144:ef7eb2e8f9f7 | 84 | * Disable interrupt |
<> | 144:ef7eb2e8f9f7 | 85 | * |
<> | 144:ef7eb2e8f9f7 | 86 | * @param None |
<> | 144:ef7eb2e8f9f7 | 87 | * @return None |
<> | 144:ef7eb2e8f9f7 | 88 | */ |
<> | 144:ef7eb2e8f9f7 | 89 | void fRtcDisableInterrupt(void); |
<> | 144:ef7eb2e8f9f7 | 90 | |
<> | 144:ef7eb2e8f9f7 | 91 | /** |
<> | 144:ef7eb2e8f9f7 | 92 | * @details |
<> | 144:ef7eb2e8f9f7 | 93 | * Enable interrupt |
<> | 144:ef7eb2e8f9f7 | 94 | * |
<> | 144:ef7eb2e8f9f7 | 95 | * @param None |
<> | 144:ef7eb2e8f9f7 | 96 | * @return None |
<> | 144:ef7eb2e8f9f7 | 97 | */ |
<> | 144:ef7eb2e8f9f7 | 98 | void fRtcEnableInterrupt(void); |
<> | 144:ef7eb2e8f9f7 | 99 | |
<> | 144:ef7eb2e8f9f7 | 100 | /** |
<> | 144:ef7eb2e8f9f7 | 101 | * @details |
<> | 144:ef7eb2e8f9f7 | 102 | * Clear interrupt |
<> | 144:ef7eb2e8f9f7 | 103 | * |
<> | 144:ef7eb2e8f9f7 | 104 | * @param None |
<> | 144:ef7eb2e8f9f7 | 105 | * @return None |
<> | 144:ef7eb2e8f9f7 | 106 | */ |
<> | 144:ef7eb2e8f9f7 | 107 | void fRtcClearInterrupt(void); |
<> | 144:ef7eb2e8f9f7 | 108 | |
<> | 144:ef7eb2e8f9f7 | 109 | /** |
<> | 144:ef7eb2e8f9f7 | 110 | * @details |
<> | 144:ef7eb2e8f9f7 | 111 | * Returns RTC time in micro seconds |
<> | 144:ef7eb2e8f9f7 | 112 | * |
<> | 144:ef7eb2e8f9f7 | 113 | * @param None |
<> | 144:ef7eb2e8f9f7 | 114 | * @return RTC Time in micro second |
<> | 144:ef7eb2e8f9f7 | 115 | */ |
<> | 144:ef7eb2e8f9f7 | 116 | uint64_t fRtcRead(void); |
<> | 144:ef7eb2e8f9f7 | 117 | |
<> | 144:ef7eb2e8f9f7 | 118 | /** |
<> | 144:ef7eb2e8f9f7 | 119 | * @details |
<> | 144:ef7eb2e8f9f7 | 120 | * Set RTC time in micro seconds |
<> | 144:ef7eb2e8f9f7 | 121 | * |
<> | 144:ef7eb2e8f9f7 | 122 | * @param RtcTime in micro Seconds |
<> | 144:ef7eb2e8f9f7 | 123 | * @return None |
<> | 144:ef7eb2e8f9f7 | 124 | */ |
<> | 144:ef7eb2e8f9f7 | 125 | void fRtcWrite(uint64_t RtcTimeus); |
<> | 144:ef7eb2e8f9f7 | 126 | |
<> | 144:ef7eb2e8f9f7 | 127 | /** |
<> | 144:ef7eb2e8f9f7 | 128 | * @details |
<> | 144:ef7eb2e8f9f7 | 129 | * RTC interrupt handler |
<> | 144:ef7eb2e8f9f7 | 130 | * |
<> | 144:ef7eb2e8f9f7 | 131 | * @param None |
<> | 144:ef7eb2e8f9f7 | 132 | * @return None |
<> | 144:ef7eb2e8f9f7 | 133 | */ |
<> | 144:ef7eb2e8f9f7 | 134 | void fRtcHandler(void); |
<> | 144:ef7eb2e8f9f7 | 135 | |
<> | 144:ef7eb2e8f9f7 | 136 | /** |
<> | 144:ef7eb2e8f9f7 | 137 | * @details |
<> | 144:ef7eb2e8f9f7 | 138 | * Is RTC enabled? |
<> | 144:ef7eb2e8f9f7 | 139 | * |
<> | 144:ef7eb2e8f9f7 | 140 | * @param None |
<> | 144:ef7eb2e8f9f7 | 141 | * @return RTC status |
<> | 144:ef7eb2e8f9f7 | 142 | */ |
<> | 144:ef7eb2e8f9f7 | 143 | boolean fIsRtcEnabled(void); |
<> | 144:ef7eb2e8f9f7 | 144 | #endif /* RTC_H_ */ |