17#define LOG_PIN(prefix, pin) log_pin(TAG, F(prefix), pin)
19#define LOG_PIN(prefix, pin) log_pin(TAG, prefix, pin)
45 return static_cast<Flags>(
static_cast<uint8_t
>(lhs) &
static_cast<uint8_t
>(rhs));
48 return static_cast<Flags>(
static_cast<uint8_t
>(lhs) |
static_cast<uint8_t
>(rhs));
90 virtual bool is_held()
const {
return false; }
100class ESP32InternalGPIOPin;
102#elif defined(USE_ESP8266)
106#elif defined(USE_LIBRETINY)
108class ArduinoInternalGPIOPin;
110#elif defined(USE_RP2)
114#elif defined(USE_HOST)
118#elif defined(USE_ZEPHYR)
127#if defined(USE_ESP32)
129#elif defined(USE_ESP8266)
131#elif defined(USE_LIBRETINY)
133#elif defined(USE_RP2)
135#elif defined(USE_HOST)
137#elif defined(USE_ZEPHYR)
151 template<std::derived_from<GPIOPin> T>
153 :
arg_(const_cast<T *>(pin)) {}
164 { pin.get_pin() } -> std::same_as<uint8_t>;
165 { pin.is_inverted() } -> std::same_as<bool>;
166 { pin.to_isr() } -> std::same_as<ISRInternalGPIOPin>;
167 { pin.detach_interrupt() } -> std::same_as<void>;
168 { pin.attach_interrupt(func, arg,
type) } -> std::same_as<void>;
189void log_pin(
const char *
tag,
const __FlashStringHelper *prefix, GPIOPin *pin);
191void log_pin(
const char *
tag,
const char *prefix, GPIOPin *pin);
virtual void pin_mode(gpio::Flags flags)=0
virtual void digital_write(bool value)=0
virtual bool is_internal()
Only the platform pin class behind the InternalGPIOPin alias may return true: callers static_cast to ...
virtual gpio::Flags get_flags() const =0
Retrieve GPIO pin flags.
virtual bool digital_read()=0
virtual bool is_held() const
virtual size_t dump_summary(char *buffer, size_t len) const
Write a summary of this pin to the provided buffer.
ISR-safe handle to an internal pin (no virtual calls); every handle points at the pin itself and shar...
ISRInternalGPIOPin(void *arg)
void digital_write(bool value)
void pin_mode(gpio::Flags flags)
ISRInternalGPIOPin()=default
ISRInternalGPIOPin(const T *pin)
constexpr FlagsHelper(Flags val)
constexpr FlagsHelper operator|(Flags lhs, Flags rhs)
constexpr FlagsHelper operator&(Flags lhs, Flags rhs)
void pulse_reset_ms(GPIOPin *pin, uint32_t high_before_ms, uint32_t low_ms, uint32_t high_after_ms)
Out-of-line body of pulse_reset(); call that instead.
char host[MAX_ORIGIN_LENGTH+1]
void pulse_pin(GPIOPin *pin, bool level, uint32_t width_us)
Drive pin to level for width_us microseconds, then to the opposite level.
void HOT esp_log_printf_(int level, const char *tag, int line, const char *format,...)
void log_pin_with_prefix(const char *tag, const char *prefix, GPIOPin *pin)
void setup_output_pin(GPIOPin *pin, bool level)
Set up pin and drive it to level. Does nothing when pin is null, so an optional pin needs no check.
constexpr size_t GPIO_SUMMARY_MAX_LEN
Maximum buffer size for dump_summary output.
ESPHOME_ALWAYS_INLINE void pulse_reset(GPIOPin *pin, ResetPulse pulse)
Set up an active-low reset pin and drive it through pulse.
void log_pin(const char *tag, const __FlashStringHelper *prefix, GPIOPin *pin)
Waveform for pulse_reset(): high, low, then high again.
uint32_t low_ms
Hold the pin low (in reset) this long.
uint32_t high_before_ms
Drive high this long first; skipped when 0.
uint32_t high_after_ms
Wait this long after releasing the pin.