Applications and drivers need to pass commands, so they need to define a set of data structures that can be recognized by both parties, in actual use, they include header files with the same name and content but different positions.
For example, the header file spi_gpio_ad7193.h contains the _ mode/_ Conf
struct _mode { // Mode Register Settings unsigned char mode:3; unsigned char dat_sta:1; unsigned char clk:2; unsigned char avg:2; unsigned int fs:10;};
It also includes the definitions used by drivers and applications.
// reset the device #define CMD_DEVICE_RESET _IOW(SPI_IOC_MAGIC, 1, __u32)// Calibrate channel// (‘cmd‘refer to: Operations Modes[MOD_INTERNAL_ZS_CAL:MOD_SYSTEML_FS_CAL])#define CMD_CHANNEL_CALIB _IOW(SPI_IOC_MAGIC, 2, __u32)
In my openwrt, the C source code of the driver and application is stored in openwrt/package/utils.
SPI driver header file # include <Linux/SPI/spi_gpio_ad7193.h> corresponds to build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/include/uapi/Linux/SPI/spi_gpio_ad7193.h
SPI application header file # include <Linux/SPI/spi_gpio_ad7193.h> corresponds to build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.49/user_headers/include/Linux/SPI/spi_gpio_ad7193.h
The header file of the application can be placed under the directory of your utils file, which should be easier to manage.
If you want to automatically copy your spi_gpio_ad7193.h to your/linux-3.10.49/include/uapi/Linux/SPI/after make clean, before making clean, place the spi_gpio_ad7193.h file in target/Linux/generic/files/include/uapi/Linux/SPI.
In this way, after you make clean & make v = s, the file will be automatically copied to the corresponding directory, and the header file will not be found during driver compilation.