1
1
#include " Arduino.h"
2
2
#include " st7701.h"
3
3
#include " dsi.h"
4
+ #include " video_modes.h"
4
5
5
6
/* Command2 BKx selection command */
6
7
#define DSI_CMD2BKX_SEL 0xFF
@@ -52,15 +53,32 @@ static void DCS_Short_Write_NP(uint8_t data0);
52
53
static void Generic_Short_Write_1P (uint8_t data0, uint8_t data1);
53
54
static void DCS_Short_Read_NP (uint8_t data0, int length, uint8_t * p_data);
54
55
55
- void st7701_init (void ) {
56
+ void st7701_init (enum edid_modes mode) {
57
+ struct edid _edid;
58
+ struct display_timing dt;
59
+
60
+ // DSI Configuration
61
+ dt.pixelclock = envie_known_modes[mode].pixel_clock ;
62
+ dt.hactive = envie_known_modes[mode].hactive ;
63
+ dt.hsync_len = envie_known_modes[mode].hsync_len ;
64
+ dt.hback_porch = envie_known_modes[mode].hback_porch ;
65
+ dt.hfront_porch = envie_known_modes[mode].hfront_porch ;
66
+ dt.vactive = envie_known_modes[mode].vactive ;
67
+ dt.vsync_len = envie_known_modes[mode].vsync_len ;
68
+ dt.vback_porch = envie_known_modes[mode].vback_porch ;
69
+ dt.vfront_porch = envie_known_modes[mode].vfront_porch ;
70
+ dt.hpol = envie_known_modes[mode].hpol ;
71
+ dt.vpol = envie_known_modes[mode].vpol ;
72
+ dsi_init (0 , &_edid, &dt);
73
+
56
74
DCS_Short_Write_NP (MIPI_DCS_SOFT_RESET);
57
75
Delay (200 );
58
76
59
77
// ST7701S+IVO5.0
60
78
DCS_Short_Write_NP (MIPI_DCS_EXIT_SLEEP_MODE);
61
79
62
- // ------------------------------------------Bank0 Setting-------------------------------------------------- //
63
- // ------------------------------------Display Control setting---------------------------------------------- //
80
+ // ------------------------------------------Bank0 Setting------------------------------------------------//
81
+ // ------------------------------------Display Control setting--------------------------------------------//
64
82
Delay (800 );
65
83
66
84
const uint8_t Display_Control_0[] = {0xFF ,0x77 ,0x01 ,0x00 ,0x00 ,0x10 };
@@ -75,7 +93,7 @@ void st7701_init(void) {
75
93
Generic_Long_Write ((uint8_t *)Display_Control_3, sizeof (Display_Control_3));
76
94
Generic_Long_Write ((uint8_t *)Display_Control_4, sizeof (Display_Control_4));
77
95
78
- // -------------------------------------Gamma Cluster Setting-------------------------------------------//
96
+ // -------------------------------------Gamma Cluster Setting--------------------------------------------- //
79
97
const uint8_t _B0[] = {0xB0 , 0x40 , 0xc9 , 0x91 , 0x0d ,
80
98
0x12 , 0x07 , 0x02 , 0x09 , 0x09 ,
81
99
0x1f , 0x04 , 0x50 , 0x0f , 0xe4 ,
@@ -99,9 +117,9 @@ void st7701_init(void) {
99
117
Generic_Long_Write ((uint8_t *)_FF1, sizeof (_FF1));
100
118
101
119
Generic_Short_Write_1P (DSI_CMD2_BK1_VRHS,0x65 );
102
- // -------------------------------------------Vcom Setting--------------------------------------------------- //
120
+ // -------------------------------------------Vcom Setting------------------------------------------------//
103
121
Generic_Short_Write_1P (DSI_CMD2_BK1_VCOM,0x34 );
104
- // -----------------------------------------End Vcom Setting----------------------------------------------- //
122
+ // -----------------------------------------End Vcom Setting----------------------------------------------//
105
123
Generic_Short_Write_1P (DSI_CMD2_BK1_VGHSS,0x87 );
106
124
Generic_Short_Write_1P (DSI_CMD2_BK1_TESTCMD,0x80 );
107
125
@@ -113,18 +131,18 @@ void st7701_init(void) {
113
131
Generic_Short_Write_1P (DSI_CMD2_BK1_SPD1,0x78 );
114
132
Generic_Short_Write_1P (DSI_CMD2_BK1_SPD2,0x78 );
115
133
Generic_Short_Write_1P (DSI_CMD2_BK1_MIPISET1,0x88 );
116
- // ---------------------------------End Power Control Registers Initial -------------------------------//
134
+ // ---------------------------------End Power Control Registers Initial ---------------------------------- //
117
135
Delay (100 );
118
- // ---------------------------------------------GIP Setting---------------------------------------------------- //
136
+ // ---------------------------------------------GIP Setting-----------------------------------------------//
119
137
const uint8_t _E0[] = {0xE0 ,0x00 ,0x00 ,0x02 };
120
138
Generic_Long_Write ((uint8_t *)_E0, sizeof (_E0));
121
- // ----------------------------------GIP----------------------------------------------------
139
+ // ----------------------------------GIP------------------------------------------------------------------//
122
140
const uint8_t _E1[] = {0xE1 ,0x08 ,0x00 ,0x0A ,0x00 ,0x07 ,0x00 ,0x09 ,0x00 ,0x00 ,0x33 ,0x33 };
123
141
const uint8_t _E2[] = {0xE2 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 };
124
142
Generic_Long_Write ((uint8_t *)_E1, sizeof (_E1));
125
143
Generic_Long_Write ((uint8_t *)_E2, sizeof (_E2));
126
144
127
- // --------------------------------------------------------------------------------------
145
+ // -------------------------------------------------------------------------------------------------------//
128
146
const uint8_t _E3[] = {0xE3 ,0x00 ,0x00 ,0x33 ,0x33 };
129
147
const uint8_t _E4[] = {0xE4 ,0x44 ,0x44 };
130
148
Generic_Long_Write ((uint8_t *)_E3, sizeof (_E3));
@@ -150,8 +168,8 @@ void st7701_init(void) {
150
168
Generic_Long_Write ((uint8_t *)_ED, sizeof (_ED));
151
169
152
170
// --------------------------------------------End GIP Setting-----------------------------------------------//
153
- // ------------------------------ Power Control Registers Initial End-----------------------------------//
154
- // ------------------------------------------Bank1 Setting---------------------------------------------------- //
171
+ // ------------------------------ Power Control Registers Initial End---------------------------------------- //
172
+ // ------------------------------------------Bank1 Setting---------------------------------------------------//
155
173
const uint8_t _FF2[] = {DSI_CMD2BKX_SEL,0x77 ,0x01 ,0x00 ,0x00 ,DSI_CMD2BKX_SEL_NONE};
156
174
Generic_Long_Write ((uint8_t *)_FF2, sizeof (_FF2));
157
175
0 commit comments