lol

Dependencies:   MMA8451Q

Fork of Application by Mateusz Kowalik

Committer:
Zaitsev
Date:
Tue Jan 10 20:42:26 2017 +0000
Revision:
10:41552d038a69
USB Serial bi-directional bridge

Who changed what in which revision?

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