ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
gpio.cpp
Go to the documentation of this file.
1#ifdef USE_HOST
2
3#include "gpio.h"
4#include "esphome/core/hal.h"
5#include "esphome/core/log.h"
6
7namespace esphome {
8namespace host {
9
10ESPHOME_LOG_TAG(TAG, "host");
11
13
14void HostGPIOPin::attach_interrupt_(void (*func)(void *), void *arg, gpio::InterruptType type) const {
15 ESP_LOGD(TAG, "Attaching interrupt %p to pin %d and mode %d", func, pin_, (uint32_t) type);
16 this->isr_func_ = func;
17 this->isr_arg_ = arg;
18 this->isr_type_ = type;
19}
20void HostGPIOPin::pin_mode(gpio::Flags flags) { ESP_LOGD(TAG, "Setting pin %d mode to %02X", pin_, (uint32_t) flags); }
21
22size_t HostGPIOPin::dump_summary(char *buffer, size_t len) const { return snprintf(buffer, len, "GPIO%u", this->pin_); }
23
26 // pass
27 ESP_LOGD(TAG, "Setting pin %d to %s", pin_, value != inverted_ ? "HIGH" : "LOW");
28}
30 this->isr_func_ = nullptr;
31 this->isr_arg_ = nullptr;
32}
33
34} // namespace host
35
36using namespace host;
37
38bool IRAM_ATTR ISRInternalGPIOPin::digital_read() { return static_cast<HostGPIOPin *>(this->arg_)->is_inverted(); }
39void IRAM_ATTR ISRInternalGPIOPin::digital_write(bool value) {
40 // pass
41}
43 ESP_LOGD(TAG, "Clearing interrupt for pin %d", static_cast<HostGPIOPin *>(this->arg_)->get_pin());
44}
46 // pass
47}
48
49} // namespace esphome
50
51#endif // USE_HOST
ISR-safe handle to an internal pin (no virtual calls); every handle points at the pin itself and shar...
Definition gpio_pin.h:126
void digital_write(bool value)
Definition gpio.cpp:211
void pin_mode(gpio::Flags flags)
Definition gpio.cpp:223
friend class host::HostGPIOPin
Definition gpio_pin.h:136
void detach_interrupt() const
Definition gpio.cpp:29
void attach_interrupt_(void(*func)(void *), void *arg, gpio::InterruptType type) const
Definition gpio.cpp:14
ISRInternalGPIOPin to_isr() const
Definition gpio.cpp:12
bool digital_read() override
Definition gpio.cpp:24
void digital_write(bool value) override
Definition gpio.cpp:25
void pin_mode(gpio::Flags flags) override
Definition gpio.cpp:20
gpio::InterruptType isr_type_
Definition gpio.h:44
void(* isr_func_)(void *)
Definition gpio.h:39
size_t dump_summary(char *buffer, size_t len) const override
Definition gpio.cpp:22
uint16_t flags
uint8_t type
uint32_t buffer
Definition gif.cpp:50
ESPHOME_LOG_TAG(TAG, "host")
char host[MAX_ORIGIN_LENGTH+1]
uint32_t value
Definition hal.cpp:59
const void size_t len
Definition hal.h:68
static void uint32_t