ESPHome 2025.5.0
Loading...
Searching...
No Matches
ina2xx_spi.cpp
Go to the documentation of this file.
1#include "ina2xx_spi.h"
2#include "esphome/core/log.h"
3
4namespace esphome {
5namespace ina2xx_spi {
6
7static const char *const TAG = "ina2xx_spi";
8
10 this->spi_setup();
11 INA2XX::setup();
12}
13
15 INA2XX::dump_config();
16 LOG_PIN(" CS Pin: ", this->cs_);
17}
18
19bool INA2XXSPI::read_ina_register(uint8_t reg, uint8_t *data, size_t len) {
20 reg = (reg << 2); // top 6 bits
21 reg |= 0x01; // read
22 this->enable();
23 this->write_byte(reg);
24 this->read_array(data, len);
25 this->disable();
26 return true;
27}
28
29bool INA2XXSPI::write_ina_register(uint8_t reg, const uint8_t *data, size_t len) {
30 reg = (reg << 2); // top 6 bits
31 this->enable();
32 this->write_byte(reg);
33 this->write_array(data, len);
34 this->disable();
35 return true;
36}
37} // namespace ina2xx_spi
38} // namespace esphome
bool write_ina_register(uint8_t reg, const uint8_t *data, size_t len) override
bool read_ina_register(uint8_t reg, uint8_t *data, size_t len) override
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
std::string size_t len
Definition helpers.h:301