ST25R3911 library for the STMicroelectronics X-NUCLEO-NFC05A1

Dependents:   mbed-os-nfc05a1

Committer:
DiegoOstuni
Date:
Thu Nov 14 14:36:52 2019 +0000
Revision:
0:98fcd1266df0
Fork of the GitHub

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DiegoOstuni 0:98fcd1266df0 1 /******************************************************************************
DiegoOstuni 0:98fcd1266df0 2 * @attention
DiegoOstuni 0:98fcd1266df0 3 *
DiegoOstuni 0:98fcd1266df0 4 * <h2><center>&copy; 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.c
DiegoOstuni 0:98fcd1266df0 28 *
DiegoOstuni 0:98fcd1266df0 29 * \brief SW Timer implementation
DiegoOstuni 0:98fcd1266df0 30 *
DiegoOstuni 0:98fcd1266df0 31 * \author Gustavo Patricio
DiegoOstuni 0:98fcd1266df0 32 *
DiegoOstuni 0:98fcd1266df0 33 * This module makes use of a System Tick in millisconds and provides
DiegoOstuni 0:98fcd1266df0 34 * an abstraction for SW timers
DiegoOstuni 0:98fcd1266df0 35 *
DiegoOstuni 0:98fcd1266df0 36 */
DiegoOstuni 0:98fcd1266df0 37
DiegoOstuni 0:98fcd1266df0 38 /*
DiegoOstuni 0:98fcd1266df0 39 ******************************************************************************
DiegoOstuni 0:98fcd1266df0 40 * INCLUDES
DiegoOstuni 0:98fcd1266df0 41 ******************************************************************************
DiegoOstuni 0:98fcd1266df0 42 */
DiegoOstuni 0:98fcd1266df0 43 #include "timer1.h"
DiegoOstuni 0:98fcd1266df0 44
DiegoOstuni 0:98fcd1266df0 45
DiegoOstuni 0:98fcd1266df0 46 /*
DiegoOstuni 0:98fcd1266df0 47 ******************************************************************************
DiegoOstuni 0:98fcd1266df0 48 * LOCAL DEFINES
DiegoOstuni 0:98fcd1266df0 49 ******************************************************************************
DiegoOstuni 0:98fcd1266df0 50 */
DiegoOstuni 0:98fcd1266df0 51
DiegoOstuni 0:98fcd1266df0 52 /*
DiegoOstuni 0:98fcd1266df0 53 ******************************************************************************
DiegoOstuni 0:98fcd1266df0 54 * LOCAL VARIABLES
DiegoOstuni 0:98fcd1266df0 55 ******************************************************************************
DiegoOstuni 0:98fcd1266df0 56 */
DiegoOstuni 0:98fcd1266df0 57
DiegoOstuni 0:98fcd1266df0 58 static uint32_t timerStopwatchTick;
DiegoOstuni 0:98fcd1266df0 59
DiegoOstuni 0:98fcd1266df0 60 /*
DiegoOstuni 0:98fcd1266df0 61 ******************************************************************************
DiegoOstuni 0:98fcd1266df0 62 * GLOBAL FUNCTIONS
DiegoOstuni 0:98fcd1266df0 63 ******************************************************************************
DiegoOstuni 0:98fcd1266df0 64 */
DiegoOstuni 0:98fcd1266df0 65
DiegoOstuni 0:98fcd1266df0 66
DiegoOstuni 0:98fcd1266df0 67 /*******************************************************************************/
DiegoOstuni 0:98fcd1266df0 68 uint32_t timerCalculateTimer( uint16_t time )
DiegoOstuni 0:98fcd1266df0 69 {
DiegoOstuni 0:98fcd1266df0 70 return (platformGetSysTick() + time);
DiegoOstuni 0:98fcd1266df0 71 }
DiegoOstuni 0:98fcd1266df0 72
DiegoOstuni 0:98fcd1266df0 73
DiegoOstuni 0:98fcd1266df0 74 /*******************************************************************************/
DiegoOstuni 0:98fcd1266df0 75 bool timerIsExpired( uint32_t timer )
DiegoOstuni 0:98fcd1266df0 76 {
DiegoOstuni 0:98fcd1266df0 77 uint32_t uDiff;
DiegoOstuni 0:98fcd1266df0 78 int32_t sDiff;
DiegoOstuni 0:98fcd1266df0 79
DiegoOstuni 0:98fcd1266df0 80 uDiff = (timer - platformGetSysTick()); /* Calculate the diff between the timers */
DiegoOstuni 0:98fcd1266df0 81 sDiff = uDiff; /* Convert the diff to a signed var */
DiegoOstuni 0:98fcd1266df0 82
DiegoOstuni 0:98fcd1266df0 83 /* Check if the given timer has expired already */
DiegoOstuni 0:98fcd1266df0 84 if( sDiff < 0 )
DiegoOstuni 0:98fcd1266df0 85 {
DiegoOstuni 0:98fcd1266df0 86 return true;
DiegoOstuni 0:98fcd1266df0 87 }
DiegoOstuni 0:98fcd1266df0 88
DiegoOstuni 0:98fcd1266df0 89 return false;
DiegoOstuni 0:98fcd1266df0 90 }
DiegoOstuni 0:98fcd1266df0 91
DiegoOstuni 0:98fcd1266df0 92
DiegoOstuni 0:98fcd1266df0 93 /*******************************************************************************/
DiegoOstuni 0:98fcd1266df0 94 void timerDelay( uint16_t tOut )
DiegoOstuni 0:98fcd1266df0 95 {
DiegoOstuni 0:98fcd1266df0 96 uint32_t t;
DiegoOstuni 0:98fcd1266df0 97
DiegoOstuni 0:98fcd1266df0 98 /* Calculate the timer and wait blocking until is running */
DiegoOstuni 0:98fcd1266df0 99 t = timerCalculateTimer( tOut );
DiegoOstuni 0:98fcd1266df0 100 while( timerIsRunning(t) );
DiegoOstuni 0:98fcd1266df0 101 }
DiegoOstuni 0:98fcd1266df0 102
DiegoOstuni 0:98fcd1266df0 103
DiegoOstuni 0:98fcd1266df0 104 /*******************************************************************************/
DiegoOstuni 0:98fcd1266df0 105 void timerStopwatchStart( void )
DiegoOstuni 0:98fcd1266df0 106 {
DiegoOstuni 0:98fcd1266df0 107 timerStopwatchTick = platformGetSysTick();
DiegoOstuni 0:98fcd1266df0 108 }
DiegoOstuni 0:98fcd1266df0 109
DiegoOstuni 0:98fcd1266df0 110
DiegoOstuni 0:98fcd1266df0 111 /*******************************************************************************/
DiegoOstuni 0:98fcd1266df0 112 uint32_t timerStopwatchMeasure( void )
DiegoOstuni 0:98fcd1266df0 113 {
DiegoOstuni 0:98fcd1266df0 114 return (uint32_t)(platformGetSysTick() - timerStopwatchTick);
DiegoOstuni 0:98fcd1266df0 115 }
DiegoOstuni 0:98fcd1266df0 116