/* Configure the GPIO pin to output and set it to high/low depending on val  */
int kinetis_gpio_set_out(struct kinetis_gpio_dsc *dsc, int val)
/* Configure the GPIO pin to output and set it to high/low depending on val  */
int kinetis_gpio_set_out(struct kinetis_gpio_dsc *dsc, int val)
{
	int rv;
	rv = kinetis_validate_gpio(dsc);
	if (rv != 0)
		goto out;
	kinetis_gpio_config(dsc, KINETIS_GPIO_CONFIG_MUX(1));
	KINETIS_GPIO(dsc->port)->pddr |= (1 << dsc->pin);
	if (val)
		KINETIS_GPIO(dsc->port)->psor |= (1 << dsc->pin);
	else
		KINETIS_GPIO(dsc->port)->pcor |= (1 << dsc->pin);
	rv = 0;
out:
	return rv;
}