linux spidev,linux - SPI device access using SPIDEV - Stack Overflow

在嵌入式Linux系统上尝试通过SPIDEV驱动访问连接到SPI0的AvagoTech光学鼠标设备,已启用SPI和用户模式SPI设备驱动,配置了board.c文件,但系统启动后在/sys/class/spidev/目录下找不到设备,且没有SPI相关的引用。检查过电气连接,问题可能出在配置或驱动加载上。
摘要由CSDN通过智能技术生成

I want to access an SPI device (an optical mouse device from Avago Tech) on an embedded Linux system using the SPIDEV driver. The device is connected to SPI0.

I enabled SPI and "User mode SPI device driver support" in menuconfig > "Device Drivers" > "SPI".

I added the code to the board.c file

static struct spi_board_info spidev_board_info[] {

{

.modalias = "spidev",

.max_speed_hz = 1000000,

.bus_num = 1,

.chips_select = 0,

.mode = SPI_MODE_3,

},

{

.modalias = "spidev",

.max_speed_hz = 1000000,

.bus_num = 1,

.chips_select = 1,

.mode = SPI_MODE_3,

},

};

spi_register_board_info(spidev_board_info, ARRAY_SIZE(spidev_board_info));

I tried both 500000 and 1000000 as max_speed_hz (1Mhz being the highest allowed by the sensor). SPI_MODE_3 is correct, checked on the datasheet. bus_num = 1 should correct as it refers to SPI0 (I also tried = 0 out of curiosity).

I checked the electrical connections and are all working.

The kernel compiles and the image starts correctly, but I cannot find any device in /sys/class/spidev/ (neither in /sys/bus/spi/...). No reference to SPI appears during system boot either.

Any idea on where the problem can be?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值