天嵌 ARM开发社区

 找回密码
 注册
查看: 2100|回复: 0

AM335x(TQ335x)学习笔记——spidev驱动的生成

[复制链接]
freewing 发表于 2015-8-31 14:36:41 | 显示全部楼层 |阅读模式
  硬件:tq335x board v2
  kernel:CD盘的kernel3.2包
  环境:vmware10,ubuntu14.04
  修改的部分:
  arch/arm/mach-omap2/board-am335xevm.c文件中
  1. <font face="微软雅黑">static struct spi_board_info am335x_spi1_slave_info[] = {
  2.   {
  3.   .modalias = "smb380",
  4.   .platform_data = &Acceleration_sensor,
  5.   .irq = -1,
  6.   .mode =SPI_MODE_0,
  7.   .max_speed_hz = 120000,
  8.   .bus_num = 2,
  9.   .chip_select = 0,
  10.   },
  11.   };</font>
复制代码

  改为
  1. <font face="微软雅黑">static struct spi_board_info am335x_spi1_info[] = {
  2.   {
  3.   .modalias = "spidev",
  4.   .max_speed_hz = 48000000, //根据实际需要进行修改
  5.   .bus_num = 2, //必须为2,不然这个驱动没法使用,这个还需要研究原因
  6.   .chip_select = 0,
  7.   .mode = SPI_MODE_1 , //根据实际需要进行修改
  8.   },
  9.   };</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会看到如下打印
  1. <font face="微软雅黑">      spi mode: 0
  2.   bits per word: 8
  3.   max speed: 48000000 Hz (48000 KHz)
  4.   00 00 00 00 00 00
  5.   00 00 00 00 00 00
  6.   00 00 00 00 00 00
  7.   00 00 00 00 00 00
  8.   00 00 00 00 00 00
  9.   00 00 00 00 00 00
  10.   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




您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号 )

GMT+8, 2024-3-29 17:31 , Processed in 1.046875 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表