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:
@@ -414,8 +414,17 @@ mraa_gpio_dir(mraa_gpio_context dev, gpio_dir_t dir)
|
|||||||
int direction = open(filepath, O_RDWR);
|
int direction = open(filepath, O_RDWR);
|
||||||
|
|
||||||
if (direction == -1) {
|
if (direction == -1) {
|
||||||
|
// 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;
|
return MRAA_ERROR_INVALID_RESOURCE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char bu[MAX_SIZE];
|
char bu[MAX_SIZE];
|
||||||
int length;
|
int length;
|
||||||
|
|||||||
Reference in New Issue
Block a user