this is avaiable project
Fork of LoRaMacLib by
Diff: board/timer.cpp
- Revision:
- 0:9be122c18509
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/board/timer.cpp Wed Aug 12 14:08:29 2015 +0000 @@ -0,0 +1,43 @@ +/* + / _____) _ | | +( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | +(______/|_____)_|_|_| \__)_____)\____)_| |_| + (C)2013 Semtech + +Description: Target board general functions implementation + +License: Revised BSD License, see LICENSE.TXT file include in the project + +Maintainer: Miguel Luis and Gregory Cristian +*/ +#include "board.h" + +Timer TimeCounter; +Ticker LoadTimeCounter; + + +volatile uint32_t currentTime = 0; + +void ResetTimecounter( void ) +{ + currentTime = currentTime + TimeCounter.read_us(); + TimeCounter.reset(); + TimeCounter.start( ); +} + +void TimerHwInit( void ) +{ + TimeCounter.start( ); + LoadTimeCounter.attach( &ResetTimecounter, 10 ); +} + +TimerTime_t TimerGetCurrentTime( void ) +{ + currentTime += TimeCounter.read_us(); + TimeCounter.reset(); + TimeCounter.start( ); + return ( ( TimerTime_t )currentTime ); +} +