Added backwards compatibility to PWM to operate in 2.0.0 and 1.0.6
Accounts for new *required* elements of the LEDC channel and timer structures to be set in later versions of the IDF. These elements are not available in earlier versions of the IDF and the program can't be compiled unless ignored.
This commit is contained in:
parent
07da5ac924
commit
0ea762b4a8
|
|
@ -18,7 +18,10 @@ LedC::LedC(uint8_t pin, uint16_t freq){
|
|||
timerList[nTimer][nMode]->speed_mode=(ledc_mode_t)nMode;
|
||||
timerList[nTimer][nMode]->timer_num=(ledc_timer_t)nTimer;
|
||||
timerList[nTimer][nMode]->freq_hz=freq;
|
||||
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
|
||||
timerList[nTimer][nMode]->clk_cfg=LEDC_USE_APB_CLK;
|
||||
#endif
|
||||
|
||||
int res=LEDC_TIMER_BIT_MAX-1; // find the maximum possible resolution
|
||||
while(getApbFrequency()/(freq*pow(2,res))<1)
|
||||
|
|
@ -37,7 +40,9 @@ LedC::LedC(uint8_t pin, uint16_t freq){
|
|||
channelList[nChannel][nMode]->channel=(ledc_channel_t)nChannel;
|
||||
channelList[nChannel][nMode]->timer_sel=(ledc_timer_t)nTimer;
|
||||
channelList[nChannel][nMode]->intr_type=LEDC_INTR_DISABLE;
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0)
|
||||
channelList[nChannel][nMode]->flags.output_invert=0;
|
||||
#endif
|
||||
channelList[nChannel][nMode]->hpoint=0;
|
||||
channelList[nChannel][nMode]->gpio_num=pin;
|
||||
timer=timerList[nTimer][nMode];
|
||||
|
|
|
|||
Loading…
Reference in New Issue