Skip to content

Commit

Permalink
ESP32: Minor optimization when setting hw timer
Browse files Browse the repository at this point in the history
If IRAM mode doesn't change, don't set it
  • Loading branch information
rojer committed Oct 13, 2021
1 parent 604e1d2 commit e5a232c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions platforms/esp32/src/esp32_hw_timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ IRAM bool mgos_hw_timers_dev_set(struct mgos_hw_timer_info *ti, int usecs,
}
}

if (esp_intr_set_in_iram(dd->inth, (flags & MGOS_ESP32_HW_TIMER_IRAM) != 0) !=
ESP_OK) {
return false;
bool want_iram = (flags & MGOS_ESP32_HW_TIMER_IRAM) != 0;
if (want_iram != dd->iram) {
if (esp_intr_set_in_iram(dd->inth, want_iram) != ESP_OK) return false;
dd->iram = want_iram;
}

tg->int_ena.val |= mask;
Expand Down
2 changes: 2 additions & 0 deletions platforms/esp32/src/esp32_hw_timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#pragma once

#include <stdbool.h>
#include <stdint.h>

#include "esp_intr_alloc.h"
Expand All @@ -33,6 +34,7 @@ struct mgos_hw_timer_dev_data {
timg_dev_t *tg;
uint8_t tgn;
uint8_t tn;
bool iram;
};

#ifdef __cplusplus
Expand Down

0 comments on commit e5a232c

Please sign in to comment.