简体   繁体   English

Raspberry PI计算模块-SPI1

[英]Raspberry PI Compute Module - SPI1

I'm using Raspberry PI Compute Module , and i would like to use SPI1 . 我正在使用Raspberry PI Compute Module ,并且我想使用SPI1

But there is a struggle. 但是有一个斗争。

Are there any drivers or do you have some idea how to use that? 是否有任何驱动程序,或者你有一些想法如何使用? Because there are only drivers for SPI0 which is the only SPI accessible in Raspberry PI B+. 因为只有SPI0驱动程序,这是Raspberry PI B +中唯一可访问的SPI。

Thank you. 谢谢。

I also didn't find any kernel suitable. 我也没有找到合适的内核。 But yes you can using this library which is well writen : http://abyz.co.uk/rpi/pigpio/index.html 但是是的,您可以使用写得很好的这个库: http ://abyz.co.uk/rpi/pigpio/index.html

To use the second SPI, use the example program in x_pigpio.c void tc(). 要使用第二个SPI,请使用x_pigpio.c中的示例程序void tc()。 Change the parameters in 更改参数

h = spiOpen(1, 50000, 0);

In gpio.h, you can check what to put in the 3 parameters : 在gpio.h中,您可以检查3个参数中的内容:

int spiOpen(unsigned spiChan, unsigned baud, unsigned spiFlags);

spiChan: 0-1 (0-2 for A+/B+/Pi2 auxiliary device) baud: 32K-125M (values above 30M are unlikely to work) and spiFlags : spiChan:0-1(A + / B + / Pi2辅助设备为0-2)波特率:32K-125M(高于30M的值不太可能起作用)和spiFlags:

Returns a handle (>=0) if OK, otherwise PI_BAD_SPI_CHANNEL, PI_BAD_SPI_SPEED, PI_BAD_FLAGS, PI_NO_AUX_SPI, or PI_SPI_OPEN_FAILED. 如果确定,则返回句柄(> = 0),否则返回PI_BAD_SPI_CHANNEL,PI_BAD_SPI_SPEED,PI_BAD_FLAGS,PI_NO_AUX_SPI或PI_SPI_OPEN_FAILED。 spiFlags consists of the least significant 22 bits. spiFlags由最低有效22位组成。

. . 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 bbbbbb RT nnnn WA u2 u1 u0 p2 p1 p0 mm . 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 bbbbbb RT nnnn WA u2 u1 u0 p2 p1 p0毫米。 .

mm defines the SPI mode. mm定义SPI模式。

So now that you understood, you take the example, change the parameters or spiOpen like that and it's working. 现在,您已经了解了,您以示例为例,像这样更改参数或spiOpen即可正常工作。

spiChan = 1
spiFlags = PI_SPI_FLAGS_GET_AUX_SPI(1)

The best way to confirm it's working is to make a loop between your MISO and MOSI pins and checking with a logic analyzer your message is readable. 确认其正常工作的最佳方法是在MISO和MOSI引脚之间循环,并使用逻辑分析仪检查消息是否可读。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM