1
1
/* Includes ------------------------------------------------------------------*/
2
2
#include <unicore-mx/stm32/rcc.h>
3
3
#include <unicore-mx/stm32/gpio.h>
4
- #include <unicore-mx/stm32/ltdc .h>
4
+ #include <unicore-mx/lcd_tft/lcd_tft .h>
5
5
#include "RGB_565_480_272.h"
6
6
#include "rk043fn48h.h"
7
7
8
8
/* Private function prototypes -----------------------------------------------*/
9
9
static void lcd_config (void );
10
10
static void lcd_pinmux (void );
11
11
static void lcd_clock (void );
12
- static void lcd_config_layer (void );
12
+ static void lcd_config_layer (lcd_tft * lt );
13
13
14
14
/* Private functions ---------------------------------------------------------*/
15
15
@@ -71,36 +71,23 @@ void lcd_pinmux(void)
71
71
gpio_set (GPIOK , GPIO3 );
72
72
}
73
73
74
- static void lcd_config_layer (void )
74
+ static void lcd_config_layer (lcd_tft * lt )
75
75
{
76
- /* Windowing configuration */
77
- ltdc_setup_windowing (LTDC_LAYER_2 , 480 , 272 );
78
-
79
- /* Specifies the pixel format */
80
- ltdc_set_pixel_format (LTDC_LAYER_2 , LTDC_LxPFCR_RGB565 );
81
-
82
- /* Default color values */
83
- ltdc_set_default_colors (LTDC_LAYER_2 , 0 , 0 , 0 , 0 );
84
- /* Constant alpha */
85
- ltdc_set_constant_alpha (LTDC_LAYER_2 , 255 );
86
-
87
- /* Blending factors */
88
- ltdc_set_blending_factors (LTDC_LAYER_2 , LTDC_LxBFCR_BF1_CONST_ALPHA , LTDC_LxBFCR_BF2_CONST_ALPHA );
89
-
90
- /* Framebuffer address */
91
- ltdc_set_fbuffer_address (LTDC_LAYER_2 , (uint32_t )& RGB_565_480_272 .pixel_data );
92
-
93
- /* Configures the color frame buffer pitch in byte */
94
- ltdc_set_fb_line_length (LTDC_LAYER_2 , 2 * 480 , 2 * 480 ); /* RGB565 is 2 bytes/pixel */
95
-
96
- /* Configures the frame buffer line number */
97
- ltdc_set_fb_line_count (LTDC_LAYER_2 , 272 );
98
-
99
- /* Enable layer 1 */
100
- ltdc_layer_ctrl_enable (LTDC_LAYER_2 , LTDC_LxCR_LAYER_ENABLE );
101
-
102
- /* Sets the Reload type */
103
- ltdc_reload (LTDC_SRCR_IMR );
76
+ const struct lcd_tft_layer layer = {
77
+ .framebuffer = {
78
+ .x = 0 ,
79
+ .y = 0 ,
80
+ .width = RGB_565_480_272 .width ,
81
+ .height = RGB_565_480_272 .height ,
82
+ .format = LCD_TFT_RGB565 ,
83
+ .data = RGB_565_480_272 .pixel_data
84
+ },
85
+
86
+ .palette = {.data = NULL , .count = 0 },
87
+ .transparent = {.data = NULL , .count = 0 }
88
+ };
89
+
90
+ lcd_tft_layer_set (lt , 1 , & layer );
104
91
}
105
92
106
93
/**
@@ -116,24 +103,29 @@ static void lcd_config_layer(void)
116
103
*/
117
104
static void lcd_config (void )
118
105
{
119
- /* LTDC Initialization */
120
- ltdc_ctrl_disable (LTDC_GCR_HSPOL_ACTIVE_HIGH ); /* Active Low Horizontal Sync */
121
- ltdc_ctrl_disable (LTDC_GCR_VSPOL_ACTIVE_HIGH ); /* Active Low Vertical Sync */
122
- ltdc_ctrl_disable (LTDC_GCR_DEPOL_ACTIVE_HIGH ); /* Active Low Date Enable */
123
- ltdc_ctrl_disable (LTDC_GCR_PCPOL_ACTIVE_HIGH ); /* Active Low Pixel Clock */
124
-
125
- /* Configure the LTDC */
126
- ltdc_set_tft_sync_timings (RK043FN48H_HSYNC , RK043FN48H_VSYNC ,
127
- RK043FN48H_HBP , RK043FN48H_VBP ,
128
- RK043FN48H_WIDTH , RK043FN48H_HEIGHT ,
129
- RK043FN48H_HFP , RK043FN48H_VFP );
130
-
131
- ltdc_set_background_color (0 , 0 , 0 );
132
- ltdc_ctrl_enable (LTDC_GCR_LTDC_ENABLE );
133
-
134
- /* Configure the Layer*/
135
- lcd_config_layer ();
136
-
106
+ const struct lcd_tft_config config = {
107
+ .timing = {
108
+ .hsync = RK043FN48H_HSYNC ,
109
+ .vsync = RK043FN48H_VSYNC ,
110
+ .hbp = RK043FN48H_HBP ,
111
+ .vbp = RK043FN48H_VBP ,
112
+ .height = RK043FN48H_HEIGHT ,
113
+ .width = RK043FN48H_WIDTH ,
114
+ .vfp = RK043FN48H_VFP ,
115
+ .hfp = RK043FN48H_HFP
116
+ },
117
+ .features = LCD_TFT_HSYNC_ACTIVE_LOW |
118
+ LCD_TFT_VSYNC_ACTIVE_LOW |
119
+ LCD_TFT_DE_ACTIVE_LOW |
120
+ LCD_TFT_CLK_ACTIVE_LOW ,
121
+ .output = LCD_TFT_OUTPUT_RGB888 ,
122
+ .background = 0x00000000
123
+ };
124
+
125
+ lcd_tft * lt = lcd_tft_init (LCD_TFT_STM32_LTDC , & config );
126
+
127
+ /* Configure the Layer*/
128
+ lcd_config_layer (lt );
137
129
}
138
130
139
131
0 commit comments