1、测试环境 硬件:wukongpi H3 系统:ubantu 镜像:Orangepizerolts_2.0.8_ubuntu_bionic_server_linux5.4.27.img 2、外设功能测试引脚图:
1、spi//1、系统默认关闭了SPI,打开该文件:vi /boot/orangepiEnv.txt//2、输入以下内容:overlays=spi-spidevparam_spidev_spi_bus=1 #修改为开发板所支持的对应的spi 总线号//3、保存后重启reboot重启后进入dev可以看到刚开启的spi
spi功能可以用杜邦线将MOSI和MISO短接,进行自收发的数据测试。
简单写了一个spi驱动测试: 代码:[color=rgb(12, 147, 228) !important]*附件:SPI_test.zip
测试结果: root@orangepizerolts:~# lsSPI_test.ziproot@orangepizerolts:~# unzip SPI_test.zipArchive: SPI_test.zip inflating: SPI_test/Makefile inflating: SPI_test/spi_main.cpp inflating: SPI_test/SpiDevice.cpp inflating: SPI_test/SpiDevice.hroot@orangepizerolts:~# lsSPI_test SPI_test.ziproot@orangepizerolts:~# cd SPI_test/root@orangepizerolts:~/SPI_test# lsMakefile SpiDevice.cpp SpiDevice.h spi_main.cpproot@orangepizerolts:~/SPI_test# makemake: Warning: File 'Makefile' has modification time 27539 s in the futureg++ -Wall -std=c++11 -c spi_main.cppspi_main.cpp: In function ‘int main()’:spi_main.cpp:22:9: warning: unused variable ‘num’ [-Wunused-variable] int num =10; ^~~g++ -Wall -std=c++11 -c SpiDevice.cppg++ -Wall -std=c++11 -o spi_test spi_main.o SpiDevice.omake: warning: Clock skew detected. Your build may be incomplete.root@orangepizerolts:~/SPI_test# lsMakefile SpiDevice.cpp SpiDevice.h SpiDevice.o spi_main.cpp spi_main.o spi_testroot@orangepizerolts:~/SPI_test# ./spi_testReceived data: 0xaa 0xbb 0xccReceived data: 0xaa 0xbb 0xccReceived data: 0xaa 0xbb 0xccReceived data: 0xaa 0xbb 0xccReceived data: 0xaa 0xbb 0xccReceived data: 0x0 0x0 0x0Received data: 0x0 0x0 0x0Received data: 0x0 0x0 0x0Received data: 0x0 0x0 0x0Received data: 0x0 0x0 0x0Received data: 0x0 0x0 0x0Received data: 0xaa 0xbb 0xccReceived data: 0xaa 0xbb 0xccReceived data: 0xaa 0xbb 0xccReceived data: 0xaa 0xbb 0xcc^Croot@orangepizerolts:~/SPI_test#默认发送aa bb cc,当mosi和miso短接后,接收到的数据也是aa bb cc,中间拔掉一端后无法正常接收到aa bb cc。 2、uart//1、系统默认关闭了uart1,uart2,打开该文件:vi /boot/orangepiEnv.txt//2、输入以下内容:overlays=uart1 uart2//3、保存后重启reboota) 26pin 中的 uart1 对应/dev/ttyS1
b) 26pin 中的 uart2 对应/dev/ttyS2
|