cl spidev
1.1.0A library for the Linux SPIDEV kernel module as used on hobby kits such as the Raspberry Pi
Table of Contents
About cl-spidev
This is a bindings library for the Linux SPIDEV kernel module as described on https://www.kernel.org/doc/Documentation/spi/spidev. It provides both direct low-level, and high-level convenient access.
How To
List all the available SPIDEV devices.
(spidev:devices)
Create a handle object to one of them.
(defvar *handle* (spidev:open "0.0"))
You can then read out the current information of the device.
(spidev:mode *handle*)
(spidev:lsb-first *handle*)
(spidev:bits/word *handle*)
(spidev:max-speed *handle*)
You can also set the above places to the values you need them to be. See the respective docstrings.
Finally you can read from and write to the device.
(spidev:read* 12 *handle*)
(spidev:write* *handle* 1 2 3 4)
Once you are done you can either close the handle explicitly...
(spidev:close *handle*)
Or simply lose all references to it and wait for the GC to take care of it for you. Either way, it should be safe.
System Information
Definition Index
-
CL-SPIDEV-LLI
- ORG.SHIRAKUMO.SPIDEV.LLI
No documentation provided.-
EXTERNAL CONSTANT SPI-3WIRE
Constant holding the value defined in the kernel constant SPI_3WIRE.
-
EXTERNAL CONSTANT SPI-CPOL
Constant holding the value defined in the kernel constant SPI_CPOL.
-
EXTERNAL CONSTANT SPI-CS-HIGH
Constant holding the value defined in the kernel constant SPI_CS_HIGH.
-
EXTERNAL CONSTANT SPI-IOC-MESSAGE-1
Constant holding the value defined in the kernel constant SPI_IOC_MESSAGE(1).
-
EXTERNAL CONSTANT SPI-IOC-RD-BITS-PER-WORD
Constant holding the value defined in the kernel constant SPI_IOC_RD_BITS_PER_WORD.
-
EXTERNAL CONSTANT SPI-IOC-RD-LSB-FIRST
Constant holding the value defined in the kernel constant SPI_IOC_RD_LSB_FIRST.
-
EXTERNAL CONSTANT SPI-IOC-RD-MAX-SPEED-HZ
Constant holding the value defined in the kernel constant SPI_IOC_RD_MAX_SPEED_HZ.
-
EXTERNAL CONSTANT SPI-IOC-RD-MODE
Constant holding the value defined in the kernel constant SPI_IOC_RD_MODE.
-
EXTERNAL CONSTANT SPI-IOC-RD-MODE32
Constant holding the value defined in the kernel constant SPI_IOC_RD_MODE32.
-
EXTERNAL CONSTANT SPI-IOC-WR-BITS-PER-WORD
Constant holding the value defined in the kernel constant SPI_IOC_WR_BITS_PER_WORD.
-
EXTERNAL CONSTANT SPI-IOC-WR-LSB-FIRST
Constant holding the value defined in the kernel constant SPI_IOC_WR_LSB_FIRST.
-
EXTERNAL CONSTANT SPI-IOC-WR-MAX-SPEED-HZ
Constant holding the value defined in the kernel constant SPI_IOC_WR_MAX_SPEED_HZ.
-
EXTERNAL CONSTANT SPI-IOC-WR-MODE
Constant holding the value defined in the kernel constant SPI_IOC_WR_MODE.
-
EXTERNAL CONSTANT SPI-IOC-WR-MODE32
Constant holding the value defined in the kernel constant SPI_IOC_WR_MODE32.
-
EXTERNAL CONSTANT SPI-LOOP
Constant holding the value defined in the kernel constant SPI_LOOP.
-
EXTERNAL CONSTANT SPI-LSB-FIRST
Constant holding the value defined in the kernel constant SPI_LSB_FIRST.
-
EXTERNAL CONSTANT SPI-MODE-0
Constant holding the value defined in the kernel constant SPI_MODE_0.
-
EXTERNAL CONSTANT SPI-MODE-1
Constant holding the value defined in the kernel constant SPI_MODE_1.
-
EXTERNAL CONSTANT SPI-MODE-2
Constant holding the value defined in the kernel constant SPI_MODE_2.
-
EXTERNAL CONSTANT SPI-MODE-3
Constant holding the value defined in the kernel constant SPI_MODE_3.
-
EXTERNAL CONSTANT SPI-NO-CS
Constant holding the value defined in the kernel constant SPI_NO_CS.
-
EXTERNAL CONSTANT SPI-READY
Constant holding the value defined in the kernel constant SPI_READY.
-
EXTERNAL CONSTANT SPI-RX-DUAL
Constant holding the value defined in the kernel constant SPI_RX_DUAL.
-
EXTERNAL CONSTANT SPI-RX-QUAD
Constant holding the value defined in the kernel constant SPI_RX_QUAD.
-
EXTERNAL CONSTANT SPI-TX-DUAL
Constant holding the value defined in the kernel constant SPI_TX_DUAL.
-
EXTERNAL CONSTANT SPI-TX-QUAD
Constant holding the value defined in the kernel constant SPI_TX_QUAD.
-
EXTERNAL SPECIAL-VARIABLE *SPIDEV-ROOT*
The root path for SPIDEV devices. Should be /dev/
-
EXTERNAL FUNCTION BITS/WORD
- HANDLE
- &REST
Accessor to how many bits there are per word on the SPIDEV device. The value should be a positive integer, where 0 defaults to 8. See IOCTL See SPI-IOC-RD-BITS-PER-WORD See SPI-IOC-WR-BITS-PER-WORD
-
EXTERNAL FUNCTION (SETF BITS/WORD)
- BITS
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION CLOSE-SPI
- HANDLE
- &REST
Close a handle to a SPIDEV device. See WITH-OPEN-SPI
-
EXTERNAL FUNCTION DEVICES
Return a list of available SPIDEV devices on the system.
-
EXTERNAL FUNCTION LSB-FIRST
- HANDLE
- &REST
Accessor to whether the least significant byte comes first on the SPIDEV device. The value should be T or NIL. See IOCTL See SPI-IOC-RD-LSB-FIRST See SPI-IOC-WR-LSB-FIRST
-
EXTERNAL FUNCTION (SETF LSB-FIRST)
- VALUE
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION MAX-SPEED
- HANDLE
- &REST
Accessor to the maximum speed frequency of the SPIDEV device in Hertz. The value should be a positive integer. If it is too large and the device refuses to adjust to it, a warning is signalled. The actual rate in Hertz is returned. See IOCTL See SPI-IOC-RD-MAX-SPEED-HZ See SPI-IOC-WR-MAX-SPEED-HZ
-
EXTERNAL FUNCTION (SETF MAX-SPEED)
- VALUE
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION MODE
- HANDLE
- &REST
Accessor to the mode in which the SPIDEV device operates. The value should be one of :MODE-0 :MODE-1 :MODE-2 :MODE-3 or a specific mode integer. See IOCTL See SPI-IOC-WR-MODE32 See SPI-IOC-RD-MODE32 See SPI-MODE-0 See SPI-MODE-1 See SPI-MODE-2 See SPI-MODE-3
-
EXTERNAL FUNCTION (SETF MODE)
- MODE
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION OPEN-SPI
- ID
- &KEY
- DIRECTION
- &REST
Open a handle to a SPIDEV device. See WITH-OPEN-SPI
-
EXTERNAL FUNCTION READ-BYTES
- BYTES
- HANDLE
- &KEY
- START
- END
- &REST
-
EXTERNAL FUNCTION TRANSMIT
- HANDLE
- BYTES
- SPEED-HZ
- DELAY-USECS
- BITS/WORD
- &REST
Perform a SPI transmission of the given byte sequence. The array must be an unsigned-byte 8 array that is sharable. On most implementations that matter this will correspond to any simple-vector with element-type unsigned-byte 8. The speed-hz, delay-usecs, and bits/word parameters are temp overrides for the device configuration during the transmission. Returned is a fresh vector of the same length as the bytes vector, containing the contents of the read buffer of the transmission. See CFFI:MAKE-SHAREABLE-BYTE-VECTOR
-
EXTERNAL FUNCTION WRITE-BYTES
- BYTES
- HANDLE
- &KEY
- START
- END
- &REST
-
EXTERNAL MACRO WITH-OPEN-SPI
- HANDLE
- ID
- &KEY
- DIRECTION
- &REST
- &BODY
- BODY
- &REST
-
CL-SPIDEV
- ORG.SHIRAKUMO.SPIDEV
- SPIDEV
No documentation provided.-
EXTERNAL STRUCTURE HANDLE
-
EXTERNAL FUNCTION BITS/WORD
- INSTANCE
- &REST
Accessor to how many bits there are in a word on the device. Should be an (UNSIGNED-BYTE 8) value. See HANDLE
-
EXTERNAL FUNCTION (SETF BITS/WORD)
- VALUE
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION CLOSE
- HANDLE
- &REST
Safely closes the SPIDEV device. It becomes unusable after this. See HANDLE
-
EXTERNAL FUNCTION DEVICES
Return a list of available SPIDEV devices on the system.
-
EXTERNAL FUNCTION HANDLE
- INSTANCE
- &REST
Returns the underlying stream handle of the handle object. This is useful when you need to interact with the low-level system directly for some reason. See HANDLE
-
EXTERNAL FUNCTION LSB-FIRST
- INSTANCE
- &REST
Accessor to whether the least significant byte comes first. Should be a boolean. See HANDLE
-
EXTERNAL FUNCTION (SETF LSB-FIRST)
- VALUE
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION MAX-SPEED
- INSTANCE
- &REST
Accessor to the maximum transfer speed of the SPIDEV device in Hertz. Should be an (UNSIGNED-BYTE 32) value. The device may reject your requested speed, in which case a warning is signalled and the actual speed is returned. See HANDLE
-
EXTERNAL FUNCTION (SETF MAX-SPEED)
- VALUE
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION MODE
- INSTANCE
- &REST
Accessor to the SPIDEV device's transfer mode. The value should be one of :MODE-0 :MODE-1 :MODE-2 :MODE-3 See HANDLE
-
EXTERNAL FUNCTION (SETF MODE)
- VALUE
- HANDLE
- &REST
No documentation provided. -
EXTERNAL FUNCTION OPEN
- ID
- &REST
Open a handle to a SPIDEV device. This will produce a safe object that will always ensure the underlying file-system handle is closed when the object is no longer referenced. It will also cache the properties of the underlying device, so read access to them should be fast. See HANDLE
-
EXTERNAL FUNCTION READ
- BYTES
- HANDLE
- &KEY
- START
- END
- &REST
-
EXTERNAL FUNCTION READ*
- N
- HANDLE
- &REST
Read n words from the SPIDEV device into a fresh array. See READ
-
EXTERNAL FUNCTION TRANSMIT
- HANDLE
- BYTES
- &KEY
- SPEED
- DELAY
- BITS/WORD
- &REST
Perform a SPI transmission of the given byte sequence. The array must be an unsigned-byte 8 array. The speed-hz, delay-usecs, and bits/word parameters are temp overrides for the device configuration during the transmission. They default to MAX-SPEED, 0, and BITS/WORD respectively. Returned is a fresh vector of the same length as the bytes vector, containing the contents of the read buffer of the transmission. See HANDLE See MAX-SPEED See BITS/WORD
-
EXTERNAL FUNCTION WRITE
- BYTES
- HANDLE
- &KEY
- START
- END
- &REST
Write a sequence of words to the SPIDEV device. The bytes vector should contain unsigned-bytes of size up to the number of BITS/WORD of the handle. The bytes written are automatically flushed to the spi device handle, so that when WRITE returns, the operation should have completed. If you need to manually control flushing or need to write in much smaller intervals, please refer to the low- level interface. See HANDLE See WRITE*
-
EXTERNAL FUNCTION WRITE*
- HANDLE
- &REST
- BYTES
- &REST
Writes the bytes in the arguments list to the SPIDEV device. See WRITE