牛卧堂MCU技术交流
标题:
NUC970如何修改底层来正常使用spidev0.1
[打印本页]
作者:
匿名
时间:
2023-5-6 11:28
标题:
NUC970如何修改底层来正常使用spidev0.1
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;
}
复制代码
作者:
匿名
时间:
2023-5-6 11:28
NUC972DF61Y 带linux系统运行,根据默认配置生成了对应的u-boot-spl.bin u-boot.bin 970uimage ubi.img并通过NuWriter.exe将这些文件烧录到芯片中。
运行如下代码: 提示can't set spi mode 用perror打印错误 提示Invalid atgument
作者:
匿名
时间:
2023-5-9 16:35
请用demo测试看看
https://github.com/OpenNuvoton/N ... s/spi/spidev_test.c
欢迎光临 牛卧堂MCU技术交流 (http://nuvoton-mcu.com/)
Powered by Discuz! X3.2