Skip to content

Commit

Permalink
fix platformio.ini for espressif idf builds and combine fas_arch/ hea…
Browse files Browse the repository at this point in the history
…der files
  • Loading branch information
gin66 committed Aug 19, 2024
1 parent 2d85ee4 commit 46d8cab
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 231 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/build_idf_examples_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
60 changes: 54 additions & 6 deletions extras/ci/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion extras/idf_examples/UsageExample/UsageExample.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "FastAccelStepper.h"

#include <cinttypes>

// As in StepperDemo for Motor 1 on ESP32
#define dirPinStepper 18
#define enablePinStepper 26
Expand Down Expand Up @@ -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);
Expand Down
151 changes: 1 addition & 150 deletions src/fas_arch/arduino_esp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,160 +3,11 @@

// this is an arduino platform, so include the Arduino.h header file
#include <Arduino.h>
#include <sdkconfig.h>

#define SUPPORT_ESP32
#define SUPPORT_EXTERNAL_DIRECTION_PIN
#define SUPPORT_UNSAFE_ABS_SPEED_LIMIT_SETTING 1

// Some more esp32 specific includes
#include <driver/gpio.h>
#include <esp_task_wdt.h>

//==========================================================================
//
// ESP32 derivate - the first one
//
//==========================================================================

#if CONFIG_IDF_TARGET_ESP32
#include <driver/mcpwm.h>
#include <driver/pcnt.h>
#include <soc/mcpwm_reg.h>
#include <soc/mcpwm_struct.h>
#include <soc/pcnt_reg.h>
#include <soc/pcnt_struct.h>

#define SUPPORT_ESP32_MCPWM_PCNT
#define SUPPORT_ESP32_RMT
#include <driver/rmt.h>
#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 <driver/pcnt.h>
#include <driver/periph_ctrl.h>
#include <driver/rmt.h>
#include <soc/pcnt_reg.h>
#include <soc/pcnt_struct.h>
#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 <driver/mcpwm.h>
#include <driver/pcnt.h>
#include <soc/mcpwm_reg.h>
#include <soc/mcpwm_struct.h>
#include <soc/pcnt_reg.h>
#include <soc/pcnt_struct.h>

#define SUPPORT_ESP32_RMT
#define SUPPORT_ESP32S3_RMT
#include <driver/periph_ctrl.h>
#include <driver/rmt.h>
#include <soc/rmt_periph.h>
#include <soc/rmt_reg.h>
#include <soc/rmt_struct.h>
#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 <driver/periph_ctrl.h>
#include <driver/rmt.h>
#include <soc/rmt_periph.h>
#include <soc/rmt_reg.h>
#include <soc/rmt_struct.h>
#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 <driver/periph_ctrl.h>
#include <soc/periph_defs.h>
#include <soc/rmt_periph.h>
#include <soc/rmt_reg.h>
#include <soc/rmt_struct.h>
#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 <driver/periph_ctrl.h>
#include <soc/periph_defs.h>
#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 */
Loading

0 comments on commit 46d8cab

Please sign in to comment.