#include #include "ftdi.h" int main (int argc, const char * argv[]) { unsigned char eeprom_buf[128]; int size_check; int res = 0; struct ftdi_context ftdi; struct ftdi_eeprom eeprom; FILE* fp = NULL; if( argc != 2 || !(fp = fopen(argv[1], "rb")) ) { return -1; } res = fread(eeprom_buf, 1, 128, fp); fclose(fp); if( res != 128 ) { printf("Read only %d bytes, 128 required!\n", res); return -1; } puts("Opening device..."); ftdi_init(&ftdi); res = ftdi_usb_open(&ftdi, 0x0403, 0x6001); if( res < 0 ) { printf("Error opening device: %d\n", res); return -1; } printf("erase: %d\n", ftdi_erase_eeprom(&ftdi)); printf("write: %d\n", ftdi_write_eeprom(&ftdi, eeprom_buf)); ftdi_usb_close(&ftdi); ftdi_deinit(&ftdi); // insert code here... printf("OK\n"); return 0; }