Skip to main content

Python bindings for Linux SPI access through spidev

Project description

#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)

##Usage

`python import spidev spi = spidev.SpiDev() spi.open(bus, device) to_send = [0x01, 0x02, 0x03] spi.xfer(to_send) ` ##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.

#Changelog

## 3.0

## 2.0

Code sourced from http://elk.informatik.fh-augsburg.de/da/da-49/trees/pyap7k/lang/py-spi and modified.

## Pre 2.0

spimodule.c originally uathored by Volker Thoms, 2009.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spidev-3.0.tar.gz (12.4 kB view details)

Uploaded Source

File details

Details for the file spidev-3.0.tar.gz.

File metadata

  • Download URL: spidev-3.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for spidev-3.0.tar.gz
Algorithm Hash digest
SHA256 af3ec8bf50f2577f62407b1ff1c0be3d5dadcdc3ce0ba2f8eea15e647ff2b51e
MD5 06a4f20ad3fb108b719bf4fcc5126607
BLAKE2b-256 94c7d7434902a367cacb975c0905b05bc3592737eadf36dce8b2320ac885bf4e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page