DIO protocol
Introduction
The protocol for the SPI_dio, SPI_3FETs and SPI_7FETs will be explained on this page. Most functions apply to all three boards, but some don't.
The addresses on the SPI bus are 7 bits wide. The lower bit specifies if the transaction is to be a read or a write. Write transactions have the lower bit cleared (0), read transactions have the lower bit set (1).
Each transaction on the SPI bus starts with the address of the board. The spi_lcd board will ignore any transactions on the SPI bus that do not start with its own address.
After the address a single byte indicates the "port" on the board that the data is written to. The software can thus define 256 ports on each board.
Also see the general SPI protocol
write ports
Some ports just set a single value. So writing more than one byte to such a port is redundant. Other ports are logically a stream of bytes. So writing more than one byte is encouraged.
The spi_dio, spi_3fets and spi_7fets boards define several ports.
port | function |
---|---|
0x10 | set all outputs (bit 0 is output 0, etc). |
0x20 .. 0x27 | set one output (0x20 for output 0, 0x21 for output 1 etc) |
0x30 | define pins as inputs or outputs. 0 means input, 1 means output. |
0x40 | set current position. (only spi_dio and spi_7fets) |
0x41 | set target position. (only spi_dio and spi_7fets) |
0x42 | set relative position. (only spi_dio and spi_7fets) |
0x43 | set stepdelay. (in tenths of a microsecond, default 200: 20ms between steps). (only spi_dio and spi_7fets) |
0xf0 | change address. |
All the above ports are read/write. I.e. if you read from that port, you will get the current value.
read ports
The spi_dio, spi_3fets and spi_7fets boards support the following read ports:
port | function |
---|---|
0x01 | identification string. (terminated with 0). |
0x02 | read eeprom (serial number). |
0x10 | read all inputs |
0x20 .. 0x27 | read one input (0x20 for input 0, 0x21 for input 1 etc) |
0x40 | read current position. (only spi_dio and spi_7fets) |
0x41 | read target position. (only spi_dio and spi_7fets) |
0x43 | read stepdelay. (in tenths of a microsecond, default 200: 20ms between steps). (only spi_dio and spi_7fets) |
examples
read identification
read the identification string of the board. (spi_dio)
data sent | data recieved | explanation |
---|---|---|
0x85 | xx | select destination with address 0x82 for READ. |
0x01 | xx | identify |
xx | 0x73 | 's' |
xx | 0x70 | 'p' |
xx | 0x69 | 'i' |
xx | ... | etc. |
turn on all outputs
data sent | data recieved | explanation |
---|---|---|
0x88 | xx | select destination with address 0x88 for WRITE |
0x10 | xx | set outputs as in bitpattern (next byte) |
0xff | xx | All outputs active. |
turn on output 4
data sent | data recieved | explanation |
---|---|---|
0x88 | xx | select destination with address 0x88 for WRITE |
0x24 | xx | port 0x24: output 4... |
0xff | xx | ... active. |
move stepper to step 0x1234
data sent | data recieved | explanation |
---|---|---|
0x88 | xx | select destination with address 0x88 for WRITE |
0x41 | xx | port 0x41: set target position |
0x34 | xx | low byte |
0x12 | xx | high byte. |