File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed
Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * timerUtil.c
3+ *
4+ * Created: 18.05.2022 09:57:51
5+ * Author: qfj
6+ */
7+
8+ #include <stdint.h>
9+
10+ #include "Gascounter_main.h"
11+ #include "timerUtil.h"
12+
13+ TimerArrType timers = {.t_elapsed = & count_t_elapsed ,.TArr [RECONNECT ].end = 0 ,.TArr [RECONNECT ].start = 0 };
14+
15+
16+ void t_start (TIMER_NAME t_name ,uint32_t duration_s ){
17+ timers .TArr [t_name ].start = * timers .t_elapsed ;
18+ timers .TArr [t_name ].end = * timers .t_elapsed + duration_s ;
19+ }
20+
21+ uint8_t t_check (TIMER_NAME t_name ){
22+ if (* timers .t_elapsed >= timers .TArr [t_name ].end ){
23+ return 1 ;
24+ }
25+ return 0 ;
26+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * timerUtil.h
3+ *
4+ * Created: 18.05.2022 09:57:37
5+ * Author: qfj
6+ */
7+
8+
9+ #ifndef TIMERUTIL_H_
10+ #define TIMERUTIL_H_
11+
12+
13+ typedef struct
14+ {
15+ uint32_t start ;
16+ uint32_t end ;
17+ }TimerType ;
18+
19+
20+ typedef struct
21+ {
22+ TimerType TArr [20 ];
23+ volatile uint32_t * t_elapsed ;
24+ }TimerArrType ;
25+
26+
27+
28+ typedef enum {
29+ RECONNECT ,
30+ PING ,
31+ I2C_CHECK
32+
33+ }TIMER_NAME ;
34+
35+ void t_start (TIMER_NAME t_name ,uint32_t duration_s );
36+ uint8_t t_check (TIMER_NAME t_name );
37+ #endif /* TIMERUTIL_H_ */
You can’t perform that action at this time.
0 commit comments