Page 1 of 1

pass arg to High resolution timer callback

Posted: Sat Feb 12, 2022 2:03 pm
by kyrpav
Hi i have a high resolution timer set like this.

Code: Select all

    
    esp_timer_handle_t timerHandle;
    const esp_timer_create_args_t timerArgs={
        .callback = onTimer,
        .arg = NULL,
        .dispatch_method = ESP_TIMER_TASK,
        .name = "Measurement",
        .skip_unhandled_events = false
    };
    esp_timer_create(&timerArgs,&timerHandle);
I can use start and stop of timer with the next functions.

Code: Select all

esp_timer_start_periodic(timerHandle,timeout_us);
    esp_timer_stop(timerHandle));
The onTimer callback function is this

Code: Select all

void onTimer(void *args){
    // print a message from args, pass value on notification
}
From which function can i pass the info to the args of the callback function. Except making the variables extern or static and have them in the c file. I want to be able to pass the args.

Re: pass arg to High resolution timer callback

Posted: Sat Feb 12, 2022 2:23 pm
by kyrpav
i will try to pass it in the .arg of the args of timer.