Private
Public Access
2
0

gpio: add behaviour for pin without direction

If a gpio doesnt have a direction, like some muxes do, try and set value
if HIGH or LOW was passed.

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

View File

@@ -414,7 +414,16 @@ mraa_gpio_dir(mraa_gpio_context dev, gpio_dir_t dir)
int direction = open(filepath, O_RDWR);
if (direction == -1) {
return MRAA_ERROR_INVALID_RESOURCE;
// Direction Failed to Open. If HIGH or LOW was passed will try and set
// If not fail as usual.
switch (dir) {
case MRAA_GPIO_OUT_HIGH:
return mraa_gpio_write(dev, 1);
case MRAA_GPIO_OUT_LOW:
return mraa_gpio_write(dev, 0);
default:
return MRAA_ERROR_INVALID_RESOURCE;
}
}
char bu[MAX_SIZE];