ESPHome 2025.9.0-dev
Loading...
Searching...
No Matches
adc128s102.cpp
Go to the documentation of this file.
1#include "adc128s102.h"
2#include "esphome/core/log.h"
3
4namespace esphome {
5namespace adc128s102 {
6
7static const char *const TAG = "adc128s102";
8
10
11void ADC128S102::setup() { this->spi_setup(); }
12
14 ESP_LOGCONFIG(TAG, "ADC128S102:");
15 LOG_PIN(" CS Pin:", this->cs_);
16}
17
18uint16_t ADC128S102::read_data(uint8_t channel) {
19 uint8_t control = channel << 3;
20
21 this->enable();
22 uint8_t adc_primary_byte = this->transfer_byte(control);
23 uint8_t adc_secondary_byte = this->transfer_byte(0x00);
24 this->disable();
25
26 uint16_t digital_value = adc_primary_byte << 8 | adc_secondary_byte;
27
28 return digital_value;
29}
30
31} // namespace adc128s102
32} // namespace esphome
float get_setup_priority() const override
Definition adc128s102.cpp:9
uint16_t read_data(uint8_t channel)
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.cpp:49
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7