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