public FT_STATUS EraseEEPROM()
{
// Initialise ftStatus to something other than FT_OK
FT_STATUS ftStatus = FT_STATUS.FT_OTHER_ERROR;
FT_ERROR ftErrorCondition = FT_ERROR.FT_NO_ERROR;
// If the DLL hasn't been loaded, just return here
if (hFTD2XXDLL == IntPtr.Zero)
return ftStatus;
// Check for our required function pointers being set up
if (pFT_EraseEE != IntPtr.Zero)
{
tFT_EraseEE FT_EraseEE = (tFT_EraseEE)Marshal.GetDelegateForFunctionPointer(pFT_EraseEE, typeof(tFT_EraseEE));
if (ftHandle != IntPtr.Zero)
{
FT_DEVICE DeviceType = FT_DEVICE.FT_DEVICE_UNKNOWN;
// Check that it is not an FT232R or FT245R that we are trying to erase
GetDeviceType(ref DeviceType);
if (DeviceType == FT_DEVICE.FT_DEVICE_232R)
{
// If it is a device with an internal EEPROM, throw an exception
ftErrorCondition = FT_ERROR.FT_INCORRECT_DEVICE;
ErrorHandler(ftStatus, ftErrorCondition);
}
// Call FT_EraseEE
ftStatus = FT_EraseEE(ftHandle);
}
}
else
{
if (pFT_EraseEE == IntPtr.Zero)
{
LogB.Debug("FTD2XX: Failed to load function FT_EraseEE.");
}
}
return ftStatus;
}