|
96 | 96 | * and here: // https://docs.espressif.com/projects/esp-idf/en/v5.1.4/esp32/migration-guides/release-5.x/5.0/peripherals.html
|
97 | 97 | */
|
98 | 98 |
|
99 |
| -#include "../../hardware_api.h" |
| 99 | +#include "../../hardware_api.h" |
100 | 100 |
|
101 | 101 | #if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) && defined(SOC_MCPWM_SUPPORTED) && !defined(SIMPLEFOC_ESP32_USELEDC)
|
102 | 102 |
|
| 103 | +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 4, 0) |
| 104 | +#define ESP_IDF_VERSION_UNDER_5_4_0 |
| 105 | +#pragma message("") |
| 106 | +#pragma message("SimpleFOC: ESP IDF version under 5.4.0, consider upgrading!") |
| 107 | +#pragma message("") |
| 108 | +#else ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) |
| 109 | +#define ESP_IDF_VERSION_ABOVE_5_4_0 |
| 110 | +#endif |
| 111 | + |
| 112 | + |
103 | 113 | #include "esp32_driver_mcpwm.h"
|
104 | 114 |
|
105 | 115 | // MCPWM driver hardware timer pointers
|
@@ -282,7 +292,9 @@ void* _configure6PWMPinsMCPWM(long pwm_frequency, int mcpwm_group, int timer_no,
|
282 | 292 | pwm_config.count_mode = MCPWM_TIMER_COUNT_MODE_UP_DOWN;
|
283 | 293 | pwm_config.intr_priority = 0;
|
284 | 294 | pwm_config.period_ticks = _calcPWMPeriod(pwm_frequency);
|
| 295 | +#ifdef ESP_IDF_VERSION_ABOVE_5_4_0 |
285 | 296 | pwm_config.flags.allow_pd = 0;
|
| 297 | +#endif |
286 | 298 |
|
287 | 299 | CHECK_ERR(mcpwm_new_timer(&pwm_config, &timers[mcpwm_group][timer_no]), "Could not initialize the timer in group: " + String(mcpwm_group));
|
288 | 300 | pwm_periods[mcpwm_group][timer_no] = pwm_config.period_ticks / 2;
|
@@ -411,7 +423,9 @@ void* _configurePinsMCPWM(long pwm_frequency, int mcpwm_group, int timer_no, int
|
411 | 423 | pwm_config.count_mode = MCPWM_TIMER_COUNT_MODE_UP_DOWN;
|
412 | 424 | pwm_config.intr_priority = 0;
|
413 | 425 | pwm_config.period_ticks = _calcPWMPeriod(pwm_frequency);
|
| 426 | +#ifdef ESP_IDF_VERSION_ABOVE_5_4_0 |
414 | 427 | pwm_config.flags.allow_pd = 0;
|
| 428 | +#endif |
415 | 429 | // initialise the timer
|
416 | 430 | CHECK_ERR(mcpwm_new_timer(&pwm_config, &timers[mcpwm_group][timer_no]), "Could not initialize the timer in group: " + String(mcpwm_group));
|
417 | 431 | // save variables for later
|
|
0 commit comments