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:
16
src/mraa.c
16
src/mraa.c
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user