SPI-------------LINUX----------驱动中的几个关键结构体

struct spi_board_info {
  char modalias[SPI_NAME_SIZE];
  const void * platform_data;
  void * controller_data;
  int irq;
  u32 max_speed_hz;
  u16 bus_num;
  u16 chip_select;
  u16 mode;
};  
struct spi_board_info info[] = {
        	{
                	.modalias = "spidev",
                	.max_speed_hz = 3000000,
                	.bus_num = 1,
                	.chip_select = 0,  //<---使用哪个spi,例如SoC上有两个spi总线,则这里是选择第一个
        	},
        	
        	{
                	.modalias = "spidev",
                	.max_speed_hz = 3000000,
                	.bus_num = 1,
                	.chip_select = 1,   //<---使用哪个spi,例如SoC上有两个spi总线,则这里是选择第二个
        	},
    	};
</pre><pre name="code" class="cpp">//------------关于mode这个成员变量, 在别的网站找到如下说明(经测试,如果不加.mode后的参数,默认是CS脚是低电平。
</pre><pre name="code" class="cpp"><p style="margin-top: 0.5em; margin-bottom: 0.5em; line-height: 22.399999618530273px; color: rgb(37, 37, 37); font-family: sans-serif; font-size: 14px;">ome devices expect that the CS lines are active-high (instead of the more common active-low). This can be accomplished by modifying spi_board_info in the board file as follows,</p><pre style="font-family: monospace, Courier; border: 1px solid rgb(221, 221, 221); padding: 1em; line-height: 1.3em; font-size: 14px; background-color: rgb(249, 249, 249);">diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 58bacb6..44643b7 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -526,7 +526,7 @@ static struct spi_board_info beagle_mcspi_board_info[] = {
                .max_speed_hz   = 48000000, //48 Mbps
                .bus_num        = 3,
                .chip_select    = 0,    
-               .mode = SPI_MODE_1,
+               .mode = SPI_MODE_1 | SPI_CS_HIGH,
        },
SPI_MODE_x说明在:

Linux/include/uapi/linux/spi/spidev.h

或者可以看http://lxr.free-electrons.com/source/include/uapi/linux/spi/spidev.h#L35。



 

                
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值