- static int fd_ADC;
- static unsigned int mode;
- static unsigned char bits = 8;
- static unsigned int speed = 500000;
- static unsigned short spi_delay=0;
- int OpenADC()
- {
- int ret=0;
- fd_ADC = open("/dev/spidev1.0", O_RDWR);
- if (fd_ADC == -1)
- {
- printf("Open /dev/adc error\n");
- return -1;
- }
- mode=SPI_MODE_0;
- ret = ioctl(fd_ADC, SPI_IOC_WR_MODE, &mode);
- if (ret == -1) { printf("can't set spi mode\n");
- perror("Fail:"); exit(EXIT_FAILURE);}
- ret = ioctl(fd_ADC, SPI_IOC_WR_BITS_PER_WORD, &bits);
- if (ret == -1) printf("can't set bits per word\n");
- ret = ioctl(fd_ADC, SPI_IOC_WR_MAX_SPEED_HZ, &speed);
- if (ret == -1) printf("can't set max speed hz\n");
- return 0;
- }
[color=rgb(51, 102, 153) !important]复制代码
|
大佬,你弄好了吗?我现在spi可以打开,但是怎么加PDMA?