QNX , i.mx6q通过spi配置APIX

原创
2018/10/26 09:49
阅读数 1.6K

#include <hw/spi-master.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <termios.h>
#include <fcntl.h>

 uint16_t Init_Data[37] ={
         0x7d81,0x0782,0x0083,0x0f84,0x0085,0x0086,0x0087,0x0e88,0x0089,0x208a,0x008b,0xc98c,
         0xae8d,0x008e,0x008f,0x0090,0x0191,0x6092,0xdc93,0x7094,0xe095,0x1f96,0x3f97,0x1f98,
         0x3f99,0x699a,0x119b,0x009c,0x629d,0x019e,0x6c9f,0x67a0,0x16a1,0x3fa2,0x80a3,0x00a4,0x01A6
};
unsigned char Read_Data =0x01;

spi_drvinfo_t drvinfo_lzq;
spi_devinfo_t devinfo_lzq;
spi_cfg_t cfg_lzq;

int main(int argc, char *argv[]) {

    unsigned char i;
    int fd_spi= spi_open("/dev/spi5");

    if(fd_spi){
        printf("SPI open ok, fd is %d \n",fd_spi);
    }

    cfg_lzq.mode=0x302;
    cfg_lzq.clock_rate=25000;

    spi_setcfg( fd_spi,SPI_DEV_DEFAULT,&cfg_lzq);
    spi_getdrvinfo( fd_spi, &drvinfo_lzq);
    spi_getdevinfo( fd_spi,SPI_DEV_DEFAULT,&devinfo_lzq);

    for(i=0;i<37;i++){
    spi_write(fd_spi,SPI_DEV_LOCK,&Init_Data[i],sizeof(Init_Data[0]));
    };

    close(fd_spi);

    printf("Welcome to the QNX Momentics IDE\n");
    return EXIT_SUCCESS;
}
 

展开阅读全文
加载中

作者的其它热门文章

打赏
0
0 收藏
分享
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部