Where can source code for ESP32 adc1_get_raw function be found?

I can find its definition in

but not the function itself.

In the same repository

Thank you, very much.

I need to write my own version of adc1_get_raw function which should internally call adc1_adc_mode_acquire() and adc1_lock_release(), similar to the original one.

I declared extern esp_err_t adc1_adc_mode_acquire(); and extern esp_err_t adc1_lock_release(); respectively, but I'm getting errors "undefined reference to ..." while compiling. Is there a way to call original adc1_adc_mode_acquire and adc1_lock_release functions?

If not, they are both calling _lock_acquire( &adc1_i2s_lock ); but the problems with extern _lock_t adc1_i2s_lock; are exactly the same.

Don't do that. extern is for data (variables), not functions.

It works for functions as well. But I found the cause of the problem here: c - why no need to add `extern` for external functions? - Stack Overflow

You can not link functions and variables declared as static :confused:

Perhaps, but it's not needed. Have you tried just calling adc1_get_raw()?

If that doesn't work, add:

#include "driver/adc.h"

I can call adc1_get_raw() but I would like to modify it in the way that bulk reads would work faster by making a lock only once at the beginning and releasing it only once at the end. So I would like to write a new function that basically does the same and also follows the locking mechanism.

The locking is done by calling adc1_adc_mode_acquire() and adc1_lock_release() or by _lock_acquire( &adc1_i2s_lock ) and _lock_release( &adc1_i2s_lock ) directly. Unfortunately adc1_i2s_lock is declared as static. adc1_adc_mode_acquire() and adc1_lock_release() are not, but I can still not link to them. I'm getting "undefined reference to `adc1_adc_mode_acquire()" linker error message.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.