Changes between Version 1 and Version 2 of SPI


Ignore:
Timestamp:
11/20/2017 08:28:50 PM (22 months ago)
Author:
Ryan Erbstoesser
Comment:

add spidev section back in

Legend:

Unmodified
Added
Removed
Modified
  • SPI

    v1 v2  
    7878
    7979[[Image(spi2388.png,800px)]]
     80
     81== spidev - Userspace SPI API ==
     82
     83SPI devices have a limited userspace API, supporting basic half-duplex read() and write() access to SPI slave devices. Using ioctl() requests, full duplex transfers and device I/O configuration are also available.
     84{{{
     85        #include <fcntl.h>
     86        #include <unistd.h>
     87        #include <sys/ioctl.h>
     88        #include <linux/types.h>
     89        #include <linux/spi/spidev.h>
     90}}}
     91Some reasons you might want to use this programming interface include:
     92
     93* Prototyping in an environment that's not crash-prone; stray pointers in userspace won't normally bring down any Linux system.
     94* Developing simple protocols used to talk to microcontrollers acting as SPI slaves, which you may need to change quite often.
     95
     96Of course there are drivers that can never be written in userspace, because they need to access kernel interfaces (such as IRQ handlers or other layers of the driver stack) that are not accessible to userspace.
     97
     98Userspace access to SPI devices is done through the /dev/spidev<bus>.<chip-select> device interface. In order to use this you must have spidev enabled in the kernel (CONFIG_SPI_SPIDEV) and have a spidev node defined under the SPI controller in the device-tree.
     99
     100For more info see:
     101* [https://web.archive.org/web/20170619204541/https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/spi/spidev spidev Kernel Documentation]
     102* [https://web.archive.org/web/20170619204541/https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/spi/spidev spidev examples]
     103* [https://web.archive.org/web/20170619204541/https://lxr.missinglinkelectronics.com/linux/drivers/spi/spidev.c spidev kernel driver]