BF561提供的测试代码是种全双工操作。我们在测试的时候使用的半双工。
1 首先要进行内核的配置
device drivers
spi support
选中 BF5xx spi和user mode
2 系统启动之后 在设备文件下面有个spidev0.* 这个具体的值要看你的硬件如何定义的。 它还定义了时钟,是否使用DMA格式,总线,片选
3 测试代码
系统自带的程序我就不赘述了。源码文件都能找到
我说说自己写的小程序
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/types.h>
#include <linux/spi/spidev.h>
int buff[] = {
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0x40, 0x00, 0x00, 0x00, 0x00, 0x95,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,