Private
Public Access
2
0

setup_mux_mapped: use HIGH/LOW instead

Avoids on some platforms where when setting a mux will set it low when
it wouldn't be safe to.

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
This commit is contained in:
Thomas Ingleby
2015-01-22 17:36:16 +00:00
parent e76d85eade
commit 6c73a8adce

View File

@@ -154,13 +154,17 @@ mraa_setup_mux_mapped(mraa_pin_t meta)
if (mux_i == NULL) {
return MRAA_ERROR_INVALID_HANDLE;
}
// this function will sometimes fail, however this is not critical as
// long as the write succeeds - Test case galileo gen2 pin2
mraa_gpio_dir(mux_i, MRAA_GPIO_OUT);
if (mraa_gpio_write(mux_i, meta.mux[mi].value) != MRAA_SUCCESS) {
mraa_gpio_close(mux_i);
return MRAA_ERROR_INVALID_RESOURCE;
if (meta.mux[mi].value) {
if (mraa_gpio_dir(mux_i, MRAA_GPIO_OUT_HIGH) != MRAA_SUCCESS) {
mraa_gpio_close(mux_i);
return MRAA_ERROR_INVALID_RESOURCE;
}
} else {
if (mraa_gpio_dir(mux_i, MRAA_GPIO_OUT_LOW) != MRAA_SUCCESS) {
mraa_gpio_close(mux_i);
return MRAA_ERROR_INVALID_RESOURCE;
}
}
mraa_gpio_close(mux_i);
}