Skip to content

Commit b832638

Browse files
halyssonJrxiaoxiang781216
authored andcommitted
add support to LTDC for Linum board
1 parent 17a06ce commit b832638

File tree

4 files changed

+236
-0
lines changed

4 files changed

+236
-0
lines changed

boards/arm/stm32h7/linum-stm32h753bi/include/board.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,72 @@
548548
#define GPIO_TIM5_CH1IN GPIO_TIM5_CH1IN_1 /* PA0 */
549549
#define GPIO_TIM5_CH2IN GPIO_TIM5_CH2IN_2 /* PH11 */
550550

551+
/* LTDC */
552+
553+
#define GPIO_LTDC_R0 (GPIO_LTDC_R0_3 | GPIO_SPEED_100MHz)
554+
#define GPIO_LTDC_R1 (GPIO_LTDC_R1_3 | GPIO_SPEED_100MHz)
555+
#define GPIO_LTDC_R2 (GPIO_LTDC_R2_4 | GPIO_SPEED_100MHz)
556+
#define GPIO_LTDC_R3 (GPIO_LTDC_R3_3 | GPIO_SPEED_100MHz)
557+
#define GPIO_LTDC_R4 (GPIO_LTDC_R4_4 | GPIO_SPEED_100MHz)
558+
#define GPIO_LTDC_R5 (GPIO_LTDC_R5_4 | GPIO_SPEED_100MHz)
559+
#define GPIO_LTDC_R6 (GPIO_LTDC_R6_4 | GPIO_SPEED_100MHz)
560+
#define GPIO_LTDC_R7 (GPIO_LTDC_R7_3 | GPIO_SPEED_100MHz)
561+
562+
#define GPIO_LTDC_G0 (GPIO_LTDC_G0_2 | GPIO_SPEED_100MHz)
563+
#define GPIO_LTDC_G1 (GPIO_LTDC_G1_2 | GPIO_SPEED_100MHz)
564+
#define GPIO_LTDC_G2 (GPIO_LTDC_G2_3 | GPIO_SPEED_100MHz)
565+
#define GPIO_LTDC_G3 (GPIO_LTDC_G3_4 | GPIO_SPEED_100MHz)
566+
#define GPIO_LTDC_G4 (GPIO_LTDC_G4_3 | GPIO_SPEED_100MHz)
567+
#define GPIO_LTDC_G5 (GPIO_LTDC_G5_3 | GPIO_SPEED_100MHz)
568+
#define GPIO_LTDC_G6 (GPIO_LTDC_G6_3 | GPIO_SPEED_100MHz)
569+
#define GPIO_LTDC_G7 (GPIO_LTDC_G7_3 | GPIO_SPEED_100MHz)
570+
571+
#define GPIO_LTDC_B0 (GPIO_LTDC_B0_3 | GPIO_SPEED_100MHz)
572+
#define GPIO_LTDC_B1 (GPIO_LTDC_B1_2 | GPIO_SPEED_100MHz)
573+
#define GPIO_LTDC_B2 (GPIO_LTDC_B2_3 | GPIO_SPEED_100MHz)
574+
#define GPIO_LTDC_B3 (GPIO_LTDC_B3_3 | GPIO_SPEED_100MHz)
575+
#define GPIO_LTDC_B4 (GPIO_LTDC_B4_3 | GPIO_SPEED_100MHz)
576+
#define GPIO_LTDC_B5 (GPIO_LTDC_B5_3 | GPIO_SPEED_100MHz)
577+
#define GPIO_LTDC_B6 (GPIO_LTDC_B6_3 | GPIO_SPEED_100MHz)
578+
#define GPIO_LTDC_B7 (GPIO_LTDC_B7_3 | GPIO_SPEED_100MHz)
579+
580+
#define GPIO_LTDC_VSYNC (GPIO_LTDC_VSYNC_2 | GPIO_SPEED_100MHz)
581+
#define GPIO_LTDC_HSYNC (GPIO_LTDC_HSYNC_2 | GPIO_SPEED_100MHz)
582+
#define GPIO_LTDC_DE (GPIO_LTDC_DE_3 | GPIO_SPEED_100MHz)
583+
#define GPIO_LTDC_CLK (GPIO_LTDC_CLK_3 | GPIO_SPEED_100MHz)
584+
585+
/* LCD definitions **********************************************************/
586+
587+
#define BOARD_LTDC_WIDTH 1024
588+
#define BOARD_LTDC_HEIGHT 600
589+
590+
#define BOARD_LTDC_OUTPUT_BPP 16
591+
#define BOARD_LTDC_HFP 160
592+
#define BOARD_LTDC_HBP 160
593+
#define BOARD_LTDC_VFP 1
594+
#define BOARD_LTDC_VBP 23
595+
#define BOARD_LTDC_HSYNC 0
596+
#define BOARD_LTDC_VSYNC 0
597+
598+
#define BOARD_LTDC_PLLSAIN 192
599+
#define BOARD_LTDC_PLLSAIR 5
600+
601+
/* Pixel Clock Polarity */
602+
603+
#define BOARD_LTDC_GCR_PCPOL 0 /* !LTDC_GCR_PCPOL */
604+
605+
/* Data Enable Polarity */
606+
607+
#define BOARD_LTDC_GCR_DEPOL 0 /* !LTDC_GCR_DEPOL */
608+
609+
/* Vertical Sync Polarity */
610+
611+
#define BOARD_LTDC_GCR_VSPOL 0 /* !LTDC_GCR_VSPOL */
612+
613+
/* Horizontal Sync Polarity */
614+
615+
#define BOARD_LTDC_GCR_HSPOL 0 /* !LTDC_GCR_HSPOL */
616+
551617
/****************************************************************************
552618
* Public Data
553619
****************************************************************************/

boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@
118118

119119
#define LINUMSTM32H753BI_QETIMER 5
120120

121+
/* LCD */
122+
123+
#define GPIO_LCD_DISP (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
124+
GPIO_OUTPUT_SET|GPIO_PORTI|GPIO_PIN7)
125+
126+
#define GPIO_LCD_BL (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
127+
GPIO_OUTPUT_SET|GPIO_PORTH|GPIO_PIN6)
128+
121129
/****************************************************************************
122130
* Public Function Prototypes
123131
****************************************************************************/

boards/arm/stm32h7/linum-stm32h753bi/src/stm32_bringup.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,38 @@
5353
#include <nuttx/usb/rndis.h>
5454
#endif
5555

56+
#ifdef CONFIG_VIDEO_FB
57+
# include <nuttx/video/fb.h>
58+
#endif
59+
60+
#include <arch/board/board.h>
61+
5662
/****************************************************************************
5763
* Private Functions
5864
****************************************************************************/
5965

66+
static void convert_lcd_rgb565(void)
67+
{
68+
/* Put LCD_{R0,R1,R2,G0,G1,B0,B1,B2} in low level */
69+
70+
stm32_configgpio(GPIO_LTDC_R0);
71+
stm32_gpiowrite(GPIO_LTDC_R0, 0);
72+
stm32_configgpio(GPIO_LTDC_R1);
73+
stm32_gpiowrite(GPIO_LTDC_R1, 0);
74+
stm32_configgpio(GPIO_LTDC_R2);
75+
stm32_gpiowrite(GPIO_LTDC_R2, 0);
76+
stm32_configgpio(GPIO_LTDC_G0);
77+
stm32_gpiowrite(GPIO_LTDC_G0, 0);
78+
stm32_configgpio(GPIO_LTDC_G1);
79+
stm32_gpiowrite(GPIO_LTDC_G1, 0);
80+
stm32_configgpio(GPIO_LTDC_B0);
81+
stm32_gpiowrite(GPIO_LTDC_B0, 0);
82+
stm32_configgpio(GPIO_LTDC_B1);
83+
stm32_gpiowrite(GPIO_LTDC_B1, 0);
84+
stm32_configgpio(GPIO_LTDC_B2);
85+
stm32_gpiowrite(GPIO_LTDC_B2, 0);
86+
}
87+
6088
/****************************************************************************
6189
* Name: stm32_i2c_register
6290
*
@@ -158,6 +186,20 @@ int stm32_bringup(void)
158186
}
159187
#endif /* CONFIG_FS_PROCFS */
160188

