/* transaction time: 2ms for 16 data bytes @6MHz, 1kB chunks */ int lgw_spi_rb(void *spi_target, uint8_t spi_mux_mode, uint8_t spi_mux_target, uint8_t address, uint8_t *data, uint16_t size) { struct mpsse_context *mpsse = spi_target; uint8_t command[2]; uint8_t command_size; int size_to_do, chunk_size, offset; int a=0, b=0, c=0, d=0; int i; /* check input parameters */ CHECK_NULL(spi_target); if ((address & 0x80) != 0) { DEBUG_MSG("WARNING: SPI address > 127\n"); } CHECK_NULL(data); if (size == 0) { DEBUG_MSG("ERROR: BURST OF NULL LENGTH\n"); return LGW_SPI_ERROR; } /* prepare command bytes */ if (spi_mux_mode == LGW_SPI_MUX_MODE1) { command[0] = spi_mux_target; command[1] = READ_ACCESS | (address & 0x7F); command_size = 2; } else { command[0] = READ_ACCESS | (address & 0x7F); command_size = 1; } size_to_do = size; /* start MPSSE transaction */ a = Start(mpsse); b = FastWrite(mpsse, (char *)&command, command_size); for (i=0; size_to_do > 0; ++i) { chunk_size = (size_to_do < LGW_BURST_CHUNK) ? size_to_do : LGW_BURST_CHUNK; offset = i * LGW_BURST_CHUNK; c = FastRead(mpsse, (char *)(data + offset), chunk_size); size_to_do -= chunk_size; /* subtract the quantity of data already transferred */ } d = Stop(mpsse); /* determine return code (only the last FastRead is checked) */ if ((a != MPSSE_OK) || (b != MPSSE_OK) || (c != MPSSE_OK) || (d != MPSSE_OK)) { DEBUG_MSG("ERROR: SPI BURST READ FAILURE\n"); return LGW_SPI_ERROR; } else { DEBUG_MSG("Note: SPI burst read success\n"); return LGW_SPI_SUCCESS; } }
void ByteBuffer::FastReadMultiCore( T& v, TS& ...vs ) { FastRead( v ); FastReadMultiCore( vs... ); }
void ByteBuffer::FastReadMultiCore( T& v ) { FastRead( v ); }