1 /* 2 * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <stdbool.h> 8 #include "regi2c_ctrl.h" 9 #include "driver/adc.h" 10 11 /* 12 * This file is used to override the hooks provided by the PHY lib for some system features. 13 * Call phy_override() so that this file will be linked. 14 */ 15 16 static bool s_wifi_adc_xpd_flag; 17 include_esp_phy_override(void)18void include_esp_phy_override(void) 19 { 20 /* When this empty function is called, all functions below will be linked. */ 21 } 22 23 /* Coordinate ADC power with other modules. */ 24 // It seems that it is only required on ESP32, but we still compile it for all chips, in case it is 25 // called by PHY unexpectedly. set_xpd_sar(bool en)26void set_xpd_sar(bool en) 27 { 28 if (s_wifi_adc_xpd_flag == en) { 29 /* ignore repeated calls to set_xpd_sar when the state is already correct */ 30 return; 31 } 32 33 s_wifi_adc_xpd_flag = en; 34 if (en) { 35 adc_power_acquire(); 36 } else { 37 adc_power_release(); 38 } 39 } 40 41 //add spinlock protection phy_i2c_enter_critical(void)42IRAM_ATTR void phy_i2c_enter_critical(void) 43 { 44 regi2c_enter_critical(); 45 } 46 phy_i2c_exit_critical(void)47IRAM_ATTR void phy_i2c_exit_critical(void) 48 { 49 regi2c_exit_critical(); 50 } 51