File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ int FtdiSpi::ft2232_spi_wr_and_rd(//struct ftdi_spi *spi,
171171 const uint8_t * writearr, uint8_t * readarr)
172172{
173173 // -3: for MPSSE instruction
174- const uint32_t max_xfer = ((readarr) ? _buffer_size : 4096 );
174+ const uint16_t max_xfer = ((readarr) ? _buffer_size : 4096 );
175175 uint8_t buf[max_xfer];
176176 uint8_t cmd[] = {
177177 static_cast <uint8_t >(((readarr) ? (MPSSE_DO_READ | _rd_mode) : 0 ) |
@@ -195,16 +195,18 @@ int FtdiSpi::ft2232_spi_wr_and_rd(//struct ftdi_spi *spi,
195195 * operations.
196196 */
197197 while (len > 0 ) {
198- const uint32_t xfer = (len > max_xfer) ? max_xfer : len;
199- cmd[1 ] = ((xfer - 1 ) >> 0 ) & 0xff ;
200- cmd[2 ] = ((xfer - 1 ) >> 8 ) & 0xff ;
198+ const uint16_t xfer = (len > max_xfer) ? max_xfer : len;
199+ cmd[1 ] = static_cast <uint8_t >(((xfer - 1 ) >> 0 ) & 0xff );
200+ cmd[2 ] = static_cast <uint8_t >(((xfer - 1 ) >> 8 ) & 0xff );
201+ uint16_t xfer_len = 0 ; // 0 when read-only
202+
201203 mpsse_store (cmd, 3 );
202204 if (writearr) {
203205 memcpy (buf, tx_ptr, xfer);
204206 tx_ptr += xfer;
207+ xfer_len = xfer;
205208 }
206-
207- ret = mpsse_store (buf, xfer);
209+ ret = mpsse_store (buf, xfer_len);
208210 if (ret) {
209211 printError (" send_buf failed before read with error: " +
210212 std::string (ftdi_get_error_string (_ftdi)) + " (" +
You can’t perform that action at this time.
0 commit comments