Source code for the SX126xDVK1xAS Dev Kit. This example code has only been tested on the Nucleo L476RG

Dependencies:   mbed DmTftLibrary SX126xLib

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Timers.cpp Source File

Timers.cpp

00001 /*
00002   ______                              _
00003  / _____)             _              | |
00004 ( (____  _____ ____ _| |_ _____  ____| |__
00005  \____ \| ___ |    (_   _) ___ |/ ___)  _ \
00006  _____) ) ____| | | || |_| ____( (___| | | |
00007 (______/|_____)_|_|_| \__)_____)\____)_| |_|
00008     (C)2016 Semtech
00009 
00010 Description: Timers
00011 
00012 Maintainer: Gregory Cristian & Gilbert Menth
00013 */
00014 
00015 #include "mbed.h"
00016 #include "Timers.h"
00017 
00018 
00019 Ticker TickTimer;
00020 
00021 static uint32_t SoftTimer = 0;
00022 static void TimersIncSoftTimer( void );
00023 
00024 
00025 void TimersInit( void )
00026 {
00027     TickTimer.attach_us( &TimersIncSoftTimer, 1000 ); // Ticks every millisecond
00028 }
00029 
00030 static void TimersIncSoftTimer( void )
00031 {
00032     SoftTimer++;
00033 }
00034 
00035 void TimersSetTimer( uint32_t *sTimer, uint32_t timeLength )
00036 {
00037     if( timeLength > MAX_TIMER_VALUE )
00038     {
00039         timeLength = MAX_TIMER_VALUE;
00040     }
00041     *sTimer = SoftTimer + timeLength;
00042 }
00043 
00044 uint32_t TimersTimerHasExpired ( const uint32_t * sTimer )
00045 {
00046     if( ( SoftTimer - *sTimer ) > 0x7fffffff )
00047     {
00048         return false;
00049     }
00050     return true;
00051 }
00052 
00053 uint32_t TimersTimerValue ( void )
00054 {
00055     return SoftTimer;
00056 }