8,367
edits
Changes
→40pin SPI test method
# As can be seen from the table below, the spi available for the 40pin interface is spi1, and there are two chip select pins cs0 and cs1
<div style="display: flex;">{| class="wikitable" style="width:390px;margin-right: 20px;text-align: center;"
|-
| '''GPIO serial numberNO.'''
| '''GPIO'''
| '''Function'''
| '''pin'''|| '''pin'''| '''Function'''| '''GPIO'''| '''GPIO serial numberPin'''
|-
| style="text-align: left;"|
| '''3.3V'''
| '''1'''
|-| '''264'''| '''PI8'''| '''TWI1-SDA'''| '''3'''|-| '''263'''| '''PI7'''| '''TWI1-SCL'''| '''5'''|-| '''269'''| '''PI13'''| '''PWM3'''| '''7'''|-| style="text-align: left;"|| style="text-align: left;"|| '''GND'''| '''9'''|-| '''226'''| '''PH2'''| '''UART5_TX'''| '''11'''|-| '''227'''| '''PH3'''| '''UART5_RX'''| '''13'''|-| '''261'''| '''PI5'''| '''UART2_TX'''| '''15'''|-| style="text-align: left;"|| style="text-align: left;"|| '''3.3V'''| '''17'''|-| '''231'''| '''PH7'''| '''SPI1_MOSI'''| '''19'''|-| '''232'''| '''PH8'''| '''SPI1_MISO'''| '''21'''|-| '''230'''| '''PH6'''| '''SPI1_CLK'''| '''23'''|-| style="text-align: left;"|| style="text-align: left;"|| '''GND'''| '''25'''|-| '''266'''| '''PI10'''| '''TWI2-SDA'''| '''27'''|-| '''256'''| '''PI0'''| style="text-align: left;"|| '''29'''|-| '''271'''| '''PI15'''| style="text-align: left;"|| '''31'''|-| '''268'''| '''PI12'''| '''PWM2'''| '''33'''|-| '''258'''| '''PI2'''| style="text-align: left;"|| '''35'''|}{| class="wikitable" style="width:390px;margin-right: 20px;text-align: center;"|-| '''Pin'''| '''Function'''| '''GPIO'''| '''GPIO NO.'''|-
| '''2'''
| '''5V'''
| style="text-align: left;"|
|-
| '''4'''
| '''5V'''
| style="text-align: left;"|
|-
| '''6'''
| '''GND'''
| style="text-align: left;"|
|-
| '''8'''
| '''UART0_TX'''
| '''224'''
|-
| '''10'''
| '''UART0_RX'''
| '''225'''
|-
| '''12'''
| style="text-align: left;"|
| '''257'''
|-
| '''14'''
| '''GND'''
| style="text-align: left;"|
|-
| '''16'''
| '''PWM4'''
| '''270'''
|-
| '''18'''
| style="text-align: left;"|
| '''228'''
|-
| '''20'''
| '''GND'''
| style="text-align: left;"|
|-
| '''22'''
| '''UART2_RX'''
| '''262'''
|-
| '''24'''
| '''SPI1_CS0'''
| '''229'''
|-
| '''26'''
| '''SPI1_CS1'''
| '''233'''
|-
| '''28'''
| '''TWI2-SCL'''
| '''265'''
|-
| '''30'''
| '''GND'''
| style="text-align: left;"|
|-
| '''32'''
| '''PWM1'''
| '''267'''
|-
| '''34'''
| '''GND'''
| style="text-align: left;"|
|-
| '''36'''
| style="text-align: left;"|
| '''76'''
|}
</div>
<ol start="2" style="list-style-type: decimal;">
<li>The device node corresponding to SPI1 CS0 is '''/dev/spidev1.0''', and the device node corresponding to SPI1 CS1 is '''/dev/spidev1.1'''</li></ol>{| class="wikitable" style="width:800px;" |-|
apollo-p2:/ # '''ls /dev/spidev1.*'''
'''<span style="color:#FF0000">/dev/spidev1.0 /dev/spidev1.1</span>'''|}</ol>
<ol start="3" style="list-style-type: decimal;">
<li>Here is a demonstration to test the SPI1 interface through the '''w25qxx''' module. First, connect the w25qxx module to the SPI1 interface.</li>{| class="wikitable" style="background-color:#ffffdc;width:800px;" |-| </olbig> '''It doesn't matter if there is no w25qxx module, because there is a SPIFlash on the development board connected to SPI0, and the configuration of SPI0 is also turned on by default in Android, so we can also directly use the onboard SPIFlash for testing.'''</big>|}</ol>
<ol start="4" style="list-style-type: decimal;">
<li>Then open wiringOP APP on the desktop</li></ol>
[[File:zero2w-img351.png]]
</ol>
<ol start="5" style="list-style-type: decimal;">
<li>Then click the '''SPI_TEST''' button to open the SPI test interface</li></ol>
[[File:zero2w-img365.png]]
</ol>
<ol start="6" style="list-style-type: decimal;">
<li><p>Then select the spi device node in the upper left corner. If you test the onboard SPIFlash directly, just keep the default '''/dev/spidev0.0'''. If the '''w25qxx''' module is connected to the 40pin spi1 cs0, then please select'''/dev/spidev1.0''', if the w25qxx module is connected to the 40pin spi1 cs1, then please select '''/dev/spidev1.1'''</p>
</div></li>
<li><p>Then click the '''OPEN''' button to initialize the SPI</p></li></ol>
[[File:zero2w-img367.png]]
</ol>
<ol start="8" style="list-style-type: decimal;">
<li>Then fill in the bytes that need to be sent, such as reading the ID information of the onboard SPIFlash, filling in the address 0x9f in data[0], and then click the '''TRANSFER''' button</li></ol>
[[File:zero2w-img368.png]]
</ol>
<ol start="9" style="list-style-type: decimal;">
<li>Finally, the APP will display the read ID information of the onboard SPI Flash.</li></ol>
[[File:zero2w-img369.png]]
</ol>
<ol start="10" style="list-style-type: decimal;">
<li>If the w25qxx module connected to 40pin SPI1 is read, the ID information of the onboard SPI Flash is also similar.</li></ol>
<span id="pin-i2c-test-method"></span>
=== 40pin I2C test method ===