Renamed the C++ implementation files to match the component folder naming: - lsm6ds.h -> lsm6ds_base.h - lsm6ds.cpp -> lsm6ds_base.cpp Updated all includes: - lsm6ds_base/lsm6ds_base.cpp: Updated self-include - lsm6ds_i2c/lsm6ds_i2c.h: Updated to include lsm6ds_base.h - lsm6ds_spi/lsm6ds_spi.h: Updated to include lsm6ds_base.h Fixed test file: - tests/lsm6ds_test.yaml: Updated sensor platforms to use lsm6ds_i2c and lsm6ds_spi This ensures all files follow consistent naming conventions with the _base suffix.
31 lines
879 B
C++
31 lines
879 B
C++
#pragma once
|
|
|
|
#include "esphome/components/lsm6ds_base/lsm6ds_base.h"
|
|
#include "esphome/components/spi/spi.h"
|
|
|
|
namespace esphome {
|
|
namespace lsm6ds_spi {
|
|
|
|
class LSM6DSSPIDevice : public lsm6ds_base::LSM6DSComponent,
|
|
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
|
|
spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_1MHZ> {
|
|
public:
|
|
bool read_register(uint8_t reg, uint8_t *data, size_t len) override {
|
|
this->enable();
|
|
this->transfer_byte(reg | 0x80);
|
|
this->transfer_bytes(nullptr, data, len);
|
|
this->disable();
|
|
return true;
|
|
}
|
|
bool write_register(uint8_t reg, uint8_t data) override {
|
|
this->enable();
|
|
this->transfer_byte(reg & 0x7F);
|
|
this->transfer_byte(data);
|
|
this->disable();
|
|
return true;
|
|
}
|
|
};
|
|
|
|
} // namespace lsm6ds_spi
|
|
} // namespace esphome
|