您尚未登录。

楼主 #1 2021-01-06 15:42:21

sawgsxiao
会员
注册时间: 2020-07-15
已发帖子: 2
积分: 2

全志 f1200s spi1 求助 oled驱动

linux 设备树怎么驱动spi1  驱动oled,求助!!!

离线

楼主 #3 2021-01-06 15:53:14

sawgsxiao
会员
注册时间: 2020-07-15
已发帖子: 2
积分: 2

Re: 全志 f1200s spi1 求助 oled驱动

&spi1 {
    pinctrl-names = "default";
    pinctrl-0 = <&spi1_pins_a &oled_dc_rst_pins>;
    status = "okay";
    spioled@0 {
        #address-cells = <1>;
        #size-cells = <1>;
        compatible = "spioled";
        spi-max-frequency = <1000000>;
        dc-gpio = <&pio 4 11 GPIO_ACTIVE_HIGH>;
        rst-gpio = <&pio 4 12 GPIO_ACTIVE_HIGH>;
        reg = <0>;
    };
};

离线

楼主 #4 2021-01-06 15:56:30

sawgsxiao
会员
注册时间: 2020-07-15
已发帖子: 2
积分: 2

Re: 全志 f1200s spi1 求助 oled驱动

自己改的写了 设备驱动 没有成功点亮oled
oled_probe 是否有问题

static int oled_probe(struct spi_device *spi)
{
    int ret = 0;
    oled_dev.spi_oled_dev = spi;
    struct device *dev = &spi->dev;
   
    ret = spi_setup(spi);
    if (ret)
        return ret;
    oled_dev.node = dev->of_node;

    if(oled_dev.node == NULL){
        printk("fail_get_node\r\n");
    }

    oled_dev.spi_oled_dc_pin = of_get_named_gpio(oled_dev.node, "dc-gpio", 0);

    if(oled_dev.spi_oled_dc_pin<0){
        ret = -EINVAL;
        goto fail_get_node;
    }
    oled_dev.spi_oled_rst_pin = of_get_named_gpio(oled_dev.node, "rst-gpio", 0);
    if(oled_dev.spi_oled_rst_pin<0){
        ret = -EINVAL;
        goto fail_get_node;
    }
    printk("request gpio %d\r\n", oled_dev.spi_oled_dc_pin);

    ret = gpio_direction_output(oled_dev.spi_oled_dc_pin, 0);
    if(ret<0){
        printk("can't gpio_direction_output gpio  %d\r\n", oled_dev.spi_oled_dc_pin);
        goto setout_fail;
    }
    ret = gpio_direction_output(oled_dev.spi_oled_rst_pin, 0);
    if(ret<0){
        printk("can't gpio_direction_output gpio  %d\r\n", oled_dev.spi_oled_rst_pin);
        goto setout_fail;
    }
    oled_dev.major = register_chrdev(0, "oled", &oled_ops);

    oled_dev.class = class_create(THIS_MODULE, "oled");
    printk("matched\r\n");

    device_create(oled_dev.class, NULL, MKDEV(oled_dev.major, 0), NULL, DRIVER_NAME);
    OLEDInit();

    // OLED_Set_DC(0);
    // OLED_Set_RST(0);
    return 0;
setout_fail:
fail_get_node:
    return ret;
}

离线

楼主 #6 2021-01-07 23:06:29

sawgsxiao
会员
注册时间: 2020-07-15
已发帖子: 2
积分: 2

Re: 全志 f1200s spi1 求助 oled驱动

raspberryman 说:

逻辑分析仪怼上去,看下时序,对照手册比较一下。

逻辑分析仪怼不上去,出问题了 怎么改大神 们,怎么调

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn