Skip to content

tkl_timer_handle() pb with ESP32 #545

@ccarlotti

Description

@ccarlotti

It could existing a pb by using tkl_timer.c api under ESP32-S3 environnement: during the call of "tkl_timer_start()", this fct call ESP api fct "gptimer_register_event_callbacks()". The last parameters used come from a "volatile" parameters inside the tkl_timer() call. So when the ISR "tkl_timer_handle()" callback is called, the inside check "if (timer_id >= TIMER_DEV_NUM)" is always true. Patch solutions:
static bool tkl_timer_handle(gptimer_handle_t timer, const gptimer_alarm_event_data_t *data, void *ctx)
{
//TUYA_TIMER_NUM_E timer_id = *(TUYA_TIMER_NUM_E *)ctx;
TUYA_TIMER_NUM_E timer_id = 0;
for(timer_id = 0; timer_id < TIMER_DEV_NUM; timer_id++)
{
if (s_timer_dev[timer_id].time_handle == timer)
{
break;
}
}
if (timer_id >= TIMER_DEV_NUM)
{
return OPRT_INVALID_PARM;
}

if (s_timer_dev[timer_id].timer_cfg && s_timer_dev[timer_id].timer_cfg->cfg.cb)
{
    s_timer_dev[timer_id].timer_cfg->cfg.cb(ctx);
}

return OPRT_OK;

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions