From cf4cfc69ed2e4b230bc3053109110b4b3b1f1148 Mon Sep 17 00:00:00 2001 From: morris Date: Tue, 2 Aug 2022 17:53:32 +0800 Subject: [PATCH] esp_adc: add test with -O0 --- components/esp_adc/test_apps/adc/sdkconfig.ci.iram_safe | 3 +++ components/hal/esp32/include/hal/adc_ll.h | 2 ++ components/hal/esp32c2/include/hal/adc_ll.h | 4 ++++ components/hal/esp32c3/include/hal/adc_ll.h | 6 ++++++ components/hal/esp32h2/include/hal/adc_ll.h | 5 +++++ components/hal/esp32s2/include/hal/adc_ll.h | 6 ++++++ components/hal/esp32s2/include/hal/spi_ll.h | 5 +++++ components/hal/esp32s3/include/hal/adc_ll.h | 6 ++++++ components/hal/linker.lf | 8 +++++--- 9 files changed, 42 insertions(+), 3 deletions(-) diff --git a/components/esp_adc/test_apps/adc/sdkconfig.ci.iram_safe b/components/esp_adc/test_apps/adc/sdkconfig.ci.iram_safe index f8f19f5dff..45fabc5404 100644 --- a/components/esp_adc/test_apps/adc/sdkconfig.ci.iram_safe +++ b/components/esp_adc/test_apps/adc/sdkconfig.ci.iram_safe @@ -2,5 +2,8 @@ CONFIG_COMPILER_DUMP_RTL_FILES=y CONFIG_ADC_ONESHOT_CTRL_FUNC_IN_IRAM=y CONFIG_GPTIMER_ISR_IRAM_SAFE=y CONFIG_ADC_CONTINUOUS_ISR_IRAM_SAFE=y +CONFIG_COMPILER_OPTIMIZATION_NONE=y # silent the error check, as the error string are stored in rodata, causing RTL check failure CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y +CONFIG_HAL_ASSERTION_SILENT=y diff --git a/components/hal/esp32/include/hal/adc_ll.h b/components/hal/esp32/include/hal/adc_ll.h index 23e9205e2a..d4dd029acf 100644 --- a/components/hal/esp32/include/hal/adc_ll.h +++ b/components/hal/esp32/include/hal/adc_ll.h @@ -519,6 +519,7 @@ static inline void adc_oneshot_ll_set_atten(adc_unit_t adc_n, adc_channel_t chan * @param channel ADCn channel number. * @return atten The attenuation option. */ +__attribute__((always_inline)) static inline adc_atten_t adc_ll_get_atten(adc_unit_t adc_n, adc_channel_t channel) { if (adc_n == ADC_UNIT_1) { @@ -578,6 +579,7 @@ static inline void adc_ll_set_power_manage(adc_ll_power_t manage) * @param adc_n ADC unit. * @param ctrl ADC controller. */ +__attribute__((always_inline)) static inline void adc_ll_set_controller(adc_unit_t adc_n, adc_ll_controller_t ctrl) { if (adc_n == ADC_UNIT_1) { diff --git a/components/hal/esp32c2/include/hal/adc_ll.h b/components/hal/esp32c2/include/hal/adc_ll.h index 775200cf12..5a18f6ec1e 100644 --- a/components/hal/esp32c2/include/hal/adc_ll.h +++ b/components/hal/esp32c2/include/hal/adc_ll.h @@ -303,6 +303,7 @@ static inline void adc_ll_set_power_manage(adc_ll_power_t manage) } } +__attribute__((always_inline)) static inline void adc_ll_set_controller(adc_unit_t adc_n, adc_ll_controller_t ctrl) { //Not used on ESP32-C2 @@ -312,6 +313,7 @@ static inline void adc_ll_set_controller(adc_unit_t adc_n, adc_ll_controller_t c /** * @brief Set common calibration configuration. Should be shared with other parts (PWDET). */ +__attribute__((always_inline)) static inline void adc_ll_calibration_init(adc_unit_t adc_n) { abort(); //TODO IDF-3908 @@ -373,6 +375,7 @@ static inline void adc_ll_calibration_finish(adc_unit_t adc_n) * * @param adc_n ADC index number. */ +__attribute__((always_inline)) static inline void adc_ll_set_calibration_param(adc_unit_t adc_n, uint32_t param) { abort(); //TODO IDF-3908 @@ -554,6 +557,7 @@ static inline void adc_oneshot_ll_set_atten(adc_unit_t adc_n, adc_channel_t chan * @param channel ADCn channel number. * @return atten The attenuation option. */ +__attribute__((always_inline)) static inline adc_atten_t adc_ll_get_atten(adc_unit_t adc_n, adc_channel_t channel) { (void)adc_n; diff --git a/components/hal/esp32c3/include/hal/adc_ll.h b/components/hal/esp32c3/include/hal/adc_ll.h index 2ebd50501d..399044390d 100644 --- a/components/hal/esp32c3/include/hal/adc_ll.h +++ b/components/hal/esp32c3/include/hal/adc_ll.h @@ -491,6 +491,7 @@ static inline void adc_ll_set_power_manage(adc_ll_power_t manage) } } +__attribute__((always_inline)) static inline void adc_ll_set_controller(adc_unit_t adc_n, adc_ll_controller_t ctrl) { //Not used on ESP32C3 @@ -506,6 +507,7 @@ static inline void adc_ll_set_controller(adc_unit_t adc_n, adc_ll_controller_t c * * @param mode Refer to `adc_arbiter_mode_t`. */ +__attribute__((always_inline)) static inline void adc_ll_set_arbiter_work_mode(adc_arbiter_mode_t mode) { if (mode == ADC_ARB_MODE_FIX) { @@ -532,6 +534,7 @@ static inline void adc_ll_set_arbiter_work_mode(adc_arbiter_mode_t mode) * @param pri_dig Digital controller priority. Range: 0 ~ 2. * @param pri_pwdet Wi-Fi controller priority. Range: 0 ~ 2. */ +__attribute__((always_inline)) static inline void adc_ll_set_arbiter_priority(uint8_t pri_rtc, uint8_t pri_dig, uint8_t pri_pwdet) { if (pri_rtc != pri_dig && pri_rtc != pri_pwdet && pri_dig != pri_pwdet) { @@ -567,6 +570,7 @@ static inline void adc_ll_set_arbiter_priority(uint8_t pri_rtc, uint8_t pri_dig, /** * @brief Set common calibration configuration. Should be shared with other parts (PWDET). */ +__attribute__((always_inline)) static inline void adc_ll_calibration_init(adc_unit_t adc_n) { if (adc_n == ADC_UNIT_1) { @@ -624,6 +628,7 @@ static inline void adc_ll_calibration_finish(adc_unit_t adc_n) * * @param adc_n ADC index number. */ +__attribute__((always_inline)) static inline void adc_ll_set_calibration_param(adc_unit_t adc_n, uint32_t param) { uint8_t msb = param >> 8; @@ -875,6 +880,7 @@ static inline void adc_oneshot_ll_set_atten(adc_unit_t adc_n, adc_channel_t chan * @param channel ADCn channel number. * @return atten The attenuation option. */ +__attribute__((always_inline)) static inline adc_atten_t adc_ll_get_atten(adc_unit_t adc_n, adc_channel_t channel) { (void)adc_n; diff --git a/components/hal/esp32h2/include/hal/adc_ll.h b/components/hal/esp32h2/include/hal/adc_ll.h index bdef1ceac0..bdc13d9f13 100644 --- a/components/hal/esp32h2/include/hal/adc_ll.h +++ b/components/hal/esp32h2/include/hal/adc_ll.h @@ -521,6 +521,7 @@ static inline void adc_ll_set_power_manage(adc_ll_power_t manage) } } +__attribute__((always_inline)) static inline void adc_ll_set_controller(adc_unit_t adc_n, adc_ll_controller_t ctrl) { //Not used on ESP32H2 @@ -536,6 +537,7 @@ static inline void adc_ll_set_controller(adc_unit_t adc_n, adc_ll_controller_t c * * @param mode Refer to `adc_arbiter_mode_t`. */ +__attribute__((always_inline)) static inline void adc_ll_set_arbiter_work_mode(adc_arbiter_mode_t mode) { if (mode == ADC_ARB_MODE_FIX) { @@ -562,6 +564,7 @@ static inline void adc_ll_set_arbiter_work_mode(adc_arbiter_mode_t mode) * @param pri_dig Digital controller priority. Range: 0 ~ 2. * @param pri_pwdet Wi-Fi controller priority. Range: 0 ~ 2. */ +__attribute__((always_inline)) static inline void adc_ll_set_arbiter_priority(uint8_t pri_rtc, uint8_t pri_dig, uint8_t pri_pwdet) { if (pri_rtc != pri_dig && pri_rtc != pri_pwdet && pri_dig != pri_pwdet) { @@ -597,6 +600,7 @@ static inline void adc_ll_set_arbiter_priority(uint8_t pri_rtc, uint8_t pri_dig, /** * @brief Set common calibration configuration. Should be shared with other parts (PWDET). */ +__attribute__((always_inline)) static inline void adc_ll_calibration_init(adc_unit_t adc_n) { if (adc_n == ADC_UNIT_1) { @@ -655,6 +659,7 @@ static inline void adc_ll_calibration_finish(adc_unit_t adc_n) * * @param adc_n ADC index number. */ +__attribute__((always_inline)) static inline void adc_ll_set_calibration_param(adc_unit_t adc_n, uint32_t param) { uint8_t msb = param >> 8; diff --git a/components/hal/esp32s2/include/hal/adc_ll.h b/components/hal/esp32s2/include/hal/adc_ll.h index 2f99cf7b61..0120e427e0 100644 --- a/components/hal/esp32s2/include/hal/adc_ll.h +++ b/components/hal/esp32s2/include/hal/adc_ll.h @@ -837,6 +837,7 @@ static inline void adc_oneshot_ll_set_atten(adc_unit_t adc_n, adc_channel_t chan * @param channel ADCn channel number. * @return atten The attenuation option. */ +__attribute__((always_inline)) static inline adc_atten_t adc_ll_get_atten(adc_unit_t adc_n, adc_channel_t channel) { if (adc_n == ADC_UNIT_1) { @@ -899,6 +900,7 @@ static inline void adc_ll_set_power_manage(adc_ll_power_t manage) * @param adc_n ADC unit. * @param ctrl ADC controller. */ +__attribute__((always_inline)) static inline void adc_ll_set_controller(adc_unit_t adc_n, adc_ll_controller_t ctrl) { if (adc_n == ADC_UNIT_1) { @@ -948,6 +950,7 @@ static inline void adc_ll_set_controller(adc_unit_t adc_n, adc_ll_controller_t c * * @param mode Refer to ``adc_arbiter_mode_t``. */ +__attribute__((always_inline)) static inline void adc_ll_set_arbiter_work_mode(adc_arbiter_mode_t mode) { SENS.sar_meas2_mux.sar2_rtc_force = 0; // Enable arbiter in wakeup mode @@ -975,6 +978,7 @@ static inline void adc_ll_set_arbiter_work_mode(adc_arbiter_mode_t mode) * @param pri_dig Digital controller priority. Range: 0 ~ 2. * @param pri_pwdet Wi-Fi controller priority. Range: 0 ~ 2. */ +__attribute__((always_inline)) static inline void adc_ll_set_arbiter_priority(uint8_t pri_rtc, uint8_t pri_dig, uint8_t pri_pwdet) { if (pri_rtc != pri_dig && pri_rtc != pri_pwdet && pri_dig != pri_pwdet) { @@ -1038,6 +1042,7 @@ static inline void adc_ll_disable_sleep_controller(void) /** * @brief Set common calibration configuration. Should be shared with other parts (PWDET). */ +__attribute__((always_inline)) static inline void adc_ll_calibration_init(adc_unit_t adc_n) { if (adc_n == ADC_UNIT_1) { @@ -1101,6 +1106,7 @@ static inline void adc_ll_calibration_finish(adc_unit_t adc_n) * * @param adc_n ADC index number. */ +__attribute__((always_inline)) static inline void adc_ll_set_calibration_param(adc_unit_t adc_n, uint32_t param) { uint8_t msb = param >> 8; diff --git a/components/hal/esp32s2/include/hal/spi_ll.h b/components/hal/esp32s2/include/hal/spi_ll.h index b975206d0f..9b0fa420ec 100644 --- a/components/hal/esp32s2/include/hal/spi_ll.h +++ b/components/hal/esp32s2/include/hal/spi_ll.h @@ -969,6 +969,7 @@ static inline uint32_t spi_ll_slave_get_rcv_bitlen(spi_dev_t *hw) item(SPI_LL_INTR_CMDA, dma_int_ena.cmda, dma_int_raw.cmda, dma_int_clr.cmda=1) +__attribute__((always_inline)) static inline void spi_ll_enable_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) { #define ENA_INTR(intr_bit, en_reg, ...) if (intr_mask & (intr_bit)) hw->en_reg = 1; @@ -976,6 +977,7 @@ static inline void spi_ll_enable_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) #undef ENA_INTR } +__attribute__((always_inline)) static inline void spi_ll_disable_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) { #define DIS_INTR(intr_bit, en_reg, ...) if (intr_mask & (intr_bit)) hw->en_reg = 0; @@ -990,6 +992,7 @@ static inline void spi_ll_set_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) #undef SET_INTR } +__attribute__((always_inline)) static inline void spi_ll_clear_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) { #define CLR_INTR(intr_bit, _, __, clr_reg) if (intr_mask & (intr_bit)) hw->clr_reg; @@ -997,6 +1000,7 @@ static inline void spi_ll_clear_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) #undef CLR_INTR } +__attribute__((always_inline)) static inline bool spi_ll_get_intr(spi_dev_t *hw, spi_ll_intr_t intr_mask) { #define GET_INTR(intr_bit, _, st_reg, ...) if (intr_mask & (intr_bit) && hw->st_reg) return true; @@ -1142,6 +1146,7 @@ static inline void spi_dma_ll_rx_enable_burst_desc(spi_dma_dev_t *dma_in, uint32 * @param channel DMA channel, for chip version compatibility, not used. * @return The address */ +__attribute__((always_inline)) static inline uint32_t spi_dma_ll_get_in_suc_eof_desc_addr(spi_dma_dev_t *dma_in, uint32_t channel) { return dma_in->dma_in_suc_eof_des_addr; diff --git a/components/hal/esp32s3/include/hal/adc_ll.h b/components/hal/esp32s3/include/hal/adc_ll.h index ae4384c9bb..7dbd63f665 100644 --- a/components/hal/esp32s3/include/hal/adc_ll.h +++ b/components/hal/esp32s3/include/hal/adc_ll.h @@ -552,6 +552,7 @@ static inline void adc_ll_set_power_manage(adc_ll_power_t manage) * @param adc_n ADC unit. * @param ctrl ADC controller. */ +__attribute__((always_inline)) static inline void adc_ll_set_controller(adc_unit_t adc_n, adc_ll_controller_t ctrl) { if (adc_n == ADC_UNIT_1) { @@ -601,6 +602,7 @@ static inline void adc_ll_set_controller(adc_unit_t adc_n, adc_ll_controller_t c * * @param mode Refer to `adc_arbiter_mode_t`. */ +__attribute__((always_inline)) static inline void adc_ll_set_arbiter_work_mode(adc_arbiter_mode_t mode) { if (mode == ADC_ARB_MODE_FIX) { @@ -627,6 +629,7 @@ static inline void adc_ll_set_arbiter_work_mode(adc_arbiter_mode_t mode) * @param pri_dig Digital controller priority. Range: 0 ~ 2. * @param pri_pwdet Wi-Fi controller priority. Range: 0 ~ 2. */ +__attribute__((always_inline)) static inline void adc_ll_set_arbiter_priority(uint8_t pri_rtc, uint8_t pri_dig, uint8_t pri_pwdet) { if (pri_rtc != pri_dig && pri_rtc != pri_pwdet && pri_dig != pri_pwdet) { @@ -689,6 +692,7 @@ static inline void adc_ll_disable_sleep_controller(void) /** * @brief Set common calibration configuration. Should be shared with other parts (PWDET). */ +__attribute__((always_inline)) static inline void adc_ll_calibration_init(adc_unit_t adc_n) { if (adc_n == ADC_UNIT_1) { @@ -749,6 +753,7 @@ static inline void adc_ll_calibration_finish(adc_unit_t adc_n) * * @param adc_n ADC index number. */ +__attribute__((always_inline)) static inline void adc_ll_set_calibration_param(adc_unit_t adc_n, uint32_t param) { uint8_t msb = param >> 8; @@ -1051,6 +1056,7 @@ static inline void adc_oneshot_ll_set_atten(adc_unit_t adc_n, adc_channel_t chan * @param channel ADCn channel number. * @return atten The attenuation option. */ +__attribute__((always_inline)) static inline adc_atten_t adc_ll_get_atten(adc_unit_t adc_n, adc_channel_t channel) { if (adc_n == ADC_UNIT_1) { diff --git a/components/hal/linker.lf b/components/hal/linker.lf index 701a3d0c51..9b23d5a562 100644 --- a/components/hal/linker.lf +++ b/components/hal/linker.lf @@ -30,11 +30,13 @@ entries: lcd_hal: lcd_hal_cal_pclk_freq (noflash) if ADC_ONESHOT_CTRL_FUNC_IN_IRAM = y: adc_oneshot_hal (noflash) - adc_hal_common: adc_hal_calibration_init (noflash) - adc_hal_common: adc_hal_set_calibration_param (noflash) adc_hal_common: get_controller (noflash) adc_hal_common: adc_hal_set_controller (noflash) - adc_hal_common: adc_hal_arbiter_config (noflash) + if SOC_ADC_ARBITER_SUPPORTED = y: + adc_hal_common: adc_hal_arbiter_config (noflash) + if SOC_ADC_CALIBRATION_V1_SUPPORTED = y: + adc_hal_common: adc_hal_set_calibration_param (noflash) + adc_hal_common: adc_hal_calibration_init (noflash) if ADC_CONTINUOUS_ISR_IRAM_SAFE = y: adc_hal: adc_hal_get_reading_result (noflash) adc_hal: adc_hal_digi_start (noflash)