主题 : mini6410spi驱动的问题! 复制链接 | 浏览器收藏 | 打印
级别: 侠客
UID: 47915
精华: 0
发帖: 61
金钱: 315 两
威望: 63 点
综合积分: 122 分
注册时间: 2011-05-26
最后登录: 2018-07-05
楼主  发表于: 2011-10-27 15:19

 mini6410spi驱动的问题!

内核中的spi驱动已经驱动起来!但是没法手动控制片选信号,有谁用过spi,怎么样手动控制cs拉高拉低!!!!
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2011-10-27 22:24
你需要给SPI接口设备的spi_board_info结构里指定一个“s3c64xx_spi_csinfo”结构作为controller_data成员变量的值。在"s3c64xx_spi_csinfo"里实现控制GPIO片选信号,例如GPC3作为片选信号:
复制代码
  1. static void  cs_set_level(unsigned line_id, int lvl) {
  2.     gpio_direction_output(line_id, lvl);
  3. };
  4. static struct s3c64xx_spi_csinfo s3c64xx_spi0_csinfo = {
  5.   .fb_delay=100,
  6.   .line=S3C64XX_GPC(3),
  7.   .set_level=cs_set_level,
  8. };

详细的定义参考http://www.aiothome.net/read.php?tid-10788.html
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 侠客
UID: 47915
精华: 0
发帖: 61
金钱: 315 两
威望: 63 点
综合积分: 122 分
注册时间: 2011-05-26
最后登录: 2018-07-05
2楼  发表于: 2011-10-28 20:25
你好斑竹!我已经指定了但是在应用程序里面如何控制这个片选信号呢?在spidev。c里面也没有控制这个功能的语句呀??谢谢回复~~
static void  cs_set_level(unsigned line_id, int lvl) {
    gpio_direction_output(line_id, lvl);
};

static struct s3c64xx_spi_csinfo s3c64xx_spi0_csinfo = {
  .fb_delay=100,
  .line=S3C64XX_GPC(3),
  .set_level=cs_set_level,
};

static struct spi_board_info s3c6410_spi0_board[] = {
[0] = {
.modalias = "spidev",
.bus_num= 0,
.chip_select= 0,
.irq =IRQ_SPI0,
.max_speed_hz= 500*1000,
.mode=SPI_MODE_0,
.controller_data=&s3c64xx_spi0_csinfo,
},
};
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
3楼  发表于: 2011-10-28 21:09
应用程序不需要控制片选信号,SPI controller驱动会搞定这个的。参考这里enable_cs()函数的实现:
http://lxr.linux.no/linux+v2.6.35/drivers/spi/spi_s3c64xx.c#L294
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 侠客
UID: 47915
精华: 0
发帖: 61
金钱: 315 两
威望: 63 点
综合积分: 122 分
注册时间: 2011-05-26
最后登录: 2018-07-05
4楼  发表于: 2011-10-29 08:56
不好意思!可能是我没有表达清楚。我是想用spi发送40位数据。比如8位数据模式  发5次。。。在这期间片选信号不能拉高?也就是手动让把它拉高!! 困惑ing 困惑ing 困惑ing
欲取其中,则取其上;欲取其上,则取其上上
级别: 新手上路
UID: 72674
精华: 0
发帖: 6
金钱: 35 两
威望: 7 点
综合积分: 12 分
注册时间: 2012-06-26
最后登录: 2012-09-27
5楼  发表于: 2012-07-10 10:48
您好,楼主,我最近也在尝试加载mini6410的驱动,但是却始终报错,你能把你的方法发给我一份吗?gump5106@sina.com
谢谢拉