ESP32 Change PWM Duty Cycle in Interrupt possible?

With the v2.x.x ESP32 Arduino core things have changed (quite a lot). You can call ledcWrite() from within an interrupt when compiling under the Arduino IDE. However, just like what was seen above any calls to ledcWrite() from within an interrupt with code generated by PlatformIO randomly crashes. I thought it was a fluke (and I suppose it still could be) that this worked under v2.0.2 of the Arduino core when compiling under the Arduino IDE, but it definitely works and I saw a mention of this somewhere when I was trying to track down a solution. My problem is that I have switched to PlatformIO and now I am back to having this not work from within an interrupt again.

So, I do have everything in PlatformIO updated. Using v3.5.0 of the Espressif plaform. I am not sure how that equates to the Arduino core though. I am new to PlatformIO so I am not familiar with it yet.

I am using this setup for the .ini

platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
lib_extra_dirs = ~/Documents/Arduino/libraries
monitor_speed = 115200

I have tried following the info above and taking the code from latest Arduino core (2.0.2), but I can’t get it to compile.

void IRAM_ATTR myledcWrite(uint8_t chan, uint32_t duty)
{
    if(chan >= LEDC_CHANNELS){
        return;
    }

    uint8_t group=(chan/8), channel=(chan%8);

    //Fixing if all bits in resolution is set = LEDC FULL ON

    uint32_t max_duty = (1 << channels_resolution[chan]) - 1;
    if(duty == max_duty){
        duty = max_duty + 1;
    }
    ledc_set_duty(group, channel, duty);
    ledc_update_duty(group, channel);
}

I tried every include file I could think of as well, and the errors are things are not defined, ie:

LEDC_CHANNELS' was not declared in this scope
     if(chan >= LEDC_CHANNELS)

I also get this when I look at “problems”:

identifier "LEDC_CHANNELS" is undefined
identifier "channels_resolution" is undefined
argument of type "uint8_t" is incompatible with parameter of type "ledc_mode_t"
argument of type "uint8_t" is incompatible with parameter of type "ledc_channel_t"
argument of type "uint8_t" is incompatible with parameter of type "ledc_mode_t"
argument of type "uint8_t" is incompatible with parameter of type "ledc_channel_t"

Any ideas on how to make this work with the latest Arudino framework?

Thanks!