Skip to main content

spi.readblob(numberOfBytes)

Reads data from SPI port and returns it as a series of bytes

Availability

Device

Parameters

Name Type Description
numberOfBytes Integer How many bytes to read in from the bus

Returns

Blob — the bytes read from the SPI bus

Description

This method reads a specified quantity of data from the target SPI bus and returns it as a Squirrel blob. If the SPI is configured for full duplex operation, the same number of zero bytes will be automatically clocked out of COPI (controller out, peripheral in).

COPI was previously referred to as MOSI.

Example Code

The code below provides a very basic example of interacting with an SPI device, initially by reading in eight bytes of data into a blob using spi.readblob().