Skip to content

Commit e8f4208

Browse files
ttnwosayBernardXiong
authored andcommitted
Update LVGLv81 porting.
1. Add RTGRAPHIC_CTRL_PAN_DISPLAY and RTGRAPHIC_CTRL_WAIT_VSYNC control command. 2. Add calibration data of 480x272 ADC touching. 3. Add 480x272 LCD panel menu option and driver. 4. Update lv_conf.h.
1 parent c18dae2 commit e8f4208

File tree

10 files changed

+318
-82
lines changed

10 files changed

+318
-82
lines changed

bsp/nuvoton/libraries/n9h30/Driver/Include/nu_2d.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ extern "C"
3030
/// @cond HIDDEN_SYMBOLS
3131
typedef struct
3232
{
33-
UINT32 PatternA;
34-
UINT32 PatternB;
33+
uint32_t PatternA;
34+
uint32_t PatternB;
3535
} MONOPATTERN;
3636

3737
#define COLOR_KEY 0xFF000000
@@ -169,7 +169,7 @@ void ge2dSpriteBltx_ScreenRop(int x, int y, int sprite_sx, int sprite_sy, int wi
169169
void ge2dColorExpansionBlt(int x, int y, int width, int height, int fore_color, int back_color, int opt, void *buf);
170170
void ge2dHostColorExpansionBlt(int x, int y, int width, int height, int fore_color, int back_color, int opt, void *buf);
171171
void ge2dInitMonoPattern(int opt, int fore_color, int back_color);
172-
void ge2dInitMonoInputPattern(UINT32 PatternA, UINT32 PatternB, int fore_color, int back_color);
172+
void ge2dInitMonoInputPattern(uint32_t PatternA, uint32_t PatternB, int fore_color, int back_color);
173173
void ge2dInitColorPattern(int patformat, void *patdata);
174174
void ge2dFont_PutChar(int x, int y, char asc_code, int fore_color, int back_color, int draw_mode, int font_id);
175175
void ge2dFont_PutString(int x, int y, char *str, int fore_color, int back_color, int draw_mode, int font_id);

bsp/nuvoton/libraries/n9h30/Driver/Include/nu_lcd.h

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ extern "C"
139139
#define VA_SCALE_INTERPOLATION (0) /*!< Scale mode is interpolation */
140140
#define VA_SCALE_DUPLICATION (1<<15) /*!< Scale mode is duplication */
141141

142+
#pragma anon_unions
143+
142144
typedef enum va_hcmode_e
143145
{
144146
HC_MODE0, /*!< 32X32X2bpp 4 color */
@@ -173,6 +175,7 @@ typedef struct
173175
#define DIS_PANEL_ILI9341_MPU80 1
174176
#define DIS_LSA40AT9001 2
175177
#define DIS_PANEL_FW070TFT 3
178+
#define DIS_PANEL_FW043TFT 4
176179
typedef struct
177180
{
178181
uint32_t u32DevWidth; /*!< Panel width */
@@ -184,11 +187,62 @@ typedef struct
184187
uint32_t u32MPU_Mode; /*!< MPU mode */
185188
uint32_t u32DisplayColors; /*!< Display colors */
186189
uint32_t u32DevType; /*!< Type of display panel */
187-
uint32_t u32Reg_CRTCSIZE; /*!< CRTCSIZE register value */
188-
uint32_t u32Reg_CRTCDEND; /*!< CRTCDEND register value */
189-
uint32_t u32Reg_CRTCHR; /*!< CRTCHR register value */
190-
uint32_t u32Reg_CRTCHSYNC; /*!< CRTCHSYNC register value */
191-
uint32_t u32Reg_CRTCVR; /*!< CRTCVR register value */
190+
union
191+
{
192+
uint32_t u32Reg_CRTCSIZE; /*!< CRTCSIZE register value */
193+
struct
194+
{
195+
uint32_t HTT: 11; /*!< Horizontal Total Pixels */
196+
uint32_t : 5;
197+
uint32_t VTT: 11; /*!< Vertical Total Scan Lines */
198+
uint32_t : 5;
199+
} sCRTCSIZE;
200+
};
201+
union
202+
{
203+
uint32_t u32Reg_CRTCDEND; /*!< CRTCDEND register value */
204+
struct
205+
{
206+
uint32_t HDEND: 11; /*!< Horizontal Display Enable End */
207+
uint32_t : 5;
208+
uint32_t VDEND: 11; /*!< Vertical Display Enable End */
209+
uint32_t : 5;
210+
} sCRTCDEND;
211+
};
212+
union
213+
{
214+
uint32_t u32Reg_CRTCHR; /*!< CRTCHR register value */
215+
struct
216+
{
217+
uint32_t HRS: 11; /*!< Internal Horizontal Retrace Start Timing */
218+
uint32_t : 5;
219+
uint32_t HRE: 11; /*!< Internal Horizontal Retrace End Low */
220+
uint32_t : 5;
221+
} sCRTCHR;
222+
};
223+
union
224+
{
225+
uint32_t u32Reg_CRTCHSYNC; /*!< CRTCHSYNC register value */
226+
struct
227+
{
228+
uint32_t HSYNC_S: 11; /*!< Horizontal Sync Start Timing */
229+
uint32_t : 5;
230+
uint32_t HSYNC_E: 11; /*!< Horizontal Sync End Timing */
231+
uint32_t : 3;
232+
uint32_t HSYNC_SHIFT: 2; /*!< Hsync Signal Adjustment For Multi-Cycles Per Pixel Mode Of Sync-Based Unipac-LCD */
233+
} sCRTCHSYNC;
234+
};
235+
union
236+
{
237+
uint32_t u32Reg_CRTCVR; /*!< CRTCVR register value */
238+
struct
239+
{
240+
uint32_t VRS: 11; /*!< Vertical Internal Retrace Start Timing */
241+
uint32_t : 5;
242+
uint32_t VRE: 11; /*!< Vertical Internal Retrace End Low */
243+
uint32_t : 5;
244+
} sCRTCVR;
245+
};
192246
} VPOST_T;
193247

194248
#define LCM_ERR_ID 0xFFFF0400 /*!< LCM library ID */

bsp/nuvoton/libraries/n9h30/Driver/Source/nu_lcd.c

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,74 @@ static VPOST_T DEF_FW070TFT =
103103
0x020001f6 /*!< CRTCVR register value */
104104
};
105105

106+
#define FW043TFT_WIDTH 480 /*!< XRES */
107+
#define FW043TFT_HEIGHT 272 /*!< YRES */
108+
#define FW043TFT_MARGIN_LEFT 30 /*!< HBP (Horizontal Back Porch) */
109+
#define FW043TFT_MARGIN_RIGHT 5 /*!< HFP (Horizontal Front Porch) */
110+
#define FW043TFT_MARGIN_UPPER 2 /*!< VBP (Vertical Back Porch) */
111+
#define FW043TFT_MARGIN_LOWER 27 /*!< VFP (Vertical Front Porch) */
112+
#define FW043TFT_HSYNC_LEN 41 /*!< HPW (HSYNC plus width) */
113+
#define FW043TFT_VSYNC_LEN 10 /*!< VPW (VSYNC width) */
114+
static VPOST_T DEF_FW043TFT =
115+
{
116+
FW043TFT_WIDTH, /*!< Panel width */
117+
FW043TFT_HEIGHT, /*!< Panel height */
118+
0, /*!< MPU command line low indicator */
119+
0, /*!< MPU command width */
120+
0, /*!< MPU bus width */
121+
VPOSTB_DATA16or18, /*!< Display bus width */
122+
0, /*!< MPU mode */
123+
VPOSTB_COLORTYPE_16M, /*!< Display colors */
124+
VPOSTB_DEVICE_SYNC_HIGHCOLOR, /*!< Type of display panel */
125+
126+
.sCRTCSIZE =
127+
{
128+
/*!< Horizontal Total */
129+
.HTT = FW043TFT_MARGIN_LEFT + FW043TFT_WIDTH + FW043TFT_MARGIN_RIGHT,
130+
131+
/*!< Vertical Total */
132+
.VTT = FW043TFT_MARGIN_UPPER + FW043TFT_HEIGHT + FW043TFT_MARGIN_LOWER,
133+
},
134+
.sCRTCDEND =
135+
{
136+
/*!< Horizontal Display Enable End */
137+
.HDEND = FW043TFT_WIDTH,
138+
139+
/*!< Vertical Display Enable End */
140+
.VDEND = FW043TFT_HEIGHT,
141+
},
142+
.sCRTCHR =
143+
{
144+
/*!< Internal Horizontal Retrace Start Timing */
145+
.HRS = FW043TFT_WIDTH + 1,
146+
147+
/*!< Internal Horizontal Retrace End Low */
148+
.HRE = FW043TFT_WIDTH + 5,
149+
},
150+
.sCRTCHSYNC =
151+
{
152+
/*!< Horizontal Sync Start Timing */
153+
.HSYNC_S = FW043TFT_WIDTH + FW043TFT_MARGIN_LEFT,
154+
155+
/*!< Horizontal Sync End Timing */
156+
.HSYNC_E = FW043TFT_WIDTH + FW043TFT_MARGIN_LEFT + FW043TFT_HSYNC_LEN,
157+
158+
/*!< Hsync Signal Adjustment For Multi-Cycles Per Pixel Mode Of Sync-Based Unipac-LCD */
159+
.HSYNC_SHIFT = 0,
160+
},
161+
.sCRTCVR =
162+
{
163+
/*!< Vertical Internal Retrace Start Timing */
164+
.VRS = FW043TFT_HEIGHT + FW043TFT_MARGIN_UPPER,
165+
166+
/*!< Vertical Internal Retrace End Low */
167+
.VRE = FW043TFT_HEIGHT + FW043TFT_MARGIN_UPPER + FW043TFT_VSYNC_LEN,
168+
}
169+
};
170+
171+
106172
/* LCD build-in support list */
107-
static VPOST_T *DisplayDevList[4] = {&DEF_E50A2V1, &DEF_ILI9341_MPU80, &DEF_LSA40AT9001, &DEF_FW070TFT};
173+
static VPOST_T *DisplayDevList[5] = {&DEF_E50A2V1, &DEF_ILI9341_MPU80, &DEF_LSA40AT9001, &DEF_FW070TFT, &DEF_FW043TFT};
108174
static VPOST_T curDisplayDev;
109175
static OSDFORMATEX curOSDDev = {0};
110176
static LCDFORMATEX curVADev = {0};

bsp/nuvoton/libraries/n9h30/rtt_port/Kconfig

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,13 +464,16 @@ config SOC_SERIES_N9H30
464464
prompt "Select Supported LCM panel"
465465
default LCM_USING_FW070TFT
466466
config LCM_USING_E50A2V1
467-
bool "LCM_E50A2V1(800x480x2)"
467+
bool "LCM_E50A2V1(800x480-RGB565)"
468468

469469
config LCM_USING_LSA40AT9001
470-
bool "LCM_LSA40AT9001(800x600x2)"
470+
bool "LCM_LSA40AT9001(800x600-RGB565)"
471471

472472
config LCM_USING_FW070TFT
473-
bool "LCM_FW070TFT(800x480x4)"
473+
bool "LCM_FW070TFT(800x480-RGB888)"
474+
475+
config LCM_USING_FW043TFT
476+
bool "LCM_FW043TFT(480x272-RGB888)"
474477

475478
endchoice
476479

@@ -480,13 +483,15 @@ config SOC_SERIES_N9H30
480483

481484
default 2 if LCM_USING_LSA40AT9001
482485
default 3 if LCM_USING_FW070TFT
486+
default 4 if LCM_USING_FW043TFT
483487

484488
config LCM_USING_BPP
485489
int
486490
default 2 if LCM_USING_E50A2V1
487491

488492
default 2 if LCM_USING_LSA40AT9001
489493
default 4 if LCM_USING_FW070TFT
494+
default 4 if LCM_USING_FW043TFT
490495

491496
config BSP_USING_VPOST_OSD
492497
bool "Enable VPOST OSD layer"

bsp/nuvoton/libraries/n9h30/rtt_port/drv_adc_touch.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,21 @@ typedef nu_adc_touch *nu_adc_touch_t;
2929
static nu_adc_touch s_NuAdcTouch = {0};
3030

3131
#define DEF_CALDATA_LENGTH 7
32-
static int cal_data_a[DEF_CALDATA_LENGTH] = { 13230, -66, -1161952, -85, 8600, -1636996, 65536 };
32+
33+
#if defined(LCM_USING_FW043TFT)
34+
#define LCM_WIDTH 480
35+
#define LCM_HEIGHT 272
36+
static int cal_data_a[DEF_CALDATA_LENGTH] = { 8824, -34, -2261272, -70, -6302, 21805816, 65536 };
37+
#else
38+
#define LCM_WIDTH 800
39+
#define LCM_HEIGHT 480
40+
#if defined(LCM_USING_FW070TFT)
41+
static int cal_data_a[DEF_CALDATA_LENGTH] = { 13230, -66, -1161952, -85, 8600, -1636996, 65536 };
42+
#else
43+
static int cal_data_a[DEF_CALDATA_LENGTH] = { 1, 0, 0, 0, 1, 0, 1 };
44+
#endif
45+
#endif
46+
3347
static const int cal_zero[DEF_CALDATA_LENGTH] = { 1, 0, 0, 0, 1, 0, 1 };
3448

3549
static void nu_adc_touch_cal(int *sumx, int *sumy)
@@ -152,8 +166,8 @@ int rt_hw_adc_touch_init(void)
152166
s_NuAdcTouch.dev.info.type = RT_TOUCH_TYPE_RESISTANCE;
153167
s_NuAdcTouch.dev.info.vendor = RT_TOUCH_VENDOR_UNKNOWN;
154168
s_NuAdcTouch.dev.info.point_num = 1;
155-
s_NuAdcTouch.dev.info.range_x = 800;
156-
s_NuAdcTouch.dev.info.range_x = 480;
169+
s_NuAdcTouch.dev.info.range_x = LCM_WIDTH;
170+
s_NuAdcTouch.dev.info.range_y = LCM_HEIGHT;
157171

158172
s_NuAdcTouch.dev.ops = &touch_ops;
159173

@@ -189,11 +203,11 @@ static void adc_touch_entry(void *parameter)
189203
result = rt_device_set_rx_indicate(pdev, adc_touch_rx_callback);
190204
RT_ASSERT(result == RT_EOK);
191205

192-
max_range = 800;
206+
max_range = LCM_WIDTH;
193207
result = rt_device_control(pdev, RT_TOUCH_CTRL_SET_X_RANGE, (void *)&max_range);
194208
RT_ASSERT(result == RT_EOK);
195209

196-
max_range = 480;
210+
max_range = LCM_HEIGHT;
197211
result = rt_device_control(pdev, RT_TOUCH_CTRL_SET_Y_RANGE, (void *)&max_range);
198212
RT_ASSERT(result == RT_EOK);
199213

bsp/nuvoton/libraries/n9h30/rtt_port/drv_vpost.c

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
/* Private typedef --------------------------------------------------------------*/
2424

25-
#define DEF_VPOST_BUFFER_NUMBER 2
25+
#define DEF_VPOST_BUFFER_NUMBER 3
2626

2727
typedef enum
2828
{
@@ -157,12 +157,12 @@ static rt_err_t vpost_layer_control(rt_device_t dev, int cmd, void *args)
157157
}
158158
break;
159159

160-
/* FBIO_PANDISPLAY + WAIT_VSYNC Mechanism */
161-
case RTGRAPHIC_CTRL_RECT_UPDATE:
160+
case RTGRAPHIC_CTRL_PAN_DISPLAY:
162161
{
163162
if (args != RT_NULL)
164163
{
165164
uint8_t *pu8BufPtr = (uint8_t *)args;
165+
166166
g_u32VSyncLastCommit = g_u32VSyncBlank;
167167

168168
/* Pan display */
@@ -182,20 +182,27 @@ static rt_err_t vpost_layer_control(rt_device_t dev, int cmd, void *args)
182182
return -RT_ERROR;
183183
}
184184

185-
/*Wait sync*/
186-
while (g_u32VSyncLastCommit == g_u32VSyncBlank)
187-
{
188-
rt_completion_init(&vsync_wq);
189-
rt_completion_wait(&vsync_wq, RT_TICK_PER_SECOND / 60);
190-
}
191185
}
192186
else
193187
return -RT_ERROR;
194188
}
195189
break;
196190

