tq3358 linux 串口驱动编程,TQ335x——spidev驱动的生成
kernel:CD盤的kernel3.2包
環境:vmware10,ubuntu14.04
修改的部分:
arch/arm/mach-omap2/board-am335xevm.c文件中
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,
},
};
改為
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 , //根據實際需要進行修改
},
};
重新編譯,燒錄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會看到如下打印
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
然后可以根據需要編輯自己的應用程序來使用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
總結
以上是生活随笔為你收集整理的tq3358 linux 串口驱动编程,TQ335x——spidev驱动的生成的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java学习(42):巩固练习
- 下一篇: linux+删除乱码的文件,linux