Skip to content

Commit 8e1e93c

Browse files
committed
Rename low-side ADC path labels from legacy to ADC_READ.
Wrap ESP32 digi ADC sources in ARDUINO_ARCH_ESP32 guards so AVR CI builds do not pull sdkconfig.h; include esp32_mcu.h before MCPWM guard in lowside.cpp so C6 links the low-side helpers.
1 parent b4aaeb0 commit 8e1e93c

9 files changed

Lines changed: 36 additions & 37 deletions

src/current_sense/hardware_specific/esp32/esp32_adc_digi_driver.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
* - ETM: ESP32-S3 and newer only; see esp32_adc_etm.c.
1111
*/
1212

13-
#include "sdkconfig.h"
13+
#if defined(ARDUINO_ARCH_ESP32)
14+
1415
#include "esp32_adc_digi_internal.h"
1516

1617
#if SIMPLEFOC_ESP32_ADC_DIGI_SUPPORTED
@@ -443,4 +444,5 @@ esp_err_t esp32_adc_digi_trigger_software(void)
443444
return ESP_OK;
444445
}
445446

446-
#endif
447+
#endif /* SIMPLEFOC_ESP32_ADC_DIGI_SUPPORTED */
448+
#endif /* ARDUINO_ARCH_ESP32 */

src/current_sense/hardware_specific/esp32/esp32_adc_digi_driver.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
*/
99
#pragma once
1010

11-
#include "sdkconfig.h"
11+
#if defined(ARDUINO_ARCH_ESP32)
12+
1213
#include "esp_err.h"
1314
#include "hal/adc_types.h"
1415
#include "esp32_adc_digi_internal.h"
@@ -52,3 +53,4 @@ bool esp32_adc_digi_etm_supported(void);
5253
#endif
5354

5455
#endif /* SIMPLEFOC_ESP32_ADC_DIGI_SUPPORTED */
56+
#endif /* ARDUINO_ARCH_ESP32 */

src/current_sense/hardware_specific/esp32/esp32_adc_digi_internal.h

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
*/
66
#pragma once
77

8+
#if !defined(ARDUINO_ARCH_ESP32)
9+
10+
#define SIMPLEFOC_ESP32_ADC_DIGI_SUPPORTED 0
11+
#define SIMPLEFOC_ESP32_ADC_ETM_SUPPORTED 0
12+
13+
#else
14+
815
#include <stdbool.h>
916
#include <stdint.h>
1017
#include "sdkconfig.h"
@@ -29,36 +36,21 @@
2936
* - ESP32-S3+: GDMA (esp32_adc_dma_gdma.c)
3037
*/
3138

32-
#if defined(ARDUINO_ARCH_ESP32)
33-
3439
#define SIMPLEFOC_ESP32_ADC_DIGI_SUPPORTED 1
3540

36-
/* ETM is not available on original ESP32 or ESP32-S2. */
3741
#if SOC_ETM_SUPPORTED && !CONFIG_IDF_TARGET_ESP32 && !CONFIG_IDF_TARGET_ESP32S2
3842
#define SIMPLEFOC_ESP32_ADC_ETM_SUPPORTED 1
3943
#else
4044
#define SIMPLEFOC_ESP32_ADC_ETM_SUPPORTED 0
4145
#endif
4246

43-
#else
44-
45-
#define SIMPLEFOC_ESP32_ADC_DIGI_SUPPORTED 0
46-
#define SIMPLEFOC_ESP32_ADC_ETM_SUPPORTED 0
47-
48-
#endif
49-
50-
/* Pattern / DMA sizing — kept aligned with espFoC isensor_adc_internal.h */
5147
#define SIMPLEFOC_ESP32_ADC_PATTERN_HZ 80000
5248
#define SIMPLEFOC_ESP32_ADC_NUM_CHANNELS 2
5349
#define SIMPLEFOC_ESP32_ADC_CONVERT_LIMIT 2
5450

5551
#define ESP32_ADC_DIGI_FRAME_BYTES \
5652
(SIMPLEFOC_ESP32_ADC_NUM_CHANNELS * SOC_ADC_DIGI_RESULT_BYTES)
5753

58-
/*
59-
* DMA writes adc_digi_output_data_t[N] into adc_buffer (zero-copy).
60-
* int adc_buffer[3] must be DMA-capable and >= ESP32_ADC_DIGI_FRAME_BYTES used bytes.
61-
*/
6254
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
6355
#define ESP32_ADC_DIGI_SAMPLE_RAW(p) ((int32_t)((p)->type1.data))
6456
#else
@@ -106,3 +98,5 @@ esp_err_t esp32_adc_digi_etm_enable(bool enable);
10698
void esp32_adc_digi_etm_disconnect(void);
10799

108100
#endif /* SIMPLEFOC_ESP32_ADC_ETM_SUPPORTED */
101+
102+
#endif /* ARDUINO_ARCH_ESP32 */

src/current_sense/hardware_specific/esp32/esp32_adc_digi_lowside.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
#include "esp32_adc_digi_lowside.h"
1+
#include "esp32_mcu.h"
2+
3+
#if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) && defined(SOC_MCPWM_SUPPORTED) \
4+
&& !defined(SIMPLEFOC_ESP32_USELEDC)
25

3-
#if SIMPLEFOC_ESP32_ADC_DIGI_SUPPORTED && defined(SOC_MCPWM_SUPPORTED) && !defined(SIMPLEFOC_ESP32_USELEDC)
6+
#include "esp32_adc_digi_lowside.h"
47

58
#include "esp32_adc_digi_driver.h"
69
#include "../../../drivers/hardware_specific/esp32/esp32_driver_mcpwm.h"
@@ -47,12 +50,12 @@ static esp_err_t esp32_adc_digi_bind_params(ESP32CurrentSenseParams *params)
4750
ESP32AdcLowsidePath esp32_adc_lowside_configure(ESP32CurrentSenseParams *params)
4851
{
4952
if (params == NULL || !esp32_adc_digi_supported()) {
50-
return ESP32_ADC_LOWSIDE_LEGACY;
53+
return ESP32_ADC_LOWSIDE_ADC_READ;
5154
}
5255

5356
if (esp32_adc_digi_bind_params(params) != ESP_OK) {
54-
SIMPLEFOC_ESP32_CS_DEBUG("WARN: ADC digi+DMA init failed, using legacy adcRead path");
55-
return ESP32_ADC_LOWSIDE_LEGACY;
57+
SIMPLEFOC_ESP32_CS_DEBUG("WARN: ADC digi+DMA init failed, using ADC_READ (adcRead) path");
58+
return ESP32_ADC_LOWSIDE_ADC_READ;
5659
}
5760

5861
params->adc_lowside_path = ESP32_ADC_LOWSIDE_DIGI_SW;
@@ -191,7 +194,7 @@ void *esp32_adc_lowside_sync_mcpwm(void *driver_params, ESP32CurrentSenseParams
191194
}
192195

193196
#if SIMPLEFOC_ESP32_ADC_ETM_SUPPORTED
194-
if (esp32_adc_digi_etm_supported() && cs->adc_lowside_path != ESP32_ADC_LOWSIDE_LEGACY) {
197+
if (esp32_adc_digi_etm_supported() && cs->adc_lowside_path != ESP32_ADC_LOWSIDE_ADC_READ) {
195198
return esp32_adc_lowside_sync_etm(driver_params, cs);
196199
}
197200
#endif

src/current_sense/hardware_specific/esp32/esp32_adc_digi_lowside.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
*/
88
#pragma once
99

10+
#if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) && defined(SOC_MCPWM_SUPPORTED) \
11+
&& !defined(SIMPLEFOC_ESP32_USELEDC)
12+
1013
#include "esp32_adc_digi_internal.h"
1114

12-
#if SIMPLEFOC_ESP32_ADC_DIGI_SUPPORTED && defined(SOC_MCPWM_SUPPORTED) && !defined(SIMPLEFOC_ESP32_USELEDC)
15+
#if SIMPLEFOC_ESP32_ADC_DIGI_SUPPORTED
1316

1417
#include "esp32_mcu.h"
1518

@@ -18,4 +21,5 @@ bool esp32_adc_lowside_uses_mcpwm_isr(const ESP32CurrentSenseParams *params);
1821
void *esp32_adc_lowside_sync_mcpwm(void *driver_params, ESP32CurrentSenseParams *cs);
1922
void esp32_adc_lowside_start_conversion(void);
2023

24+
#endif /* SIMPLEFOC_ESP32_ADC_DIGI_SUPPORTED */
2125
#endif

src/current_sense/hardware_specific/esp32/esp32_adc_dma_esp32.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
* I2S DMA backend for ADC digi on ESP32 (i2s_ll only).
77
*/
88

9-
#include "sdkconfig.h"
10-
11-
#if CONFIG_IDF_TARGET_ESP32
9+
#if defined(ARDUINO_ARCH_ESP32) && CONFIG_IDF_TARGET_ESP32
1210

1311
#include "esp_err.h"
1412
#include "esp_intr_alloc.h"

src/current_sense/hardware_specific/esp32/esp32_adc_dma_esp32s2.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
* SPI3 DMA backend for ADC digi on ESP32-S2 (spi_ll + spicommon).
77
*/
88

9-
#include "sdkconfig.h"
10-
11-
#if CONFIG_IDF_TARGET_ESP32S2
9+
#if defined(ARDUINO_ARCH_ESP32) && CONFIG_IDF_TARGET_ESP32S2
1210

1311
#include "esp_err.h"
1412
#include "esp_intr_alloc.h"

src/current_sense/hardware_specific/esp32/esp32_adc_dma_gdma.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
* GDMA RX backend for ADC digi (ESP32-S3, C3, C6, …) using gdma_hal + gdma_ll only.
77
*/
88

9-
#include "sdkconfig.h"
10-
11-
#if !CONFIG_IDF_TARGET_ESP32 && !CONFIG_IDF_TARGET_ESP32S2
9+
#if defined(ARDUINO_ARCH_ESP32) && !CONFIG_IDF_TARGET_ESP32 && !CONFIG_IDF_TARGET_ESP32S2
1210

1311
#include "esp_err.h"
1412
#include "esp_intr_alloc.h"

src/current_sense/hardware_specific/esp32/esp32_adc_etm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* ETM wiring: MCPWM timer event -> ADC digi START task.
77
*/
88

9-
#include "sdkconfig.h"
9+
#if defined(ARDUINO_ARCH_ESP32)
10+
1011
#include "esp32_adc_digi_internal.h"
1112

1213
#if SIMPLEFOC_ESP32_ADC_ETM_SUPPORTED
@@ -19,8 +20,6 @@
1920
#include "esp_private/etm_interface.h"
2021
#include "soc/soc_caps.h"
2122
#include "soc/soc_etm_source.h"
22-
#include "esp32_adc_digi_internal.h"
23-
2423
static const char *TAG = "esp32_adc_etm";
2524

2625
typedef struct {
@@ -157,3 +156,4 @@ void esp32_adc_digi_etm_disconnect(void)
157156
}
158157

159158
#endif /* SIMPLEFOC_ESP32_ADC_ETM_SUPPORTED */
159+
#endif /* ARDUINO_ARCH_ESP32 */

0 commit comments

Comments
 (0)