189+
/* Put pin not used in RG565 to level zero */
190+
191+
convert_lcd_rgb565();
192+
193+
#ifdef CONFIG_VIDEO_FB
194+
/* Initialize and register the framebuffer driver */
195+
196+
ret = fb_register(0, 0);
197+
if (ret < 0)
198+
{
199+
syslog(LOG_ERR, "ERROR: fb_register() failed: %d\n", ret);
200+
}
201+
#endif
202+
161203
#ifdef CONFIG_USERLED
162204
/* Register the LED driver */
163205

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/****************************************************************************
2+
* boards/arm/stm32h7/linum-stm32h753bi/src/stm32_lcd.c
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership. The
7+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance with the
9+
* License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
* License for the specific language governing permissions and limitations
17+
* under the License.
18+
*
19+
****************************************************************************/
20+
21+
/****************************************************************************
22+
* Included Files
23+
****************************************************************************/
24+
25+
#include <nuttx/config.h>
26+
27+
#include <errno.h>
28+
#include <debug.h>
29+
30+
#include <nuttx/arch.h>
31+
#include <nuttx/board.h>
32+
#include <nuttx/video/fb.h>
33+
#include <arch/board/board.h>
34+
35+
#include "stm32_gpio.h"
36+
#include "stm32_ltdc.h"
37+
38+
#include "linum-stm32h753bi.h"
39+
40+
#ifdef CONFIG_STM32H7_LTDC
41+
/****************************************************************************
42+
* Public Functions
43+
****************************************************************************/
44+
45+
/****************************************************************************
46+
* Name: up_fbinitialize
47+
*
48+
* Description:
49+
* Initialize the framebuffer video hardware associated with the display.
50+
*
51+
* Input Parameters:
52+
* display - In the case of hardware with multiple displays, this
53+
* specifies the display. Normally this is zero.
54+
*
55+
* Returned Value:
56+
* Zero is returned on success; a negated errno value is returned on any
57+
* failure.
58+
*
59+
****************************************************************************/
60+
61+
int up_fbinitialize(int display)
62+
{
63+
/* Custom LCD display with RGB interface */
64+
65+
stm32_configgpio(GPIO_LCD_DISP);
66+
stm32_configgpio(GPIO_LCD_BL);
67+
68+
stm32_gpiowrite(GPIO_LCD_DISP, true);
69+
stm32_gpiowrite(GPIO_LCD_BL, true);
70+
71+
return stm32_ltdcinitialize();
72+
}
73+
74+
/****************************************************************************
75+
* Name: up_fbgetvplane
76+
*
77+
* Description:
78+
* Return a a reference to the framebuffer object for the specified video
79+
* plane of the specified plane.
80+
* Many OSDs support multiple planes of video.
81+
*
82+
* Input Parameters:
83+
* display - In the case of hardware with multiple displays, this
84+
* specifies the display. Normally this is zero.
85+
* vplane - Identifies the plane being queried.
86+
*
87+
* Returned Value:
88+
* A non-NULL pointer to the frame buffer access structure is returned on
89+
* success; NULL is returned on any failure.
90+
*
91+
****************************************************************************/
92+
93+
struct fb_vtable_s *up_fbgetvplane(int display, int vplane)
94+
{
95+
return stm32_ltdcgetvplane(vplane);
96+
}
97+
98+
/****************************************************************************
99+
* Name: up_fbuninitialize
100+
*
101+
* Description:
102+
* Uninitialize the framebuffer support for the specified display.
103+
*
104+
* Input Parameters:
105+
* display - In the case of hardware with multiple displays, this
106+
* specifies the display. Normally this is zero.
107+
*
108+
* Returned Value:
109+
* None
110+
*
111+
****************************************************************************/
112+
113+
void up_fbuninitialize(int display)
114+
{
115+
stm32_gpiowrite(GPIO_LCD_DISP, false);
116+
stm32_gpiowrite(GPIO_LCD_BL, false);
117+
118+
stm32_ltdcuninitialize();
119+
}
120+
#endif /* CONFIG_STM32_LTDC */

0 commit comments

Comments
 (0)