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