Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e92e631

Browse files
committed
feat: Allow calls to timer functions within ISR
1 parent c369dca commit e92e631

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

‎cores/esp32/esp32-hal-timer.c‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,23 @@ struct timer_struct_t {
3636
bool timer_started;
3737
};
3838

39-
inline uint64_t timerRead(hw_timer_t *timer) {
39+
inline IRAM_ATTRuint64_t timerRead(hw_timer_t *timer) {
4040
if (timer == NULL) {
41-
log_e("Timer handle is NULL");
4241
return 0;
4342
}
4443
uint64_t value;
4544
gptimer_get_raw_count(timer->timer_handle, &value);
4645
return value;
4746
}
4847

49-
void timerWrite(hw_timer_t *timer, uint64_t val) {
48+
void IRAM_ATTRtimerWrite(hw_timer_t *timer, uint64_t val) {
5049
if (timer == NULL) {
51-
log_e("Timer handle is NULL");
5250
return;
5351
}
5452
gptimer_set_raw_count(timer->timer_handle, val);
5553
}
5654

57-
void timerAlarm(hw_timer_t *timer, uint64_t alarm_value, bool autoreload, uint64_t reload_count) {
55+
void IRAM_ATTRtimerAlarm(hw_timer_t *timer, uint64_t alarm_value, bool autoreload, uint64_t reload_count) {
5856
if (timer == NULL) {
5957
log_e("Timer handle is NULL");
6058
return;
@@ -67,7 +65,7 @@ void timerAlarm(hw_timer_t *timer, uint64_t alarm_value, bool autoreload, uint64
6765
};
6866
err = gptimer_set_alarm_action(timer->timer_handle, &alarm_cfg);
6967
if (err != ESP_OK) {
70-
log_e("Timer Alarm Write failed, error num=%d", err);
68+
; // Ignore
7169
}
7270
}
7371

@@ -80,27 +78,24 @@ uint32_t timerGetFrequency(hw_timer_t *timer) {
8078
return frequency;
8179
}
8280

83-
void timerStart(hw_timer_t *timer) {
81+
void IRAM_ATTRtimerStart(hw_timer_t *timer) {
8482
if (timer == NULL) {
85-
log_e("Timer handle is NULL");
8683
return;
8784
}
8885
gptimer_start(timer->timer_handle);
8986
timer->timer_started = true;
9087
}
9188

92-
void timerStop(hw_timer_t *timer) {
89+
void IRAM_ATTRtimerStop(hw_timer_t *timer) {
9390
if (timer == NULL) {
94-
log_e("Timer handle is NULL");
9591
return;
9692
}
9793
gptimer_stop(timer->timer_handle);
9894
timer->timer_started = false;
9995
}
10096

101-
void timerRestart(hw_timer_t *timer) {
97+
void IRAM_ATTRtimerRestart(hw_timer_t *timer) {
10298
if (timer == NULL) {
103-
log_e("Timer handle is NULL");
10499
return;
105100
}
106101
gptimer_set_raw_count(timer->timer_handle, 0);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /