6 #ifdef CYW43_USES_VSYS_PIN 7 #include "pico/cyw43_arch.h" 8 #endif // CYW43_USES_VSYS_PIN 9 #include <hardware/adc.h> 14 static const char *
const TAG =
"adc.rp2040";
17 ESP_LOGCONFIG(TAG,
"Setting up ADC '%s'...", this->
get_name().c_str());
18 static bool initialized =
false;
26 LOG_SENSOR(
"",
"ADC Sensor",
this);
28 ESP_LOGCONFIG(TAG,
" Pin: Temperature");
30 #ifdef USE_ADC_SENSOR_VCC 31 ESP_LOGCONFIG(TAG,
" Pin: VCC");
33 LOG_PIN(
" Pin: ", this->
pin_);
34 #endif // USE_ADC_SENSOR_VCC 38 LOG_UPDATE_INTERVAL(
this);
46 adc_set_temp_sensor_enabled(
true);
54 adc_set_temp_sensor_enabled(
false);
56 return aggr.aggregate();
58 return aggr.aggregate() * 3.3f / 4096.0f;
62 #ifdef CYW43_USES_VSYS_PIN 63 if (pin == PICO_VSYS_PIN) {
70 #endif // CYW43_USES_VSYS_PIN 73 adc_select_input(pin - 26);
80 #ifdef CYW43_USES_VSYS_PIN 81 if (pin == PICO_VSYS_PIN) {
84 #endif // CYW43_USES_VSYS_PIN 87 return aggr.aggregate();
89 float coeff = pin == PICO_VSYS_PIN ? 3.0f : 1.0f;
90 return aggr.aggregate() * 3.3f / 4096.0f * coeff;
const LogString * sampling_mode_to_str(SamplingMode mode)
SamplingMode sampling_mode_
void setup() override
Setup ADC.
virtual uint8_t get_pin() const =0
Implementation of SPI Controller mode.
void dump_config() override
const StringRef & get_name() const
void IRAM_ATTR HOT delay(uint32_t ms)