drivers: display: st7735r: hold CS for pixels
Use a continuous transaction with CS kept low for the entire batch of row address, column address and actual pixel data write. This is required by ST7735S and shouldn't hurt elsewhere. Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
parent
64c46ae56a
commit
19113d6e8c
1 changed files with 13 additions and 9 deletions
|
@ -182,18 +182,19 @@ static int st7735r_set_mem_area(const struct device *dev,
|
|||
|
||||
spi_data[0] = sys_cpu_to_be16(ram_x);
|
||||
spi_data[1] = sys_cpu_to_be16(ram_x + w - 1);
|
||||
ret = st7735r_transmit(dev, ST7735R_CMD_CASET, (uint8_t *)&spi_data[0], 4);
|
||||
ret = st7735r_transmit_hold(dev, ST7735R_CMD_CASET, (uint8_t *)&spi_data[0], 4);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
spi_data[0] = sys_cpu_to_be16(ram_y);
|
||||
spi_data[1] = sys_cpu_to_be16(ram_y + h - 1);
|
||||
ret = st7735r_transmit(dev, ST7735R_CMD_RASET, (uint8_t *)&spi_data[0], 4);
|
||||
ret = st7735r_transmit_hold(dev, ST7735R_CMD_RASET, (uint8_t *)&spi_data[0], 4);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* NB: CS still held - data transfer coming next */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -220,7 +221,7 @@ static int st7735r_write(const struct device *dev,
|
|||
desc->width, desc->height, x, y);
|
||||
ret = st7735r_set_mem_area(dev, x, y, desc->width, desc->height);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (desc->pitch > desc->width) {
|
||||
|
@ -231,11 +232,11 @@ static int st7735r_write(const struct device *dev,
|
|||
nbr_of_writes = 1U;
|
||||
}
|
||||
|
||||
ret = st7735r_transmit(dev, ST7735R_CMD_RAMWR,
|
||||
(void *) write_data_start,
|
||||
desc->width * ST7735R_PIXEL_SIZE * write_h);
|
||||
ret = st7735r_transmit_hold(dev, ST7735R_CMD_RAMWR,
|
||||
(void *) write_data_start,
|
||||
desc->width * ST7735R_PIXEL_SIZE * write_h);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
goto out;
|
||||
}
|
||||
|
||||
tx_bufs.buffers = &tx_buf;
|
||||
|
@ -247,13 +248,16 @@ static int st7735r_write(const struct device *dev,
|
|||
tx_buf.len = desc->width * ST7735R_PIXEL_SIZE * write_h;
|
||||
ret = spi_write_dt(&config->bus, &tx_bufs);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
goto out;
|
||||
}
|
||||
|
||||
write_data_start += (desc->pitch * ST7735R_PIXEL_SIZE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
ret = 0;
|
||||
out:
|
||||
spi_release_dt(&config->bus);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void *st7735r_get_framebuffer(const struct device *dev)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue