Strange behaviour: implicit declaration of function 'timer_spinlock_take' [-Werror=implicit-function-declaration]

ice.bob
Posts: 7
Joined: Thu Jan 30, 2020 10:31 pm

Strange behaviour: implicit declaration of function 'timer_spinlock_take' [-Werror=implicit-function-declaration]

Postby ice.bob » Wed Apr 08, 2020 2:40 pm

I have some kind of strange behaviour. Maybe someone can help me.

Facts:
- esp-idf v4.0
- macOS 10.5.4

Problem:
I want to get time based interrupts (timer / alarms). So I studied this example: https://github.com/espressif/esp-idf/tr ... imer_group

I can compile it and flash it a ESP32-WROVER-V DevKitC board. As soon as I copy the content of the above mentioned example to my own project code, I cannot compile it anymore using

Code: Select all

idf.py build
. I get the following error messages:

Code: Select all

../main/hello_world_main.c:60:5: error: implicit declaration of function 'timer_spinlock_take' [-Werror=implicit-function-declaration]
     timer_spinlock_take(TIMER_GROUP_0);
     ^~~~~~~~~~~~~~~~~~~
../main/hello_world_main.c:64:27: error: implicit declaration of function 'timer_group_get_intr_status_in_isr'; did you mean 'timer_group_intr_disable'? [-Werror=implicit-function-declaration]
     uint32_t timer_intr = timer_group_get_intr_status_in_isr(TIMER_GROUP_0);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                           timer_group_intr_disable
../main/hello_world_main.c:65:36: error: implicit declaration of function 'timer_group_get_counter_value_in_isr'; did you mean 'timer_get_counter_value'? [-Werror=implicit-function-declaration]
     uint64_t timer_counter_value = timer_group_get_counter_value_in_isr(TIMER_GROUP_0, timer_idx);
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                    timer_get_counter_value
../main/hello_world_main.c:74:22: error: 'TIMER_INTR_T0' undeclared (first use in this function); did you mean 'TIMER_INTR_MAX'?
     if (timer_intr & TIMER_INTR_T0) {
                      ^~~~~~~~~~~~~
                      TIMER_INTR_MAX
../main/hello_world_main.c:74:22: note: each undeclared identifier is reported only once for each function it appears in
../main/hello_world_main.c:76:9: error: implicit declaration of function 'timer_group_clr_intr_status_in_isr'; did you mean 'timer_group_intr_disable'? [-Werror=implicit-function-declaration]
         timer_group_clr_intr_status_in_isr(TIMER_GROUP_0, timer_idx);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         timer_group_intr_disable
../main/hello_world_main.c:78:9: error: implicit declaration of function 'timer_group_set_alarm_value_in_isr'; did you mean 'timer_get_alarm_value'? [-Werror=implicit-function-declaration]
         timer_group_set_alarm_value_in_isr(TIMER_GROUP_0, timer_idx, timer_counter_value);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         timer_get_alarm_value
../main/hello_world_main.c:79:29: error: 'TIMER_INTR_T1' undeclared (first use in this function); did you mean 'TIMER_INTR_MAX'?
     } else if (timer_intr & TIMER_INTR_T1) {
                             ^~~~~~~~~~~~~
                             TIMER_INTR_MAX
../main/hello_world_main.c:87:5: error: implicit declaration of function 'timer_group_enable_alarm_in_isr'; did you mean 'timer_enable_intr'? [-Werror=implicit-function-declaration]
     timer_group_enable_alarm_in_isr(TIMER_GROUP_0, timer_idx);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     timer_enable_intr
../main/hello_world_main.c:91:5: error: implicit declaration of function 'timer_spinlock_give' [-Werror=implicit-function-declaration]
     timer_spinlock_give(TIMER_GROUP_0);
     ^~~~~~~~~~~~~~~~~~~
These are my includes:

Code: Select all

#include <stdio.h>
#include <esp_types.h>
#include <string.h>
#include "sdkconfig.h"
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <freertos/queue.h>
#include <driver/gpio.h>
#include <esp_system.h>
#include <esp_spi_flash.h>
#include <nvs_flash.h>
#include <driver/timer.h>
#include "mcp23x17.h"
#include "mcp23x17.c"
#include "pinning.h"
Does anybody has experience the same? Why is the compiler is throwing 'implicit-function-declaration' error, but I have imported everything from the example. All the method, the compiler throws errors for, can be found in 'driver/timer.h'.

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

Re: Strange behaviour: implicit declaration of function 'timer_spinlock_take' [-Werror=implicit-function-declaration]

Postby ESP_Sprite » Thu Apr 09, 2020 5:13 am

The code you looked up is in the master branch of esp-idf, and the timer spinlocks were only added recently. The example for the 4.0 branch, which you are using, can be found here. Note that the examples can also be found in the esp-idf folder on your hard disk, no need to look them up online.

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 111 guests