# GPIO_FTDI Gpio driver using ftdi usb chips e.g.: ```shell $ lsusb Bus 001 Device 008: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC ``` ## Requirements * libftdi1 * libftdi1-dev ### Debian ```shell apt install libftdi1 libftdi1-dev ``` ### Alpine Linux ```shell apk add libftdi1 libftdi1-dev ``` ## Installation ```shell make install ``` Installs `lobgpio_ftdi.a` and `libgpio_ftdi.so` in the directory `$(PREFIX)/lib/`. It also installs the include header files `ftdi_dev.h` and `gpio.h` in the directory `$(PREFIX)/include/gpio_ftdi`. The default value for `PREFIX` is: `PREFIX=usr`. To use another location for installation changing the value of the `PREFIX` variable is needed. E.g.: ```shell PREFIX=/usr/local/ make install ``` ## Uninstallation ```shell make install ``` Removes the files installed with the `install` make target. > **NOTE:** When `PREFIX` variable was changed during installation process the same value needs to be set for uninstallation. E.g.: ```shell PREFIX=/usr/local/ make install ``` ## Example ```C #include #include #include #include #include #include #include static struct ftdi_dev ftdi_obj = { .ftdi = NULL, .is_open = false, .vendor_id = 0x0403, .product_id = 0x6001, .bit_mask = 0, .status_mask = 0, }; static const struct gpio gpio_1 = { .pin = 0x08, /* CTS (brown wire on FTDI cable) */ .ftdi_dev = &ftdi_obj, }; int main(void) { int res, cnt; unsigned int value; openlog("ftdi_gpio", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1); res = gpio_open(&gpio_1); if(res != EXIT_SUCCESS) { syslog(LOG_ERR, "Unable to open gpio\n"); return res; } gpio_write(&gpio_1, 1); for(cnt = 0; cnt < 10; cnt++) { gpio_toggle(&gpio_1); gpio_read(&gpio_1, &value); printf("Gpio1: %u\n", value); sleep(1); } gpio_close(&gpio_1); return EXIT_SUCCESS; } ``` ## Additional make targets | Target | Meaning | | --------------- | ----------------------------------------------------------- | | all | Build the code, assemble the static and shared library. | | install | Install the libraries and necessary include header files. | | uninstall | Uninstall the libraries and necessary include header files. | | clean | Clean up build artifacts. | | build_unit_test | Build the unit tests. | | exec_unit_test | Execute the unit tests. | | coverage | Determine code coverage of the unit tests. | | check | Static code analysis (cppcheck). |