ESPHome 2025.5.0
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
12 ESP_LOGCONFIG(TAG, "Setting up adc128s102");
13 this->spi_setup();
14}
15
17 ESP_LOGCONFIG(TAG, "ADC128S102:");
18 LOG_PIN(" CS Pin:", this->cs_);
19}
20
21uint16_t ADC128S102::read_data(uint8_t channel) {
22 uint8_t control = channel << 3;
23
24 this->enable();
25 uint8_t adc_primary_byte = this->transfer_byte(control);
26 uint8_t adc_secondary_byte = this->transfer_byte(0x00);
27 this->disable();
28
29 uint16_t digital_value = adc_primary_byte << 8 | adc_secondary_byte;
30
31 return digital_value;
32}
33
34} // namespace adc128s102
35} // 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:18
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7