1、测试环境
硬件:wukongpi H3
系统:ubantu
镜像:Orangepizerolts_2.0.8_ubuntu_bionic_server_linux5.4.27.img
2、外设功能测试
引脚图:
1、spi
vi /boot/orangepiEnv.txt
overlays=spi-spidev
param_spidev_spi_bus=1 #修改为开发板所支持的对应的spi 总线号
reboot
重启后进入dev可以看到刚开启的spi
spi功能可以用杜邦线将MOSI和MISO短接,进行自收发的数据测试。
简单写了一个spi驱动测试:
代码:*附件:SPI_test.zip
测试结果:
root@orangepizerolts:~
SPI_test.zip
root@orangepizerolts:~
Archive: SPI_test.zip
inflating: SPI_test/Makefile
inflating: SPI_test/spi_main.cpp
inflating: SPI_test/SpiDevice.cpp
inflating: SPI_test/SpiDevice.h
root@orangepizerolts:~
SPI_test SPI_test.zip
root@orangepizerolts:~
root@orangepizerolts:~/SPI_test
Makefile SpiDevice.cpp SpiDevice.h spi_main.cpp
root@orangepizerolts:~/SPI_test
make: Warning: File 'Makefile' has modification time 27539 s in the future
g++ -Wall -std=c++11 -c spi_main.cpp
spi_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.cpp
g++ -Wall -std=c++11 -o spi_test spi_main.o SpiDevice.o
make: warning: Clock skew detected. Your build may be incomplete.
root@orangepizerolts:~/SPI_test
Makefile SpiDevice.cpp SpiDevice.h SpiDevice.o spi_main.cpp spi_main.o spi_test
root@orangepizerolts:~/SPI_test
Received data: 0xaa 0xbb 0xcc
Received data: 0xaa 0xbb 0xcc
Received data: 0xaa 0xbb 0xcc
Received data: 0xaa 0xbb 0xcc
Received data: 0xaa 0xbb 0xcc
Received data: 0x0 0x0 0x0
Received data: 0x0 0x0 0x0
Received data: 0x0 0x0 0x0
Received data: 0x0 0x0 0x0
Received data: 0x0 0x0 0x0
Received data: 0x0 0x0 0x0
Received data: 0xaa 0xbb 0xcc
Received data: 0xaa 0xbb 0xcc
Received data: 0xaa 0xbb 0xcc
Received data: 0xaa 0xbb 0xcc
^C
root@orangepizerolts:~/SPI_test
默认发送aa bb cc,当mosi和miso短接后,接收到的数据也是aa bb cc,中间拔掉一端后无法正常接收到aa bb cc。
2、uart
vi /boot/orangepiEnv.txt
overlays=uart1 uart2
reboot
a) 26pin 中的 uart1 对应/dev/ttyS1
b) 26pin 中的 uart2 对应/dev/ttyS2
后续逐步更新中。。。
|