SX126x-Arduino  1.3.0
timer.h
Go to the documentation of this file.
1 /*
2  / _____) _ | |
3 ( (____ _____ ____ _| |_ _____ ____| |__
4  \____ \| ___ | (_ _) ___ |/ ___) _ \
5  _____) ) ____| | | || |_| ____( (___| | | |
6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
7  (C)2013 Semtech
8 
9 Description: Timer objects and scheduling management
10 
11 License: Revised BSD License, see LICENSE.TXT file include in the project
12 
13 Maintainer: Miguel Luis and Gregory Cristian
14 */
15 
16 /******************************************************************************
17  * @file timer.h
18  * @author Insight SiP
19  * @version V1.0.0
20  * @date 02-mars-2018
21  * @brief timer header functions for LORA.
22  *
23  * @attention
24  * THIS SOFTWARE IS PROVIDED BY INSIGHT SIP "AS IS" AND ANY EXPRESS
25  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26  * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  * DISCLAIMED. IN NO EVENT SHALL INSIGHT SIP OR CONTRIBUTORS BE
28  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
30  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  *
35  *****************************************************************************/
36 
37 #ifndef __TIMER_H__
38 #define __TIMER_H__
39 
40 #include "stdint.h"
41 #include "stdbool.h"
42 #if defined(ESP32) || defined(ESP8266)
43 #include <Ticker.h>
44 #endif
45 
46 extern "C"
47 {
48 #define ROUNDED_DIV(A, B) (((A) + ((B) / 2)) / (B))
49 
50  typedef void (*callbackType)(void);
51 
54  typedef struct TimerEvent_s
55  {
56  uint8_t timerNum;
57  bool oneShot = false;
58  uint32_t Timestamp;
59  uint32_t ReloadValue;
60  bool IsRunning;
61  void (*Callback)(void);
62  struct TimerEvent_s *Next;
64 
67 #ifndef TimerTime_t
68  typedef uint32_t TimerTime_t;
69 #endif
70 
77  void TimerConfig(void);
78 
87  void TimerInit(TimerEvent_t *obj, void (*callback)(void));
88 
94 
99  void TimerStop(TimerEvent_t *obj);
100 
106 
113  void TimerSetValue(TimerEvent_t *obj, uint32_t value);
114 
122 
128 };
129 #endif // __TIMER_H__
TimerGetCurrentTime
TimerTime_t TimerGetCurrentTime(void)
Read the current time ellapsed since the start (or restart) of RTC2.
TimerGetElapsedTime
TimerTime_t TimerGetElapsedTime(TimerTime_t savedTime)
Return the Time elapsed since a fix moment in Time.
TimerEvent_s::ReloadValue
uint32_t ReloadValue
Definition: timer.h:59
TimerEvent_s::Next
struct TimerEvent_s * Next
Definition: timer.h:62
TimerSetValue
void TimerSetValue(TimerEvent_t *obj, uint32_t value)
Set timer new timeout value.
TimerInit
void TimerInit(TimerEvent_t *obj, void(*callback)(void))
Initializes the timer object.
TimerEvent_t
struct TimerEvent_s TimerEvent_t
Timer object description.
TimerStart
void TimerStart(TimerEvent_t *obj)
Starts and adds the timer object to the list of timer events.
TimerEvent_s::timerNum
uint8_t timerNum
Definition: timer.h:56
TimerEvent_s::Timestamp
uint32_t Timestamp
Definition: timer.h:58
callbackType
void(* callbackType)(void)
Definition: timer.h:50
TimerEvent_s::IsRunning
bool IsRunning
Definition: timer.h:60
TimerEvent_s::Callback
void(* Callback)(void)
Definition: timer.h:61
TimerEvent_s
Timer object description.
Definition: timer.h:55
TimerConfig
void TimerConfig(void)
Initializes the RTC2 timer.
TimerReset
void TimerReset(TimerEvent_t *obj)
Resets the timer object.
TimerEvent_s::oneShot
bool oneShot
Definition: timer.h:57
TimerTime_t
uint32_t TimerTime_t
Timer time variable definition.
Definition: timer.h:68
TimerStop
void TimerStop(TimerEvent_t *obj)
Stops and removes the timer object from the list of timer events.