打印
[RISC-V MCU 应用开发]

关于全志D1的SPI通讯问题

[复制链接]
534|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
本帖最后由 神棍地海棠 于 2023-1-9 09:46 编辑

D1的SPI,空闲的时候是低电平,而且每个字节CLK 有9个脉冲,如图所示:


以下是SPI的配置


如果想将空闲时变成高电平,以及每个字节的CLK设为8个,可以尝试通过一下两个角度去分析。

SPI通讯的问题首先考虑是不是 spi_dbi_enable 的问题,目前 spi_dbi_enable 设置的是1,在将 spi_dbi_enable 设置为0后CLK,MOSI都没有数据了。


其实spi_dbi_enable是spi lcd显示屏专用的驱动,配置两个逻辑不太一样

配置lcd屏幕需要单独写lcd的配置

<pre class="markdown-highlight" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 13px; padding: 9.5px; margin-top: 1rem; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255); border: none; border-radius: 0px; max-height: 350px;"><code class="hljs xml" style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: inherit; padding: 0.5em; color: rgb(230, 225, 220); background: rgb(35, 35, 35); border-radius: 0px; display: inline-block; overflow-x: auto; overflow-wrap: normal; min-width: 100%;">&lcd_fb0 {
        lcd_used = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">1</span>></span>;
        lcd_driver_name = "kld2844b";
        lcd_if = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">1</span>></span>;
        lcd_dbi_if = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">4</span>></span>;
        lcd_data_speed = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">60</span>></span>;
        lcd_spi_bus_num = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">1</span>></span>;
        lcd_x = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">240</span>></span>;
        lcd_y = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">320</span>></span>;
        lcd_width = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">60</span>></span>;
        lcd_height = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">95</span>></span>;
        lcd_pwm_used = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">1</span>></span>;
        lcd_pwm_ch = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">7</span>></span>;
        lcd_pwm_freq = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">5000</span>></span>;
        lcd_pwm_pol = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">0</span>></span>;
        lcd_pixel_fmt = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">0</span>></span>;
        lcd_dbi_fmt = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">3</span>></span>;
        lcd_rgb_order = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">0</span>></span>;
        lcd_frm = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">1</span>></span>;
        lcd_gamma_en = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">1</span>></span>;
        fb_buffer_num = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">2</span>></span>;
        lcd_backlight = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">100</span>></span>;
        lcd_dbi_te = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">1</span>></span>;
        lcd_fps = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">60</span>></span>;
        lcd_gpio_0 = <span class="hljs-tag" style="box-sizing: border-box; color: rgb(232, 191, 106);"><<span class="hljs-name" style="box-sizing: border-box;">&pio</span> <span class="hljs-attr" style="box-sizing: border-box; color: rgb(109, 156, 190);">PC</span> <span class="hljs-attr" style="box-sizing: border-box; color: rgb(109, 156, 190);">0</span> <span class="hljs-attr" style="box-sizing: border-box; color: rgb(109, 156, 190);">GPIO_ACTIVE_HIGH</span>></span>;  // reset
        status = "okay";
};</code></pre>


另外检查一下,spi-rx-bus-width=<0x04>是四线spi驱动,需要确认从机是4bit SPI <D0 D1 D2 D3 CLK CS>,否则请改成 spi-rx-bus-width=<0x01>;

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

260

主题

268

帖子

0

粉丝