From 936fe64c4a04aece9738c07f468d7fa6febc8275 Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Wed, 31 Dec 2025 12:09:58 +0100 Subject: [PATCH] ftdipp_mpsse.cpp: setClkFreq: flush buffers before changing clock frequency --- src/ftdipp_mpsse.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ftdipp_mpsse.cpp b/src/ftdipp_mpsse.cpp index 0c13a4e..3deb7da 100644 --- a/src/ftdipp_mpsse.cpp +++ b/src/ftdipp_mpsse.cpp @@ -377,6 +377,17 @@ int FTDIpp_MPSSE::setClkFreq(uint32_t clkHZ) float real_freq = 0; uint16_t presc; +#if (FTDI_VERSION < 105) + ftdi_usb_purge_buffers(_ftdi); +#else + if ((ret = ftdi_tcioflush(_ftdi)) < 0) { + printError("selfClkFreq: fail to flush buffers: " + + string(ftdi_get_error_string(_ftdi))); + return ret; + } + +#endif + _clkHZ = clkHZ; /* FT2232C has no divide by 5 instruction @@ -446,17 +457,6 @@ int FTDIpp_MPSSE::setClkFreq(uint32_t clkHZ) return ret; } -#if (FTDI_VERSION < 105) - ftdi_usb_purge_buffers(_ftdi); -#else - if ((ret = ftdi_tcioflush(_ftdi)) < 0) { - printError("selfClkFreq: fail to flush buffers: " + - string(ftdi_get_error_string(_ftdi))); - return ret; - } - -#endif - _clkHZ = real_freq; return real_freq;