/* Set GPIO Pin Mode. 
Sets the mode (input/output) and configuration (analog/digitial and open drain/push pull), for a set of GPIO pins on a given GPIO port. */
void gpio_mode_setup(uint32_t gpioport, uint32_t mode, uint32_t pull_up_down, uint32_t gpios)
/* Set GPIO Pin Mode. 
Sets the mode (input/output) and configuration (analog/digitial and open drain/push pull), for a set of GPIO pins on a given GPIO port. */
void gpio_mode_setup(uint32_t gpioport, uint32_t mode, uint32_t pull_up_down, uint32_t gpios)
{
	(void) gpioport;
	uint8_t i = 0;
	while (gpios) {
		if (gpios & 1) {
			GPIO_PIN_CNF(i) = (
					GPIO_PIN_CNF(i) &
					~((GPIO_CNF_MODE_MASK << GPIO_CNF_MODE_SHIFT)
						| (GPIO_CNF_PUPD_MASK << GPIO_CNF_PUPD_SHIFT)
					 )
				) | (mode << GPIO_CNF_MODE_SHIFT)
				| (pull_up_down << GPIO_CNF_PUPD_SHIFT);
		}
		++i;
		gpios >>= 1;
	}
}