October 2017
Intermediate to advanced
586 pages
14h 8m
English
The advantage of using IOCTL is that you can work in full duplex. The best example you can find is documentation/spi/spidev_test.c in the kernel source tree, of course.
The preceding example using read/write did not change any SPI configuration. However, the kernel exposes to the user space a set of IOCTL commands, which you can use in order to set up the bus according to your needs, just like what is done in the DT. The following example shows how you can change the bus settings:
#include <stdint.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <sys/ioctl.h> #include <linux/types.h> #include <linux/spi/spidev.h> static int pabort(const char *s) { perror(s); return -1; ...