X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=src%2Fftdi.c;h=2a979423b61b0e81a049fe9a0c2ffc537da3bde8;hp=79e24abba354d093a355ccd18207a787d472af59;hb=672fd36819344656810c1c1c69442a2901972794;hpb=cffed9f55dd41244427a803cc755d50330c84fd8 diff --git a/src/ftdi.c b/src/ftdi.c index 79e24ab..2a97942 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -3508,6 +3508,29 @@ int ftdi_get_eeprom_buf(struct ftdi_context *ftdi, unsigned char * buf, int size return 0; } +/** Set the EEPROM content from the user-supplied prefilled buffer + + \param ftdi pointer to ftdi_context + \param buf buffer to read EEPROM content + \param size Size of buffer + + \retval 0: All fine + \retval -1: struct ftdi_contxt or ftdi_eeprom of buf missing +*/ +int ftdi_set_eeprom_buf(struct ftdi_context *ftdi, const unsigned char * buf, int size) +{ + if (!ftdi || !(ftdi->eeprom) || !buf) + ftdi_error_return(-1, "No appropriate structure"); + + // Only copy up to FTDI_MAX_EEPROM_SIZE bytes + if (size > FTDI_MAX_EEPROM_SIZE) + size = FTDI_MAX_EEPROM_SIZE; + + memcpy(ftdi->eeprom->buf, buf, size); + + return 0; +} + /** Read eeprom location