void DispatcherPrivate::set_receive_input(SYNCHRONIZATION_CHANNEL* channel, PinName pin, PinMode pull, ReceiveChannelMode rcmode) { if (channel->data->state->recv.mode != ReceiveChannelModeNone) gpio_irq_free(&channel->data->state->recv.gpio_irq); channel->data->state->recv.mode = rcmode; gpio_init_in(&channel->data->state->recv.gpio, pin); gpio_irq_init(&channel->data->state->recv.gpio_irq, pin, (&DispatcherPrivate::channel_irq_handler), (uint32_t)channel); gpio_mode(&channel->data->state->recv.gpio, pull); gpio_irq_event evt = IRQ_NONE; switch (rcmode) { case ReceiveChannelInterruptRise: evt = IRQ_RISE; break; case ReceiveChannelInterruptFall: evt = IRQ_FALL; break; case ReceiveChannelModeNone: break; } if (evt != IRQ_NONE) { gpio_irq_set(&channel->data->state->recv.gpio_irq, evt, 1); gpio_irq_enable(&channel->data->state->recv.gpio_irq); } }
void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable) { uint16_t porarity; if (enable) { if (event == IRQ_RISE) { porarity = EXTI_Trigger_Rising; obj->event = EDGE_RISE; } if (event == IRQ_FALL) { porarity = EXTI_Trigger_Falling; obj->event = EDGE_FALL; } uint32_t port_index = WIZ_PORT(obj->pin); uint32_t pin_index = WIZ_PIN(obj->pin); // Enable GPIO clock uint32_t gpio_add = Get_GPIO_BaseAddress(port_index); EXTI_Polarity_Set(port_index,(1<<pin_index),porarity); } else { // Disable gpio_irq_free(obj); } }
InterruptIn::~InterruptIn() { gpio_irq_free(&gpio_irq); }
InterruptIn::~InterruptIn() { // No lock needed in the destructor gpio_irq_free(&gpio_irq); }