| Online Development Notebook > Index > ODN > USBm DLL Programming > Device Commands > SPIMaster |
SPIMaster
Description:
This is a USBm.dll function that is used to communicate with a slave SPI device. Zero to six bytes can be transferred in a single command. For each byte sent to a SPI slave device, a byte is returned. The returned bytes are in the response to the command
Command Syntax: (USBm.dll)
USBm_SPIMaster(device, count, data)
The USBm_SPIMaster function syntax has these parts:
| Part | Description |
| device | A zero-based index to address the appropriate USB device. |
| count | The number of bytes received (sent). |
| data | The function causes these variables to be changed to the data received from the SPI transfer. |
Remarks:
When the InitSPI function sets the SPI subsystem to be a master, only the SPI lines SCK, MISO, and MOSI are configured. A SPI device needs to be addressed with a slave select signal. Any remaining line of the U4xx can be set to be an output that controls the slave device SS input.
The slave must be selected prior to issuing the USBm_SPIMaster command and deselected afterward.
VB Declaration
| Public Declare Function USBm_SPIMaster _ Lib "USBm.dll" _ (ByVal device As Byte, _ ByRef count As Byte, _ ByRef data As Byte) _ As Integer |
VB Example
| Dim dataarray(6) As Byte dataarray(0) = &H55 USBm_SPIMaster 6, 1, dataarray(0) |
The slave must be selected (perhaps an active low CS) prior to issuing the SPIMaster funcrion and deselected afterward.
This code fragment will shift a single byte (55h) out the SPI port.
C Example
-TBD-
| Hardware: U401 USB Interface U421 USB Interface |
| Programming: USBm DLL Programming Download Files |
| Application Notes: U4x1 Application Notes Misc Applications and Information FAQ |