summaryrefslogtreecommitdiff
path: root/bsp/nxp/lpc/lpc55sxx/libraries/drivers/drv_st7796.h
blob: 22263d7016067a033a7664781d409952332e42ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * Copyright (c) 2006-2023, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2023-05-23     Chushicheng  the first version.
 */

#ifndef DRV_ST7796_H__
#define DRV_ST7796_H__

#include <rtdevice.h>

#define LCD_DEVICE_NAME  "st7796"
typedef enum
{
    ST7796_DIR_0   = 0x08U,
    ST7796_DIR_90  = 0x68U,
    ST7796_DIR_180 = 0xC8U,
    ST7796_DIR_270 = 0xA8U,
} st7796_direction_t;

typedef enum
{
    ST7796_RGB444 = 3,
    ST7796_RGB565 = 5,
    ST7796_RGB666 = 6,
    ST7796_RGB888 = 7
} st7796_pixfmt_t;

typedef struct
{
    rt_err_t (*reset_cb)(void *handle);
    rt_err_t (*backlight_cb)(void *handle, rt_uint8_t on);
    rt_err_t (*write_cmd_cb)(void *handle, rt_uint8_t *cmd, rt_uint8_t len);
    rt_err_t (*write_data_cb)(void *handle, void *data, rt_uint32_t len);
} st7796_cb_t;

typedef struct
{
    st7796_direction_t direction;
    st7796_pixfmt_t pix_fmt;
    rt_uint8_t inversion;
    rt_uint8_t bgr_mode;
    uint8_t mirrored;
} st7796_config_t;

typedef struct
{
    void *user_data;
    st7796_cb_t cb;
    st7796_config_t config;
} st7796_lcd_t;

typedef struct
{
    struct rt_device            parent;
    st7796_lcd_t                st7796;
    struct rt_spi_device        *spi_dev;
} st7796_t;

void lcd_load(rt_uint16_t x_start, rt_uint16_t x_end, rt_uint16_t y_start, rt_uint16_t y_end, void *data);
int drv_st7796_init(void);

#endif /* DRV_ST7796_H__ */