硬件:tq335x board v2
kernel:CD盘的kernel3.2包
环境:vmware10,ubuntu14.04
修改的部分:
arch/arm/mach-omap2/board-am335xevm.c文件中
- <font face="微软雅黑">static struct spi_board_info am335x_spi1_slave_info[] = {
- {
- .modalias = "smb380",
- .platform_data = &Acceleration_sensor,
- .irq = -1,
- .mode =SPI_MODE_0,
- .max_speed_hz = 120000,
- .bus_num = 2,
- .chip_select = 0,
- },
- };</font>
复制代码
改为
- <font face="微软雅黑">static struct spi_board_info am335x_spi1_info[] = {
- {
- .modalias = "spidev",
- .max_speed_hz = 48000000, //根据实际需要进行修改
- .bus_num = 2, //必须为2,不然这个驱动没法使用,这个还需要研究原因
- .chip_select = 0,
- .mode = SPI_MODE_1 , //根据实际需要进行修改
- },
- };</font>
复制代码
重新编译,烧录uImage后启动内核
在dev下发现spidev2.0模块
使用chmod 777 spidev2.0修改权限
使用arm-linux-gcc -o spidev_test Documentation/spi/spidev_test.c -static命令
编译出spidev_test文件(spidev_test在实际使用中需要设置相同的spi条件,比如速度和模式)
拷贝到u盘插入开发板,在内核下找出u盘所在的盘,找到spidev_test文件
cp命令无法使用,使用cat spidev_test >/data/spidev_test命令拷贝到data目录下
然后执行 ./spidev_test会看到如下打印
- <font face="微软雅黑"> spi mode: 0
- bits per word: 8
- max speed: 48000000 Hz (48000 KHz)
- 00 00 00 00 00 00
- 00 00 00 00 00 00
- 00 00 00 00 00 00
- 00 00 00 00 00 00
- 00 00 00 00 00 00
- 00 00 00 00 00 00
- 00 00</font>
复制代码
然后可以根据需要编辑自己的应用程序来使用SPI通信。
相关产品:
http://www.embedsky.com/index.php?s=/Product/show/id/49.html http://www.embedsky.com/index.php?s=/Product/show/id/86.html
|