diff --git a/.github/workflows/build_idf_examples_matrix.yml b/.github/workflows/build_idf_examples_matrix.yml index 89c92b4..03c631a 100644 --- a/.github/workflows/build_idf_examples_matrix.yml +++ b/.github/workflows/build_idf_examples_matrix.yml @@ -14,9 +14,15 @@ jobs: - esp32_idf_V4_4_0 - esp32_idf_V5_0_0 - esp32_idf_V5_1_0 -# - esp32c3_idf_V5_0_0 -# - esp32s2_idf_V5_0_0 -# - esp32s3_idf_V5_0_0 + - esp32_idf_V5_2_0 + - esp32_idf_V5_3_0 + # - esp32_idf_V6_0_0 fails + - esp32c3_idf_V5_3_0 + # - esp32c3_idf_V6_0_0 fails + - esp32s2_idf_V5_3_0 + # - esp32s2_idf_V6_0_0 fails + - esp32s3_idf_V5_3_0 + # - esp32s3_idf_V6_0_0 fails runs-on: ubuntu-latest diff --git a/extras/ci/platformio.ini b/extras/ci/platformio.ini index 9128c20..0d2fdd0 100644 --- a/extras/ci/platformio.ini +++ b/extras/ci/platformio.ini @@ -317,6 +317,30 @@ build_flags = -Wall board_build.f_cpu = 240000000L lib_extra_dirs = ../../.. +[env:esp32_idf_V6_3_0] +platform = espressif32 @ 5.3.0 +board = esp32dev +framework = espidf +build_flags = -Werror -Wall -Wno-deprecated-declarations -Wno-error=incompatible-pointer-types -Wno-unused-function -Wno-error=attributes +board_build.f_cpu = 240000000L +lib_extra_dirs = ../.. + +[env:esp32_idf_V6_0_0] +platform = espressif32 @ 6.0.0 +board = esp32dev +framework = espidf +build_flags = -Werror -Wall -Wno-deprecated-declarations -Wno-error=incompatible-pointer-types -Wno-unused-function -Wno-error=attributes +board_build.f_cpu = 240000000L +lib_extra_dirs = ../.. + +[env:esp32_idf_V5_3_0] +platform = espressif32 @ 5.3.0 +board = esp32dev +framework = espidf +build_flags = -Werror -Wall -Wno-deprecated-declarations -Wno-error=incompatible-pointer-types -Wno-unused-function -Wno-error=attributes +board_build.f_cpu = 240000000L +lib_extra_dirs = ../.. + [env:esp32_idf_V5_2_0] platform = espressif32 @ 5.2.0 board = esp32dev @@ -349,24 +373,48 @@ build_flags = -Werror -Wall -Wno-deprecated-declarations -Wno-error=incompatible board_build.f_cpu = 240000000L lib_extra_dirs = ../../ -[env:esp32c3_idf_V5_0_0] -platform = espressif32 @ 5.0.0 +[env:esp32c3_idf_V6_0_0] +platform = espressif32 @ 6.0.0 board = esp32-c3-devkitm-1 framework = espidf build_flags = -Werror -Wall -Wno-deprecated-declarations -Wno-error=incompatible-pointer-types -Wno-unused-function -Wno-error=attributes board_build.f_cpu = 240000000L lib_extra_dirs = ../.. -[env:esp32s2_idf_V5_0_0] -platform = espressif32 @ 5.0.0 +[env:esp32c3_idf_V5_3_0] +platform = espressif32 @ 5.3.0 +board = esp32-c3-devkitm-1 +framework = espidf +build_flags = -Werror -Wall -Wno-deprecated-declarations -Wno-error=incompatible-pointer-types -Wno-unused-function -Wno-error=attributes +board_build.f_cpu = 240000000L +lib_extra_dirs = ../.. + +[env:esp32s2_idf_V6_0_0] +platform = espressif32 @ 6.0.0 board = esp32-s2-saola-1 framework = espidf build_flags = -Werror -Wall -Wno-deprecated-declarations -Wno-error=incompatible-pointer-types -Wno-unused-function -Wno-error=attributes board_build.f_cpu = 240000000L lib_extra_dirs = ../.. -[env:esp32s3_idf_V5_0_0] -platform = espressif32 @ 5.0.0 +[env:esp32s2_idf_V5_3_0] +platform = espressif32 @ 5.3.0 +board = esp32-s2-saola-1 +framework = espidf +build_flags = -Werror -Wall -Wno-deprecated-declarations -Wno-error=incompatible-pointer-types -Wno-unused-function -Wno-error=attributes +board_build.f_cpu = 240000000L +lib_extra_dirs = ../.. + +[env:esp32s3_idf_V6_0_0] +platform = espressif32 @ 6.0.0 +board = esp32-s3-devkitc-1 +framework = espidf +build_flags = -Werror -Wall -Wno-deprecated-declarations -Wno-error=incompatible-pointer-types -Wno-unused-function -Wno-error=attributes +board_build.f_cpu = 240000000L +lib_extra_dirs = ../.. + +[env:esp32s3_idf_V5_3_0] +platform = espressif32 @ 5.3.0 board = esp32-s3-devkitc-1 framework = espidf build_flags = -Werror -Wall -Wno-deprecated-declarations -Wno-error=incompatible-pointer-types -Wno-unused-function -Wno-error=attributes diff --git a/extras/idf_examples/UsageExample/UsageExample.cpp b/extras/idf_examples/UsageExample/UsageExample.cpp index f011887..f754fd3 100644 --- a/extras/idf_examples/UsageExample/UsageExample.cpp +++ b/extras/idf_examples/UsageExample/UsageExample.cpp @@ -1,5 +1,7 @@ #include "FastAccelStepper.h" +#include + // As in StepperDemo for Motor 1 on ESP32 #define dirPinStepper 18 #define enablePinStepper 26 @@ -61,7 +63,7 @@ void setup() { void loop() { while (stepper->isRunning()) { esp_task_wdt_reset(); - printf("pos=%d\n", stepper->getCurrentPosition()); + printf("pos=%" PRId32 "\n", stepper->getCurrentPosition()); vTaskDelay(pdMS_TO_TICKS(500)); } stepper->move(1000); diff --git a/src/fas_arch/arduino_esp32.h b/src/fas_arch/arduino_esp32.h index 7456de9..691b119 100644 --- a/src/fas_arch/arduino_esp32.h +++ b/src/fas_arch/arduino_esp32.h @@ -3,160 +3,11 @@ // this is an arduino platform, so include the Arduino.h header file #include -#include - -#define SUPPORT_ESP32 -#define SUPPORT_EXTERNAL_DIRECTION_PIN -#define SUPPORT_UNSAFE_ABS_SPEED_LIMIT_SETTING 1 - -// Some more esp32 specific includes -#include -#include - -//========================================================================== -// -// ESP32 derivate - the first one -// -//========================================================================== - -#if CONFIG_IDF_TARGET_ESP32 -#include -#include -#include -#include -#include -#include - -#define SUPPORT_ESP32_MCPWM_PCNT -#define SUPPORT_ESP32_RMT -#include -#define QUEUES_MCPWM_PCNT 6 -#define QUEUES_RMT 8 - -// have support for pulse counter -#define SUPPORT_ESP32_PULSE_COUNTER -#define FAS_RMT_MEM(channel) ((uint32_t *)RMT_CHANNEL_MEM(channel)) - -//========================================================================== -// -// ESP32 derivate - ESP32S2 -// -//========================================================================== -#elif CONFIG_IDF_TARGET_ESP32S2 -#define SUPPORT_ESP32S3_PULSE_COUNTER -#define SUPPORT_ESP32_RMT -#include -#include -#include -#include -#include -#define QUEUES_MCPWM_PCNT 0 -#define QUEUES_RMT 4 -#define FAS_RMT_MEM(channel) ((uint32_t *)RMTMEM.chan[channel].data32) - -//========================================================================== -// -// ESP32 derivate - ESP32S3 -// -//========================================================================== -#elif CONFIG_IDF_TARGET_ESP32S3 -#define SUPPORT_ESP32_MCPWM_PCNT -#define SUPPORT_ESP32S3_MCPWM_PCNT -#include -#include -#include -#include -#include -#include - -#define SUPPORT_ESP32_RMT -#define SUPPORT_ESP32S3_RMT -#include -#include -#include -#include -#include -#define FAS_RMT_MEM(channel) ((uint32_t *)RMTMEM.chan[channel].data32) - -#define QUEUES_MCPWM_PCNT 4 -#define QUEUES_RMT 4 - -// have support for pulse counter -#define SUPPORT_ESP32_PULSE_COUNTER - -//========================================================================== -// -// ESP32 derivate - ESP32C3 -// -//========================================================================== -#elif CONFIG_IDF_TARGET_ESP32C3 -#define SUPPORT_ESP32_RMT -#define SUPPORT_ESP32C3_RMT -#include -#include -#include -#include -#include -#define QUEUES_MCPWM_PCNT 0 -#define QUEUES_RMT 2 -#define FAS_RMT_MEM(channel) ((uint32_t *)RMTMEM.chan[channel].data32) - -//========================================================================== -// -// For all unsupported ESP32 derivates -// -//========================================================================== -#else -#error "Unsupported derivate" -#endif // For esp32 using arduino, just use arduino definition #define fasEnableInterrupts interrupts #define fasDisableInterrupts noInterrupts -#if ESP_IDF_VERSION_MAJOR == 4 -#define __ESP32_IDF_V44__ -#include -#include -#include -#include -#include -#elif ESP_IDF_VERSION_MAJOR == 3 -#endif - -// Esp32 queue definitions -#define NUM_QUEUES (QUEUES_MCPWM_PCNT + QUEUES_RMT) -#define MAX_STEPPER (NUM_QUEUES) -#define QUEUE_LEN 32 - -// Esp32 timing definition -#define TICKS_PER_S 16000000L -#define MIN_CMD_TICKS (TICKS_PER_S / 5000) -#define MIN_DIR_DELAY_US (MIN_CMD_TICKS / (TICKS_PER_S / 1000000)) -#define MAX_DIR_DELAY_US (65535 / (TICKS_PER_S / 1000000)) -#define DELAY_MS_BASE 4 - -#define SUPPORT_QUEUE_ENTRY_START_POS_U16 - -// debug led timing -#define DEBUG_LED_HALF_PERIOD 50 - -#define noop_or_wait vTaskDelay(1) - -// have more than one core -#define SUPPORT_CPU_AFFINITY - -#ifdef __ESP32_IDF_V44__ -#include -#include -#endif /* __ESP32_IDF_V44__ */ - -//========================================================================== -// determine, if driver type selection should be supported -#if defined(QUEUES_MCPWM_PCNT) && defined(QUEUES_RMT) -#if (QUEUES_MCPWM_PCNT > 0) && (QUEUES_RMT > 0) -#define SUPPORT_SELECT_DRIVER_TYPE -#endif -#endif +#include "fas_arch/common_esp32.h" #endif /* FAS_ARCH_ARDUINO_ESP32_H */ diff --git a/src/fas_arch/common_esp32.h b/src/fas_arch/common_esp32.h new file mode 100644 index 0000000..1becdb8 --- /dev/null +++ b/src/fas_arch/common_esp32.h @@ -0,0 +1,151 @@ +#ifndef FAS_ARCH_COMMON_ESP32_H +#define FAS_ARCH_COMMON_ESP32_H + +#include + +#define SUPPORT_ESP32 +#define SUPPORT_EXTERNAL_DIRECTION_PIN +#define SUPPORT_UNSAFE_ABS_SPEED_LIMIT_SETTING 1 + +// Some more esp32 specific includes +#include +#include + +//========================================================================== +// +// ESP32 derivate - the first one +// +//========================================================================== + +#if CONFIG_IDF_TARGET_ESP32 +#include +#include +#include +#include +#include +#include +#include + +#define SUPPORT_ESP32_MCPWM_PCNT +#define SUPPORT_ESP32_RMT +#define QUEUES_MCPWM_PCNT 6 +#define QUEUES_RMT 8 + +// have support for pulse counter +#define SUPPORT_ESP32_PULSE_COUNTER +#define FAS_RMT_MEM(channel) ((uint32_t *)RMT_CHANNEL_MEM(channel)) + +//========================================================================== +// +// ESP32 derivate - ESP32S2 +// +//========================================================================== +#elif CONFIG_IDF_TARGET_ESP32S2 +#define SUPPORT_ESP32S3_PULSE_COUNTER +#define SUPPORT_ESP32_RMT +#include +#include +#include +#include +#include +#define QUEUES_MCPWM_PCNT 0 +#define QUEUES_RMT 4 +#define FAS_RMT_MEM(channel) ((uint32_t *)RMTMEM.chan[channel].data32) + +//========================================================================== +// +// ESP32 derivate - ESP32S3 +// +//========================================================================== +#elif CONFIG_IDF_TARGET_ESP32S3 +#define SUPPORT_ESP32_MCPWM_PCNT +#define SUPPORT_ESP32S3_MCPWM_PCNT +#include +#include +#include +#include +#include +#include + +#define SUPPORT_ESP32_RMT +#define SUPPORT_ESP32S3_RMT +#include +#include +#include +#include +#include +#define FAS_RMT_MEM(channel) ((uint32_t *)RMTMEM.chan[channel].data32) + +#define QUEUES_MCPWM_PCNT 4 +#define QUEUES_RMT 4 + +// have support for pulse counter +#define SUPPORT_ESP32_PULSE_COUNTER + +//========================================================================== +// +// ESP32 derivate - ESP32C3 +// +//========================================================================== +#elif CONFIG_IDF_TARGET_ESP32C3 +#define SUPPORT_ESP32_RMT +#define SUPPORT_ESP32C3_RMT +#include +#include +#include +#include +#include +#define QUEUES_MCPWM_PCNT 0 +#define QUEUES_RMT 2 +#define FAS_RMT_MEM(channel) ((uint32_t *)RMTMEM.chan[channel].data32) + +//========================================================================== +// +// For all unsupported ESP32 derivates +// +//========================================================================== +#else +#error "Unsupported derivate" +#endif + +#if ESP_IDF_VERSION_MAJOR == 4 +#define __ESP32_IDF_V44__ +#include +#include +#include +#include +#include +#elif ESP_IDF_VERSION_MAJOR == 3 +#endif + +// Esp32 queue definitions +#define NUM_QUEUES (QUEUES_MCPWM_PCNT + QUEUES_RMT) +#define MAX_STEPPER (NUM_QUEUES) +#define QUEUE_LEN 32 + +// Esp32 timing definition +#define TICKS_PER_S 16000000L +#define MIN_CMD_TICKS (TICKS_PER_S / 5000) +#define MIN_DIR_DELAY_US (MIN_CMD_TICKS / (TICKS_PER_S / 1000000)) +#define MAX_DIR_DELAY_US (65535 / (TICKS_PER_S / 1000000)) +#define DELAY_MS_BASE 4 + +#define SUPPORT_QUEUE_ENTRY_START_POS_U16 + +// debug led timing +#define DEBUG_LED_HALF_PERIOD 50 + +#define noop_or_wait vTaskDelay(1) + +// have more than one core +#define SUPPORT_CPU_AFFINITY + +//========================================================================== +// determine, if driver type selection should be supported +#if defined(QUEUES_MCPWM_PCNT) && defined(QUEUES_RMT) +#if (QUEUES_MCPWM_PCNT > 0) && (QUEUES_RMT > 0) +#define SUPPORT_SELECT_DRIVER_TYPE +#endif +#endif + +#endif /* FAS_ARCH_COMMON_ESP32_H */ diff --git a/src/fas_arch/espidf_esp32.h b/src/fas_arch/espidf_esp32.h index c21c935..41b7dfb 100644 --- a/src/fas_arch/espidf_esp32.h +++ b/src/fas_arch/espidf_esp32.h @@ -1,26 +1,8 @@ #ifndef FAS_ARCH_ESPIDF_ESP32_H #define FAS_ARCH_ESPIDF_ESP32_H -#define SUPPORT_ESP32 -#define SUPPORT_UNSAFE_ABS_SPEED_LIMIT_SETTING 1 - -#define SUPPORT_ESP32_RMT -#define SUPPORT_ESP32_MCPWM_PCNT - // esp32 specific includes -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include // on espidf need to use portDISABLE/ENABLE_INTERRUPTS #include @@ -28,27 +10,6 @@ #define fasDisableInterrupts portDISABLE_INTERRUPTS #define fasEnableInterrupts portENABLE_INTERRUPTS -// Only since esp-idf v4.4 MCPWM_TIMER0_PHASE_DIRECTION_S is defined. So use -// this to distinguish between the two versions -#if defined(MCPWM_TIMER0_PHASE_DIRECTION_S) -#define __ESP32_IDF_V44__ -#endif - -// Esp32 queue definitions -#define MAX_STEPPER 6 -#define NUM_QUEUES 6 -#define QUEUES_MCPWM_PCNT 6 -#define QUEUES_RMT 8 -#define QUEUE_LEN 32 -#define SUPPORT_EXTERNAL_DIRECTION_PIN - -// Esp32 timing definition -#define TICKS_PER_S 16000000L -#define MIN_CMD_TICKS (TICKS_PER_S / 2000) -#define MIN_DIR_DELAY_US (MIN_CMD_TICKS / (TICKS_PER_S / 1000000)) -#define MAX_DIR_DELAY_US (65535 / (TICKS_PER_S / 1000000)) -#define DELAY_MS_BASE 4 - // The espidf-platform needs a couple of arduino like definitions #define LOW 0 #define HIGH 1 @@ -56,37 +17,6 @@ #define pinMode(pin, mode) gpio_set_direction((gpio_num_t)pin, mode) #define digitalWrite(pin, level) gpio_set_level((gpio_num_t)pin, level) -// debug led timing -#define DEBUG_LED_HALF_PERIOD 50 - -#define noop_or_wait vTaskDelay(1) - -#define SUPPORT_QUEUE_ENTRY_START_POS_U16 - -// have support for pulse counter -#define SUPPORT_ESP32_PULSE_COUNTER - -// have more than one core -#define SUPPORT_CPU_AFFINITY - -#if defined(ARDUINO_ESP32_RELEASE_3_0_0) -#else -// have support for pulse counter -#define SUPPORT_ESP32_PULSE_COUNTER -#define FAS_RMT_MEM(channel) ((uint32_t *)RMT_CHANNEL_MEM(channel)) -#endif - -#ifdef __ESP32_IDF_V44__ -#include -#include -#endif /* __ESP32_IDF_V44__ */ - -//========================================================================== -// determine, if driver type selection should be supported -#if defined(QUEUES_MCPWM_PCNT) && defined(QUEUES_RMT) -#if (QUEUES_MCPWM_PCNT > 0) && (QUEUES_RMT > 0) -#define SUPPORT_SELECT_DRIVER_TYPE -#endif -#endif +#include "fas_arch/common_esp32.h" #endif /* FAS_ARCH_ESPIDF_ESP32_H */