9static const char *
const TAG =
"esp8266";
11static int flags_to_mode(
gpio::Flags flags, uint8_t pin) {
26 return INPUT_PULLDOWN_16;
28 return OUTPUT_OPEN_DRAIN;
37 volatile uint32_t *in_reg;
38 volatile uint32_t *out_set_reg;
39 volatile uint32_t *out_clr_reg;
40 volatile uint32_t *mode_set_reg;
41 volatile uint32_t *mode_clr_reg;
42 volatile uint32_t *func_reg;
47 auto *arg =
new ISRPinArg{};
48 arg->pin = this->
pin_;
50 if (this->
pin_ < 16) {
52 arg->out_set_reg = &GPOS;
53 arg->out_clr_reg = &GPOC;
54 arg->mode_set_reg = &GPES;
55 arg->mode_clr_reg = &GPEC;
56 arg->func_reg = &GPF(this->
pin_);
57 arg->mask = 1 << this->
pin_;
60 arg->out_set_reg = &GP16O;
61 arg->out_clr_reg =
nullptr;
62 arg->mode_set_reg = &GP16E;
63 arg->mode_clr_reg =
nullptr;
64 arg->func_reg = &GPF16;
71 uint8_t arduino_mode = 0;
74 arduino_mode =
inverted_ ? FALLING : RISING;
77 arduino_mode =
inverted_ ? RISING : FALLING;
80 arduino_mode = CHANGE;
83 arduino_mode =
inverted_ ? ONHIGH : ONLOW;
86 arduino_mode =
inverted_ ? ONLOW : ONHIGH;
90 attachInterruptArg(
pin_, func, arg, arduino_mode);
93 pinMode(
pin_, flags_to_mode(flags,
pin_));
98 snprintf(buffer,
sizeof(buffer),
"GPIO%u",
pin_);
112using namespace esp8266;
115 auto *arg =
reinterpret_cast<ISRPinArg *
>(this->
arg_);
116 return bool(*arg->in_reg & arg->mask) != arg->inverted;
120 auto *arg =
reinterpret_cast<ISRPinArg *
>(
arg_);
122 if (value != arg->inverted) {
123 *arg->out_set_reg = arg->mask;
125 *arg->out_clr_reg = arg->mask;
128 if (value != arg->inverted) {
129 *arg->out_set_reg |= 1;
131 *arg->out_set_reg &= ~1;
137 auto *arg =
reinterpret_cast<ISRPinArg *
>(
arg_);
138 GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, 1UL << arg->pin);
142 auto *arg =
reinterpret_cast<ISRPinArg *
>(this->
arg_);
145 *arg->mode_set_reg = arg->mask;
147 *arg->mode_clr_reg = arg->mask;
150 *arg->func_reg |= 1 << GPFPU;
152 *arg->func_reg &= ~(1 << GPFPU);
156 *arg->mode_set_reg |= 1;
158 *arg->mode_set_reg &= ~1;
161 *arg->func_reg |= 1 << GP16FPD;
163 *arg->func_reg &= ~(1 << GP16FPD);
Copy of GPIOPin that is safe to use from ISRs (with no virtual functions)
void digital_write(bool value)
void pin_mode(gpio::Flags flags)
bool digital_read() override
ISRInternalGPIOPin to_isr() const override
void digital_write(bool value) override
void attach_interrupt(void(*func)(void *), void *arg, gpio::InterruptType type) const override
std::string dump_summary() const override
void detach_interrupt() const override
void pin_mode(gpio::Flags flags) override
Providing packet encoding functions for exchanging data with a remote host.