Constructor
new SoftSPI(options)
Creates a new SPI instance for a slave device.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Members
(static, constant) LSB
Least Significatn Bit (= 0)
- Source:
(static, constant) MSB
Most Significant Bit (= 1)
- Source:
bitOrder
Returns the bit order.
- Source:
bitOrder
Sets the bit order at transfering data.
- Source:
mode
Returns the SPI mode.
- Source:
mode
Sets the SPI mode.
- Source:
Methods
close() → {SoftSPI}
Closes the connection to the client by closing the pins.
- Source:
Returns:
- Type
- SoftSPI
open() → {SoftSPI}
Opens the connection to the client by setting up the pins.
- Source:
Returns:
- Type
- SoftSPI
read(bytes) → {Array}
Reads the number of bytes from client and supplies them as an array.
Parameters:
| Name | Type | Description |
|---|---|---|
bytes |
Number | Number of bytes to read |
- Source:
Returns:
- Type
- Array
transfer(data, readopt, writeopt) → {Array}
Transfers the given data to the client and returns data from the client.
The given data can be any data, which is transformable to a byte array.
Returns the read data from the client as an array. Each element is one byte.
The read data has exactly the same number of bytes like the written data.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
data |
Any | |||
read |
Boolean |
<optional> |
true | Read data from the client |
write |
Boolean |
<optional> |
true | Write data to the client |
- Source:
Returns:
- Type
- Array
write(data) → {SoftSPI}
Writes the given data to the client.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Any |
- Source:
Returns:
- Type
- SoftSPI