Stabilus 322699 wDoublePID

Dependencies:   mbed QEI PID DmTftLibraryEx

Committer:
GregCr
Date:
Mon Mar 13 15:12:05 2017 +0000
Revision:
0:9c0917bfde97
alpha release

Who changed what in which revision?

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