How to register a RMT RX callback within ESP32 Arduino?

obones
Posts: 3
Joined: Mon May 17, 2021 12:53 pm

How to register a RMT RX callback within ESP32 Arduino?

Postby obones » Thu Aug 18, 2022 1:30 pm

Hello,

I'm using the ESP32 Arduino framework and was able to setup usage of the RMT module just fine.
What I'm trying to do now is to register a RX callback to get notified when the module disables itself because of the idle_threshold being reached.
Here is the code that I used:

Code: Select all

            rmt_config_t rmt_rx;

            rmt_rx.channel = 1;

            rmt_rx_event_callbacks_t cbs = {
                .on_recv_done = rmt_rx_done_callback
            };
            rmt_rx_register_event_callbacks(rmt_rx.channel, &cbs, nullptr);
But sadly, this does not compile, it complains about rmt_rx_event_callbacks_t and rmt_rx_register_event_callbacks not being defined.
Considering that the Arduino SDK is built on top of ESP IDF, I tried to declare those items as they are found in that SDK header files, but alas while it does compile, it won't link because the rmt_rx_register_event_callbacks function is not found in the object files.

Is there a way for me to register such a callback? Or is there another way to be notified of the fact that the idle_threshold has been reached?

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

Re: How to register a RMT RX callback within ESP32 Arduino?

Postby ESP_Sprite » Fri Aug 19, 2022 1:16 pm

Arduino is C++ but those callbacks should be C. Try

Code: Select all

extern "C" {
void my_callback_function(int param, ...) {

}

}

obones
Posts: 3
Joined: Mon May 17, 2021 12:53 pm

Re: How to register a RMT RX callback within ESP32 Arduino?

Postby obones » Mon Aug 22, 2022 9:32 am

Thanks, that occurred to me as well the day after I posted this message.

But sadly it did not help for another reason that I overlooked:
The project I'm working on is based on the 3.4.0 ESP32 Arduino framework which means it uses a 3.X version of the IDF framework and as such does not have all the nice possibilities the latest 4.X versions has.

I'll see how to update the project to a more recent Arduino framework but for now, there is no way for me to do what I want.

Thanks for the help

Who is online

Users browsing this forum: No registered users and 76 guests