![VersaLogic VL-EBX-37 Скачать руководство пользователя страница 45](http://html1.mh-extra.com/html/versalogic/vl-ebx-37/vl-ebx-37_reference-manual_1006785045.webp)
Interfaces and Connectors
EBX-37 Reference Manual
39
'D6 SLAVEFA2 = 1 " " " "
'D5 SLAVEFA1 = 0 " " " "
'D4 SLAVEFA0 = 0 " " " "
'D3 SLAVEHA2 = 0 Slave Address Bits (Hardware Address Bits)
'D2 SLAVEHA1 = 0 " " " "
'D1 SLAVEHA0 = 0 " " " "
'D0 READWRITE = 0 Read/Write Bit = Write
OUT SPIDATA3, &H40
WHILE (INP(SPISTATUS) AND &H1) = &H1: WEND
'INITIALIZE DIRECTION OF DIO LINES D15-D8 AS INPUTS
'==================================================
'Direction = All Inputs
OUT SPIDATA1, &HFF
'MCP23S17 IODIRA Register Address
OUT SPIDATA2, &H0
'MCP23S17 SPI Control Byte (Write)
OUT SPIDATA3, &H40
WHILE (INP(SPISTATUS) AND &H1) = &H1: WEND
'Repeat until ESC key is pressed
WHILE INKEY$ <> CHR$(27)
'READ DIO INPUT DATA FROM MCP23S17
'---------------------------------
'MCP23S17 GPIOA Register Address
OUT SPIDATA2, &H12
'MCP23S17 SPI Control Byte (Read)
OUT SPIDATA3, &H41
WHILE (INP(SPISTATUS) AND &H1) = &H1: WEND
'DIO Input Data
PRINT HEX$(INP(SPIDATA1))
WEND
SYSTEM