linux 设备树怎么驱动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>;
};
};
离线
自己改的写了 设备驱动 没有成功点亮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;
}
离线
逻辑分析仪怼上去,看下时序,对照手册比较一下。
逻辑分析仪怼不上去,出问题了 怎么改大神 们,怎么调
离线