mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-24 08:33:45 +02:00
refactor(Monitoring): abstract platform-specific ADC code and add ESP32-S2 support
- Move calibration functions to platform-specific files - Add ADC_SAMPLER_SUPPORTED macro for unified platform detection - Add ESP32-S2 support (UNTESTED) - Remove explicit #if defined() macros from common code
This commit is contained in:
@@ -9,14 +9,30 @@
|
||||
# +-----------------------+
|
||||
# | ESP-IDF ADC HAL | ← Espressif official driver
|
||||
# +-----------------------+
|
||||
#
|
||||
# Supported platforms (must support ESP-CAM):
|
||||
# - ESP32: Tested
|
||||
# - ESP32-S3: Tested
|
||||
# - ESP32-S2: UNTESTED - Based on datasheet
|
||||
|
||||
set(
|
||||
requires
|
||||
Helpers
|
||||
)
|
||||
|
||||
# List of supported ADC platforms (aligned with ESP_CAMERA_SUPPORTED)
|
||||
set(ADC_SUPPORTED_TARGETS "esp32" "esp32s3" "esp32s2")
|
||||
|
||||
# Check if current target supports ADC
|
||||
list(FIND ADC_SUPPORTED_TARGETS "$ENV{IDF_TARGET}" ADC_TARGET_INDEX)
|
||||
if (NOT ADC_TARGET_INDEX EQUAL -1)
|
||||
set(ADC_SAMPLER_SUPPORTED TRUE)
|
||||
else()
|
||||
set(ADC_SAMPLER_SUPPORTED FALSE)
|
||||
endif()
|
||||
|
||||
# Platform-specific dependencies
|
||||
if ("$ENV{IDF_TARGET}" STREQUAL "esp32s3" OR "$ENV{IDF_TARGET}" STREQUAL "esp32")
|
||||
if (ADC_SAMPLER_SUPPORTED)
|
||||
list(APPEND requires
|
||||
driver
|
||||
esp_adc
|
||||
@@ -32,22 +48,20 @@ set(
|
||||
)
|
||||
|
||||
# BSP Layer: ADC sampler implementation
|
||||
if ("$ENV{IDF_TARGET}" STREQUAL "esp32s3" OR "$ENV{IDF_TARGET}" STREQUAL "esp32")
|
||||
# Common ADC implementation
|
||||
list(APPEND source_files
|
||||
"Monitoring/AdcSampler.cpp"
|
||||
if (ADC_SAMPLER_SUPPORTED)
|
||||
# Common ADC implementation
|
||||
list(APPEND source_files
|
||||
"Monitoring/AdcSampler.cpp"
|
||||
)
|
||||
|
||||
# Platform-specific GPIO-to-channel mapping
|
||||
if ("$ENV{IDF_TARGET}" STREQUAL "esp32s3")
|
||||
list(APPEND source_files
|
||||
"Monitoring/AdcSampler_esp32s3.cpp"
|
||||
)
|
||||
elseif ("$ENV{IDF_TARGET}" STREQUAL "esp32")
|
||||
list(APPEND source_files
|
||||
"Monitoring/AdcSampler_esp32.cpp"
|
||||
)
|
||||
endif()
|
||||
# Platform-specific GPIO-to-channel mapping and calibration
|
||||
if ("$ENV{IDF_TARGET}" STREQUAL "esp32s3")
|
||||
list(APPEND source_files "Monitoring/AdcSampler_esp32s3.cpp")
|
||||
elseif ("$ENV{IDF_TARGET}" STREQUAL "esp32s2")
|
||||
list(APPEND source_files "Monitoring/AdcSampler_esp32s2.cpp")
|
||||
elseif ("$ENV{IDF_TARGET}" STREQUAL "esp32")
|
||||
list(APPEND source_files "Monitoring/AdcSampler_esp32.cpp")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user