/* Generate the PORTx address of the give pin.  */
static uint16_t _port_addr(gpio_t pin)
/* Generate the PORTx address of the give pin.  */
static uint16_t _port_addr(gpio_t pin)
{
    uint8_t port_num = _port_num(pin);
    uint16_t port_addr = port_num * GPIO_OFFSET_PIN_PIN;
    port_addr += GPIO_BASE_PORT_A;
    port_addr += GPIO_OFFSET_PIN_PORT;
    if (port_num > PORT_G) {
        port_addr += GPIO_OFFSET_PORT_H;
    }
    return port_addr;
}