191+
case RTGRAPHIC_CTRL_WAIT_VSYNC:
192+
{
193+
if (args != RT_NULL)
194+
g_u32VSyncLastCommit = g_u32VSyncBlank+1;
195+
196+
if (g_u32VSyncLastCommit >= g_u32VSyncBlank)
197+
{
198+
rt_completion_init(&vsync_wq);
199+
rt_completion_wait(&vsync_wq, RT_TICK_PER_SECOND / 60);
200+
}
201+
}
202+
break;
203+
197204
default:
198-
break;
205+
return -RT_ERROR;
199206
}
200207

201208
return RT_EOK;
@@ -254,8 +261,19 @@ int rt_hw_vpost_init(void)
254261
VPOST_T *psVpostLcmInst = vpostLCMGetInstance(VPOST_USING_LCD_IDX);
255262
RT_ASSERT(psVpostLcmInst != RT_NULL);
256263

257-
/* LCD clock is selected from UPLL and divide to 20MHz */
258-
outpw(REG_CLK_DIVCTL1, (inpw(REG_CLK_DIVCTL1) & ~0xff1f) | 0xE18);
264+
if ( (psVpostLcmInst->u32DevWidth * psVpostLcmInst->u32DevHeight) > (480*272) )
265+
{
266+
/* LCD clock is selected from UPLL and divide to 20MHz */
267+
outpw(REG_CLK_DIVCTL1, (inpw(REG_CLK_DIVCTL1) & ~0xff1f) | 0xE18);
268+
269+
/* LCD clock is selected from UPLL and divide to 30MHz */
270+
//outpw(REG_CLK_DIVCTL1, (inpw(REG_CLK_DIVCTL1) & ~0xff1f) | 0x918);
271+
}
272+
else
273+
{
274+
/* LCD clock is selected from UPLL and divide to 10MHz */
275+
outpw(REG_CLK_DIVCTL1, (inpw(REG_CLK_DIVCTL1) & ~0xff1f) | 0xE19);
276+
}
259277

