10static constexpr uint32_t READ_RETRY_TIMEOUT_ID = 0;
18 uint8_t coef_data_raw[DPS310_NUM_COEF_REGS];
19 auto timer = DPS310_INIT_TIMEOUT;
22 if (!this->
write_byte(DPS310_REG_RESET, DPS310_CMD_RESET)) {
27 while (timer-- && (!(
reg & DPS310_BIT_SENSOR_RDY) || !(
reg & DPS310_BIT_COEF_RDY))) {
32 if (!(
reg & DPS310_BIT_SENSOR_RDY) || !(
reg & DPS310_BIT_COEF_RDY)) {
40 if (!this->
read_bytes(DPS310_REG_COEF, coef_data_raw, DPS310_NUM_COEF_REGS)) {
48 if (!this->
write_byte(DPS310_REG_PRS_CFG, DPS310_VAL_PRS_CFG)) {
51 if (!this->
write_byte(DPS310_REG_TMP_CFG, DPS310_VAL_TMP_CFG | (
reg & DPS310_BIT_TMP_COEF_SRC))) {
54 if (!this->
write_byte(DPS310_REG_CFG, DPS310_VAL_REG_CFG)) {
57 if (!this->
write_byte(DPS310_REG_MEAS_CFG, 0x07)) {
81 LOG_UPDATE_INTERVAL(
this);
100 if ((!this->
got_pres_) && (reg & DPS310_BIT_PRS_RDY)) {
104 if ((!this->
got_temp_) && (reg & DPS310_BIT_TMP_RDY)) {
121 if (!this->
read_bytes(DPS310_REG_PRS_B2, bytes, 3)) {
131 if (!this->
read_bytes(DPS310_REG_TMP_B2, bytes, 3)) {
144 const float t_raw_sc = (float) raw_temperature / DPS310_SCALE_FACTOR;
145 const float p_raw_sc = (float) raw_pressure / DPS310_SCALE_FACTOR;
150 t_raw_sc * this->
c01_ + t_raw_sc * p_raw_sc * (this->
c11_ + p_raw_sc * this->
c21_)) /
void mark_failed()
Mark this component as failed.
void status_set_warning()
void set_timeout(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a const char* name.
void status_clear_warning()
void dump_config() override
sensor::Sensor * pressure_sensor_
sensor::Sensor * temperature_sensor_
void calculate_values_(int32_t raw_temperature, int32_t raw_pressure)
bool setup_registers_()
Configure the sensor; false on a failure.
bool write_byte(uint8_t a_register, uint8_t data) const
bool read_byte(uint8_t a_register, uint8_t *data)
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
void publish_state(float state)
Publish a new state to the front-end.
ESPHOME_LOG_TAG(TAG, "dps310")
constexpr uint32_t encode_uint24(uint8_t byte1, uint8_t byte2, uint8_t byte3)
Encode a 24-bit value given three bytes in most to least significant byte order.
constexpr T encode_value(const uint8_t *bytes)
Encode a value from its constituent bytes (from most to least significant) in an array with length si...
constexpr int32_t sign_extend(uint32_t value)
Sign-extend the low BITS bits of value, e.g. sign_extend<24>(0xFFFFFE) == -2. Higher bits are ignored...
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
void HOT delay(uint32_t ms)