Python Library – spidev

library icon
Python spidev library

Informatie (ENG):

Python bindings for Linux SPI access through spidev

Python Spidev
=============
This project contains a python module for interfacing with SPI devices from user space via the spidev linux kernel driver.
This is a modified version of the code originally found [here](http://elk.informatik.fh-augsburg.de/da/da-49/trees/pyap7k/lang/py-spi)
All code is GPLv2 licensed unless explicitly stated otherwise.

Usage

Settings

* bits_per_word
* cshigh
* loop
* lsbfirst
* max_speed_hz
* mode – SPI mode as two bit pattern of clock polarity and phase [CPOL|CPHA], min: 0b00 = 0, max: 0b11 = 3
* threewire – SI/SO signals shared

Methods
——-
open(bus, device) / Connects to the specified SPI device, opening /dev/spidev-bus.device
readbytes(n) / Read n bytes from SPI device.
writebytes(list of values) / Writes a list of values to SPI device.

xfer(list of values[, speed_hz, delay_usec, bits_per_word])
Performs an SPI transaction. Chip-select should be released and reactivated between blocks.
Delay specifies the delay in usec between blocks.

xfer2(list of values[, speed_hz, delay_usec, bits_per_word])
Performs an SPI transaction. Chip-select should be held active between blocks.

close()
Disconnects from the SPI device.

Installatie via Source (TAR.GZ)

Eerst heb je de python DEV dependancies nodig, installeer deze met het commando:

sudo apt-get install python-dev

Installeer de module met de volgende commando’s:

wget https://pypi.python.org/packages/source/s/spidev/spidev-3.1.tar.gz

tar -zxvf spidev-3.1.tar.gz

cd spidev-3.1

sudo python setup.py install

Download spidev @ pypi.python.org