forked from lvgl/lvgl_esp32_drivers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lvgl_i2c_conf.h
116 lines (91 loc) · 2.86 KB
/
lvgl_i2c_conf.h
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
* @file lvgl_i2c_config.h
*/
#ifndef LVGL_I2C_CONF_H
#define LVGL_I2C_CONF_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif
/*********************
* DEFINES
*********************/
/* TODO: Define the I2C bus clock based on the selected display or touch
* controllers. */
/* Do both display and touch controllers uses I2C? */
#if defined (CONFIG_LV_TOUCH_DRIVER_PROTOCOL_I2C) && \
defined (CONFIG_LV_TFT_DISPLAY_PROTOCOL_I2C)
#if defined (CONFIG_LV_DISPLAY_I2C_PORT_0) && \
defined (CONFIG_LV_TOUCH_I2C_PORT_0)
#define SHARED_I2C_PORT
#define DISP_I2C_PORT I2C_NUM_0
#endif
#if defined (CONFIG_LV_DISPLAY_I2C_PORT_1) && \
defined (CONFIG_LV_TOUCH_I2C_PORT_1)
#define SHARED_I2C_PORT
#define DISP_I2C_PORT I2C_NUM_1
#endif
#if !defined (SHARED_I2C_PORT)
#endif
#endif
#if defined (SHARED_I2C_PORT)
/* If the port is shared the display and touch controllers must use the same
* SCL and SDA pins, otherwise let the user know with an error. */
#if (CONFIG_LV_DISP_PIN_SDA != CONFIG_LV_TOUCH_I2C_SDA) || \
(CONFIG_LV_DISP_PIN_SCL != CONFIG_LV_TOUCH_I2C_SCL)
#error "To share I2C port you need to choose the same SDA and SCL pins on both display and touch configurations"
#endif
#define DISP_I2C_SDA CONFIG_LV_DISP_PIN_SDA
#define DISP_I2C_SCL CONFIG_LV_DISP_PIN_SCL
#define DISP_I2C_ORIENTATION TFT_ORIENTATION_LANDSCAPE
/* Setting the I2C speed to the slowest one */
#if DISP_I2C_SPEED_HZ < TOUCH_I2C_SPEED_HZ
#define DISP_I2C_SPEED_HZ 400000 /* DISP_I2C_SPEED_HZ */
#else
#define DISP_I2C_SPEED_HZ 400000 /* DISP_I2C_SPEED_HZ */
#endif
#else
/* lets check if the touch controller uses I2C... */
#if defined (CONFIG_LV_TOUCH_DRIVER_PROTOCOL_I2C)
#if defined (CONFIG_LV_TOUCH_I2C_PORT_0)
#define TOUCH_I2C_PORT I2C_NUM_0
#else
#define TOUCH_I2C_PORT I2C_NUM_1
#endif
#define TOUCH_I2C_SDA CONFIG_LV_TOUCH_I2C_SDA
#define TOUCH_I2C_SCL CONFIG_LV_TOUCH_I2C_SCL
#define TOUCH_I2C_SPEED_HZ 400000
#endif
/* lets check if the display controller uses I2C... */
#if defined (CONFIG_LV_TFT_DISPLAY_PROTOCOL_I2C)
#if defined (CONFIG_LV_DISPLAY_I2C_PORT_0)
#define DISP_I2C_PORT I2C_NUM_0
#else
#define DISP_I2C_PORT I2C_NUM_1
#endif
#define DISP_I2C_SDA CONFIG_LV_DISP_PIN_SDA
#define DISP_I2C_SCL CONFIG_LV_DISP_PIN_SCL
#define DISP_I2C_ORIENTATION TFT_ORIENTATION_LANDSCAPE
#define DISP_I2C_SPEED_HZ 400000
#endif
#endif
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LVGL_I2C_CONF_H*/