1st Fork

Dependencies:   mbed QEI DmTftLibrary

Committer:
lex9296
Date:
Tue Feb 15 07:22:09 2022 +0000
Revision:
27:654100855f5c
Parent:
20:626b92b70bf7
Release "Stabile"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mverdy 20:626b92b70bf7 1 /*
mverdy 20:626b92b70bf7 2 ______ _
mverdy 20:626b92b70bf7 3 / _____) _ | |
mverdy 20:626b92b70bf7 4 ( (____ _____ ____ _| |_ _____ ____| |__
mverdy 20:626b92b70bf7 5 \____ \| ___ | (_ _) ___ |/ ___) _ \
mverdy 20:626b92b70bf7 6 _____) ) ____| | | || |_| ____( (___| | | |
mverdy 20:626b92b70bf7 7 (______/|_____)_|_|_| \__)_____)\____)_| |_|
mverdy 20:626b92b70bf7 8 (C)2016 Semtech
mverdy 20:626b92b70bf7 9
mverdy 20:626b92b70bf7 10 Description: Timers
mverdy 20:626b92b70bf7 11
mverdy 20:626b92b70bf7 12 Maintainer: Gregory Cristian & Gilbert Menth
mverdy 20:626b92b70bf7 13 */
mverdy 20:626b92b70bf7 14
mverdy 20:626b92b70bf7 15 #include "mbed.h"
mverdy 20:626b92b70bf7 16 #include "Timers.h"
mverdy 20:626b92b70bf7 17
mverdy 20:626b92b70bf7 18
mverdy 20:626b92b70bf7 19 Ticker TickTimer;
mverdy 20:626b92b70bf7 20
mverdy 20:626b92b70bf7 21 static uint32_t SoftTimer = 0;
mverdy 20:626b92b70bf7 22 static void TimersIncSoftTimer( void );
mverdy 20:626b92b70bf7 23
mverdy 20:626b92b70bf7 24
mverdy 20:626b92b70bf7 25 void TimersInit( void )
mverdy 20:626b92b70bf7 26 {
mverdy 20:626b92b70bf7 27 TickTimer.attach_us( &TimersIncSoftTimer, 1000 ); // Ticks every millisecond
mverdy 20:626b92b70bf7 28 }
mverdy 20:626b92b70bf7 29
mverdy 20:626b92b70bf7 30 static void TimersIncSoftTimer( void )
mverdy 20:626b92b70bf7 31 {
mverdy 20:626b92b70bf7 32 SoftTimer++;
mverdy 20:626b92b70bf7 33 }
mverdy 20:626b92b70bf7 34
mverdy 20:626b92b70bf7 35 void TimersSetTimer( uint32_t *sTimer, uint32_t timeLength )
mverdy 20:626b92b70bf7 36 {
mverdy 20:626b92b70bf7 37 if( timeLength > MAX_TIMER_VALUE )
mverdy 20:626b92b70bf7 38 {
mverdy 20:626b92b70bf7 39 timeLength = MAX_TIMER_VALUE;
mverdy 20:626b92b70bf7 40 }
mverdy 20:626b92b70bf7 41 *sTimer = SoftTimer + timeLength;
mverdy 20:626b92b70bf7 42 }
mverdy 20:626b92b70bf7 43
mverdy 20:626b92b70bf7 44 uint32_t TimersTimerHasExpired ( const uint32_t * sTimer )
mverdy 20:626b92b70bf7 45 {
mverdy 20:626b92b70bf7 46 if( ( SoftTimer - *sTimer ) > 0x7fffffff )
mverdy 20:626b92b70bf7 47 {
mverdy 20:626b92b70bf7 48 return false;
mverdy 20:626b92b70bf7 49 }
mverdy 20:626b92b70bf7 50 return true;
mverdy 20:626b92b70bf7 51 }
mverdy 20:626b92b70bf7 52
mverdy 20:626b92b70bf7 53 uint32_t TimersTimerValue ( void )
mverdy 20:626b92b70bf7 54 {
mverdy 20:626b92b70bf7 55 return SoftTimer;
mverdy 20:626b92b70bf7 56 }
mverdy 20:626b92b70bf7 57