Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:c1_hardware_spidev [2016/04/01 13:10] charles.park [SPIDEV Test] |
en:c1_hardware_spidev [2016/06/17 14:26] (current) odroid [SPI-mode change test] |
||
---|---|---|---|
Line 4: | Line 4: | ||
**SPI (/dev/spidev0.0)** | **SPI (/dev/spidev0.0)** | ||
- | ^Pin Number^Net Name^Export Number^ | + | ^ Pin Number ^ Net Name ^ Export Number ^ |
- | ^:::^:::^C0/C1/C1+^ | + | ^ ::: ^ ::: ^ C0/C1/C1+ ^ |
| 19 | SPI-MOSI(GPIOX.10) | 107 | | | 19 | SPI-MOSI(GPIOX.10) | 107 | | ||
| 21 | SPI-MISO(GPIOX.9) | 106 | | | 21 | SPI-MISO(GPIOX.9) | 106 | | ||
Line 12: | Line 12: | ||
===== Loading SPI driver ===== | ===== Loading SPI driver ===== | ||
- | Dedicated pins for SPI are configured for GPIO, these pins can be configured as I2C bus while change the pin configuration. In order to change the configuration, you must load the driver. | + | Dedicated pins for SPI are configured for GPIO, these pins can be configured as SPI bus while change the pin configuration. In order to change the configuration, you must load the driver. |
<code> | <code> | ||
- | $ modprobe spicc | + | $ sudo modprobe spicc |
</code> | </code> | ||
Line 28: | Line 28: | ||
spidev 16 bits per word, clock speed = 1Mhz | spidev 16 bits per word, clock speed = 1Mhz | ||
<code> | <code> | ||
- | $ sudo ./spidev_test -D /dev/spidev0.0 -s 1000000 -b 8 | + | $ sudo ./spidev_test -D /dev/spidev0.0 -s 1000000 -b 16 |
</code> | </code> | ||
Line 35: | Line 35: | ||
spidev 32 bits per word, clock speed = 1Mhz | spidev 32 bits per word, clock speed = 1Mhz | ||
<code> | <code> | ||
- | $ sudo ./spidev_test -D /dev/spidev0.0 -s 1000000 -b 8 | + | $ sudo ./spidev_test -D /dev/spidev0.0 -s 1000000 -b 32 |
</code> | </code> | ||
{{http://dn.odroid.com/wiki_image/a.png?500|SPIDEV-32bits-1Mhz}} | {{http://dn.odroid.com/wiki_image/a.png?500|SPIDEV-32bits-1Mhz}} | ||
+ | |||
+ | |||
+ | ===== SPI-mode change test ===== | ||
+ | |||
+ | <WRAP left round important 100%> | ||
+ | **Update**\\ | ||
+ | SPI mode works correctly only with kernel version 3.10.96-151 or higher\\ | ||
+ | </WRAP>\\ | ||
+ | \\ | ||
+ | spidev 32 bits per word, spi mode = 0 \\ | ||
+ | <code> | ||
+ | $ sudo ./spidev_test -D /dev/spidev0.0 -s 1000000 -b 32 | ||
+ | </code> | ||
+ | |||
+ | {{http://dn.odroid.com/wiki_image/spi_mode_0.png?500|SPIDEV-32bits-mode-0}} | ||
+ | |||
+ | spidev 32 bits per word, spi mode = 1 | ||
+ | <code> | ||
+ | $ sudo ./spidev_test -D /dev/spidev0.0 -s 1000000 -b 32 -H | ||
+ | </code> | ||
+ | |||
+ | {{http://dn.odroid.com/wiki_image/spi_mode_1.png?500|SPIDEV-32bits-mode-1}} | ||
+ | |||
+ | spidev 32 bits per word, spi mode = 2 | ||
+ | <code> | ||
+ | $ sudo ./spidev_test -D /dev/spidev0.0 -s 1000000 -b 32 -O | ||
+ | </code> | ||
+ | |||
+ | {{http://dn.odroid.com/wiki_image/spi_mode_2.png?500|SPIDEV-32bits-mode-2}} | ||
+ | |||
+ | spidev 32 bits per word, spi mode = 3 | ||
+ | <code> | ||
+ | $ sudo ./spidev_test -D /dev/spidev0.0 -s 1000000 -b 32 -H -O | ||
+ | </code> | ||
+ | |||
+ | {{http://dn.odroid.com/wiki_image/spi_mode_3.png?500|SPIDEV-32bits-mode-3}} | ||
+ | |||
+ | ** spidev_test source code ** | ||
+ | |||
+ | spidev test code compile. | ||
+ | |||
+ | <code> | ||
+ | $ gcc -o spidev_test spidev_test.c | ||
+ | </code> | ||
<file c spidev_test.c> | <file c spidev_test.c> |