本帖最后由 cx9911 于 2023-5-5 16:10 编辑
NUC972DF61Y 带linux系统运行,根据默认配置生成了对应的u-boot-spl.bin u-boot.bin 970uimage ubi.img并通过NuWriter.exe将这些文件烧录到芯片中。
运行如下代码: 提示can't set spi mode 用perror打印错误 提示Invalid atgument
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;
} |