From fb9f57ac9b1efd9611004dfc3663c110b93d0c1e Mon Sep 17 00:00:00 2001 From: Richard Unger Date: Mon, 30 Oct 2023 20:38:38 +0100 Subject: [PATCH 1/7] remove deprecated header --- src/current_sense/hardware_specific/esp32/esp32_adc_driver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/current_sense/hardware_specific/esp32/esp32_adc_driver.cpp b/src/current_sense/hardware_specific/esp32/esp32_adc_driver.cpp index 807c387d..6581de87 100644 --- a/src/current_sense/hardware_specific/esp32/esp32_adc_driver.cpp +++ b/src/current_sense/hardware_specific/esp32/esp32_adc_driver.cpp @@ -6,7 +6,7 @@ #include "freertos/task.h" #include "rom/ets_sys.h" #include "esp_attr.h" -#include "esp_intr.h" +//#include "esp_intr.h" deprecated #include "soc/rtc_io_reg.h" #include "soc/rtc_cntl_reg.h" #include "soc/sens_reg.h" From e28f0cde02318c0b6b030c1ad238b3de4cb0ea9d Mon Sep 17 00:00:00 2001 From: Richard Unger Date: Mon, 30 Oct 2023 21:05:14 +0100 Subject: [PATCH 2/7] change cast to make ESP32 compiler happy --- src/common/foc_utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/foc_utils.cpp b/src/common/foc_utils.cpp index 9136dd73..071e70cd 100644 --- a/src/common/foc_utils.cpp +++ b/src/common/foc_utils.cpp @@ -92,9 +92,9 @@ __attribute__((weak)) float _sqrtApprox(float number) {//low in fat // x = number * 0.5F; float y = number; - long i = * ( long * ) &y; + uint32_t i = *reinterpret_cast(&y); i = 0x5f375a86 - ( i >> 1 ); - y = * ( float * ) &i; + y = *reinterpret_cast(&i); // y = y * ( f - ( x * y * y ) ); // better precision return number * y; } From 9b3037b2f8e6221f9374466f190a35217b291c81 Mon Sep 17 00:00:00 2001 From: Richard Unger Date: Mon, 30 Oct 2023 21:12:05 +0100 Subject: [PATCH 3/7] fix missing extension in workflow file --- .github/workflows/ccpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 5c50bb1e..1ec45f72 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -59,7 +59,7 @@ jobs: - arduino-boards-fqbn: esp32:esp32:esp32s2 # esp32s2 platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json - sketch-names: bldc_driver_3pwm_standalone.ino, stepper_driver_2pwm_standalone.ino, stepper_driver_4pwm_standalone + sketch-names: bldc_driver_3pwm_standalone.ino,stepper_driver_2pwm_standalone.ino,stepper_driver_4pwm_standalone.ino - arduino-boards-fqbn: esp32:esp32:esp32s3 # esp32s3 platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json From 3dd61bbf0f145a30fc4c78aa47490859daa7a76b Mon Sep 17 00:00:00 2001 From: Richard Unger Date: Mon, 30 Oct 2023 21:16:01 +0100 Subject: [PATCH 4/7] deconfuse esp32 compiler --- src/common/foc_utils.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/foc_utils.cpp b/src/common/foc_utils.cpp index 071e70cd..e29a0901 100644 --- a/src/common/foc_utils.cpp +++ b/src/common/foc_utils.cpp @@ -91,7 +91,8 @@ __attribute__((weak)) float _sqrtApprox(float number) {//low in fat // const float f = 1.5F; // better precision // x = number * 0.5F; - float y = number; + float y; + y = number; uint32_t i = *reinterpret_cast(&y); i = 0x5f375a86 - ( i >> 1 ); y = *reinterpret_cast(&i); From 839e293ff7892d3f764387b2d0c4cad2ca4c2ce4 Mon Sep 17 00:00:00 2001 From: Richard Unger Date: Mon, 30 Oct 2023 21:31:02 +0100 Subject: [PATCH 5/7] trying to fix sqrt compiler issue on esp32 --- src/common/foc_utils.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/common/foc_utils.cpp b/src/common/foc_utils.cpp index e29a0901..233bd246 100644 --- a/src/common/foc_utils.cpp +++ b/src/common/foc_utils.cpp @@ -87,15 +87,10 @@ float _electricalAngle(float shaft_angle, int pole_pairs) { // https://reprap.org/forum/read.php?147,219210 // https://en.wikipedia.org/wiki/Fast_inverse_square_root __attribute__((weak)) float _sqrtApprox(float number) {//low in fat - // float x; - // const float f = 1.5F; // better precision - - // x = number * 0.5F; - float y; - y = number; - uint32_t i = *reinterpret_cast(&y); - i = 0x5f375a86 - ( i >> 1 ); - y = *reinterpret_cast(&i); - // y = y * ( f - ( x * y * y ) ); // better precision - return number * y; + union { + float f; + uint32_t i; + } y = { .f = number }; + y.i = 0x5f375a86 - ( y.i >> 1 ); + return number * y.f; } From c39ea37addc3c2811cb9c8021e0d82fcce3d5c4f Mon Sep 17 00:00:00 2001 From: Richard Unger Date: Mon, 30 Oct 2023 22:28:24 +0100 Subject: [PATCH 6/7] fix esp32 compiler warnings --- src/current_sense/hardware_specific/esp32/esp32_adc_driver.cpp | 1 + src/current_sense/hardware_specific/esp32/esp32_mcu.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/current_sense/hardware_specific/esp32/esp32_adc_driver.cpp b/src/current_sense/hardware_specific/esp32/esp32_adc_driver.cpp index 6581de87..9cd1b34e 100644 --- a/src/current_sense/hardware_specific/esp32/esp32_adc_driver.cpp +++ b/src/current_sense/hardware_specific/esp32/esp32_adc_driver.cpp @@ -7,6 +7,7 @@ #include "rom/ets_sys.h" #include "esp_attr.h" //#include "esp_intr.h" deprecated +#include "esp_intr_alloc.h" #include "soc/rtc_io_reg.h" #include "soc/rtc_cntl_reg.h" #include "soc/sens_reg.h" diff --git a/src/current_sense/hardware_specific/esp32/esp32_mcu.cpp b/src/current_sense/hardware_specific/esp32/esp32_mcu.cpp index 3df9dff6..2057463c 100644 --- a/src/current_sense/hardware_specific/esp32/esp32_mcu.cpp +++ b/src/current_sense/hardware_specific/esp32/esp32_mcu.cpp @@ -121,6 +121,8 @@ void _driverSyncLowSide(void* driver_params, void* cs_params){ mcpwm_isr_register(mcpwm_unit, mcpwm1_isr_handler, NULL, ESP_INTR_FLAG_IRAM, NULL); //Set ISR Handler } +static void IRAM_ATTR mcpwm0_isr_handler(void*) __attribute__ ((unused)); + // Read currents when interrupt is triggered static void IRAM_ATTR mcpwm0_isr_handler(void*){ // // high side @@ -139,6 +141,7 @@ static void IRAM_ATTR mcpwm0_isr_handler(void*){ // MCPWM0.int_clr.timer0_tez_int_clr = mcpwm_intr_status_0; } +static void IRAM_ATTR mcpwm1_isr_handler(void*) __attribute__ ((unused)); // Read currents when interrupt is triggered static void IRAM_ATTR mcpwm1_isr_handler(void*){ From f39aa92a762695d8b577ca8965762095d92b1cc6 Mon Sep 17 00:00:00 2001 From: Richard Unger Date: Mon, 30 Oct 2023 23:38:10 +0100 Subject: [PATCH 7/7] don't use dev platform for esp32 tests --- .github/workflows/ccpp.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 1ec45f72..6c396ea9 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -58,15 +58,15 @@ jobs: sketch-names: single_full_control_example.ino - arduino-boards-fqbn: esp32:esp32:esp32s2 # esp32s2 - platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json + platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json sketch-names: bldc_driver_3pwm_standalone.ino,stepper_driver_2pwm_standalone.ino,stepper_driver_4pwm_standalone.ino - arduino-boards-fqbn: esp32:esp32:esp32s3 # esp32s3 - platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json + platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json sketch-names: esp32_position_control.ino, esp32_i2c_dual_bus_example.ino - arduino-boards-fqbn: esp32:esp32:esp32doit-devkit-v1 # esp32 - platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json + platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json sketch-names: esp32_position_control.ino, esp32_i2c_dual_bus_example.ino, esp32_current_control_low_side.ino, esp32_spi_alt_example.ino - arduino-boards-fqbn: STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 # bluepill - hs examples