Connection between openwrt driver and Application

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.