The use of Cubieboard SPI

Source: Internet
Author: User
Toss for nearly one months of SPI communication (if it is big God's words estimated early to get out, but the harvest is quite large, at least almost understand the SPI subsystem), finally small results, cubieboard on the SPI mouth, is also called through, Here to thank Hipboi and so on the network of the Great God to help me, thanks to CCTV.

First of all, related to SPI communications, there are mainly three code files, spi_sunxi.c,spi.c,spidev.c.
SPI_SUNXI.C is mainly the SPI drive of A10, SPI.C is the center of the whole SPI subsystem, which provides interface for SPI_SUNXI.C and SPIDEV.C, and also plays a role of bridge.
SPIDEV.C is mainly used to provide the interface for user space to read and write SPI, that is, to generate spi0.0 and so on under/dev/.

To enable the full log SPI to communicate, the underlying code is already written, and we only need to make the appropriate changes to the configuration file (Script.fex).
spi_used = 1
Spi_cs_bitmap = 1
Spi_cs0 = port:pi10<3><default><default><default>
SPI_SCLK = port:pi11<3><default><default><default>
Spi_mosi = port:pi12<3><default><default><default>
Spi_miso = port:pi13<3><default><default><default>

Among them, the need is particularly important, understanding SPI_CS0 = port:pi10<3><default><default><default>
Port:pi10 means to use PI10 this pin,<3> this bracket, the value can be 0~7, if configured to 0, this pin represents the Gpio input, 1 represents Gpio
Output, as for the value of 2~7, according to the different pins, different values have different functions but 2~7 is mainly representative of the reuse of ports, as to what the reuse into the port, please refer to
[Url]http://linux-sunxi.org/a10/pio[/url]

You can see from the diagram, if you want to use SPI, you should use MUX2, and my Fex file, the default is <3&gt, Port Multiplexing became UART, so this place must change, I just because this place has not changed, so the whole for a long time.

[Spi_devices]
Spi_dev_num = 1
[Spi_board0]
Modalias = "Spidev"
Max_speed_hz = 12000000
Bus_num = 0
Chip_select = 0
mode = 3
Full_Duplex = 0
Manual_cs = 0
This should be noted Modalias, which is the same name as in spidev.c. Name = "Spidev". Specific knowledge of the driver should know why, there is the full log of the SPI does not support Full-duplex.

After the above configuration is complete, oneself writes an application casually, or writes the point value in the/dev/spidev0.0, should have the reaction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.