-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimer.h
84 lines (74 loc) · 2.39 KB
/
timer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* @file timer.h
* @author Sefa Eren AKDOGAN
* @brief Linux Timer API
* @version 1.0
* @date 2022-07-20
* @copyright Copyright (c) 2022
*/
#ifndef __TIMER__H
#define __TIMER__H
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>
#include <errno.h>
#include <string.h>
#include <stdint.h>
#define TIMER_SIGNAL_1 SIGRTMIN + 1
#define TIMER_SIGNAL_2 SIGRTMIN + 2
#define TIMER_SIGNAL_3 SIGRTMIN + 3
#define TIMER_SIGNAL_4 SIGRTMIN + 4
#define TIMER_SIGNAL_5 SIGRTMIN + 5
#define TIMER_SIGNAL_6 SIGRTMIN + 6
#define TIMER_SIGNAL_7 SIGRTMIN + 7
/**
* @brief Timer Values Structere
* @param timer [timer_t] Timer Configs;
* @param oneShotMsec [uint16_t] One Shot Timer Value
* @param periodicMsec [uint16_t] Periodic Timer Value
* @param timerSignal [uint16_t] Timer Signal Name
*/
typedef struct{
timer_t timer;
uint16_t oneShotMsec;
uint16_t periodicMsec;
uint16_t timerSignal;
}timerValues_t;
/**
* @brief Initalize Timer [ Look Example ]
* @param [in] values [timerValues_t*] Timer Values Variables
* @param [in] SIGNAL [uint16_t] Timer Signal
* @param [in] CALLBACK [void*] Timer Interrupt Callback Function
* @return [int8_t] Function Execute Result
* @retval [0] Success
* @retval [-1] Fail
*/
int8_t timerInit(timerValues_t *values,uint16_t SIGNAL,void *CALLBACK);
/**
* @brief Deinitalize Timer
* @param [in] values [timerValues_t*] Timer Values Variables
* @return [int8_t] Function Execute Result
* @retval [0] Always Success
*/
int8_t timerDeinit(timerValues_t *values);
/**
* @brief Timer Start
* @param [in] values [timerValues_t*] Timer Values Variables
* @param [in] ONESHOTMS [uint16_t] Timer One Shot Value
* @param [in] PERIODICMS[uint16_t] Timer Periodic Value
* @return [int8_t] Function Execute Result
* @retval [0] Success
* @retval [-1] Fail
*/
int8_t timerStart(timerValues_t *values,uint16_t ONESHOTMS,uint16_t PERIODICMS);
/**
* @brief Timer Stop
* @param [in] values [timerValues_t*] Timer Values Variables
* @return [int8_t] Function Execute Result
* @retval [0] Success
* @retval [-1] Fail
*/
int8_t timerStop(timerValues_t *values);
#endif