Fork me on GitHub

eFirmata

Connecting the real world to the digital world.

Introduction

Compatable Hardware:

Protocols:

Example Projects:

Compiler

Installing the Binary

About / Credits / Contact

Protocol - SPI over UDP (port 2118)

SPI - Send SPI data


SPI data from the PC to the eFirmata
0001020304050607 0809101112131415 1617181920212223 2425262728293031
'e' 'F' 'i' 'r'
'm' 'a' 't' 'a'
'S' 'P' 'I' Version = 0
Reserved = 0 wait CPOL CPHA

SPI character data ...

... 255 octets max ...
 

The SPI data transfer format is set by CPOL and CPHA.

If the wait bit is set, the firmware should wait for the CS pin to become inactive before sending this data. (This is to help deal with the buggy dSpin stepper-motor controller.)

NOTE: the "wait", "CPOL" and "CPHA" bits are not implemented yet. :-(
There is no wait. CPOL and CPHA are both hard-coded to 1. (coming soon!...)

The number of bytes is inferred from the UDP packet length.

The data should be kept fairly small. The PC should wait for return data before sending more data. The internal buffer is only 256 frames, and the network can run much faster than the SPI. It is possible to completely overflow the input buffer. (Perhaps this would work better as TCP?...)

Response

SPI - Return SPI data


SPI data from the eFirmata to the PC
0001020304050607 0809101112131415 1617181920212223 2425262728293031

SPI character data ...

...
 

The return data has no additional structure; it is simply the data contained in the UDP packet.

The eFirmata MAY return multiple packets. (In fact, it is LIKELY that the return data will be broken up across multiple packets.)

The eFirmata MUST return the same number of data bytes as were sent to it. (This is the very nature of SPI -- one byte is received and transmitted at the same time.)