nsdsp_session_fetch_data_nb
nsdsp_session_flush nsdsp_session_send_uart nsdsp_session_send_spi nsdsp_session_receive_spi nsdsp_session_set_cke nsdsp_session_set_smp nsdsp_session_set_mclr nsdsp_session_set_hvp nsdsp_session_set_pgm nsdsp_session_set_pgcd nsdsp_session_set_red_led nsdsp_session_set_green_led nsdsp_session_short_delay nsdsp_session_delay_us nsdsp_session_delay_msnsdsp_session_fetch_data_nb
This function retrieves the data from NSDSP. Unlike nsdsp_session_fetch_data, if the data is not immediately available, it fetches whatever data is available and returns.
Syntax
unsigned int nsdsp_session_fetch_data_nb(
nsdsp_session_t session,
void* data,
unsigned int size
);
Parameters
session - a reference to the Session Object
data - the buffer to be filled in with data
size - the size of the data requested in bytes
Return
The function returns the amount of data put into the buffer. This may be less than size. If there is no data immediately available, the function returns zero.
Example
This example shows how to organize a pipeline to receive SPI data.
#define MAX_CHUNK 0x8000
int ReceiveSPIData(nsdsp_session_t Session, char* Buffer, int Length) {
int Chunk;
int Outstanding;
int Received;
Outstanding = 0;
while (Length) {
Chunk = MAX_CHUNK;
if (Chunk > Length) Chunk = Length;
// Transmit read commands to the NSDSP programmer
if (!nsdsp_session_receive_spi(Session,Chunk)) return 0;
Outstanding += Chunk;
Length -= Chunk;
// Receive only the data that has already arrived
Received = nsdsp_session_fetch_data_nb(Session,Buffer,Outstanding);
Outstanding -= Received;
Buffer += Received;
}
// Make sure all the commands are transferred to the NSDSP programmer
if (!nsdsp_session_flush(Session)) return 0;
if (Outstanding == 0) return 1;
// Wait until the rest of the data arrives and fetch it
return nsdsp_session_fetch_data(Session,Buffer,Outstanding);
}
Supported session types: UART,SPI
Minimum library version - 163
© 2007-2025 Northern Software Inc. All Rights Reserved.