Skip to content

Commit b6b5994

Browse files
leonardocavagnisfacchinm
authored andcommitted
add DSI initialization inside ST7701 lib
1 parent c38444b commit b6b5994

File tree

5 files changed

+39
-54
lines changed

5 files changed

+39
-54
lines changed

libraries/H7_Video/src/H7_Video.cpp

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -58,54 +58,18 @@ int H7_Video::begin(bool landscape) {
5858
//Configure SDRAM
5959
SDRAM.begin(dsi_getFramebufferEnd());
6060
} else if (_shield == GIGA_DISPLAY_SHIELD) {
61-
#define EDID_MODE_SELECTED EDID_MODE_480x800_60Hz
62-
struct edid _edid;
63-
struct display_timing dt;
64-
65-
//DSI Configuration
66-
dt.pixelclock = envie_known_modes[EDID_MODE_SELECTED].pixel_clock;
67-
dt.hactive = envie_known_modes[EDID_MODE_SELECTED].hactive;
68-
dt.hsync_len = envie_known_modes[EDID_MODE_SELECTED].hsync_len;
69-
dt.hback_porch = envie_known_modes[EDID_MODE_SELECTED].hback_porch;
70-
dt.hfront_porch = envie_known_modes[EDID_MODE_SELECTED].hfront_porch;
71-
dt.vactive = envie_known_modes[EDID_MODE_SELECTED].vactive;
72-
dt.vsync_len = envie_known_modes[EDID_MODE_SELECTED].vsync_len;
73-
dt.vback_porch = envie_known_modes[EDID_MODE_SELECTED].vback_porch;
74-
dt.vfront_porch = envie_known_modes[EDID_MODE_SELECTED].vfront_porch;
75-
dt.hpol = envie_known_modes[EDID_MODE_SELECTED].hpol;
76-
dt.vpol = envie_known_modes[EDID_MODE_SELECTED].vpol;
77-
dsi_init(0, &_edid, &dt);
61+
//Init LCD Controller
62+
st7701_init(EDID_MODE_480x800_60Hz);
7863

7964
//Configure SDRAM
8065
SDRAM.begin();
81-
82-
//Init LCD Controller
83-
st7701_init();
8466
}
8567
#elif defined(ARDUINO_GIGA)
86-
#define EDID_MODE_SELECTED EDID_MODE_480x800_60Hz
87-
struct edid _edid;
88-
struct display_timing dt;
89-
90-
//DSI Configuration
91-
dt.pixelclock = envie_known_modes[EDID_MODE_SELECTED].pixel_clock;
92-
dt.hactive = envie_known_modes[EDID_MODE_SELECTED].hactive;
93-
dt.hsync_len = envie_known_modes[EDID_MODE_SELECTED].hsync_len;
94-
dt.hback_porch = envie_known_modes[EDID_MODE_SELECTED].hback_porch;
95-
dt.hfront_porch = envie_known_modes[EDID_MODE_SELECTED].hfront_porch;
96-
dt.vactive = envie_known_modes[EDID_MODE_SELECTED].vactive;
97-
dt.vsync_len = envie_known_modes[EDID_MODE_SELECTED].vsync_len;
98-
dt.vback_porch = envie_known_modes[EDID_MODE_SELECTED].vback_porch;
99-
dt.vfront_porch = envie_known_modes[EDID_MODE_SELECTED].vfront_porch;
100-
dt.hpol = envie_known_modes[EDID_MODE_SELECTED].hpol;
101-
dt.vpol = envie_known_modes[EDID_MODE_SELECTED].vpol;
102-
dsi_init(0, &_edid, &dt);
68+
//Init LCD Controller
69+
st7701_init(EDID_MODE_480x800_60Hz);
10370

10471
//Configure SDRAM
10572
SDRAM.begin();
106-
107-
//Init LCD Controller
108-
st7701_init();
10973
#else
11074
#error Board not compatible with this library
11175
#endif

libraries/H7_Video/src/st7701.cpp

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "Arduino.h"
22
#include "st7701.h"
33
#include "dsi.h"
4+
#include "video_modes.h"
45

56
/* Command2 BKx selection command */
67
#define DSI_CMD2BKX_SEL 0xFF
@@ -52,15 +53,32 @@ static void DCS_Short_Write_NP(uint8_t data0);
5253
static void Generic_Short_Write_1P(uint8_t data0, uint8_t data1);
5354
static void DCS_Short_Read_NP(uint8_t data0, int length, uint8_t* p_data);
5455

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+
5674
DCS_Short_Write_NP(MIPI_DCS_SOFT_RESET);
5775
Delay(200);
5876

5977
//ST7701S+IVO5.0
6078
DCS_Short_Write_NP(MIPI_DCS_EXIT_SLEEP_MODE);
6179

62-
//------------------------------------------Bank0 Setting--------------------------------------------------//
63-
//------------------------------------Display Control setting----------------------------------------------//
80+
//------------------------------------------Bank0 Setting------------------------------------------------//
81+
//------------------------------------Display Control setting--------------------------------------------//
6482
Delay(800);
6583

