| SX126x-Arduino 2.0.1

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 #include "sx126x-debug.h"
46
47 extern "C"
48 {
49 #define ROUNDED_DIV(A, B) (((A) + ((B) / 2)) / (B))
50
51 typedef void (*callbackType)(void);
52
55 typedef struct TimerEvent_s
56 {
57 uint8_t timerNum;
58 bool oneShot = true;
59 uint32_t Timestamp;
60 uint32_t ReloadValue = 10000;
61 bool IsRunning;
62 void (*Callback)(void);
63 struct TimerEvent_s *Next;
64 } TimerEvent_t;
65
68 #ifndef TimerTime_t
69 typedef uint32_t TimerTime_t;
70 #endif
71
78 void TimerConfig(void);
79
88 void TimerInit(TimerEvent_t *obj, void (*callback)(void));
89
94 void TimerStart(TimerEvent_t *obj);
95
100 void TimerStop(TimerEvent_t *obj);
101
106 void TimerReset(TimerEvent_t *obj);
107
114 void TimerSetValue(TimerEvent_t *obj, uint32_t value);
115
122 TimerTime_t TimerGetElapsedTime(TimerTime_t savedTime);
123
128 TimerTime_t TimerGetCurrentTime(void);
129 };
130 #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:60
TimerEvent_s::Next
struct TimerEvent_s * Next
Definition: timer.h:63
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:57
TimerEvent_s::Timestamp
uint32_t Timestamp
Definition: timer.h:59
callbackType
void(* callbackType)(void)
Definition: timer.h:51
sx126x-debug.h
Unified debug output for all platforms Set LIB_DEBUG to 1 to enable debug output.
TimerEvent_s::IsRunning
bool IsRunning
Definition: timer.h:61
TimerEvent_s::Callback
void(* Callback)(void)
Definition: timer.h:62
TimerEvent_s
Timer object description.
Definition: timer.h:56
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:58
TimerTime_t
uint32_t TimerTime_t
Timer time variable definition.
Definition: timer.h:69
TimerStop
void TimerStop(TimerEvent_t *obj)
Stops and removes the timer object from the list of timer events.