Skip to content

Commit 1260396

Browse files
committed
fix: conditional logs when not ISR
1 parent 67c59a2 commit 1260396

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

cores/esp32/esp32-hal-timer.c

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
#include "esp_clk_tree.h"
2323
#endif
2424

25+
#if CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
26+
#define TIMER_IRAM IRAM_ATTR
27+
#else
28+
#define TIMER_IRAM
29+
#endif
30+
2531
typedef void (*voidFuncPtr)(void);
2632
typedef void (*voidFuncPtrArg)(void *);
2733

@@ -36,24 +42,33 @@ struct timer_struct_t {
3642
bool timer_started;
3743
};
3844

39-
inline IRAM_ATTR uint64_t timerRead(hw_timer_t *timer) {
45+
inline TIMER_IRAM uint64_t timerRead(hw_timer_t *timer) {
4046
if (timer == NULL) {
47+
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
48+
log_e("Timer handle is NULL");
49+
#endif
4150
return 0;
4251
}
4352
uint64_t value;
4453
gptimer_get_raw_count(timer->timer_handle, &value);
4554
return value;
4655
}
4756

48-
void IRAM_ATTR timerWrite(hw_timer_t *timer, uint64_t val) {
57+
void TIMER_IRAM timerWrite(hw_timer_t *timer, uint64_t val) {
4958
if (timer == NULL) {
59+
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
60+
log_e("Timer handle is NULL");
61+
#endif
5062
return;
5163
}
5264
gptimer_set_raw_count(timer->timer_handle, val);
5365
}
5466

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) {
5668
if (timer == NULL) {
69+
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
70+
log_e("Timer handle is NULL");
71+
#endif
5772
return;
5873
}
5974
esp_err_t err = ESP_OK;
@@ -64,7 +79,9 @@ void IRAM_ATTR timerAlarm(hw_timer_t *timer, uint64_t alarm_value, bool autorelo
6479
};
6580
err = gptimer_set_alarm_action(timer->timer_handle, &alarm_cfg);
6681
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
6885
}
6986
}
7087

@@ -77,24 +94,33 @@ uint32_t timerGetFrequency(hw_timer_t *timer) {
7794
return frequency;
7895
}
7996

80-
void IRAM_ATTR timerStart(hw_timer_t *timer) {
97+
void TIMER_IRAM timerStart(hw_timer_t *timer) {
8198
if (timer == NULL) {
99+
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
100+
log_e("Timer handle is NULL");
101+
#endif
82102
return;
83103
}
84104
gptimer_start(timer->timer_handle);
85105
timer->timer_started = true;
86106
}
87107

88-
void IRAM_ATTR timerStop(hw_timer_t *timer) {
108+
void TIMER_IRAM timerStop(hw_timer_t *timer) {
89109
if (timer == NULL) {
110+
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
111+
log_e("Timer handle is NULL");
112+
#endif
90113
return;
91114
}
92115
gptimer_stop(timer->timer_handle);
93116
timer->timer_started = false;
94117
}
95118

96-
void IRAM_ATTR timerRestart(hw_timer_t *timer) {
119+
void TIMER_IRAM timerRestart(hw_timer_t *timer) {
97120
if (timer == NULL) {
121+
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
122+
log_e("Timer handle is NULL");
123+
#endif
98124
return;
99125
}
100126
gptimer_set_raw_count(timer->timer_handle, 0);

0 commit comments

Comments
 (0)