Boilerplate library to get started with LvGL on STM DISCO F746NG board. Adapted from https://os.mbed.com/users/JohnnyK/code/DISCO-F746NG_MbedOs_LvGL_example/
Dependencies: BSP_DISCO_F746NG
lv_port_disp.c@0:cffa136e7f8f, 2020-09-08 (annotated)
- Committer:
- elelthvd
- Date:
- Tue Sep 08 05:23:58 2020 +0000
- Revision:
- 0:cffa136e7f8f
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elelthvd | 0:cffa136e7f8f | 1 | /** |
elelthvd | 0:cffa136e7f8f | 2 | * @file lv_port_disp_templ.c |
elelthvd | 0:cffa136e7f8f | 3 | * |
elelthvd | 0:cffa136e7f8f | 4 | */ |
elelthvd | 0:cffa136e7f8f | 5 | |
elelthvd | 0:cffa136e7f8f | 6 | /*Copy this file as "lv_port_disp.c" and set this value to "1" to enable content*/ |
elelthvd | 0:cffa136e7f8f | 7 | #if 1 |
elelthvd | 0:cffa136e7f8f | 8 | |
elelthvd | 0:cffa136e7f8f | 9 | /********************* |
elelthvd | 0:cffa136e7f8f | 10 | * INCLUDES |
elelthvd | 0:cffa136e7f8f | 11 | *********************/ |
elelthvd | 0:cffa136e7f8f | 12 | #include "lv_port_disp.h" |
elelthvd | 0:cffa136e7f8f | 13 | #include "lvgl/lvgl.h" |
elelthvd | 0:cffa136e7f8f | 14 | #include "stm32f7xx.h" |
elelthvd | 0:cffa136e7f8f | 15 | #include "stm32746g_discovery.h" |
elelthvd | 0:cffa136e7f8f | 16 | #include "stm32746g_discovery_sdram.h" |
elelthvd | 0:cffa136e7f8f | 17 | #include "stm32746g_discovery_lcd.h" |
elelthvd | 0:cffa136e7f8f | 18 | #include "stm32746g_discovery_ts.h" |
elelthvd | 0:cffa136e7f8f | 19 | |
elelthvd | 0:cffa136e7f8f | 20 | /********************* |
elelthvd | 0:cffa136e7f8f | 21 | * DEFINES |
elelthvd | 0:cffa136e7f8f | 22 | *********************/ |
elelthvd | 0:cffa136e7f8f | 23 | |
elelthvd | 0:cffa136e7f8f | 24 | /********************** |
elelthvd | 0:cffa136e7f8f | 25 | * TYPEDEFS |
elelthvd | 0:cffa136e7f8f | 26 | **********************/ |
elelthvd | 0:cffa136e7f8f | 27 | |
elelthvd | 0:cffa136e7f8f | 28 | /********************** |
elelthvd | 0:cffa136e7f8f | 29 | * STATIC PROTOTYPES |
elelthvd | 0:cffa136e7f8f | 30 | **********************/ |
elelthvd | 0:cffa136e7f8f | 31 | static void disp_init(void); |
elelthvd | 0:cffa136e7f8f | 32 | |
elelthvd | 0:cffa136e7f8f | 33 | static void disp_flush(lv_disp_drv_t* disp_drv, const lv_area_t* area, lv_color_t* color_p); |
elelthvd | 0:cffa136e7f8f | 34 | |
elelthvd | 0:cffa136e7f8f | 35 | #if LV_USE_GPU |
elelthvd | 0:cffa136e7f8f | 36 | DMA2D_HandleTypeDef Dma2dHandle; |
elelthvd | 0:cffa136e7f8f | 37 | static void DMA2D_Config(void); |
elelthvd | 0:cffa136e7f8f | 38 | static void Error_Handler(void); |
elelthvd | 0:cffa136e7f8f | 39 | static void DMA2D_TransferComplete(DMA2D_HandleTypeDef *hdma2d); |
elelthvd | 0:cffa136e7f8f | 40 | static void DMA2D_TransferError(DMA2D_HandleTypeDef *hdma2d); |
elelthvd | 0:cffa136e7f8f | 41 | static void gpu_blend(lv_disp_drv_t * disp_drv,lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa); |
elelthvd | 0:cffa136e7f8f | 42 | static void gpu_fill(lv_disp_drv_t * disp_drv,lv_color_t * dest_buf, lv_coord_t dest_width, const lv_area_t * fill_area, lv_color_t color); |
elelthvd | 0:cffa136e7f8f | 43 | #endif |
elelthvd | 0:cffa136e7f8f | 44 | |
elelthvd | 0:cffa136e7f8f | 45 | /********************** |
elelthvd | 0:cffa136e7f8f | 46 | * STATIC VARIABLES |
elelthvd | 0:cffa136e7f8f | 47 | **********************/ |
elelthvd | 0:cffa136e7f8f | 48 | |
elelthvd | 0:cffa136e7f8f | 49 | /********************** |
elelthvd | 0:cffa136e7f8f | 50 | * MACROS |
elelthvd | 0:cffa136e7f8f | 51 | **********************/ |
elelthvd | 0:cffa136e7f8f | 52 | |
elelthvd | 0:cffa136e7f8f | 53 | /********************** |
elelthvd | 0:cffa136e7f8f | 54 | * GLOBAL FUNCTIONS |
elelthvd | 0:cffa136e7f8f | 55 | **********************/ |
elelthvd | 0:cffa136e7f8f | 56 | |
elelthvd | 0:cffa136e7f8f | 57 | void lv_port_disp_init(void) |
elelthvd | 0:cffa136e7f8f | 58 | { |
elelthvd | 0:cffa136e7f8f | 59 | /*------------------------- |
elelthvd | 0:cffa136e7f8f | 60 | * Initialize your display |
elelthvd | 0:cffa136e7f8f | 61 | * -----------------------*/ |
elelthvd | 0:cffa136e7f8f | 62 | disp_init(); |
elelthvd | 0:cffa136e7f8f | 63 | |
elelthvd | 0:cffa136e7f8f | 64 | /*----------------------------- |
elelthvd | 0:cffa136e7f8f | 65 | * Create a buffer for drawing |
elelthvd | 0:cffa136e7f8f | 66 | *----------------------------*/ |
elelthvd | 0:cffa136e7f8f | 67 | |
elelthvd | 0:cffa136e7f8f | 68 | /* LittlevGL requires a buffer where it draws the objects. The buffer's has to be greater than 1 display row |
elelthvd | 0:cffa136e7f8f | 69 | * |
elelthvd | 0:cffa136e7f8f | 70 | * There are three buffering configurations: |
elelthvd | 0:cffa136e7f8f | 71 | * 1. Create ONE buffer with some rows: |
elelthvd | 0:cffa136e7f8f | 72 | * LittlevGL will draw the display's content here and writes it to your display |
elelthvd | 0:cffa136e7f8f | 73 | * |
elelthvd | 0:cffa136e7f8f | 74 | * 2. Create TWO buffer with some rows: |
elelthvd | 0:cffa136e7f8f | 75 | * LittlevGL will draw the display's content to a buffer and writes it your display. |
elelthvd | 0:cffa136e7f8f | 76 | * You should use DMA to write the buffer's content to the display. |
elelthvd | 0:cffa136e7f8f | 77 | * It will enable LittlevGL to draw the next part of the screen to the other buffer while |
elelthvd | 0:cffa136e7f8f | 78 | * the data is being sent form the first buffer. It makes rendering and flushing parallel. |
elelthvd | 0:cffa136e7f8f | 79 | * |
elelthvd | 0:cffa136e7f8f | 80 | * 3. Create TWO screen-sized buffer: |
elelthvd | 0:cffa136e7f8f | 81 | * Similar to 2) but the buffer have to be screen sized. When LittlevGL is ready it will give the |
elelthvd | 0:cffa136e7f8f | 82 | * whole frame to display. This way you only need to change the frame buffer's address instead of |
elelthvd | 0:cffa136e7f8f | 83 | * copying the pixels. |
elelthvd | 0:cffa136e7f8f | 84 | * */ |
elelthvd | 0:cffa136e7f8f | 85 | |
elelthvd | 0:cffa136e7f8f | 86 | /* Example for 1) */ |
elelthvd | 0:cffa136e7f8f | 87 | static lv_disp_buf_t disp_buf_1; |
elelthvd | 0:cffa136e7f8f | 88 | static lv_color_t buf1_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/ |
elelthvd | 0:cffa136e7f8f | 89 | lv_disp_buf_init(&disp_buf_1, buf1_1, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/ |
elelthvd | 0:cffa136e7f8f | 90 | |
elelthvd | 0:cffa136e7f8f | 91 | /* Example for 2) */ |
elelthvd | 0:cffa136e7f8f | 92 | //static lv_disp_buf_t disp_buf_2; |
elelthvd | 0:cffa136e7f8f | 93 | //static lv_color_t buf2_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/ |
elelthvd | 0:cffa136e7f8f | 94 | //static lv_color_t buf2_2[LV_HOR_RES_MAX * 10]; /*An other buffer for 10 rows*/ |
elelthvd | 0:cffa136e7f8f | 95 | //lv_disp_buf_init(&disp_buf_2, buf2_1, buf2_2, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/ |
elelthvd | 0:cffa136e7f8f | 96 | |
elelthvd | 0:cffa136e7f8f | 97 | /* Example for 3) */ |
elelthvd | 0:cffa136e7f8f | 98 | // static lv_disp_buf_t disp_buf_3; |
elelthvd | 0:cffa136e7f8f | 99 | // static lv_color_t buf3_1[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*A screen sized buffer*/ |
elelthvd | 0:cffa136e7f8f | 100 | // static lv_color_t buf3_2[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*An other screen sized buffer*/ |
elelthvd | 0:cffa136e7f8f | 101 | // lv_disp_buf_init(&disp_buf_3, buf3_1, buf3_2, LV_HOR_RES_MAX * LV_VER_RES_MAX); /*Initialize the display buffer*/ |
elelthvd | 0:cffa136e7f8f | 102 | |
elelthvd | 0:cffa136e7f8f | 103 | |
elelthvd | 0:cffa136e7f8f | 104 | /*----------------------------------- |
elelthvd | 0:cffa136e7f8f | 105 | * Register the display in LittlevGL |
elelthvd | 0:cffa136e7f8f | 106 | *----------------------------------*/ |
elelthvd | 0:cffa136e7f8f | 107 | |
elelthvd | 0:cffa136e7f8f | 108 | lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ |
elelthvd | 0:cffa136e7f8f | 109 | lv_disp_drv_init(&disp_drv); /*Basic initialization*/ |
elelthvd | 0:cffa136e7f8f | 110 | /*Set up the functions to access to your display*/ |
elelthvd | 0:cffa136e7f8f | 111 | /*Set the resolution of the display*/ |
elelthvd | 0:cffa136e7f8f | 112 | disp_drv.hor_res = 480; |
elelthvd | 0:cffa136e7f8f | 113 | disp_drv.ver_res = 272; |
elelthvd | 0:cffa136e7f8f | 114 | /*Used to copy the buffer's content to the display*/ |
elelthvd | 0:cffa136e7f8f | 115 | disp_drv.flush_cb = disp_flush; |
elelthvd | 0:cffa136e7f8f | 116 | /*Set a display buffer*/ |
elelthvd | 0:cffa136e7f8f | 117 | disp_drv.buffer = &disp_buf_1; |
elelthvd | 0:cffa136e7f8f | 118 | // disp_drv.buffer = &disp_buf_2; |
elelthvd | 0:cffa136e7f8f | 119 | // disp_drv.buffer = &disp_buf_3; |
elelthvd | 0:cffa136e7f8f | 120 | #if LV_USE_GPU |
elelthvd | 0:cffa136e7f8f | 121 | /*Optionally add functions to access the GPU. (Only in buffered mode, LV_VDB_SIZE != 0)*/ |
elelthvd | 0:cffa136e7f8f | 122 | DMA2D_Config(); |
elelthvd | 0:cffa136e7f8f | 123 | /*Blend two color array using opacity*/ |
elelthvd | 0:cffa136e7f8f | 124 | disp_drv.gpu_blend_cb = gpu_blend; |
elelthvd | 0:cffa136e7f8f | 125 | /*Fill a memory array with a color*/ |
elelthvd | 0:cffa136e7f8f | 126 | disp_drv.gpu_fill_cb = gpu_fill; |
elelthvd | 0:cffa136e7f8f | 127 | #endif |
elelthvd | 0:cffa136e7f8f | 128 | /*Finally register the driver*/ |
elelthvd | 0:cffa136e7f8f | 129 | lv_disp_drv_register(&disp_drv); |
elelthvd | 0:cffa136e7f8f | 130 | } |
elelthvd | 0:cffa136e7f8f | 131 | |
elelthvd | 0:cffa136e7f8f | 132 | /********************** |
elelthvd | 0:cffa136e7f8f | 133 | * STATIC FUNCTIONS |
elelthvd | 0:cffa136e7f8f | 134 | **********************/ |
elelthvd | 0:cffa136e7f8f | 135 | |
elelthvd | 0:cffa136e7f8f | 136 | /* Initialize your display and the required peripherals. */ |
elelthvd | 0:cffa136e7f8f | 137 | static void disp_init(void){ |
elelthvd | 0:cffa136e7f8f | 138 | /*You code here*/ |
elelthvd | 0:cffa136e7f8f | 139 | BSP_LCD_Init(); |
elelthvd | 0:cffa136e7f8f | 140 | #if LV_COLOR_DEPTH == 16 |
elelthvd | 0:cffa136e7f8f | 141 | Dma2dHandle.LayerCfg[0].InputColorMode = DMA2D_INPUT_RGB565; |
elelthvd | 0:cffa136e7f8f | 142 | BSP_LCD_LayerRgb565Init(1, LCD_FB_START_ADDRESS)); |
elelthvd | 0:cffa136e7f8f | 143 | #elif LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32 |
elelthvd | 0:cffa136e7f8f | 144 | BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS); |
elelthvd | 0:cffa136e7f8f | 145 | #endif |
elelthvd | 0:cffa136e7f8f | 146 | BSP_LCD_DisplayOn(); |
elelthvd | 0:cffa136e7f8f | 147 | BSP_LCD_SelectLayer(0); |
elelthvd | 0:cffa136e7f8f | 148 | } |
elelthvd | 0:cffa136e7f8f | 149 | |
elelthvd | 0:cffa136e7f8f | 150 | /* Flush the content of the internal buffer the specific area on the display |
elelthvd | 0:cffa136e7f8f | 151 | * You can use DMA or any hardware acceleration to do this operation in the background but |
elelthvd | 0:cffa136e7f8f | 152 | * 'lv_disp_flush_ready()' has to be called when finished. */ |
elelthvd | 0:cffa136e7f8f | 153 | static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p){ |
elelthvd | 0:cffa136e7f8f | 154 | //The most simple case (but also the slowest) to put all pixels to the screen one-by-one |
elelthvd | 0:cffa136e7f8f | 155 | uint16_t x, y; |
elelthvd | 0:cffa136e7f8f | 156 | for(y = area->y1; y <= area->y2; y++) { |
elelthvd | 0:cffa136e7f8f | 157 | for(x = area->x1; x <= area->x2; x++) { |
elelthvd | 0:cffa136e7f8f | 158 | //put_px(x, y, *color_p) |
elelthvd | 0:cffa136e7f8f | 159 | BSP_LCD_DrawPixel( x, y, color_p->full); |
elelthvd | 0:cffa136e7f8f | 160 | color_p++; |
elelthvd | 0:cffa136e7f8f | 161 | } |
elelthvd | 0:cffa136e7f8f | 162 | } |
elelthvd | 0:cffa136e7f8f | 163 | // IMPORTANT!!!* Inform the graphics library that you are ready with the flushing |
elelthvd | 0:cffa136e7f8f | 164 | lv_disp_flush_ready(disp_drv); |
elelthvd | 0:cffa136e7f8f | 165 | } |
elelthvd | 0:cffa136e7f8f | 166 | |
elelthvd | 0:cffa136e7f8f | 167 | |
elelthvd | 0:cffa136e7f8f | 168 | /*OPTIONAL: GPU INTERFACE*/ |
elelthvd | 0:cffa136e7f8f | 169 | #if LV_USE_GPU |
elelthvd | 0:cffa136e7f8f | 170 | |
elelthvd | 0:cffa136e7f8f | 171 | /* If your MCU has hardware accelerator (GPU) then you can use it to blend to memories using opacity |
elelthvd | 0:cffa136e7f8f | 172 | * It can be used only in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/ |
elelthvd | 0:cffa136e7f8f | 173 | |
elelthvd | 0:cffa136e7f8f | 174 | static void DMA2D_Config(void){ |
elelthvd | 0:cffa136e7f8f | 175 | //onfigure the DMA2D Mode, Color Mode and output offset |
elelthvd | 0:cffa136e7f8f | 176 | Dma2dHandle.Init.Mode = DMA2D_M2M_BLEND; |
elelthvd | 0:cffa136e7f8f | 177 | #if LV_COLOR_DEPTH == 16 |
elelthvd | 0:cffa136e7f8f | 178 | Dma2dHandle.Init.ColorMode = DMA2D_RGB565; |
elelthvd | 0:cffa136e7f8f | 179 | #elif LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32 |
elelthvd | 0:cffa136e7f8f | 180 | Dma2dHandle.Init.ColorMode = DMA2D_ARGB8888; |
elelthvd | 0:cffa136e7f8f | 181 | #endif |
elelthvd | 0:cffa136e7f8f | 182 | Dma2dHandle.Init.OutputOffset = 0x0; |
elelthvd | 0:cffa136e7f8f | 183 | //DMA2D Callbacks Configuration |
elelthvd | 0:cffa136e7f8f | 184 | Dma2dHandle.XferCpltCallback = DMA2D_TransferComplete; |
elelthvd | 0:cffa136e7f8f | 185 | Dma2dHandle.XferErrorCallback = DMA2D_TransferError; |
elelthvd | 0:cffa136e7f8f | 186 | //Foreground Configuration |
elelthvd | 0:cffa136e7f8f | 187 | Dma2dHandle.LayerCfg[1].AlphaMode = DMA2D_REPLACE_ALPHA; |
elelthvd | 0:cffa136e7f8f | 188 | Dma2dHandle.LayerCfg[1].InputAlpha = 0xFF; |
elelthvd | 0:cffa136e7f8f | 189 | #if LV_COLOR_DEPTH == 16 |
elelthvd | 0:cffa136e7f8f | 190 | Dma2dHandle.LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB565; |
elelthvd | 0:cffa136e7f8f | 191 | #elif LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32 |
elelthvd | 0:cffa136e7f8f | 192 | Dma2dHandle.LayerCfg[1].InputColorMode = DMA2D_INPUT_ARGB8888; |
elelthvd | 0:cffa136e7f8f | 193 | #endif |
elelthvd | 0:cffa136e7f8f | 194 | Dma2dHandle.LayerCfg[1].InputOffset = 0x0; |
elelthvd | 0:cffa136e7f8f | 195 | //Background Configuration |
elelthvd | 0:cffa136e7f8f | 196 | Dma2dHandle.LayerCfg[0].AlphaMode = DMA2D_REPLACE_ALPHA; |
elelthvd | 0:cffa136e7f8f | 197 | Dma2dHandle.LayerCfg[0].InputAlpha = 0xFF; |
elelthvd | 0:cffa136e7f8f | 198 | #if LV_COLOR_DEPTH == 16 |
elelthvd | 0:cffa136e7f8f | 199 | Dma2dHandle.LayerCfg[0].InputColorMode = DMA2D_INPUT_RGB565; |
elelthvd | 0:cffa136e7f8f | 200 | #elif LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32 |
elelthvd | 0:cffa136e7f8f | 201 | Dma2dHandle.LayerCfg[0].InputColorMode = DMA2D_INPUT_ARGB8888; |
elelthvd | 0:cffa136e7f8f | 202 | #endif |
elelthvd | 0:cffa136e7f8f | 203 | Dma2dHandle.LayerCfg[0].InputOffset = 0x0; |
elelthvd | 0:cffa136e7f8f | 204 | Dma2dHandle.Instance = DMA2D; |
elelthvd | 0:cffa136e7f8f | 205 | //DMA2D Initialization |
elelthvd | 0:cffa136e7f8f | 206 | if(HAL_DMA2D_Init(&Dma2dHandle) != HAL_OK){ |
elelthvd | 0:cffa136e7f8f | 207 | Error_Handler();// Initialization Error |
elelthvd | 0:cffa136e7f8f | 208 | } |
elelthvd | 0:cffa136e7f8f | 209 | HAL_DMA2D_ConfigLayer(&Dma2dHandle, 0); |
elelthvd | 0:cffa136e7f8f | 210 | HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1); |
elelthvd | 0:cffa136e7f8f | 211 | } |
elelthvd | 0:cffa136e7f8f | 212 | |
elelthvd | 0:cffa136e7f8f | 213 | static void gpu_blend(lv_disp_drv_t * disp_drv, lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa){ |
elelthvd | 0:cffa136e7f8f | 214 | /*Wait for the previous operation*/ |
elelthvd | 0:cffa136e7f8f | 215 | HAL_DMA2D_PollForTransfer(&Dma2dHandle, 100); |
elelthvd | 0:cffa136e7f8f | 216 | Dma2dHandle.Init.Mode = DMA2D_M2M_BLEND; |
elelthvd | 0:cffa136e7f8f | 217 | /* DMA2D Initialization */ |
elelthvd | 0:cffa136e7f8f | 218 | if(HAL_DMA2D_Init(&Dma2dHandle) != HAL_OK){ |
elelthvd | 0:cffa136e7f8f | 219 | /* Initialization Error */ |
elelthvd | 0:cffa136e7f8f | 220 | while(1); |
elelthvd | 0:cffa136e7f8f | 221 | } |
elelthvd | 0:cffa136e7f8f | 222 | Dma2dHandle.LayerCfg[1].InputAlpha = opa; |
elelthvd | 0:cffa136e7f8f | 223 | HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1); |
elelthvd | 0:cffa136e7f8f | 224 | HAL_DMA2D_BlendingStart(&Dma2dHandle, (uint32_t) src, (uint32_t) dest, (uint32_t)dest, length, 1); |
elelthvd | 0:cffa136e7f8f | 225 | } |
elelthvd | 0:cffa136e7f8f | 226 | |
elelthvd | 0:cffa136e7f8f | 227 | /* If your MCU has hardware accelerator (GPU) then you can use it to fill a memory with a color |
elelthvd | 0:cffa136e7f8f | 228 | * It can be used only in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/ |
elelthvd | 0:cffa136e7f8f | 229 | static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width, const lv_area_t * fill_area, lv_color_t color){ |
elelthvd | 0:cffa136e7f8f | 230 | /*Wait for the previous operation*/ |
elelthvd | 0:cffa136e7f8f | 231 | HAL_DMA2D_PollForTransfer(&Dma2dHandle, 100); |
elelthvd | 0:cffa136e7f8f | 232 | Dma2dHandle.Init.Mode = DMA2D_R2M; |
elelthvd | 0:cffa136e7f8f | 233 | /* DMA2D Initialization */ |
elelthvd | 0:cffa136e7f8f | 234 | if(HAL_DMA2D_Init(&Dma2dHandle) != HAL_OK){ |
elelthvd | 0:cffa136e7f8f | 235 | /* Initialization Error */ |
elelthvd | 0:cffa136e7f8f | 236 | while(1); |
elelthvd | 0:cffa136e7f8f | 237 | } |
elelthvd | 0:cffa136e7f8f | 238 | Dma2dHandle.LayerCfg[1].InputAlpha = 0xff; |
elelthvd | 0:cffa136e7f8f | 239 | HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1); |
elelthvd | 0:cffa136e7f8f | 240 | lv_color_t * dest_buf_ofs = dest_buf; |
elelthvd | 0:cffa136e7f8f | 241 | dest_buf_ofs += dest_width * fill_area->y1; |
elelthvd | 0:cffa136e7f8f | 242 | dest_buf_ofs += fill_area->x1; |
elelthvd | 0:cffa136e7f8f | 243 | lv_coord_t area_w = lv_area_get_width(fill_area); |
elelthvd | 0:cffa136e7f8f | 244 | uint32_t i; |
elelthvd | 0:cffa136e7f8f | 245 | for(i = fill_area->y1; i <= fill_area->y2; i++) { |
elelthvd | 0:cffa136e7f8f | 246 | /*Wait for the previous operation*/ |
elelthvd | 0:cffa136e7f8f | 247 | HAL_DMA2D_PollForTransfer(&Dma2dHandle, 100); |
elelthvd | 0:cffa136e7f8f | 248 | HAL_DMA2D_BlendingStart(&Dma2dHandle, (uint32_t) lv_color_to32(color), (uint32_t) dest_buf_ofs, (uint32_t)dest_buf_ofs, area_w, 1); |
elelthvd | 0:cffa136e7f8f | 249 | dest_buf_ofs += dest_width; |
elelthvd | 0:cffa136e7f8f | 250 | } |
elelthvd | 0:cffa136e7f8f | 251 | } |
elelthvd | 0:cffa136e7f8f | 252 | |
elelthvd | 0:cffa136e7f8f | 253 | static void Error_Handler(void){ |
elelthvd | 0:cffa136e7f8f | 254 | while(1){} |
elelthvd | 0:cffa136e7f8f | 255 | } |
elelthvd | 0:cffa136e7f8f | 256 | |
elelthvd | 0:cffa136e7f8f | 257 | static void DMA2D_TransferComplete(DMA2D_HandleTypeDef *hdma2d){ |
elelthvd | 0:cffa136e7f8f | 258 | |
elelthvd | 0:cffa136e7f8f | 259 | } |
elelthvd | 0:cffa136e7f8f | 260 | |
elelthvd | 0:cffa136e7f8f | 261 | static void DMA2D_TransferError(DMA2D_HandleTypeDef *hdma2d){ |
elelthvd | 0:cffa136e7f8f | 262 | |
elelthvd | 0:cffa136e7f8f | 263 | } |
elelthvd | 0:cffa136e7f8f | 264 | |
elelthvd | 0:cffa136e7f8f | 265 | #endif /*LV_USE_GPU*/ |
elelthvd | 0:cffa136e7f8f | 266 | |
elelthvd | 0:cffa136e7f8f | 267 | #else /* Enable this file at the top */ |
elelthvd | 0:cffa136e7f8f | 268 | |
elelthvd | 0:cffa136e7f8f | 269 | /* This dummy typedef exists purely to silence -Wpedantic. */ |
elelthvd | 0:cffa136e7f8f | 270 | typedef int keep_pedantic_happy; |
elelthvd | 0:cffa136e7f8f | 271 | #endif |
elelthvd | 0:cffa136e7f8f | 272 | |
elelthvd | 0:cffa136e7f8f | 273 |