ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
tps65185.h
Go to the documentation of this file.
1#pragma once
2
6#include "esphome/core/gpio.h"
8
9#ifdef USE_TPS65185_TEMPERATURE
11#endif
12
13namespace esphome::tps65185 {
14
15// What a display driver sees of the panel supply
16enum class PowerState : uint8_t {
17 // Power is not requested; the rails may still be discharging for up to 181 ms
20 // Checked once at power up; a rail fault while the power stays on is not seen
22 // The last power-up failed, or the chip did not answer at setup; cleared by the next request_power(true)
24};
25
26enum class ChipState : uint8_t {
27 CHIP_STATE_SLEEP, // WAKEUP low, registers reset
28 CHIP_STATE_WAKING, // WAKEUP high, waiting until I2C is accepted
29 CHIP_STATE_STANDBY, // I2C works, rails off
30 CHIP_STATE_POWERING_DOWN, // PWRUP low, the power-down sequence running
31 CHIP_STATE_POWERING_UP, // PWRUP high, waiting for the panel rails
32 CHIP_STATE_CHECKING, // rails enabled, waiting for every PG bit
33 CHIP_STATE_ACTIVE, // all rails in regulation
34};
35
41
42class TPS65185 final : public Component, public i2c::I2CDevice {
43 public:
44 TPS65185(GPIOPin *wakeup_pin, GPIOPin *pwrup_pin, GPIOPin *vcom_ctrl_pin, uint16_t vcom)
45 : wakeup_pin_(wakeup_pin), pwrup_pin_(pwrup_pin), vcom_ctrl_pin_(vcom_ctrl_pin), vcom_(vcom) {}
46 void set_power_good_pin(GPIOPin *pin) { this->power_good_pin_ = pin; }
47#ifdef USE_TPS65185_TEMPERATURE
49 // Starts a thermistor reading, waking the chip if it is asleep
50 void request_temperature();
51#endif
52
53 void setup() override;
54 void loop() override;
55 void dump_config() override;
56 // Keeps the rails going while the display finishes an update in its own teardown
57 bool teardown() override;
58 // Runs after teardown, so the display has finished with the rails; the chip discharges them before it sleeps
59 void on_powerdown() override;
60
61 // Turns the panel rails on or off. The rails come up over several loop passes; poll get_power_state().
62 void request_power(bool on);
64
65 protected:
66 bool power_good_();
67 bool write_vcom_();
68 void power_down_();
69 void power_fault_();
70 void sleep_();
71 void start_work_();
72 // True while a thermistor conversion holds the chip awake
74 // Ends a pending thermistor reading with NAN
75 void fail_temperature_();
76
82 uint16_t vcom_; // magnitude in 10 mV steps
83 uint8_t revision_{0};
86 bool power_requested_{false};
87 bool power_failed_{false};
88 bool tearing_down_{false};
90};
91
92#ifdef USE_TPS65185_TEMPERATURE
93class TPS65185TemperatureSensor final : public sensor::Sensor, public PollingComponent, public Parented<TPS65185> {
94 public:
95 void update() override { this->parent_->request_temperature(); }
96 void dump_config() override;
97};
98#endif
99
100} // namespace esphome::tps65185
Helper class to request loop() to be called as fast as possible.
Definition helpers.h:2601
Helper class to easily give an object a parent of type T.
Definition helpers.h:2432
This class simplifies creating components that periodically check a state.
Definition component.h:542
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
Base-class for all sensors.
Definition sensor.h:48
TPS65185(GPIOPin *wakeup_pin, GPIOPin *pwrup_pin, GPIOPin *vcom_ctrl_pin, uint16_t vcom)
Definition tps65185.h:44
TemperatureRead temperature_read_
Definition tps65185.h:85
HighFrequencyLoopRequester high_freq_
Definition tps65185.h:89
SUB_SENSOR(temperature) void request_temperature()
void request_power(bool on)
Definition tps65185.cpp:85
void set_power_good_pin(GPIOPin *pin)
Definition tps65185.h:46
void on_powerdown() override
Definition tps65185.cpp:79
PowerState get_power_state() const
Definition tps65185.cpp:92
bool teardown() override
Definition tps65185.cpp:69
bool handle_temperature_(uint32_t now)
Definition tps65185.cpp:287
void dump_config() override
Definition tps65185.cpp:56
static void uint32_t
uint16_t temperature
Definition sun_gtil2.cpp:12