LoRaWAN demo 76 bootcamp
Dependencies: mbed DigitDisplay Chainable_RGB_LED LoRaWAN-lib SX1276Lib
Diff: system/timer.cpp
- Revision:
- 5:d87bb1eabccd
- Parent:
- 3:de1dcfbe175a
--- a/system/timer.cpp Tue Apr 04 13:39:43 2017 +0000 +++ b/system/timer.cpp Mon Apr 24 13:40:32 2017 +0000 @@ -17,11 +17,11 @@ Timer TimeCounter; Ticker LoadTimeCounter; -volatile uint64_t CurrentTime = 0; +volatile uint32_t CurrentTime = 0; void TimerResetTimeCounter( void ) { - CurrentTime = CurrentTime + TimeCounter.read_us( ); + CurrentTime = CurrentTime + TimeCounter.read_us( ) / 1e3; TimeCounter.reset( ); TimeCounter.start( ); } @@ -29,12 +29,12 @@ void TimerTimeCounterInit( void ) { TimeCounter.start( ); - LoadTimeCounter.attach( &TimerResetTimeCounter, 10 ); + LoadTimeCounter.attach( mbed::callback( &TimerResetTimeCounter ), 10 ); } TimerTime_t TimerGetCurrentTime( void ) { - CurrentTime += TimeCounter.read_us( ); + CurrentTime += TimeCounter.read_us( ) / 1e3; TimeCounter.reset( ); TimeCounter.start( ); return ( ( TimerTime_t )CurrentTime ); @@ -42,7 +42,7 @@ TimerTime_t TimerGetElapsedTime( TimerTime_t savedTime ) { - CurrentTime += TimeCounter.read_us( ); + CurrentTime += TimeCounter.read_us( ) / 1e3; TimeCounter.reset( ); TimeCounter.start( ); return ( TimerTime_t )( CurrentTime - savedTime ); @@ -50,7 +50,7 @@ TimerTime_t TimerGetFutureTime( TimerTime_t eventInFuture ) { - CurrentTime += TimeCounter.read_us( ); + CurrentTime += TimeCounter.read_us( ) / 1e3; TimeCounter.reset( ); TimeCounter.start( ); return ( TimerTime_t )( CurrentTime + eventInFuture ); @@ -64,7 +64,7 @@ void TimerStart( TimerEvent_t *obj ) { - obj->Timer.attach_us( obj->Callback, obj->value ); + obj->Timer.attach_us( mbed::callback( obj->Callback ), obj->value * 1e3 ); } void TimerStop( TimerEvent_t *obj )