I want to connect Waveshare E-ink display to nRF5340 using e-Paper Driver HAT. At first, I tried to make all the calls by my own, just by rewriting the code from the ESP driver. unfortunately, this ended up in nothing - the display was not updating, although all the SPI messenges were delivered and the configuration did not have any failures - the program worked well, only the display did not do anything.
Then I figured out, that I using the mipi_dbi for this is the most modern and easy approach. I then created the following overlay file
nrf5340dk_nrf5340_cpuapp_ns.overlay
#include <zephyr/dt-bindings/mipi_dbi/mipi_dbi.h>
&i2c0 { status = "disabled";};
&spi0 { status = "disabled";};
&spi1 {status = "disabled";};
&i2c1 { status = "disabled";};
/ {
chosen {
zephyr,display = &epd;
};
mipi_dbi {
compatible = "zephyr,mipi-dbi-spi";
reset-gpios = <&gpio1 14 GPIO_ACTIVE_LOW>;
dc-gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>;
spi-dev = <&spi4>;
#address-cells = <1>;
#size-cells = <0>;
epd: ssd1680@0 {
compatible = "solomon,ssd1680";
reg = <0>;
mipi-max-frequency = <4000000>;
busy-gpios = <&gpio1 15 GPIO_ACTIVE_HIGH>;
height = <800>;
width = <480>;
};
};
};
&spi4 {
//compatible = "nordic,nrf-spim";
status = "okay";
pinctrl-0 = <&spi4_default>;
pinctrl-1 = <&spi4_sleep>;
pinctrl-names = "default", "sleep";
cs-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
};
&pinctrl {
spi4_default: spi4_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 1, 11)>,
<NRF_PSEL(SPIM_MOSI, 1, 10)>,
<NRF_PSEL(SPIM_MISO, 1, 8)>;
};
};
spi4_sleep: spi4_sleep {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 1, 11)>,
<NRF_PSEL(SPIM_MOSI, 1, 10)>,
<NRF_PSEL(SPIM_MISO, 1, 8)>;
low-power-enable;
};
};
};prj.conf
CONFIG_MAIN_STACK_SIZE=4096 CONFIG_HEAP_MEM_POOL_SIZE=16384 CONFIG_SPI=y CONFIG_GPIO=y CONFIG_DISPLAY=y CONFIG_SSD16XX=y CONFIG_MIPI_DBI=y CONFIG_LOG=y CONFIG_LOG_DEFAULT_LEVEL=3
main.c
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/display.h>
#include <string.h>
const struct device *display;
int main(void)
{
display = DEVICE_DT_GET(DT_CHOSEN(zephyr_display)); // DEVICE_DT_GET(DT_NODELABEL(epd));
device_init(display);
while (!device_is_ready(display))
{
printk("Device not ready");
k_msleep(100);
}
display_blanking_off(display);
static uint8_t fb[800 * 480 / 8];
memset(fb, 0xFF, sizeof(fb));
struct display_buffer_descriptor desc = {
.width = 800,
.height = 480,
.pitch = 800,
.buf_size = sizeof(fb),
};
int ret = display_write(display, 0, 0, &desc, fb);
if (ret) {
printk("display_write failed: %d\n", ret);
}
}As the result:
the program gets stuck in a while loop. the device has init_res = 22 '\026', which, as far as I understand, means wrong configuration, but I can not figure what is the problem in my case. please help. I am sure, that there is no any problem with my display, because it worked like a charm with ESP32, the problem is with the code