Page 299 of 346 Start Back Next End ZBasic System Library 287 ZBasic Microcontrollers SPIGetData Type Function returning UnsignedInteger Invocation SPIGetData(channel, readCnt, readData, writeData) SPIGetData(channel, readCnt, readData) Parameter Method Type Description channel ByVal Byte The SPI channel number (1-4). readCnt ByVal integral The number of bytes to read (0 – 65535). readData ByRef any type The variable in which to place the data read from the slave device. writeData ByVal Byte The data value to send to the slave for each byte received. Discussion This function sends a data byte to an SPI slave the specified number of times and stores the byte returned by the slave in response in successive bytes of the variable provided (typically a Byte array). For the second form, the data byte sent while receiving is zero. The value returned is equal to the number of bytes placed in the variable. If the channel number is invalid or the channel is not open, the return value is zero. Note that this is a low level function that must be used in concert with other low level routines to effect an SPI bus transaction. Example Dim idata(1 to 10) as Byte Call OpenSPI(1, 0, 12) Call SPIStart(1, &H03) Call SPIGetData(1, 10, idata) Compatibility This routine is not available in BasicX compatibility mode nor it is available for VM devices. See Also CloseSPI, OpenSPI, SPIGetByte, SPIPutByte, SPIPutData, SPIStart, SPIStop