int fd = open(NULL == device ? default_device : device, O_WRONLY);
if (fd != -1) {
drv8825_rotate cfg;
cfg.step = step;
cfg.delay = delay;
ioctl(fd, DRV8825_SET_ROTATE, &cfg);
close(fd);
}
#define GPIO_SYSFS "/sys/class/gpio"
static int gpio_enable(int gpio, unsigned char enable)
{
const char *export_file = GPIO_SYSFS "/export";
const char *unexport_file = GPIO_SYSFS "/unexport";
int fd;
int status = -1;
if (gpio <= 0)
return -1;
fd = open(enable ? export_file : unexport_file, O_WRONLY);
if (fd != -1) {
char number[4] = {0};
const size_t len = 3;
snprintf(number, len, "%u", gpio);
if ((ssize_t)len == write(fd, number, len))
status = 0;
close(fd);
}
return status;
}