====== SPI Bus in the MLAB Kit ====== [[https://en.wikipedia.org/wiki/Serial_Peripheral_Interface|SPI]] is, alongside [[i2c|I²C]], another widely used interface. Its advantages include simple operation, high data transfer rates, and full-duplex bidirectional communication. ===== Interface Handling in Python ===== To use SPI from a Python program, there is an [[https://pypi.python.org/pypi/spidev|existing library]]. In Linux, it can be installed from the command line: sudo apt-get install python-pip sudo pip install spidev [[http://tightdev.net/SpiDev_Doc.pdf|Library documentation.]] ===== Options for Connecting Devices to SPI ===== ==== Native SPI Interface ==== A significant portion of commercially available microcontrollers have an SPI interface as one of their peripherals. ==== Interfaces Created by Conversion ==== An SPI interface can also be created by converting from other standard buses. === From I²C === If the data transfer speed is not critical, the SPI interface can be created from the I²C bus using, for example, the [[i2cspi|I2CSPI01A]] module. This allows connecting multiple SPI slave devices. === From USB === When data transfer speed is important, it's preferable to use a bus with higher bandwidth, such as USB. To create an SPI interface, there are specific integrated circuits that mainly differ in software support: * [[https://www.microchip.com/wwwproducts/en/MCP2210|MCP2210]] [[https://github.com/daniel-santos/mcp2210-linux|out-of-tree driver]] * [[https://www.ftdichip.com/Products/ICs/FT4222H.html|FT4222H]] - HID driver? * [[http://www.silabs.com/products/interface/usbtouart/Pages/usb-to-spi-bridge.aspx|CP2130]] * [[xvc_ft220x|FTDI FT220]] - a possible candidate when writing an HID driver Connecting these chips to the operating system is rather [[https://christian.amsuess.com/idea-incubator/ftdi-kernel-support/|complicated]]. However, the [[https://archive.fosdem.org/2018/schedule/event/rapid_spi_over_usb/attachments/audio/2461/export/events/attachments/rapid_spi_over_usb/audio/2461/USB_SPI_FOSDEM_2018.pdf|best solution is probably]] using the MCP2210 on a new MLAB module. ===== Related Pages ===== * [[hbstep|Stepper Motor Driver]] * [[i2cspi|]]