Kashish Haresh Shah
/
HXCClientShield
HXC Client Shield Repository.
Driver/hw_rtc.h@0:bacc6e701fb4, 2021-03-29 (annotated)
- Committer:
- kashish_mbed
- Date:
- Mon Mar 29 15:37:08 2021 +0000
- Revision:
- 0:bacc6e701fb4
Initial Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kashish_mbed | 0:bacc6e701fb4 | 1 | /* |
kashish_mbed | 0:bacc6e701fb4 | 2 | / _____) _ | | |
kashish_mbed | 0:bacc6e701fb4 | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ |
kashish_mbed | 0:bacc6e701fb4 | 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ |
kashish_mbed | 0:bacc6e701fb4 | 5 | _____) ) ____| | | || |_| ____( (___| | | | |
kashish_mbed | 0:bacc6e701fb4 | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| |
kashish_mbed | 0:bacc6e701fb4 | 7 | (C)2013 Semtech |
kashish_mbed | 0:bacc6e701fb4 | 8 | |
kashish_mbed | 0:bacc6e701fb4 | 9 | Description: Bleeper board GPIO driver implementation |
kashish_mbed | 0:bacc6e701fb4 | 10 | |
kashish_mbed | 0:bacc6e701fb4 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project |
kashish_mbed | 0:bacc6e701fb4 | 12 | |
kashish_mbed | 0:bacc6e701fb4 | 13 | Maintainer: Miguel Luis and Gregory Cristian |
kashish_mbed | 0:bacc6e701fb4 | 14 | */ |
kashish_mbed | 0:bacc6e701fb4 | 15 | /****************************************************************************** |
kashish_mbed | 0:bacc6e701fb4 | 16 | * @file hw_rtc.h |
kashish_mbed | 0:bacc6e701fb4 | 17 | * @author MCD Application Team |
kashish_mbed | 0:bacc6e701fb4 | 18 | * @version V1.1.4 |
kashish_mbed | 0:bacc6e701fb4 | 19 | * @date 08-January-2018 |
kashish_mbed | 0:bacc6e701fb4 | 20 | * @brief Header for driver hw_rtc.c module |
kashish_mbed | 0:bacc6e701fb4 | 21 | ****************************************************************************** |
kashish_mbed | 0:bacc6e701fb4 | 22 | * @attention |
kashish_mbed | 0:bacc6e701fb4 | 23 | * |
kashish_mbed | 0:bacc6e701fb4 | 24 | * <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V. |
kashish_mbed | 0:bacc6e701fb4 | 25 | * All rights reserved.</center></h2> |
kashish_mbed | 0:bacc6e701fb4 | 26 | * |
kashish_mbed | 0:bacc6e701fb4 | 27 | * Redistribution and use in source and binary forms, with or without |
kashish_mbed | 0:bacc6e701fb4 | 28 | * modification, are permitted, provided that the following conditions are met: |
kashish_mbed | 0:bacc6e701fb4 | 29 | * |
kashish_mbed | 0:bacc6e701fb4 | 30 | * 1. Redistribution of source code must retain the above copyright notice, |
kashish_mbed | 0:bacc6e701fb4 | 31 | * this list of conditions and the following disclaimer. |
kashish_mbed | 0:bacc6e701fb4 | 32 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
kashish_mbed | 0:bacc6e701fb4 | 33 | * this list of conditions and the following disclaimer in the documentation |
kashish_mbed | 0:bacc6e701fb4 | 34 | * and/or other materials provided with the distribution. |
kashish_mbed | 0:bacc6e701fb4 | 35 | * 3. Neither the name of STMicroelectronics nor the names of other |
kashish_mbed | 0:bacc6e701fb4 | 36 | * contributors to this software may be used to endorse or promote products |
kashish_mbed | 0:bacc6e701fb4 | 37 | * derived from this software without specific written permission. |
kashish_mbed | 0:bacc6e701fb4 | 38 | * 4. This software, including modifications and/or derivative works of this |
kashish_mbed | 0:bacc6e701fb4 | 39 | * software, must execute solely and exclusively on microcontroller or |
kashish_mbed | 0:bacc6e701fb4 | 40 | * microprocessor devices manufactured by or for STMicroelectronics. |
kashish_mbed | 0:bacc6e701fb4 | 41 | * 5. Redistribution and use of this software other than as permitted under |
kashish_mbed | 0:bacc6e701fb4 | 42 | * this license is void and will automatically terminate your rights under |
kashish_mbed | 0:bacc6e701fb4 | 43 | * this license. |
kashish_mbed | 0:bacc6e701fb4 | 44 | * |
kashish_mbed | 0:bacc6e701fb4 | 45 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" |
kashish_mbed | 0:bacc6e701fb4 | 46 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT |
kashish_mbed | 0:bacc6e701fb4 | 47 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A |
kashish_mbed | 0:bacc6e701fb4 | 48 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
kashish_mbed | 0:bacc6e701fb4 | 49 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT |
kashish_mbed | 0:bacc6e701fb4 | 50 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
kashish_mbed | 0:bacc6e701fb4 | 51 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
kashish_mbed | 0:bacc6e701fb4 | 52 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, |
kashish_mbed | 0:bacc6e701fb4 | 53 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
kashish_mbed | 0:bacc6e701fb4 | 54 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
kashish_mbed | 0:bacc6e701fb4 | 55 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
kashish_mbed | 0:bacc6e701fb4 | 56 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
kashish_mbed | 0:bacc6e701fb4 | 57 | * |
kashish_mbed | 0:bacc6e701fb4 | 58 | ****************************************************************************** |
kashish_mbed | 0:bacc6e701fb4 | 59 | */ |
kashish_mbed | 0:bacc6e701fb4 | 60 | |
kashish_mbed | 0:bacc6e701fb4 | 61 | #ifndef __HW_RTC_H__ |
kashish_mbed | 0:bacc6e701fb4 | 62 | #define __HW_RTC_H__ |
kashish_mbed | 0:bacc6e701fb4 | 63 | |
kashish_mbed | 0:bacc6e701fb4 | 64 | #ifdef __cplusplus |
kashish_mbed | 0:bacc6e701fb4 | 65 | extern "C" { |
kashish_mbed | 0:bacc6e701fb4 | 66 | #endif |
kashish_mbed | 0:bacc6e701fb4 | 67 | |
kashish_mbed | 0:bacc6e701fb4 | 68 | /* Includes ------------------------------------------------------------------*/ |
kashish_mbed | 0:bacc6e701fb4 | 69 | #include "utilities.h" |
kashish_mbed | 0:bacc6e701fb4 | 70 | |
kashish_mbed | 0:bacc6e701fb4 | 71 | /* Exported types ------------------------------------------------------------*/ |
kashish_mbed | 0:bacc6e701fb4 | 72 | /* Exported constants --------------------------------------------------------*/ |
kashish_mbed | 0:bacc6e701fb4 | 73 | /* External variables --------------------------------------------------------*/ |
kashish_mbed | 0:bacc6e701fb4 | 74 | /* Exported macros -----------------------------------------------------------*/ |
kashish_mbed | 0:bacc6e701fb4 | 75 | /* Exported functions ------------------------------------------------------- */ |
kashish_mbed | 0:bacc6e701fb4 | 76 | |
kashish_mbed | 0:bacc6e701fb4 | 77 | /*! |
kashish_mbed | 0:bacc6e701fb4 | 78 | * @brief Initializes the RTC timer |
kashish_mbed | 0:bacc6e701fb4 | 79 | * @note The timer is based on the RTC |
kashish_mbed | 0:bacc6e701fb4 | 80 | * @param none |
kashish_mbed | 0:bacc6e701fb4 | 81 | * @retval none |
kashish_mbed | 0:bacc6e701fb4 | 82 | */ |
kashish_mbed | 0:bacc6e701fb4 | 83 | void HW_RTC_Init( void ); |
kashish_mbed | 0:bacc6e701fb4 | 84 | |
kashish_mbed | 0:bacc6e701fb4 | 85 | /*! |
kashish_mbed | 0:bacc6e701fb4 | 86 | * @brief Stop the Alarm |
kashish_mbed | 0:bacc6e701fb4 | 87 | * @param none |
kashish_mbed | 0:bacc6e701fb4 | 88 | * @retval none |
kashish_mbed | 0:bacc6e701fb4 | 89 | */ |
kashish_mbed | 0:bacc6e701fb4 | 90 | void HW_RTC_StopAlarm( void ); |
kashish_mbed | 0:bacc6e701fb4 | 91 | |
kashish_mbed | 0:bacc6e701fb4 | 92 | /*! |
kashish_mbed | 0:bacc6e701fb4 | 93 | * @brief Return the minimum timeout the RTC is able to handle |
kashish_mbed | 0:bacc6e701fb4 | 94 | * @param none |
kashish_mbed | 0:bacc6e701fb4 | 95 | * @retval minimum value for a timeout |
kashish_mbed | 0:bacc6e701fb4 | 96 | */ |
kashish_mbed | 0:bacc6e701fb4 | 97 | uint32_t HW_RTC_GetMinimumTimeout( void ); |
kashish_mbed | 0:bacc6e701fb4 | 98 | |
kashish_mbed | 0:bacc6e701fb4 | 99 | /*! |
kashish_mbed | 0:bacc6e701fb4 | 100 | * @brief Set the alarm |
kashish_mbed | 0:bacc6e701fb4 | 101 | * @note The alarm is set at Reference + timeout |
kashish_mbed | 0:bacc6e701fb4 | 102 | * @param timeout Duration of the Timer in ticks |
kashish_mbed | 0:bacc6e701fb4 | 103 | */ |
kashish_mbed | 0:bacc6e701fb4 | 104 | void HW_RTC_SetAlarm( uint32_t timeout ); |
kashish_mbed | 0:bacc6e701fb4 | 105 | |
kashish_mbed | 0:bacc6e701fb4 | 106 | /*! |
kashish_mbed | 0:bacc6e701fb4 | 107 | * @brief Get the RTC timer elapsed time since the last Reference was set |
kashish_mbed | 0:bacc6e701fb4 | 108 | * @retval RTC Elapsed time in ticks |
kashish_mbed | 0:bacc6e701fb4 | 109 | */ |
kashish_mbed | 0:bacc6e701fb4 | 110 | uint32_t HW_RTC_GetTimerElapsedTime( void ); |
kashish_mbed | 0:bacc6e701fb4 | 111 | |
kashish_mbed | 0:bacc6e701fb4 | 112 | /*! |
kashish_mbed | 0:bacc6e701fb4 | 113 | * @brief Get the RTC timer value |
kashish_mbed | 0:bacc6e701fb4 | 114 | * @retval none |
kashish_mbed | 0:bacc6e701fb4 | 115 | */ |
kashish_mbed | 0:bacc6e701fb4 | 116 | uint32_t HW_RTC_GetTimerValue( void ); |
kashish_mbed | 0:bacc6e701fb4 | 117 | |
kashish_mbed | 0:bacc6e701fb4 | 118 | /*! |
kashish_mbed | 0:bacc6e701fb4 | 119 | * @brief Set the RTC timer Reference |
kashish_mbed | 0:bacc6e701fb4 | 120 | * @retval Timer Reference Value in Ticks |
kashish_mbed | 0:bacc6e701fb4 | 121 | */ |
kashish_mbed | 0:bacc6e701fb4 | 122 | uint32_t HW_RTC_SetTimerContext( void ); |
kashish_mbed | 0:bacc6e701fb4 | 123 | |
kashish_mbed | 0:bacc6e701fb4 | 124 | /*! |
kashish_mbed | 0:bacc6e701fb4 | 125 | * @brief Get the RTC timer Reference |
kashish_mbed | 0:bacc6e701fb4 | 126 | * @retval Timer Value in Ticks |
kashish_mbed | 0:bacc6e701fb4 | 127 | */ |
kashish_mbed | 0:bacc6e701fb4 | 128 | uint32_t HW_RTC_GetTimerContext( void ); |
kashish_mbed | 0:bacc6e701fb4 | 129 | /*! |
kashish_mbed | 0:bacc6e701fb4 | 130 | * @brief RTC IRQ Handler on the RTC Alarm |
kashish_mbed | 0:bacc6e701fb4 | 131 | * @param none |
kashish_mbed | 0:bacc6e701fb4 | 132 | * @retval none |
kashish_mbed | 0:bacc6e701fb4 | 133 | */ |
kashish_mbed | 0:bacc6e701fb4 | 134 | void HW_RTC_IrqHandler ( void ); |
kashish_mbed | 0:bacc6e701fb4 | 135 | |
kashish_mbed | 0:bacc6e701fb4 | 136 | /*! |
kashish_mbed | 0:bacc6e701fb4 | 137 | * @brief a delay of delay ms by polling RTC |
kashish_mbed | 0:bacc6e701fb4 | 138 | * @param delay in ms |
kashish_mbed | 0:bacc6e701fb4 | 139 | * @param none |
kashish_mbed | 0:bacc6e701fb4 | 140 | * @retval none |
kashish_mbed | 0:bacc6e701fb4 | 141 | */ |
kashish_mbed | 0:bacc6e701fb4 | 142 | void HW_RTC_DelayMs( uint32_t delay ); |
kashish_mbed | 0:bacc6e701fb4 | 143 | |
kashish_mbed | 0:bacc6e701fb4 | 144 | /*! |
kashish_mbed | 0:bacc6e701fb4 | 145 | * @brief calculates the wake up time between wake up and mcu start |
kashish_mbed | 0:bacc6e701fb4 | 146 | * @note resolution in RTC_ALARM_TIME_BASE |
kashish_mbed | 0:bacc6e701fb4 | 147 | * @param none |
kashish_mbed | 0:bacc6e701fb4 | 148 | * @retval none |
kashish_mbed | 0:bacc6e701fb4 | 149 | */ |
kashish_mbed | 0:bacc6e701fb4 | 150 | void HW_RTC_setMcuWakeUpTime( void ); |
kashish_mbed | 0:bacc6e701fb4 | 151 | |
kashish_mbed | 0:bacc6e701fb4 | 152 | /*! |
kashish_mbed | 0:bacc6e701fb4 | 153 | * @brief returns the wake up time in us |
kashish_mbed | 0:bacc6e701fb4 | 154 | * @param none |
kashish_mbed | 0:bacc6e701fb4 | 155 | * @retval wake up time in ticks |
kashish_mbed | 0:bacc6e701fb4 | 156 | */ |
kashish_mbed | 0:bacc6e701fb4 | 157 | int16_t HW_RTC_getMcuWakeUpTime( void ); |
kashish_mbed | 0:bacc6e701fb4 | 158 | |
kashish_mbed | 0:bacc6e701fb4 | 159 | /*! |
kashish_mbed | 0:bacc6e701fb4 | 160 | * @brief converts time in ms to time in ticks |
kashish_mbed | 0:bacc6e701fb4 | 161 | * @param [IN] time in milliseconds |
kashish_mbed | 0:bacc6e701fb4 | 162 | * @retval returns time in timer ticks |
kashish_mbed | 0:bacc6e701fb4 | 163 | */ |
kashish_mbed | 0:bacc6e701fb4 | 164 | uint32_t HW_RTC_ms2Tick( uint32_t timeMicroSec ); |
kashish_mbed | 0:bacc6e701fb4 | 165 | |
kashish_mbed | 0:bacc6e701fb4 | 166 | /*! |
kashish_mbed | 0:bacc6e701fb4 | 167 | * @brief converts time in ticks to time in ms |
kashish_mbed | 0:bacc6e701fb4 | 168 | * @param [IN] time in timer ticks |
kashish_mbed | 0:bacc6e701fb4 | 169 | * @retval returns time in timer milliseconds |
kashish_mbed | 0:bacc6e701fb4 | 170 | */ |
kashish_mbed | 0:bacc6e701fb4 | 171 | uint32_t HW_RTC_Tick2ms( uint32_t tick ); |
kashish_mbed | 0:bacc6e701fb4 | 172 | |
kashish_mbed | 0:bacc6e701fb4 | 173 | #ifdef __cplusplus |
kashish_mbed | 0:bacc6e701fb4 | 174 | } |
kashish_mbed | 0:bacc6e701fb4 | 175 | #endif |
kashish_mbed | 0:bacc6e701fb4 | 176 | |
kashish_mbed | 0:bacc6e701fb4 | 177 | #endif /* __HW_RTC_H__ */ |
kashish_mbed | 0:bacc6e701fb4 | 178 | |
kashish_mbed | 0:bacc6e701fb4 | 179 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
kashish_mbed | 0:bacc6e701fb4 | 180 |