mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
647dea9395
During HAL layer refactoring and new chip bringup, we have several caps.h for each part, to reduce the conflicts to minimum. But this is The capabilities headers will be relataive stable once completely written (maybe after the featues are supported by drivers). Now ESP32 and ESP32-S2 drivers are relative stable, making it a good time to combine all these caps.h into one soc_caps.h This cleanup also move HAL config and pin config into separated files, to make the responsibilities of these headers more clear. This is helpful for the stabilities of soc_caps.h because we want to make it public some day.
42 lines
1.6 KiB
C
42 lines
1.6 KiB
C
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "hal/adc_hal.h"
|
|
#include "hal/adc_hal_conf.h"
|
|
|
|
void adc_hal_init(void)
|
|
{
|
|
// Set internal FSM wait time, fixed value.
|
|
adc_ll_digi_set_fsm_time(SOC_ADC_FSM_RSTB_WAIT_DEFAULT, SOC_ADC_FSM_START_WAIT_DEFAULT,
|
|
SOC_ADC_FSM_STANDBY_WAIT_DEFAULT);
|
|
adc_ll_set_sample_cycle(ADC_FSM_SAMPLE_CYCLE_DEFAULT);
|
|
adc_hal_pwdet_set_cct(SOC_ADC_PWDET_CCT_DEFAULT);
|
|
adc_ll_digi_output_invert(ADC_NUM_1, SOC_ADC_DIGI_DATA_INVERT_DEFAULT(ADC_NUM_1));
|
|
adc_ll_digi_output_invert(ADC_NUM_2, SOC_ADC_DIGI_DATA_INVERT_DEFAULT(ADC_NUM_2));
|
|
}
|
|
|
|
void adc_hal_deinit(void)
|
|
{
|
|
adc_ll_set_power_manage(ADC_POWER_SW_OFF);
|
|
}
|
|
|
|
int adc_hal_convert(adc_ll_num_t adc_n, int channel, int *value)
|
|
{
|
|
adc_ll_rtc_enable_channel(adc_n, channel);
|
|
adc_ll_rtc_start_convert(adc_n, channel);
|
|
while (adc_ll_rtc_convert_is_done(adc_n) != true);
|
|
*value = adc_ll_rtc_get_convert_value(adc_n);
|
|
return (int)adc_ll_rtc_analysis_raw_data(adc_n, (uint16_t)(*value));
|
|
}
|