/* Alternate function GPIO pins. 
Configure a group of Pins in alternate function. */
void gpio_set_af(uint32_t gpioport, uint8_t af, uint32_t gpios)
/* Alternate function GPIO pins. 
Configure a group of Pins in alternate function. */
void gpio_set_af(uint32_t gpioport, uint8_t af, uint32_t gpios)
{
	uint32_t reg = PORT_WRCONFIG_WRPINCFG |
		PORT_WRCONFIG_WRPMUX | PORT_WRCONFIG_PMUX(af) |
		PORT_WRCONFIG_PMUXEN;
	PORT_WRCONFIG(gpioport) = reg | PORT_WRCONFIG_PINMASK(gpios);
	PORT_WRCONFIG(gpioport) = reg | PORT_WRCONFIG_HWSEL | 
		PORT_WRCONFIG_PINMASK(gpios >> 16);
}