Skip to content

Commit 3721f85

Browse files
committed
allow older esp32 version to compile with the v2.3.6 #462
1 parent 7748a9d commit 3721f85

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/drivers/hardware_specific/esp32/esp32_driver_mcpwm.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,20 @@
9696
* and here: // https://docs.espressif.com/projects/esp-idf/en/v5.1.4/esp32/migration-guides/release-5.x/5.0/peripherals.html
9797
*/
9898

99-
#include "../../hardware_api.h"
99+
#include "../../hardware_api.h"
100100

101101
#if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) && defined(SOC_MCPWM_SUPPORTED) && !defined(SIMPLEFOC_ESP32_USELEDC)
102102

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+
103113
#include "esp32_driver_mcpwm.h"
104114

105115
// MCPWM driver hardware timer pointers
@@ -282,7 +292,9 @@ void* _configure6PWMPinsMCPWM(long pwm_frequency, int mcpwm_group, int timer_no,
282292
pwm_config.count_mode = MCPWM_TIMER_COUNT_MODE_UP_DOWN;
283293
pwm_config.intr_priority = 0;
284294
pwm_config.period_ticks = _calcPWMPeriod(pwm_frequency);
295+
#ifdef ESP_IDF_VERSION_ABOVE_5_4_0
285296
pwm_config.flags.allow_pd = 0;
297+
#endif
286298

287299
CHECK_ERR(mcpwm_new_timer(&pwm_config, &timers[mcpwm_group][timer_no]), "Could not initialize the timer in group: " + String(mcpwm_group));
288300
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
411423
pwm_config.count_mode = MCPWM_TIMER_COUNT_MODE_UP_DOWN;
412424
pwm_config.intr_priority = 0;
413425
pwm_config.period_ticks = _calcPWMPeriod(pwm_frequency);
426+
#ifdef ESP_IDF_VERSION_ABOVE_5_4_0
414427
pwm_config.flags.allow_pd = 0;
428+
#endif
415429
// initialise the timer
416430
CHECK_ERR(mcpwm_new_timer(&pwm_config, &timers[mcpwm_group][timer_no]), "Could not initialize the timer in group: " + String(mcpwm_group));
417431
// save variables for later

0 commit comments

Comments
 (0)