/* Configure the edge detector of an input pin.  */
static uint32_t gpio_configure_edge_detector(uint32_t pin, uint32_t mode)
/* Configure the edge detector of an input pin.  */
static uint32_t gpio_configure_edge_detector(uint32_t pin, uint32_t mode)
{
	volatile avr32_gpio_port_t *gpio_port = &AVR32_GPIO.port[pin >> 5];
	switch (mode) {
	case GPIO_PIN_CHANGE:
		gpio_port->imr0c = 1 << (pin & 0x1F);
		gpio_port->imr1c = 1 << (pin & 0x1F);
		break;
	case GPIO_RISING_EDGE:
		gpio_port->imr0s = 1 << (pin & 0x1F);
		gpio_port->imr1c = 1 << (pin & 0x1F);
		break;
	case GPIO_FALLING_EDGE:
		gpio_port->imr0c = 1 << (pin & 0x1F);
		gpio_port->imr1s = 1 << (pin & 0x1F);
		break;
	default:
		return GPIO_INVALID_ARGUMENT;
	}
	return GPIO_SUCCESS;
}