/* 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, uint8_t mode, uint32_t cnf, 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, uint8_t mode, uint32_t cnf, uint32_t gpios)
{
    (void) gpioport;
    uint8_t i = 0;
    while (gpios) {
        if (gpios & 1) {
            GPIO_PIN_CNF(i) = cnf | mode;
        }
        ++i;
        gpios >>= 1;
    }
}