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 37 LOG_UPDATE_INTERVAL(
this);
42 adc_set_temp_sensor_enabled(
true);
49 raw = (raw + (this->sample_count_ >> 1)) / this->
sample_count_;
50 adc_set_temp_sensor_enabled(
false);
54 return raw * 3.3f / 4096.0f;
58 #ifdef CYW43_USES_VSYS_PIN 59 if (pin == PICO_VSYS_PIN) {
66 #endif // CYW43_USES_VSYS_PIN 69 adc_select_input(pin - 26);
75 raw = (raw + (this->sample_count_ >> 1)) / this->
sample_count_;
77 #ifdef CYW43_USES_VSYS_PIN 78 if (pin == PICO_VSYS_PIN) {
81 #endif // CYW43_USES_VSYS_PIN 86 float coeff = pin == PICO_VSYS_PIN ? 3.0f : 1.0f;
87 return raw * 3.3f / 4096.0f * coeff;
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)