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,24 @@ 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
+ .background = 0x00000000 ,
87
+ .palette = {.data = NULL , .count = 0 },
88
+ .transparent = {.data = NULL , .count = 0 }
89
+ };
90
+
91
+ lcd_tft_layer_set (lt , 1 , & layer );
104
92
}
105
93
106
94
/**
@@ -116,24 +104,29 @@ static void lcd_config_layer(void)
116
104
*/
117
105
static void lcd_config (void )
118
106
{
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
-
107
+ const struct lcd_tft_config config = {
108
+ .timing = {
109
+ .hsync = RK043FN48H_HSYNC ,
110
+ .vsync = RK043FN48H_VSYNC ,
111
+ .hbp = RK043FN48H_HBP ,
112
+ .vbp = RK043FN48H_VBP ,
113
+ .height = RK043FN48H_HEIGHT ,
114
+ .width = RK043FN48H_WIDTH ,
115
+ .vfp = RK043FN48H_VFP ,
116
+ .hfp = RK043FN48H_HFP
117
+ },
118
+ .features = LCD_TFT_HSYNC_ACTIVE_LOW |
119
+ LCD_TFT_VSYNC_ACTIVE_LOW |
120
+ LCD_TFT_DE_ACTIVE_LOW |
121
+ LCD_TFT_CLK_ACTIVE_LOW ,
122
+ .output = LCD_TFT_OUTPUT_RGB888 ,
123
+ .background = 0x00000000
124
+ };
125
+
126
+ lcd_tft * lt = lcd_tft_init (LCD_TFT_STM32_LTDC , & config );
127
+
128
+ /* Configure the Layer*/
129
+ lcd_config_layer (lt );
137
130
}
138
131
139
132
0 commit comments