ST25R3911 library for the STMicroelectronics X-NUCLEO-NFC05A1
timer1.h@0:98fcd1266df0, 2019-11-14 (annotated)
- Committer:
- DiegoOstuni
- Date:
- Thu Nov 14 14:36:52 2019 +0000
- Revision:
- 0:98fcd1266df0
Fork of the GitHub
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DiegoOstuni | 0:98fcd1266df0 | 1 | /****************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 2 | * @attention |
DiegoOstuni | 0:98fcd1266df0 | 3 | * |
DiegoOstuni | 0:98fcd1266df0 | 4 | * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2> |
DiegoOstuni | 0:98fcd1266df0 | 5 | * |
DiegoOstuni | 0:98fcd1266df0 | 6 | * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License"); |
DiegoOstuni | 0:98fcd1266df0 | 7 | * You may not use this file except in compliance with the License. |
DiegoOstuni | 0:98fcd1266df0 | 8 | * You may obtain a copy of the License at: |
DiegoOstuni | 0:98fcd1266df0 | 9 | * |
DiegoOstuni | 0:98fcd1266df0 | 10 | * http://www.st.com/myliberty |
DiegoOstuni | 0:98fcd1266df0 | 11 | * |
DiegoOstuni | 0:98fcd1266df0 | 12 | * Unless required by applicable law or agreed to in writing, software |
DiegoOstuni | 0:98fcd1266df0 | 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
DiegoOstuni | 0:98fcd1266df0 | 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, |
DiegoOstuni | 0:98fcd1266df0 | 15 | * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY, |
DiegoOstuni | 0:98fcd1266df0 | 16 | * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. |
DiegoOstuni | 0:98fcd1266df0 | 17 | * See the License for the specific language governing permissions and |
DiegoOstuni | 0:98fcd1266df0 | 18 | * limitations under the License. |
DiegoOstuni | 0:98fcd1266df0 | 19 | * |
DiegoOstuni | 0:98fcd1266df0 | 20 | ******************************************************************************/ |
DiegoOstuni | 0:98fcd1266df0 | 21 | /* |
DiegoOstuni | 0:98fcd1266df0 | 22 | * PROJECT: ST25R391x firmware |
DiegoOstuni | 0:98fcd1266df0 | 23 | * $Revision: $ |
DiegoOstuni | 0:98fcd1266df0 | 24 | * LANGUAGE: ANSI C |
DiegoOstuni | 0:98fcd1266df0 | 25 | */ |
DiegoOstuni | 0:98fcd1266df0 | 26 | |
DiegoOstuni | 0:98fcd1266df0 | 27 | /*! \file timer.h |
DiegoOstuni | 0:98fcd1266df0 | 28 | * |
DiegoOstuni | 0:98fcd1266df0 | 29 | * \brief SW Timer implementation header file |
DiegoOstuni | 0:98fcd1266df0 | 30 | * |
DiegoOstuni | 0:98fcd1266df0 | 31 | * This module makes use of a System Tick in millisconds and provides |
DiegoOstuni | 0:98fcd1266df0 | 32 | * an abstraction for SW timers |
DiegoOstuni | 0:98fcd1266df0 | 33 | * |
DiegoOstuni | 0:98fcd1266df0 | 34 | */ |
DiegoOstuni | 0:98fcd1266df0 | 35 | |
DiegoOstuni | 0:98fcd1266df0 | 36 | |
DiegoOstuni | 0:98fcd1266df0 | 37 | /* |
DiegoOstuni | 0:98fcd1266df0 | 38 | ****************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 39 | * INCLUDES |
DiegoOstuni | 0:98fcd1266df0 | 40 | ****************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 41 | */ |
DiegoOstuni | 0:98fcd1266df0 | 42 | #include "platform1.h" |
DiegoOstuni | 0:98fcd1266df0 | 43 | |
DiegoOstuni | 0:98fcd1266df0 | 44 | /* |
DiegoOstuni | 0:98fcd1266df0 | 45 | ****************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 46 | * GLOBAL MACROS |
DiegoOstuni | 0:98fcd1266df0 | 47 | ****************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 48 | */ |
DiegoOstuni | 0:98fcd1266df0 | 49 | #define timerIsRunning(t) (!timerIsExpired(t)) |
DiegoOstuni | 0:98fcd1266df0 | 50 | |
DiegoOstuni | 0:98fcd1266df0 | 51 | /* |
DiegoOstuni | 0:98fcd1266df0 | 52 | ****************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 53 | * GLOBAL DEFINES |
DiegoOstuni | 0:98fcd1266df0 | 54 | ****************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 55 | */ |
DiegoOstuni | 0:98fcd1266df0 | 56 | |
DiegoOstuni | 0:98fcd1266df0 | 57 | /*! |
DiegoOstuni | 0:98fcd1266df0 | 58 | ***************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 59 | * \brief Calculate Timer |
DiegoOstuni | 0:98fcd1266df0 | 60 | * |
DiegoOstuni | 0:98fcd1266df0 | 61 | * This method calculates when the timer will be expired given the amount |
DiegoOstuni | 0:98fcd1266df0 | 62 | * time in milliseconds /a tOut. |
DiegoOstuni | 0:98fcd1266df0 | 63 | * Once the timer has been calculated it will then be used to check when |
DiegoOstuni | 0:98fcd1266df0 | 64 | * it expires. |
DiegoOstuni | 0:98fcd1266df0 | 65 | * |
DiegoOstuni | 0:98fcd1266df0 | 66 | * \see timersIsExpired |
DiegoOstuni | 0:98fcd1266df0 | 67 | * |
DiegoOstuni | 0:98fcd1266df0 | 68 | * \param[in] time : time/duration in Milliseconds for the timer |
DiegoOstuni | 0:98fcd1266df0 | 69 | * |
DiegoOstuni | 0:98fcd1266df0 | 70 | * \return u32 : The new timer calculated based on the given time |
DiegoOstuni | 0:98fcd1266df0 | 71 | ***************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 72 | */ |
DiegoOstuni | 0:98fcd1266df0 | 73 | uint32_t timerCalculateTimer( uint16_t time ); |
DiegoOstuni | 0:98fcd1266df0 | 74 | |
DiegoOstuni | 0:98fcd1266df0 | 75 | |
DiegoOstuni | 0:98fcd1266df0 | 76 | /*! |
DiegoOstuni | 0:98fcd1266df0 | 77 | ***************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 78 | * \brief Checks if a Timer is Expired |
DiegoOstuni | 0:98fcd1266df0 | 79 | * |
DiegoOstuni | 0:98fcd1266df0 | 80 | * This method checks if a timer has already expired. |
DiegoOstuni | 0:98fcd1266df0 | 81 | * Based on the given timer previously calculated it checks if this timer |
DiegoOstuni | 0:98fcd1266df0 | 82 | * has already elapsed |
DiegoOstuni | 0:98fcd1266df0 | 83 | * |
DiegoOstuni | 0:98fcd1266df0 | 84 | * \see timersCalculateTimer |
DiegoOstuni | 0:98fcd1266df0 | 85 | * |
DiegoOstuni | 0:98fcd1266df0 | 86 | * \param[in] timer : the timer to check |
DiegoOstuni | 0:98fcd1266df0 | 87 | * |
DiegoOstuni | 0:98fcd1266df0 | 88 | * \return true : timer has already expired |
DiegoOstuni | 0:98fcd1266df0 | 89 | * \return false : timer is still running |
DiegoOstuni | 0:98fcd1266df0 | 90 | ***************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 91 | */ |
DiegoOstuni | 0:98fcd1266df0 | 92 | bool timerIsExpired( uint32_t timer ); |
DiegoOstuni | 0:98fcd1266df0 | 93 | |
DiegoOstuni | 0:98fcd1266df0 | 94 | |
DiegoOstuni | 0:98fcd1266df0 | 95 | /*! |
DiegoOstuni | 0:98fcd1266df0 | 96 | ***************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 97 | * \brief Performs a Delay |
DiegoOstuni | 0:98fcd1266df0 | 98 | * |
DiegoOstuni | 0:98fcd1266df0 | 99 | * This method performs a delay for the given amount of time in Milliseconds |
DiegoOstuni | 0:98fcd1266df0 | 100 | * |
DiegoOstuni | 0:98fcd1266df0 | 101 | * \param[in] time : time/duration in Milliseconds of the delay |
DiegoOstuni | 0:98fcd1266df0 | 102 | * |
DiegoOstuni | 0:98fcd1266df0 | 103 | ***************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 104 | */ |
DiegoOstuni | 0:98fcd1266df0 | 105 | void timerDelay( uint16_t time ); |
DiegoOstuni | 0:98fcd1266df0 | 106 | |
DiegoOstuni | 0:98fcd1266df0 | 107 | |
DiegoOstuni | 0:98fcd1266df0 | 108 | /*! |
DiegoOstuni | 0:98fcd1266df0 | 109 | ***************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 110 | * \brief Stopwatch start |
DiegoOstuni | 0:98fcd1266df0 | 111 | * |
DiegoOstuni | 0:98fcd1266df0 | 112 | * This method initiates the stopwatch to later measure the time in ms |
DiegoOstuni | 0:98fcd1266df0 | 113 | * |
DiegoOstuni | 0:98fcd1266df0 | 114 | ***************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 115 | */ |
DiegoOstuni | 0:98fcd1266df0 | 116 | void timerStopwatchStart( void ); |
DiegoOstuni | 0:98fcd1266df0 | 117 | |
DiegoOstuni | 0:98fcd1266df0 | 118 | |
DiegoOstuni | 0:98fcd1266df0 | 119 | /*! |
DiegoOstuni | 0:98fcd1266df0 | 120 | ***************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 121 | * \brief Stopwatch Measure |
DiegoOstuni | 0:98fcd1266df0 | 122 | * |
DiegoOstuni | 0:98fcd1266df0 | 123 | * This method returns the elapsed time in ms since the stopwatch was initiated |
DiegoOstuni | 0:98fcd1266df0 | 124 | * |
DiegoOstuni | 0:98fcd1266df0 | 125 | * \return The time in ms since the stopwatch was started |
DiegoOstuni | 0:98fcd1266df0 | 126 | ***************************************************************************** |
DiegoOstuni | 0:98fcd1266df0 | 127 | */ |
DiegoOstuni | 0:98fcd1266df0 | 128 | uint32_t timerStopwatchMeasure( void ); |