Lines Matching +full:gpio +full:- +full:width
7 * Copyright (c) 2020 Kim Bøndergaard <kim@fam-boendergaard.dk>
9 * SPDX-License-Identifier: Apache-2.0
18 #include <zephyr/drivers/gpio.h>
36 uint16_t width; member
65 struct st7735r_data *data = dev->data; in st7735r_set_lcd_margins()
67 data->x_offset = x_offset; in st7735r_set_lcd_margins()
68 data->y_offset = y_offset; in st7735r_set_lcd_margins()
73 const struct st7735r_config *config = dev->config; in st7735r_set_cmd()
75 gpio_pin_set_dt(&config->cmd_data, is_cmd); in st7735r_set_cmd()
81 const struct st7735r_config *config = dev->config; in st7735r_transmit_hold()
87 ret = spi_write_dt(&config->bus, &tx_bufs); in st7735r_transmit_hold()
96 ret = spi_write_dt(&config->bus, &tx_bufs); in st7735r_transmit_hold()
108 const struct st7735r_config *config = dev->config; in st7735r_transmit()
112 spi_release_dt(&config->bus); in st7735r_transmit()
132 const struct st7735r_config *config = dev->config; in st7735r_reset_display()
136 if (config->reset.port != NULL) { in st7735r_reset_display()
137 gpio_pin_set_dt(&config->reset, 1); in st7735r_reset_display()
139 gpio_pin_set_dt(&config->reset, 0); in st7735r_reset_display()
168 return -ENOTSUP; in st7735r_read()
175 const struct st7735r_config *config = dev->config; in st7735r_set_mem_area()
176 struct st7735r_data *data = dev->data; in st7735r_set_mem_area()
182 ret = st7735r_transmit_hold(dev, ST7735R_CMD_COLMOD, &config->colmod, 1); in st7735r_set_mem_area()
187 uint16_t ram_x = x + data->x_offset; in st7735r_set_mem_area()
188 uint16_t ram_y = y + data->y_offset; in st7735r_set_mem_area()
191 spi_data[1] = sys_cpu_to_be16(ram_x + w - 1); in st7735r_set_mem_area()
198 spi_data[1] = sys_cpu_to_be16(ram_y + h - 1); in st7735r_set_mem_area()
204 /* NB: CS still held - data transfer coming next */ in st7735r_set_mem_area()
214 const struct st7735r_config *config = dev->config; in st7735r_write()
223 __ASSERT(desc->width <= desc->pitch, "Pitch is smaller than width"); in st7735r_write()
224 __ASSERT((desc->pitch * ST7735R_PIXEL_SIZE * desc->height) in st7735r_write()
225 <= desc->buf_size, "Input buffer too small"); in st7735r_write()
228 desc->width, desc->height, x, y); in st7735r_write()
229 ret = st7735r_set_mem_area(dev, x, y, desc->width, desc->height); in st7735r_write()
234 if (desc->pitch > desc->width) { in st7735r_write()
236 nbr_of_writes = desc->height; in st7735r_write()
238 write_h = desc->height; in st7735r_write()
244 desc->width * ST7735R_PIXEL_SIZE * write_h); in st7735r_write()
252 write_data_start += (desc->pitch * ST7735R_PIXEL_SIZE); in st7735r_write()
255 tx_buf.len = desc->width * ST7735R_PIXEL_SIZE * write_h; in st7735r_write()
256 ret = spi_write_dt(&config->bus, &tx_bufs); in st7735r_write()
261 write_data_start += (desc->pitch * ST7735R_PIXEL_SIZE); in st7735r_write()
266 spi_release_dt(&config->bus); in st7735r_write()
278 return -ENOTSUP; in st7735r_set_brightness()
284 return -ENOTSUP; in st7735r_set_contrast()
290 const struct st7735r_config *config = dev->config; in st7735r_get_capabilities()
293 capabilities->x_resolution = config->width; in st7735r_get_capabilities()
294 capabilities->y_resolution = config->height; in st7735r_get_capabilities()
304 if (!(config->madctl & ST7735R_MADCTL_BGR) != !config->rgb_is_inverted) { in st7735r_get_capabilities()
305 capabilities->supported_pixel_formats = PIXEL_FORMAT_BGR_565; in st7735r_get_capabilities()
306 capabilities->current_pixel_format = PIXEL_FORMAT_BGR_565; in st7735r_get_capabilities()
308 capabilities->supported_pixel_formats = PIXEL_FORMAT_RGB_565; in st7735r_get_capabilities()
309 capabilities->current_pixel_format = PIXEL_FORMAT_RGB_565; in st7735r_get_capabilities()
312 capabilities->current_orientation = DISPLAY_ORIENTATION_NORMAL; in st7735r_get_capabilities()
318 const struct st7735r_config *config = dev->config; in st7735r_set_pixel_format()
321 (~config->madctl & ST7735R_MADCTL_BGR)) { in st7735r_set_pixel_format()
326 (config->madctl & ST7735R_MADCTL_BGR)) { in st7735r_set_pixel_format()
332 return -ENOTSUP; in st7735r_set_pixel_format()
344 return -ENOTSUP; in st7735r_set_orientation()
349 const struct st7735r_config *config = dev->config; in st7735r_lcd_init()
350 struct st7735r_data *data = dev->data; in st7735r_lcd_init()
353 st7735r_set_lcd_margins(dev, data->x_offset, data->y_offset); in st7735r_lcd_init()
355 ret = st7735r_transmit(dev, ST7735R_CMD_FRMCTR1, config->frmctr1, in st7735r_lcd_init()
356 sizeof(config->frmctr1)); in st7735r_lcd_init()
361 ret = st7735r_transmit(dev, ST7735R_CMD_FRMCTR2, config->frmctr2, in st7735r_lcd_init()
362 sizeof(config->frmctr2)); in st7735r_lcd_init()
367 ret = st7735r_transmit(dev, ST7735R_CMD_FRMCTR3, config->frmctr3, in st7735r_lcd_init()
368 sizeof(config->frmctr3)); in st7735r_lcd_init()
373 ret = st7735r_transmit(dev, ST7735R_CMD_INVCTR, &config->invctr, 1); in st7735r_lcd_init()
378 ret = st7735r_transmit(dev, ST7735R_CMD_PWCTR1, config->pwctr1, in st7735r_lcd_init()
379 sizeof(config->pwctr1)); in st7735r_lcd_init()
384 ret = st7735r_transmit(dev, ST7735R_CMD_PWCTR2, config->pwctr2, in st7735r_lcd_init()
385 sizeof(config->pwctr2)); in st7735r_lcd_init()
390 ret = st7735r_transmit(dev, ST7735R_CMD_PWCTR3, config->pwctr3, in st7735r_lcd_init()
391 sizeof(config->pwctr3)); in st7735r_lcd_init()
396 ret = st7735r_transmit(dev, ST7735R_CMD_PWCTR4, config->pwctr4, in st7735r_lcd_init()
397 sizeof(config->pwctr4)); in st7735r_lcd_init()
402 ret = st7735r_transmit(dev, ST7735R_CMD_PWCTR5, config->pwctr5, in st7735r_lcd_init()
403 sizeof(config->pwctr5)); in st7735r_lcd_init()
408 ret = st7735r_transmit(dev, ST7735R_CMD_VMCTR1, &config->vmctr1, 1); in st7735r_lcd_init()
413 if (config->inversion_on) { in st7735r_lcd_init()
422 ret = st7735r_transmit(dev, ST7735R_CMD_MADCTL, &config->madctl, 1); in st7735r_lcd_init()
427 ret = st7735r_transmit(dev, ST7735R_CMD_COLMOD, &config->colmod, 1); in st7735r_lcd_init()
432 ret = st7735r_transmit(dev, ST7735R_CMD_CASET, config->caset, in st7735r_lcd_init()
433 sizeof(config->caset)); in st7735r_lcd_init()
438 ret = st7735r_transmit(dev, ST7735R_CMD_RASET, config->raset, in st7735r_lcd_init()
439 sizeof(config->raset)); in st7735r_lcd_init()
444 ret = st7735r_transmit(dev, ST7735R_CMD_GAMCTRP1, config->gamctrp1, in st7735r_lcd_init()
445 sizeof(config->gamctrp1)); in st7735r_lcd_init()
450 ret = st7735r_transmit(dev, ST7735R_CMD_GAMCTRN1, config->gamctrn1, in st7735r_lcd_init()
451 sizeof(config->gamctrn1)); in st7735r_lcd_init()
471 const struct st7735r_config *config = dev->config; in st7735r_init()
474 if (!spi_is_ready_dt(&config->bus)) { in st7735r_init()
475 LOG_ERR("SPI bus %s not ready", config->bus.bus->name); in st7735r_init()
476 return -ENODEV; in st7735r_init()
479 if (config->reset.port != NULL) { in st7735r_init()
480 if (!gpio_is_ready_dt(&config->reset)) { in st7735r_init()
481 LOG_ERR("Reset GPIO port for display not ready"); in st7735r_init()
482 return -ENODEV; in st7735r_init()
485 ret = gpio_pin_configure_dt(&config->reset, in st7735r_init()
493 if (!gpio_is_ready_dt(&config->cmd_data)) { in st7735r_init()
494 LOG_ERR("cmd/DATA GPIO port not ready"); in st7735r_init()
495 return -ENODEV; in st7735r_init()
498 ret = gpio_pin_configure_dt(&config->cmd_data, GPIO_OUTPUT); in st7735r_init()
539 ret = -ENOTSUP; in st7735r_pm_action()
568 .width = DT_INST_PROP(inst, width), \