fix: conditional logs when not ISR
This commit is contained in:
parent
67c59a2021
commit
126039663f
1 changed files with 33 additions and 7 deletions
|
|
@ -22,6 +22,12 @@
|
||||||
#include "esp_clk_tree.h"
|
#include "esp_clk_tree.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
||||||
|
#define TIMER_IRAM IRAM_ATTR
|
||||||
|
#else
|
||||||
|
#define TIMER_IRAM
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef void (*voidFuncPtr)(void);
|
typedef void (*voidFuncPtr)(void);
|
||||||
typedef void (*voidFuncPtrArg)(void *);
|
typedef void (*voidFuncPtrArg)(void *);
|
||||||
|
|
||||||
|
|
@ -36,8 +42,11 @@ struct timer_struct_t {
|
||||||
bool timer_started;
|
bool timer_started;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline IRAM_ATTR uint64_t timerRead(hw_timer_t *timer) {
|
inline TIMER_IRAM uint64_t timerRead(hw_timer_t *timer) {
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
|
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
||||||
|
log_e("Timer handle is NULL");
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
|
|
@ -45,15 +54,21 @@ inline IRAM_ATTR uint64_t timerRead(hw_timer_t *timer) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR timerWrite(hw_timer_t *timer, uint64_t val) {
|
void TIMER_IRAM timerWrite(hw_timer_t *timer, uint64_t val) {
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
|
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
||||||
|
log_e("Timer handle is NULL");
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gptimer_set_raw_count(timer->timer_handle, val);
|
gptimer_set_raw_count(timer->timer_handle, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR timerAlarm(hw_timer_t *timer, uint64_t alarm_value, bool autoreload, uint64_t reload_count) {
|
void TIMER_IRAM timerAlarm(hw_timer_t *timer, uint64_t alarm_value, bool autoreload, uint64_t reload_count) {
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
|
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
||||||
|
log_e("Timer handle is NULL");
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
esp_err_t err = ESP_OK;
|
esp_err_t err = ESP_OK;
|
||||||
|
|
@ -64,7 +79,9 @@ void IRAM_ATTR timerAlarm(hw_timer_t *timer, uint64_t alarm_value, bool autorelo
|
||||||
};
|
};
|
||||||
err = gptimer_set_alarm_action(timer->timer_handle, &alarm_cfg);
|
err = gptimer_set_alarm_action(timer->timer_handle, &alarm_cfg);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
; // Ignore
|
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
||||||
|
log_e("Timer Alarm Write failed, error num=%d", err);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,24 +94,33 @@ uint32_t timerGetFrequency(hw_timer_t *timer) {
|
||||||
return frequency;
|
return frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR timerStart(hw_timer_t *timer) {
|
void TIMER_IRAM timerStart(hw_timer_t *timer) {
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
|
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
||||||
|
log_e("Timer handle is NULL");
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gptimer_start(timer->timer_handle);
|
gptimer_start(timer->timer_handle);
|
||||||
timer->timer_started = true;
|
timer->timer_started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR timerStop(hw_timer_t *timer) {
|
void TIMER_IRAM timerStop(hw_timer_t *timer) {
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
|
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
||||||
|
log_e("Timer handle is NULL");
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gptimer_stop(timer->timer_handle);
|
gptimer_stop(timer->timer_handle);
|
||||||
timer->timer_started = false;
|
timer->timer_started = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR timerRestart(hw_timer_t *timer) {
|
void TIMER_IRAM timerRestart(hw_timer_t *timer) {
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
|
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
||||||
|
log_e("Timer handle is NULL");
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gptimer_set_raw_count(timer->timer_handle, 0);
|
gptimer_set_raw_count(timer->timer_handle, 0);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue