Revisions to support JFET LoRa module
Dependencies: mbed LoRaWAN-lib SX1272Libjlc
Fork of LoRaWAN-demo-72_tjm by
timer.cpp
00001 /* 00002 / _____) _ | | 00003 ( (____ _____ ____ _| |_ _____ ____| |__ 00004 \____ \| ___ | (_ _) ___ |/ ___) _ \ 00005 _____) ) ____| | | || |_| ____( (___| | | | 00006 (______/|_____)_|_|_| \__)_____)\____)_| |_| 00007 (C)2013 Semtech 00008 00009 Description: Timer objects and scheduling management 00010 00011 License: Revised BSD License, see LICENSE.TXT file include in the project 00012 00013 Maintainer: Miguel Luis and Gregory Cristian 00014 */ 00015 #include "board.h" 00016 00017 Timer TimeCounter; 00018 Ticker LoadTimeCounter; 00019 00020 volatile uint32_t CurrentTime = 0; 00021 00022 void TimerResetTimeCounter( void ) 00023 { 00024 CurrentTime = CurrentTime + TimeCounter.read_us( ); 00025 TimeCounter.reset( ); 00026 TimeCounter.start( ); 00027 } 00028 00029 void TimerTimeCounterInit( void ) 00030 { 00031 TimeCounter.start( ); 00032 LoadTimeCounter.attach( &TimerResetTimeCounter, 10 ); 00033 } 00034 00035 TimerTime_t TimerGetCurrentTime( void ) 00036 { 00037 CurrentTime += TimeCounter.read_us( ); 00038 TimeCounter.reset( ); 00039 TimeCounter.start( ); 00040 return ( ( TimerTime_t )CurrentTime ); 00041 } 00042 00043 void TimerInit( TimerEvent_t *obj, void ( *callback )( void ) ) 00044 { 00045 obj->value = 0; 00046 obj->Callback = callback; 00047 } 00048 00049 void TimerStart( TimerEvent_t *obj ) 00050 { 00051 obj->Timer.attach_us( obj->Callback, obj->value ); 00052 } 00053 00054 void TimerStop( TimerEvent_t *obj ) 00055 { 00056 obj->Timer.detach( ); 00057 } 00058 00059 void TimerSetValue( TimerEvent_t *obj, uint32_t value ) 00060 { 00061 obj->value = value; 00062 }
Generated on Wed Jul 13 2022 08:37:14 by 1.7.2