Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_F746NG
tft.c
00001 /** 00002 * @file tft.c 00003 * 00004 */ 00005 00006 /********************* 00007 * INCLUDES 00008 *********************/ 00009 #include "lv_conf.h" 00010 #include "lvgl/lvgl.h" 00011 #include <string.h> 00012 #include <stdlib.h> 00013 00014 #include "tft.h " 00015 #include "stm32f7xx.h" 00016 #include "stm32746g_discovery.h" 00017 #include "stm32746g_discovery_sdram.h" 00018 #include "stm32746g_discovery_ts.h" 00019 #include "../Components/rk043fn48h/rk043fn48h.h" 00020 00021 /********************* 00022 * DEFINES 00023 *********************/ 00024 00025 #if LV_COLOR_DEPTH != 16 && LV_COLOR_DEPTH != 24 && LV_COLOR_DEPTH != 32 00026 #error LV_COLOR_DEPTH must be 16, 24, or 32 00027 #endif 00028 00029 /** 00030 * @brief LCD status structure definition 00031 */ 00032 #define LCD_OK ((uint8_t)0x00) 00033 #define LCD_ERROR ((uint8_t)0x01) 00034 #define LCD_TIMEOUT ((uint8_t)0x02) 00035 00036 /** 00037 * @brief LCD special pins 00038 */ 00039 /* Display enable pin */ 00040 #define LCD_DISP_PIN GPIO_PIN_12 00041 #define LCD_DISP_GPIO_PORT GPIOI 00042 #define LCD_DISP_GPIO_CLK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE() 00043 #define LCD_DISP_GPIO_CLK_DISABLE() __HAL_RCC_GPIOI_CLK_DISABLE() 00044 00045 /* Backlight control pin */ 00046 #define LCD_BL_CTRL_PIN GPIO_PIN_3 00047 #define LCD_BL_CTRL_GPIO_PORT GPIOK 00048 #define LCD_BL_CTRL_GPIO_CLK_ENABLE() __HAL_RCC_GPIOK_CLK_ENABLE() 00049 #define LCD_BL_CTRL_GPIO_CLK_DISABLE() __HAL_RCC_GPIOK_CLK_DISABLE() 00050 00051 #define CPY_BUF_DMA_STREAM DMA2_Stream0 00052 #define CPY_BUF_DMA_CHANNEL DMA_CHANNEL_0 00053 #define CPY_BUF_DMA_STREAM_IRQ DMA2_Stream0_IRQn 00054 #define CPY_BUF_DMA_STREAM_IRQHANDLER DMA2_Stream0_IRQHandler 00055 00056 /********************** 00057 * TYPEDEFS 00058 **********************/ 00059 00060 /********************** 00061 * STATIC PROTOTYPES 00062 **********************/ 00063 00064 /*These 3 functions are needed by LittlevGL*/ 00065 static void ex_disp_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t * color_p); 00066 static void ex_disp_clean_dcache(lv_disp_drv_t *drv); 00067 00068 static uint8_t LCD_Init(void); 00069 static void LCD_LayerRgb565Init(uint32_t FB_Address); 00070 static void LCD_DisplayOn(void); 00071 00072 static void DMA_Config(void); 00073 static void DMA_TransferComplete(DMA_HandleTypeDef *han); 00074 static void DMA_TransferError(DMA_HandleTypeDef *han); 00075 00076 /********************** 00077 * STATIC VARIABLES 00078 **********************/ 00079 static LTDC_HandleTypeDef hLtdcHandler; 00080 static lv_disp_drv_t disp_drv; 00081 00082 #if LV_COLOR_DEPTH == 16 00083 typedef uint16_t uintpixel_t; 00084 #elif LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32 00085 typedef uint32_t uintpixel_t; 00086 #endif 00087 00088 /* You can try to change buffer to internal ram by uncommenting line below and commenting 00089 * SDRAM one. */ 00090 //static uintpixel_t my_fb[TFT_HOR_RES * TFT_VER_RES]; 00091 00092 static __IO uintpixel_t * my_fb = (__IO uintpixel_t*) (0x60000000); 00093 00094 static DMA_HandleTypeDef DmaHandle; 00095 static int32_t x1_flush; 00096 static int32_t y1_flush; 00097 static int32_t x2_flush; 00098 static int32_t y2_fill; 00099 static int32_t y_fill_act; 00100 static const lv_color_t * buf_to_flush; 00101 00102 static lv_disp_t *our_disp = NULL; 00103 /********************** 00104 * MACROS 00105 **********************/ 00106 00107 /** 00108 * Initialize your display here 00109 */ 00110 00111 void tft_init(void) 00112 { 00113 /* There is only one display on STM32 */ 00114 if(our_disp != NULL) 00115 abort(); 00116 /* LCD Initialization */ 00117 LCD_Init(); 00118 00119 /* LCD Initialization */ 00120 LCD_LayerRgb565Init((uint32_t)my_fb); 00121 00122 /* Enable the LCD */ 00123 LCD_DisplayOn(); 00124 00125 DMA_Config(); 00126 00127 /*----------------------------- 00128 * Create a buffer for drawing 00129 *----------------------------*/ 00130 00131 /* LittlevGL requires a buffer where it draws the objects. The buffer's has to be greater than 1 display row*/ 00132 00133 static lv_disp_draw_buf_t disp_buf_1; 00134 static lv_color_t buf1_1[TFT_HOR_RES * 68]; 00135 static lv_color_t buf1_2[TFT_HOR_RES * 68]; 00136 lv_disp_draw_buf_init(&disp_buf_1, buf1_1, buf1_2, TFT_HOR_RES * 68); /*Initialize the display buffer*/ 00137 00138 00139 /*----------------------------------- 00140 * Register the display in LittlevGL 00141 *----------------------------------*/ 00142 00143 lv_disp_drv_init(&disp_drv); /*Basic initialization*/ 00144 00145 /*Set up the functions to access to your display*/ 00146 00147 /*Set the resolution of the display*/ 00148 disp_drv.hor_res = 480; 00149 disp_drv.ver_res = 272; 00150 00151 /*Used to copy the buffer's content to the display*/ 00152 disp_drv.flush_cb = ex_disp_flush; 00153 disp_drv.clean_dcache_cb = ex_disp_clean_dcache; 00154 00155 /*Set a display buffer*/ 00156 disp_drv.draw_buf = &disp_buf_1; 00157 00158 00159 /*Finally register the driver*/ 00160 our_disp = lv_disp_drv_register(&disp_drv); 00161 } 00162 00163 /********************** 00164 * STATIC FUNCTIONS 00165 **********************/ 00166 00167 /* Flush the content of the internal buffer the specific area on the display 00168 * You can use DMA or any hardware acceleration to do this operation in the background but 00169 * 'lv_flush_ready()' has to be called when finished 00170 * This function is required only when LV_VDB_SIZE != 0 in lv_conf.h*/ 00171 static void ex_disp_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t * color_p) 00172 { 00173 int32_t x1 = area->x1; 00174 int32_t x2 = area->x2; 00175 int32_t y1 = area->y1; 00176 int32_t y2 = area->y2; 00177 /*Return if the area is out the screen*/ 00178 00179 if(x2 < 0) return; 00180 if(y2 < 0) return; 00181 if(x1 > TFT_HOR_RES - 1) return; 00182 if(y1 > TFT_VER_RES - 1) return; 00183 00184 /*Truncate the area to the screen*/ 00185 int32_t act_x1 = x1 < 0 ? 0 : x1; 00186 int32_t act_y1 = y1 < 0 ? 0 : y1; 00187 int32_t act_x2 = x2 > TFT_HOR_RES - 1 ? TFT_HOR_RES - 1 : x2; 00188 int32_t act_y2 = y2 > TFT_VER_RES - 1 ? TFT_VER_RES - 1 : y2; 00189 00190 x1_flush = act_x1; 00191 y1_flush = act_y1; 00192 x2_flush = act_x2; 00193 y2_fill = act_y2; 00194 y_fill_act = act_y1; 00195 buf_to_flush = color_p; 00196 00197 SCB_CleanInvalidateDCache(); 00198 SCB_InvalidateICache(); 00199 /*##-7- Start the DMA transfer using the interrupt mode #*/ 00200 /* Configure the source, destination and buffer size DMA fields and Start DMA Stream transfer */ 00201 /* Enable All the DMA interrupts */ 00202 HAL_StatusTypeDef err; 00203 uint32_t length = (x2_flush - x1_flush + 1); 00204 #if LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32 00205 length *= 2; /* STM32 DMA uses 16-bit chunks so multiply by 2 for 32-bit color */ 00206 #endif 00207 err = HAL_DMA_Start_IT(&DmaHandle,(uint32_t)buf_to_flush, (uint32_t)&my_fb[y_fill_act * TFT_HOR_RES + x1_flush], 00208 length); 00209 if(err != HAL_OK) 00210 { 00211 while(1); /*Halt on error*/ 00212 } 00213 } 00214 00215 static void ex_disp_clean_dcache(lv_disp_drv_t *drv) 00216 { 00217 SCB_CleanInvalidateDCache(); 00218 } 00219 00220 00221 /** 00222 * @brief Configure LCD pins, and peripheral clocks. 00223 */ 00224 static void LCD_MspInit(void) 00225 { 00226 GPIO_InitTypeDef gpio_init_structure; 00227 00228 /* Enable the LTDC and DMA2D clocks */ 00229 __HAL_RCC_LTDC_CLK_ENABLE(); 00230 __HAL_RCC_DMA2D_CLK_ENABLE(); 00231 /* Enable GPIOs clock */ 00232 __HAL_RCC_GPIOE_CLK_ENABLE(); 00233 __HAL_RCC_GPIOG_CLK_ENABLE(); 00234 __HAL_RCC_GPIOI_CLK_ENABLE(); 00235 __HAL_RCC_GPIOJ_CLK_ENABLE(); 00236 __HAL_RCC_GPIOK_CLK_ENABLE(); 00237 LCD_DISP_GPIO_CLK_ENABLE(); 00238 LCD_BL_CTRL_GPIO_CLK_ENABLE(); 00239 00240 /*** LTDC Pins configuration ***/ 00241 /* GPIOE configuration */ 00242 gpio_init_structure.Pin = GPIO_PIN_4; 00243 gpio_init_structure.Mode = GPIO_MODE_AF_PP; 00244 gpio_init_structure.Pull = GPIO_NOPULL; 00245 gpio_init_structure.Speed = GPIO_SPEED_FAST; 00246 gpio_init_structure.Alternate = GPIO_AF14_LTDC; 00247 HAL_GPIO_Init(GPIOE, &gpio_init_structure); 00248 00249 /* GPIOG configuration */ 00250 gpio_init_structure.Pin = GPIO_PIN_12; 00251 gpio_init_structure.Mode = GPIO_MODE_AF_PP; 00252 gpio_init_structure.Alternate = GPIO_AF9_LTDC; 00253 HAL_GPIO_Init(GPIOG, &gpio_init_structure); 00254 00255 /* GPIOI LTDC alternate configuration */ 00256 gpio_init_structure.Pin = GPIO_PIN_9 | GPIO_PIN_10 | \ 00257 GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; 00258 gpio_init_structure.Mode = GPIO_MODE_AF_PP; 00259 gpio_init_structure.Alternate = GPIO_AF14_LTDC; 00260 HAL_GPIO_Init(GPIOI, &gpio_init_structure); 00261 00262 /* GPIOJ configuration */ 00263 gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | \ 00264 GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | \ 00265 GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | \ 00266 GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; 00267 gpio_init_structure.Mode = GPIO_MODE_AF_PP; 00268 gpio_init_structure.Alternate = GPIO_AF14_LTDC; 00269 HAL_GPIO_Init(GPIOJ, &gpio_init_structure); 00270 00271 /* GPIOK configuration */ 00272 gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_4 | \ 00273 GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7; 00274 gpio_init_structure.Mode = GPIO_MODE_AF_PP; 00275 gpio_init_structure.Alternate = GPIO_AF14_LTDC; 00276 HAL_GPIO_Init(GPIOK, &gpio_init_structure); 00277 00278 /* LCD_DISP GPIO configuration */ 00279 gpio_init_structure.Pin = LCD_DISP_PIN; /* LCD_DISP pin has to be manually controlled */ 00280 gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; 00281 HAL_GPIO_Init(LCD_DISP_GPIO_PORT, &gpio_init_structure); 00282 00283 /* LCD_BL_CTRL GPIO configuration */ 00284 gpio_init_structure.Pin = LCD_BL_CTRL_PIN; /* LCD_BL_CTRL pin has to be manually controlled */ 00285 gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; 00286 HAL_GPIO_Init(LCD_BL_CTRL_GPIO_PORT, &gpio_init_structure); 00287 } 00288 00289 /** 00290 * @brief Configure LTDC PLL. 00291 */ 00292 static void LCD_ClockConfig(void) 00293 { 00294 static RCC_PeriphCLKInitTypeDef periph_clk_init_struct; 00295 00296 /* RK043FN48H LCD clock configuration */ 00297 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ 00298 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ 00299 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/5 = 38.4 Mhz */ 00300 /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_4 = 38.4/4 = 9.6Mhz */ 00301 periph_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; 00302 periph_clk_init_struct.PLLSAI.PLLSAIN = 192; 00303 periph_clk_init_struct.PLLSAI.PLLSAIR = RK043FN48H_FREQUENCY_DIVIDER; 00304 periph_clk_init_struct.PLLSAIDivR = RCC_PLLSAIDIVR_4; 00305 HAL_RCCEx_PeriphCLKConfig(&periph_clk_init_struct); 00306 } 00307 00308 /** 00309 * @brief Initializes the LCD. 00310 * @retval LCD state 00311 */ 00312 static uint8_t LCD_Init(void) 00313 { 00314 /* Select the used LCD */ 00315 00316 /* The RK043FN48H LCD 480x272 is selected */ 00317 /* Timing Configuration */ 00318 hLtdcHandler.Init.HorizontalSync = (RK043FN48H_HSYNC - 1); 00319 hLtdcHandler.Init.VerticalSync = (RK043FN48H_VSYNC - 1); 00320 hLtdcHandler.Init.AccumulatedHBP = (RK043FN48H_HSYNC + RK043FN48H_HBP - 1); 00321 hLtdcHandler.Init.AccumulatedVBP = (RK043FN48H_VSYNC + RK043FN48H_VBP - 1); 00322 hLtdcHandler.Init.AccumulatedActiveH = (RK043FN48H_HEIGHT + RK043FN48H_VSYNC + RK043FN48H_VBP - 1); 00323 hLtdcHandler.Init.AccumulatedActiveW = (RK043FN48H_WIDTH + RK043FN48H_HSYNC + RK043FN48H_HBP - 1); 00324 hLtdcHandler.Init.TotalHeigh = (RK043FN48H_HEIGHT + RK043FN48H_VSYNC + RK043FN48H_VBP + RK043FN48H_VFP - 1); 00325 hLtdcHandler.Init.TotalWidth = (RK043FN48H_WIDTH + RK043FN48H_HSYNC + RK043FN48H_HBP + RK043FN48H_HFP - 1); 00326 00327 /* LCD clock configuration */ 00328 LCD_ClockConfig(); 00329 00330 /* Initialize the LCD pixel width and pixel height */ 00331 hLtdcHandler.LayerCfg->ImageWidth = RK043FN48H_WIDTH; 00332 hLtdcHandler.LayerCfg->ImageHeight = RK043FN48H_HEIGHT; 00333 00334 /* Background value */ 00335 hLtdcHandler.Init.Backcolor.Blue = 0; 00336 hLtdcHandler.Init.Backcolor.Green = 0; 00337 hLtdcHandler.Init.Backcolor.Red = 0; 00338 00339 /* Polarity */ 00340 hLtdcHandler.Init.HSPolarity = LTDC_HSPOLARITY_AL; 00341 hLtdcHandler.Init.VSPolarity = LTDC_VSPOLARITY_AL; 00342 hLtdcHandler.Init.DEPolarity = LTDC_DEPOLARITY_AL; 00343 hLtdcHandler.Init.PCPolarity = LTDC_PCPOLARITY_IPC; 00344 hLtdcHandler.Instance = LTDC; 00345 00346 if(HAL_LTDC_GetState(&hLtdcHandler) == HAL_LTDC_STATE_RESET) 00347 { 00348 /* Initialize the LCD Msp: this __weak function can be rewritten by the application */ 00349 LCD_MspInit(); 00350 } 00351 HAL_LTDC_Init(&hLtdcHandler); 00352 00353 /* Assert display enable LCD_DISP pin */ 00354 HAL_GPIO_WritePin(LCD_DISP_GPIO_PORT, LCD_DISP_PIN, GPIO_PIN_SET); 00355 00356 /* Assert backlight LCD_BL_CTRL pin */ 00357 HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_PORT, LCD_BL_CTRL_PIN, GPIO_PIN_SET); 00358 00359 BSP_SDRAM_Init(); 00360 HAL_EnableFMCMemorySwapping(); 00361 00362 uint32_t i; 00363 for(i = 0; i < (TFT_HOR_RES * TFT_VER_RES) ; i++) 00364 { 00365 my_fb[i] = 0; 00366 } 00367 00368 return LCD_OK; 00369 } 00370 00371 static void LCD_LayerRgb565Init(uint32_t FB_Address) 00372 { 00373 LTDC_LayerCfgTypeDef layer_cfg; 00374 00375 /* Layer Init */ 00376 layer_cfg.WindowX0 = 0; 00377 layer_cfg.WindowX1 = TFT_HOR_RES; 00378 layer_cfg.WindowY0 = 0; 00379 layer_cfg.WindowY1 = TFT_VER_RES; 00380 00381 #if LV_COLOR_DEPTH == 16 00382 layer_cfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565; 00383 #elif LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32 00384 layer_cfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; 00385 #else 00386 #error Unsupported color depth (see tft.c) 00387 #endif 00388 layer_cfg.FBStartAdress = FB_Address; 00389 layer_cfg.Alpha = 255; 00390 layer_cfg.Alpha0 = 0; 00391 layer_cfg.Backcolor.Blue = 0; 00392 layer_cfg.Backcolor.Green = 0; 00393 layer_cfg.Backcolor.Red = 0; 00394 layer_cfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; 00395 layer_cfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; 00396 layer_cfg.ImageWidth = TFT_HOR_RES; 00397 layer_cfg.ImageHeight = TFT_VER_RES; 00398 00399 HAL_LTDC_ConfigLayer(&hLtdcHandler, &layer_cfg, 0); 00400 } 00401 00402 static void LCD_DisplayOn(void) 00403 { 00404 /* Display On */ 00405 __HAL_LTDC_ENABLE(&hLtdcHandler); 00406 HAL_GPIO_WritePin(LCD_DISP_GPIO_PORT, LCD_DISP_PIN, GPIO_PIN_SET); /* Assert LCD_DISP pin */ 00407 HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_PORT, LCD_BL_CTRL_PIN, GPIO_PIN_SET); /* Assert LCD_BL_CTRL pin */ 00408 } 00409 00410 static void DMA_Config(void) 00411 { 00412 /*## -1- Enable DMA2 clock #################################################*/ 00413 __HAL_RCC_DMA2_CLK_ENABLE(); 00414 00415 /*##-2- Select the DMA functional Parameters ###############################*/ 00416 DmaHandle.Init.Channel = CPY_BUF_DMA_CHANNEL; /* DMA_CHANNEL_0 */ 00417 DmaHandle.Init.Direction = DMA_MEMORY_TO_MEMORY; /* M2M transfer mode */ 00418 DmaHandle.Init.PeriphInc = DMA_PINC_ENABLE; /* Peripheral increment mode Enable */ 00419 DmaHandle.Init.MemInc = DMA_MINC_ENABLE; /* Memory increment mode Enable */ 00420 DmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; /* Peripheral data alignment : 16bit */ 00421 DmaHandle.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; /* memory data alignment : 16bit */ 00422 DmaHandle.Init.Mode = DMA_NORMAL; /* Normal DMA mode */ 00423 DmaHandle.Init.Priority = DMA_PRIORITY_HIGH; /* priority level : high */ 00424 DmaHandle.Init.FIFOMode = DMA_FIFOMODE_ENABLE; /* FIFO mode enabled */ 00425 DmaHandle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_1QUARTERFULL; /* FIFO threshold: 1/4 full */ 00426 DmaHandle.Init.MemBurst = DMA_MBURST_SINGLE; /* Memory burst */ 00427 DmaHandle.Init.PeriphBurst = DMA_PBURST_SINGLE; /* Peripheral burst */ 00428 00429 /*##-3- Select the DMA instance to be used for the transfer : DMA2_Stream0 #*/ 00430 DmaHandle.Instance = CPY_BUF_DMA_STREAM; 00431 00432 /*##-4- Initialize the DMA stream ##########################################*/ 00433 if(HAL_DMA_Init(&DmaHandle) != HAL_OK) 00434 { 00435 while(1) 00436 { 00437 } 00438 } 00439 00440 /*##-5- Select Callbacks functions called after Transfer complete and Transfer error */ 00441 HAL_DMA_RegisterCallback(&DmaHandle, HAL_DMA_XFER_CPLT_CB_ID, DMA_TransferComplete); 00442 HAL_DMA_RegisterCallback(&DmaHandle, HAL_DMA_XFER_ERROR_CB_ID, DMA_TransferError); 00443 00444 /*##-6- Configure NVIC for DMA transfer complete/error interrupts ##########*/ 00445 HAL_NVIC_SetPriority(CPY_BUF_DMA_STREAM_IRQ, 0, 0); 00446 HAL_NVIC_EnableIRQ(CPY_BUF_DMA_STREAM_IRQ); 00447 } 00448 00449 /** 00450 * @brief DMA conversion complete callback 00451 * @note This function is executed when the transfer complete interrupt 00452 * is generated 00453 * @retval None 00454 */ 00455 static void DMA_TransferComplete(DMA_HandleTypeDef *han) 00456 { 00457 y_fill_act ++; 00458 00459 if(y_fill_act > y2_fill) { 00460 SCB_CleanInvalidateDCache(); 00461 SCB_InvalidateICache(); 00462 lv_disp_flush_ready(&disp_drv); 00463 } else { 00464 uint32_t length = (x2_flush - x1_flush + 1); 00465 buf_to_flush += x2_flush - x1_flush + 1; 00466 /*##-7- Start the DMA transfer using the interrupt mode ####################*/ 00467 /* Configure the source, destination and buffer size DMA fields and Start DMA Stream transfer */ 00468 /* Enable All the DMA interrupts */ 00469 #if LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32 00470 length *= 2; /* STM32 DMA uses 16-bit chunks so multiply by 2 for 32-bit color */ 00471 #endif 00472 if(HAL_DMA_Start_IT(han,(uint32_t)buf_to_flush, (uint32_t)&my_fb[y_fill_act * TFT_HOR_RES + x1_flush], 00473 length) != HAL_OK) 00474 { 00475 while(1); /*Halt on error*/ 00476 } 00477 } 00478 } 00479 00480 /** 00481 * @brief DMA conversion error callback 00482 * @note This function is executed when the transfer error interrupt 00483 * is generated during DMA transfer 00484 * @retval None 00485 */ 00486 static void DMA_TransferError(DMA_HandleTypeDef *han) 00487 { 00488 00489 } 00490 00491 /** 00492 * @brief This function handles DMA Stream interrupt request. 00493 * @param None 00494 * @retval None 00495 */ 00496 void CPY_BUF_DMA_STREAM_IRQHANDLER(void) 00497 { 00498 /* Check the interrupt and clear flag */ 00499 HAL_DMA_IRQHandler(&DmaHandle); 00500 }
Generated on Sat Feb 4 2023 21:01:57 by
1.7.2