ambiguating new declaration of 'bool esp_vApplicationIdleHook()'

techtoys
Posts: 26
Joined: Sat Jun 01, 2019 11:11 am

ambiguating new declaration of 'bool esp_vApplicationIdleHook()'

Postby techtoys » Thu Dec 08, 2022 4:41 am

Hi

I am trying to define a sleep function with esp_vApplicationIdleHook() but whenever I put it in my sketch there is an error:
Compilation error: ambiguating new declaration of 'bool esp_vApplicationIdleHook()'.

My code is simple like:

Code: Select all

bool esp_vApplicationIdleHook(void)
{
  static TickType_t lastFlashTime=0;
  if((xTaskGetTickCount()-lastFlashTime) > 1000)
  {
    Serial.println(F("It is 1 sec elapse in the idle hook."));
    lastFlashTime = xTaskGetTickCount();
  }
  return true;
}
How esp_vApplicationIdleHook(void) is used actually?

Thanks for any reply in advance.

John

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: ambiguating new declaration of 'bool esp_vApplicationIdleHook()'

Postby ESP_Sprite » Thu Dec 08, 2022 6:46 am

Not sure why you think that has a bool return type; the docs define it as `void vApplicationIdleHook( void )`.

techtoys
Posts: 26
Joined: Sat Jun 01, 2019 11:11 am

Re: ambiguating new declaration of 'bool esp_vApplicationIdleHook()'

Postby techtoys » Thu Dec 08, 2022 7:10 am

Right, it should be

Code: Select all

void esp_vApplicationIdleHook(void)
instead. This function is required by tasks.c and listed as a extern in portmacro.h.

Changing it back to void esp_vApplicationIdleHook(void) in the main sketch returns the error as :
multiple definition of `esp_vApplicationIdleHook'

I think it is not possible to use esp_vApplicationIdleHook() like vApplicationIdleHook() in legacy FreeRTOS. Instead, I need to call

Code: Select all

esp_register_freertos_idle_hook(esp_freertos_idle_cb_t new_idle_cb)
to register a new callback function and this time, the new callback function type is :

Code: Select all

typedef bool (*esp_freertos_idle_cb_t)(void)
. It returns a boolean and it is not possible to call Serial.printf() from the new callback otherwise, the application will crash. Suppose the new callback should return as soon as possible without a long delay.

Who is online

Users browsing this forum: Bing [Bot] and 66 guests