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。



 
 
 

你可能感兴趣的:(SPI-------------LINUX----------驱动中的几个关键结构体)