ESPHome 2026.2.1
Loading...
Searching...
No Matches
gpio.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef USE_ZEPHYR
4#include "esphome/core/hal.h"
5#include <zephyr/device.h>
6namespace esphome {
7namespace zephyr {
8
10 public:
11 ZephyrGPIOPin(const device *gpio, int gpio_size, const char *pin_name_prefix) {
12 this->gpio_ = gpio;
13 this->gpio_size_ = gpio_size;
14 this->pin_name_prefix_ = pin_name_prefix;
15 }
16 void set_pin(uint8_t pin) { this->pin_ = pin; }
17 void set_inverted(bool inverted) { this->inverted_ = inverted; }
19
20 void setup() override;
21 void pin_mode(gpio::Flags flags) override;
22 bool digital_read() override;
23 void digital_write(bool value) override;
24 size_t dump_summary(char *buffer, size_t len) const override;
25 void detach_interrupt() const override;
26 ISRInternalGPIOPin to_isr() const override;
27 uint8_t get_pin() const override { return this->pin_; }
28 bool is_inverted() const override { return this->inverted_; }
29 gpio::Flags get_flags() const override { return flags_; }
30
31 protected:
32 void attach_interrupt(void (*func)(void *), void *arg, gpio::InterruptType type) const override;
33 const device *gpio_{nullptr};
34 const char *pin_name_prefix_{nullptr};
36 uint8_t pin_;
37 uint8_t gpio_size_{};
38 bool inverted_{};
39 bool value_{false};
40};
41
42} // namespace zephyr
43} // namespace esphome
44
45#endif // USE_ZEPHYR
Copy of GPIOPin that is safe to use from ISRs (with no virtual functions)
Definition gpio.h:92
const device * gpio_
Definition gpio.h:33
void digital_write(bool value) override
Definition gpio.cpp:82
void attach_interrupt(void(*func)(void *), void *arg, gpio::InterruptType type) const override
Definition gpio.cpp:48
ZephyrGPIOPin(const device *gpio, int gpio_size, const char *pin_name_prefix)
Definition gpio.h:11
const char * pin_name_prefix_
Definition gpio.h:34
void setup() override
Definition gpio.cpp:52
void set_flags(gpio::Flags flags)
Definition gpio.h:18
bool digital_read() override
Definition gpio.cpp:75
bool is_inverted() const override
Definition gpio.h:28
uint8_t get_pin() const override
Definition gpio.h:27
size_t dump_summary(char *buffer, size_t len) const override
Definition gpio.cpp:71
ISRInternalGPIOPin to_isr() const override
Definition gpio.cpp:41
gpio::Flags get_flags() const override
Definition gpio.h:29
void set_pin(uint8_t pin)
Definition gpio.h:16
void detach_interrupt() const override
Definition gpio.cpp:91
void pin_mode(gpio::Flags flags) override
Definition gpio.cpp:60
void set_inverted(bool inverted)
Definition gpio.h:17
uint16_t type
uint16_t flags
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
std::string size_t len
Definition helpers.h:692