6684
const uint8_t Display_Control_0[] = {0xFF,0x77,0x01,0x00,0x00,0x10};
@@ -75,7 +93,7 @@ void st7701_init(void) {
7593
Generic_Long_Write((uint8_t*)Display_Control_3, sizeof(Display_Control_3));
7694
Generic_Long_Write((uint8_t*)Display_Control_4, sizeof(Display_Control_4));
7795

78-
//-------------------------------------Gamma Cluster Setting-------------------------------------------//
96+
//-------------------------------------Gamma Cluster Setting---------------------------------------------//
7997
const uint8_t _B0[] = {0xB0, 0x40, 0xc9, 0x91, 0x0d,
8098
0x12, 0x07, 0x02, 0x09, 0x09,
8199
0x1f, 0x04, 0x50, 0x0f, 0xe4,
@@ -99,9 +117,9 @@ void st7701_init(void) {
99117
Generic_Long_Write ((uint8_t*)_FF1, sizeof(_FF1));
100118

101119
Generic_Short_Write_1P (DSI_CMD2_BK1_VRHS,0x65);
102-
//-------------------------------------------Vcom Setting---------------------------------------------------//
120+
//-------------------------------------------Vcom Setting------------------------------------------------//
103121
Generic_Short_Write_1P (DSI_CMD2_BK1_VCOM,0x34);
104-
//-----------------------------------------End Vcom Setting-----------------------------------------------//
122+
//-----------------------------------------End Vcom Setting----------------------------------------------//
105123
Generic_Short_Write_1P (DSI_CMD2_BK1_VGHSS,0x87);
106124
Generic_Short_Write_1P (DSI_CMD2_BK1_TESTCMD,0x80);
107125

@@ -113,18 +131,18 @@ void st7701_init(void) {
113131
Generic_Short_Write_1P (DSI_CMD2_BK1_SPD1,0x78);
114132
Generic_Short_Write_1P (DSI_CMD2_BK1_SPD2,0x78);
115133
Generic_Short_Write_1P (DSI_CMD2_BK1_MIPISET1,0x88);
116-
//---------------------------------End Power Control Registers Initial -------------------------------//
134+
//---------------------------------End Power Control Registers Initial ----------------------------------//
117135
Delay(100);
118-
//---------------------------------------------GIP Setting----------------------------------------------------//
136+
//---------------------------------------------GIP Setting-----------------------------------------------//
119137
const uint8_t _E0[] = {0xE0,0x00,0x00,0x02};
120138
Generic_Long_Write((uint8_t*)_E0, sizeof(_E0));
121-
//----------------------------------GIP----------------------------------------------------
139+
//----------------------------------GIP------------------------------------------------------------------//
122140
const uint8_t _E1[] = {0xE1,0x08,0x00,0x0A,0x00,0x07,0x00,0x09,0x00,0x00,0x33,0x33};
123141
const uint8_t _E2[] = {0xE2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
124142
Generic_Long_Write((uint8_t*)_E1, sizeof(_E1));
125143
Generic_Long_Write((uint8_t*)_E2, sizeof(_E2));
126144

127-
//--------------------------------------------------------------------------------------
145+
//-------------------------------------------------------------------------------------------------------//
128146
const uint8_t _E3[] = {0xE3,0x00,0x00,0x33,0x33};
129147
const uint8_t _E4[] = {0xE4,0x44,0x44};
130148
Generic_Long_Write((uint8_t*)_E3, sizeof(_E3));
@@ -150,8 +168,8 @@ void st7701_init(void) {
150168
Generic_Long_Write((uint8_t*)_ED, sizeof(_ED));
151169

152170
//--------------------------------------------End GIP Setting-----------------------------------------------//
153-
//------------------------------ Power Control Registers Initial End-----------------------------------//
154-
//------------------------------------------Bank1 Setting----------------------------------------------------//
171+
//------------------------------ Power Control Registers Initial End----------------------------------------//
172+
//------------------------------------------Bank1 Setting---------------------------------------------------//
155173
const uint8_t _FF2[] = {DSI_CMD2BKX_SEL,0x77,0x01,0x00,0x00,DSI_CMD2BKX_SEL_NONE};
156174
Generic_Long_Write ((uint8_t*)_FF2, sizeof(_FF2));
157175

libraries/H7_Video/src/st7701.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef _ST7701_H
22
#define _ST7701_H
33

4-
void st7701_init();
4+
#include "edid.h"
5+
6+
void st7701_init(enum edid_modes mode);
57

68
#endif // _ST7701_H

libraries/H7_Video/src/video_modes.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include "edid.h"
21
#include "video_modes.h"
32

43
struct envie_edid_mode envie_known_modes[NUM_KNOWN_MODES] = {

libraries/H7_Video/src/video_modes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include "edid.h"
2+
13
struct envie_edid_mode {
24
const char *name;
35
unsigned int pixel_clock;

0 commit comments

Comments
 (0)