Skip to content

Commit 43ff895

Browse files
jfischer-novanwinkeljan
authored andcommitted
drivers: display_st7789v: obtain resolution and offsets from DT
Obtain resolution and offsets from DT. Fix style. Signed-off-by: Johann Fischer <[email protected]>
1 parent f15d60b commit 43ff895

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

drivers/display/display_st7789v.c

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,14 @@ static int st7789v_init(struct device *dev)
282282
return -EPERM;
283283
}
284284

285-
data->spi_config.frequency = DT_INST_0_SITRONIX_ST7789V_SPI_MAX_FREQUENCY;
285+
data->spi_config.frequency =
286+
DT_INST_0_SITRONIX_ST7789V_SPI_MAX_FREQUENCY;
286287
data->spi_config.operation = SPI_OP_MODE_MASTER | SPI_WORD_SET(8);
287288
data->spi_config.slave = DT_INST_0_SITRONIX_ST7789V_BASE_ADDRESS;
288289

289290
#ifdef DT_INST_0_SITRONIX_ST7789V_CS_GPIOS_CONTROLLER
290-
data->cs_ctrl.gpio_dev =
291-
device_get_binding(DT_INST_0_SITRONIX_ST7789V_CS_GPIOS_CONTROLLER);
291+
data->cs_ctrl.gpio_dev = device_get_binding(
292+
DT_INST_0_SITRONIX_ST7789V_CS_GPIOS_CONTROLLER);
292293
data->cs_ctrl.gpio_pin = DT_INST_0_SITRONIX_ST7789V_CS_GPIOS_PIN;
293294
data->cs_ctrl.delay = 0U;
294295
data->spi_config.cs = &(data->cs_ctrl);
@@ -297,21 +298,22 @@ static int st7789v_init(struct device *dev)
297298
#endif
298299

299300
#ifdef DT_INST_0_SITRONIX_ST7789V_RESET_GPIOS_CONTROLLER
300-
data->reset_gpio =
301-
device_get_binding(DT_INST_0_SITRONIX_ST7789V_RESET_GPIOS_CONTROLLER);
301+
data->reset_gpio = device_get_binding(
302+
DT_INST_0_SITRONIX_ST7789V_RESET_GPIOS_CONTROLLER);
302303
if (data->reset_gpio == NULL) {
303304
LOG_ERR("Could not get GPIO port for display reset");
304305
return -EPERM;
305306
}
306307

307-
if (gpio_pin_configure(data->reset_gpio, ST7789V_RESET_PIN, GPIO_DIR_OUT)) {
308+
if (gpio_pin_configure(data->reset_gpio, ST7789V_RESET_PIN,
309+
GPIO_DIR_OUT)) {
308310
LOG_ERR("Couldn't configure reset pin");
309311
return -EIO;
310312
}
311313
#endif
312314

313-
data->cmd_data_gpio =
314-
device_get_binding(DT_INST_0_SITRONIX_ST7789V_CMD_DATA_GPIOS_CONTROLLER);
315+
data->cmd_data_gpio = device_get_binding(
316+
DT_INST_0_SITRONIX_ST7789V_CMD_DATA_GPIOS_CONTROLLER);
315317
if (data->cmd_data_gpio == NULL) {
316318
LOG_ERR("Could not get GPIO port for cmd/DATA port");
317319
return -EPERM;
@@ -322,18 +324,6 @@ static int st7789v_init(struct device *dev)
322324
return -EIO;
323325
}
324326

325-
data->width = 240;
326-
data->height = 320;
327-
data->x_offset = 0;
328-
data->y_offset = 0;
329-
330-
#ifdef DT_INST_0_SITRONIX_ST7789V_WIDTH
331-
data->width = DT_INST_0_SITRONIX_ST7789V_WIDTH;
332-
#endif
333-
#ifdef DT_INST_0_SITRONIX_ST7789V_HEIGHT
334-
data->height = DT_INST_0_SITRONIX_ST7789V_HEIGHT;
335-
#endif
336-
337327
st7789v_reset_display(data);
338328

339329
st7789v_blanking_on(dev);
@@ -358,7 +348,12 @@ static const struct display_driver_api st7789v_api = {
358348
.set_orientation = st7789v_set_orientation,
359349
};
360350

361-
static struct st7789v_data st7789v_data;
351+
static struct st7789v_data st7789v_data = {
352+
.width = DT_INST_0_SITRONIX_ST7789V_WIDTH,
353+
.height = DT_INST_0_SITRONIX_ST7789V_HEIGHT,
354+
.x_offset = DT_INST_0_SITRONIX_ST7789V_X_OFFSET,
355+
.y_offset = DT_INST_0_SITRONIX_ST7789V_Y_OFFSET,
356+
};
362357

363358
DEVICE_AND_API_INIT(st7789v, DT_INST_0_SITRONIX_ST7789V_LABEL, &st7789v_init,
364359
&st7789v_data, NULL, APPLICATION,

0 commit comments

Comments
 (0)