ESPHome 2025.7.1
Loading...
Searching...
No Matches
pi4ioe5v6408.h
Go to the documentation of this file.
1#pragma once
2
6#include "esphome/core/hal.h"
7
8namespace esphome {
9namespace pi4ioe5v6408 {
11 public i2c::I2CDevice,
12 public gpio_expander::CachedGpioExpander<uint8_t, 8> {
13 public:
15
16 void setup() override;
17 void pin_mode(uint8_t pin, gpio::Flags flags);
18
19 float get_setup_priority() const override;
20 void dump_config() override;
21 void loop() override;
22
24 void set_reset(bool reset) { this->reset_ = reset; }
25
26 protected:
27 bool digital_read_hw(uint8_t pin) override;
28 bool digital_read_cache(uint8_t pin) override;
29 void digital_write_hw(uint8_t pin, bool value) override;
30
32 uint8_t mode_mask_{0x00};
34 uint8_t output_mask_{0x00};
36 uint8_t input_mask_{0x00};
38 uint8_t pull_enable_mask_{0x00};
40 uint8_t pull_up_down_mask_{0x00};
41
42 bool reset_{true};
43
44 bool read_gpio_modes_();
45 bool write_gpio_modes_();
46 bool read_gpio_outputs_();
47};
48
49class PI4IOE5V6408GPIOPin : public GPIOPin, public Parented<PI4IOE5V6408Component> {
50 public:
51 void setup() override;
52 void pin_mode(gpio::Flags flags) override;
53 bool digital_read() override;
54 void digital_write(bool value) override;
55 std::string dump_summary() const override;
56
57 void set_pin(uint8_t pin) { this->pin_ = pin; }
58 void set_inverted(bool inverted) { this->inverted_ = inverted; }
59 void set_flags(gpio::Flags flags) { this->flags_ = flags; }
60
61 gpio::Flags get_flags() const override { return this->flags_; }
62
63 protected:
64 uint8_t pin_;
67};
68
69} // namespace pi4ioe5v6408
70} // namespace esphome
Helper class to easily give an object a parent of type T.
Definition helpers.h:599
A class to cache the read state of a GPIO expander.
Definition cached_gpio.h:18
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:133
uint8_t pull_enable_mask_
The mask to write as input buffer state - 1 means enabled, 0 means disabled.
uint8_t output_mask_
The mask to write as output state - 1 means HIGH, 0 means LOW.
uint8_t pull_up_down_mask_
The mask to write as pullup state - 1 means pullup, 0 means pulldown.
bool digital_read_cache(uint8_t pin) override
void digital_write_hw(uint8_t pin, bool value) override
uint8_t input_mask_
The state read in digital_read_hw - 1 means HIGH, 0 means LOW.
uint8_t mode_mask_
Mask for the pin mode - 1 means output, 0 means input.
void pin_mode(uint8_t pin, gpio::Flags flags)
void set_reset(bool reset)
Indicate if the component should reset the state during setup.
void pin_mode(gpio::Flags flags) override
std::string dump_summary() const override
gpio::Flags get_flags() const override
uint16_t reset
Definition ina226.h:5
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7