Add the active state argument.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
return error_descr[errnum - __GPIOD_ERRNO_OFFSET];
}
-int gpiod_simple_get_value(const char *device, unsigned int offset)
+int gpiod_simple_get_value(const char *device,
+ unsigned int offset, bool active_low)
{
struct gpiod_line_request_config config;
struct gpiod_chip *chip;
memset(&config, 0, sizeof(config));
config.consumer = libgpiod_consumer;
config.direction = GPIOD_DIRECTION_INPUT;
+ config.active_state = active_low ? GPIOD_ACTIVE_STATE_LOW
+ : GPIOD_ACTIVE_STATE_HIGH;
chip = gpiod_chip_open_lookup(device);
if (!chip)
* @brief Read current value from a single GPIO line.
* @param device Name, path or number of the gpiochip.
* @param offset GPIO line offset on the chip.
+ * @param active_low The active state of this line - true if low.
* @return 0 or 1 if the operation succeeds. On error this routine returns -1
* and sets the last error number.
*/
-int gpiod_simple_get_value(const char *device, unsigned int offset) GPIOD_API;
+int gpiod_simple_get_value(const char *device,
+ unsigned int offset, bool active_low) GPIOD_API;
/**
* @}
return EXIT_FAILURE;
}
- value = gpiod_simple_get_value(device, offset);
+ value = gpiod_simple_get_value(device, offset, false);
if (value < 0) {
fprintf(stderr,
"%s: error reading GPIO value: %s\n",