Calling HAL functions directly?

szguyer
Posts: 19
Joined: Thu Jan 11, 2018 5:41 pm

Calling HAL functions directly?

Postby szguyer » Mon May 10, 2021 6:17 pm

I am working on the ESP32 support in FastLED, and I'm trying to figure out how to make sure that our interrupt handler code is all in IRAM. We are using the RMT peripheral to generate the signal for clockless LED chips, and the problem is that we call RMT functions in ESP-IDF that are not marked with the IRAM attribute. So, users are occasionally seeing runtime failures when they use flash (e.g., SPIFFs).

One option is to hand inline the implementations of the RMT functions. But that will be a problem for long-term maintainability (especially with the new ESP32 variants coming out). It seems like a better solution is to call the HAL functions directly. For example, instead of calling rmt_tx_start, I would call rmt_ll_tx_start, which is already marked as "inline" in the header file, so presumably it would end up in IRAM if the calling function is.

Is that a viable strategy? How do I set up the #includes so it works?

(PS: I never got a response on my previous question about this issue from December)

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

Re: Calling HAL functions directly?

Postby ESP_Sprite » Tue May 11, 2021 4:52 am

You can, however do understand that the HAL layers aren't marked as 'stable' in ESP-IDF. There's not much chance we'll be changing the HAL API from release to release, but we do reserve the right to do it at any time, even when semantic versioning of ESP-IDF indicates al;l other APIs should be unchanged.

szguyer
Posts: 19
Joined: Thu Jan 11, 2018 5:41 pm

Re: Calling HAL functions directly?

Postby szguyer » Tue May 11, 2021 1:24 pm

Ok, thanks. Do you have any other advice about how to handle this situation? Specifically, when you want to call an ESP-IDF function from an interrupt handler, and you want all the code to be in IRAM, but the function doesn't have that attribute.

Who is online

Users browsing this forum: Baldhead and 137 guests