260278
/* Initial LCM */
261279
vpostLCMInit(VPOST_USING_LCD_IDX);

bsp/nuvoton/nk-980iot/applications/lvgl/lv_conf.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,18 @@
1111
#ifndef LV_CONF_H
1212
#define LV_CONF_H
1313

14-
1514
#define LV_USE_PERF_MONITOR 1
1615
#define LV_COLOR_DEPTH 16
1716

1817
#define LV_HOR_RES_MAX (320)
1918
#define LV_VER_RES_MAX (240)
2019

21-
22-
#define LV_USE_DEMO_RTT_MUSIC 1
23-
#define LV_USE_DEMO_MUSIC 1
2420
#define LV_FONT_MONTSERRAT_12 1
2521
#define LV_FONT_MONTSERRAT_16 1
26-
#define LV_DEMO_MUSIC_AUTO_PLAY 1
22+
#define LV_USE_DEMO_RTT_MUSIC 1
2723
#define LV_DEMO_RTT_MUSIC_AUTO_PLAY 1
2824

25+
#define LV_DISP_DEF_REFR_PERIOD 16
26+
2927
//#define CONFIG_LV_LOG_LEVEL LV_LOG_LEVEL_TRACE
3028
#endif

bsp/nuvoton/nk-n9h30/applications/lvgl/lv_conf.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
#define LV_HOR_RES_MAX (800)
2020
#define LV_VER_RES_MAX (480)
2121

22-
23-
#define LV_USE_DEMO_RTT_MUSIC 1
24-
#define LV_USE_DEMO_MUSIC 1
2522
#define LV_FONT_MONTSERRAT_12 1
2623
#define LV_FONT_MONTSERRAT_16 1
27-
#define LV_DEMO_MUSIC_AUTO_PLAY 1
24+
#define LV_USE_DEMO_RTT_MUSIC 1
2825
#define LV_DEMO_RTT_MUSIC_AUTO_PLAY 1
2926

27+
//#define LV_DISP_DEF_REFR_PERIOD 16
28+
3029
//#define CONFIG_LV_LOG_LEVEL LV_LOG_LEVEL_TRACE
3130
#endif

0 commit comments

Comments
 (0)