Firefly开源社区

打印 上一主题 下一主题

[Linux] SPI通讯超时

29

积分

0

威望

0

贡献

技术小白

积分
29
QQ

SPI通讯超时

发表于 2022-9-24 16:24:09      浏览:5708 | 回复:0        打印      只看该作者   [复制链接] 楼主
问题描述及复现步骤:

驱动读函数
static ssize_t adc_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off)
{
    int ret = 0;
    unsigned char data = 0x58;  
    struct adc_dev *dev = (struct adc_dev *)filp->private_data;
    struct spi_device *spi = (struct spi_device *)dev->spi;

    struct spi_message m;
    struct spi_transfer* t;
    t = kzalloc(sizeof(struct spi_transfer), GFP_KERNEL);
    if(!t) {
        return -ENOMEM;
    }
    t->tx_buf = &data;
    t->len = 1;

    printk("in ADC_read \r\n");
//  spi_read(spi,buf,1);
    spi_message_init(&m);
    spi_message_add_tail(t,&m);
    ret = spi_sync(spi,&m);
    printk("spi_sync return = %d \r\n",ret);
    printk("adc_read_ok \r\n");

    return 0;
}



设备树的配置
&spi0 {
    status = "okay";
    assigned-clock-rates = <50000000>;
    adc_5195:adc5195@2 {
        compatible = "agv,adc5195";
        status = "okay";
        reg = <0x2>;
        spi-max-frequency = <20000000>;
        cs-gpio = <&gpio0 RK_PC6 GPIO_ACTIVE_LOW>;  
        spi-cpol;
    };
};

报错截图
[  107.121487] adc_probe
[  107.122526] adc_probe finsh
[  122.861958] open file
[  122.862001] in ADC_read
[  122.862246] rockchip-pinctrl pinctrl: enable function spi0 group spi0m0-cs0
[  122.862261] rockchip-pinctrl pinctrl: setting mux of GPIO0-22 to 2
[  122.862287] rockchip-pinctrl pinctrl: setting pull of GPIO0-22 to 1
[  122.862297] rockchip-pinctrl pinctrl: enable function spi0 group spi0m0-cs1
[  122.862303] rockchip-pinctrl pinctrl: setting mux of GPIO0-20 to 2
[  122.862309] rockchip-pinctrl pinctrl: setting pull of GPIO0-20 to 1
[  122.862316] rockchip-pinctrl pinctrl: enable function spi0-hs group spi0m0-pins
[  122.862321] rockchip-pinctrl pinctrl: setting mux of GPIO0-13 to 2
[  122.862335] rockchip-pinctrl pinctrl: setting mux of GPIO0-21 to 2
[  122.862340] rockchip-pinctrl pinctrl: setting mux of GPIO0-14 to 2
[  122.862347] rockchip-pinctrl pinctrl: setting pull of GPIO0-13 to 1
[  122.862353] rockchip-pinctrl pinctrl: setting pull of GPIO0-21 to 1
[  122.862359] rockchip-pinctrl pinctrl: setting pull of GPIO0-14 to 1
[  123.065645] adc5195 spi0.2: SPI transfer timed out
[  123.065879] spi_master spi0: failed to transfer one message from queue
[  123.066072] spi_sync return = -110
[  123.066080] adc_read_ok
root@firefly:~# ^C
root@firefly:~#



帮忙分析下SPI总线超时的原因,感谢!

log.txt

3.32 KB, 下载次数: 0, 下载积分: 灯泡 -1 , 经验 -1

回复

使用道具 举报

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

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表