GithubHelp home page GithubHelp logo

rbugoo131 / spi-tools Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cpb-/spi-tools

0.0 2.0 0.0 292 KB

Simple command line tools to help using Linux spidev devices

License: GNU General Public License v2.0

Makefile 14.08% C 85.92%

spi-tools's Introduction

spi-tools

This package contains some simple command line tools to help using Linux spidev devices.

Content

spi-config

Query or set the SPI configuration (mode, speed, bits per word, etc.)

spi-pipe

Send and receive data simultaneously to and from a SPI device.

License

The tools are released under the GPLv2 license. See LICENSE file for details.

Author

Christophe Blaess http://www.blaess.fr/christophe

Installation

First, get the latest version on https://github.com/cpb-/spi-tools.git

There is no need for configuration. Simply do a make to build the tools, then make install to install them and the man pages. If you have to use a cross-compilation toolchain, simply fill the CROSS_COMPILE environment variable with the cross-compiler prefix. By default the spi-tools are installed in /usr/sbin but you can change this location by setting the INSTALL_DIR environement variable. The man pages are installed under /usr/share/man but you can change this by setting the MAN_INSTALL_DIR environment variable. You can use make uninstall to remove the installed files.

Usage

spi-config usage

options

  • -d --device=<dev> use the given spi-dev character device.
  • -q --query print the current configuration.
  • -m --mode=[0-3] use the selected spi mode.
  • -l --lsb={0,1} LSB first (1) or MSB first (0).
  • -b --bits=[7...] bits per word.
  • -s --speed=<int> set the speed in Hz.
  • -h --help help screen.
  • -v --version display the version number.

Read the current configuration

$ spi-config -d /dev/spidev0.0 -q
/dev/spidev0.0: mode=0, lsb=0, bits=8, speed=500000
$

Change the clock frequency and read it again

$ spi-config -d /dev/spidev0.0 -s 10000000
$ spi-config -d /dev/spidev0.0 -q
/dev/spidev0.0: mode=0, lsb=0, bits=8, speed=10000000
$

spi-pipe usage

Options

  • -d --device=<dev> use the given spi-dev character device.
  • -b --blocksize=<int> transfer block size in byte.
  • -n --number=<int> number of blocks to transfer.
  • -h --help help screen.
  • -v --version display the version number.

Send and receive simultaneously

Sending data from command-1 to SPI link and receiving data from SPI link to command-2

$ command_1 | spi-pipe -d /dev/spidev0.0 | command_2

Note that command_1, command_2 and spi-pipe run simultaneously in three parallel processes.

Send data to the SPI link

$ command_1 | spi-pipe -d /dev/spidev0.0

Receive data from the SPI link

$ spi-pipe -d /dev/spidev0.0 < /dev/zero | command_2

You can also use command_2 < /dev/spidev0.0 but with spi-pipe you control what is sent to the device (always 0 in this case).

Read 40 blocks of 4 bytes from the SPI link

$ spi-pipe -d /dev/spidev0.0 -b 4 -n 40 < /dev/zero | command_2

spi-tools's People

Contributors

cpb- avatar diegorondini avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.