22
22
#include "esp_clk_tree.h"
23
23
#endif
24
24
25
+ #if CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
26
+ #define TIMER_IRAM IRAM_ATTR
27
+ #else
28
+ #define TIMER_IRAM
29
+ #endif
30
+
25
31
typedef void (* voidFuncPtr )(void );
26
32
typedef void (* voidFuncPtrArg )(void * );
27
33
@@ -36,24 +42,33 @@ struct timer_struct_t {
36
42
bool timer_started ;
37
43
};
38
44
39
- inline IRAM_ATTR uint64_t timerRead (hw_timer_t * timer ) {
45
+ inline TIMER_IRAM uint64_t timerRead (hw_timer_t * timer ) {
40
46
if (timer == NULL ) {
47
+ #ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
48
+ log_e ("Timer handle is NULL" );
49
+ #endif
41
50
return 0 ;
42
51
}
43
52
uint64_t value ;
44
53
gptimer_get_raw_count (timer -> timer_handle , & value );
45
54
return value ;
46
55
}
47
56
48
- void IRAM_ATTR timerWrite (hw_timer_t * timer , uint64_t val ) {
57
+ void TIMER_IRAM timerWrite (hw_timer_t * timer , uint64_t val ) {
49
58
if (timer == NULL ) {
59
+ #ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
60
+ log_e ("Timer handle is NULL" );
61
+ #endif
50
62
return ;
51
63
}
52
64
gptimer_set_raw_count (timer -> timer_handle , val );
53
65
}
54
66
55
- void IRAM_ATTR timerAlarm (hw_timer_t * timer , uint64_t alarm_value , bool autoreload , uint64_t reload_count ) {
67
+ void TIMER_IRAM timerAlarm (hw_timer_t * timer , uint64_t alarm_value , bool autoreload , uint64_t reload_count ) {
56
68
if (timer == NULL ) {
69
+ #ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
70
+ log_e ("Timer handle is NULL" );
71
+ #endif
57
72
return ;
58
73
}
59
74
esp_err_t err = ESP_OK ;
@@ -64,7 +79,9 @@ void IRAM_ATTR timerAlarm(hw_timer_t *timer, uint64_t alarm_value, bool autorelo
64
79
};
65
80
err = gptimer_set_alarm_action (timer -> timer_handle , & alarm_cfg );
66
81
if (err != ESP_OK ) {
67
- ; // Ignore
82
+ #ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
83
+ log_e ("Timer Alarm Write failed, error num=%d" , err );
84
+ #endif
68
85
}
69
86
}
70
87
@@ -77,24 +94,33 @@ uint32_t timerGetFrequency(hw_timer_t *timer) {
77
94
return frequency ;
78
95
}
79
96
80
- void IRAM_ATTR timerStart (hw_timer_t * timer ) {
97
+ void TIMER_IRAM timerStart (hw_timer_t * timer ) {
81
98
if (timer == NULL ) {
99
+ #ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
100
+ log_e ("Timer handle is NULL" );
101
+ #endif
82
102
return ;
83
103
}
84
104
gptimer_start (timer -> timer_handle );
85
105
timer -> timer_started = true;
86
106
}
87
107
88
- void IRAM_ATTR timerStop (hw_timer_t * timer ) {
108
+ void TIMER_IRAM timerStop (hw_timer_t * timer ) {
89
109
if (timer == NULL ) {
110
+ #ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
111
+ log_e ("Timer handle is NULL" );
112
+ #endif
90
113
return ;
91
114
}
92
115
gptimer_stop (timer -> timer_handle );
93
116
timer -> timer_started = false;
94
117
}
95
118
96
- void IRAM_ATTR timerRestart (hw_timer_t * timer ) {
119
+ void TIMER_IRAM timerRestart (hw_timer_t * timer ) {
97
120
if (timer == NULL ) {
121
+ #ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
122
+ log_e ("Timer handle is NULL" );
123
+ #endif
98
124
return ;
99
125
}
100
126
gptimer_set_raw_count (timer -> timer_handle , 0 );
0 commit comments