Skip to content

fix issues in hw_timer (GIT8266O-677) #1102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions components/esp8266/driver/hw_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,20 @@ uint32_t hw_timer_get_count_data()
return frc1.count.data;
}

static void IRAM_ATTR hw_timer_isr_cb(void* arg)
{
if (!frc1.ctrl.reload) {
frc1.ctrl.en = 0;
static void IRAM_ATTR hw_timer_isr_cb(void *arg)
{
typeof ( ((frc1_struct_t*)0)->ctrl) ctrl;
ctrl.val = frc1.ctrl.val;
if (!ctrl.reload) {
ctrl.en = 0;
frc1.ctrl.val = ctrl.val; //stop counter
/* frc1.count.val == 0 causes continuous fire even with the timer disabled.
* We force an immediate reload to avoid that*/
uint32_t val = frc1.load.val; //split to suppress a warning
frc1.load.val= val;
/* Clear the interrupt just in case the timer fired again.
* This might occur even in case of interrupt latencies */
soc_clear_int_mask(1ul << (ETS_FRC_TIMER1_INUM));
}
if (hw_timer_obj->cb != NULL) {
hw_timer_obj->cb(arg);
Expand Down Expand Up @@ -242,4 +252,4 @@ esp_err_t hw_timer_init(hw_timer_callback_t callback, void *arg)
hw_timer_intr_enable();

return ESP_OK;
}
}