comparison Discovery/Src/gfx_engine.c @ 871:f7318457df4d default

support for new screen ToDo: Brightness settings
author heinrichsweikamp
date Tue, 13 Aug 2024 13:24:54 +0200
parents b7e43b28bee1
children e373e90a48db
comparison
equal deleted inserted replaced
866:3a1c533f3840 871:f7318457df4d
181 static void GFX_Dma2d_TransferError(DMA2D_HandleTypeDef* Dma2dHandle); 181 static void GFX_Dma2d_TransferError(DMA2D_HandleTypeDef* Dma2dHandle);
182 static void GFX_clear_frame_dma2d(uint8_t frameId); 182 static void GFX_clear_frame_dma2d(uint8_t frameId);
183 183
184 static uint32_t GFX_doubleBufferOne(void); 184 static uint32_t GFX_doubleBufferOne(void);
185 static uint32_t GFX_doubleBufferTwo(void); 185 static uint32_t GFX_doubleBufferTwo(void);
186
187 static void GFX_LTDC_Init_display0(void);
188 static void GFX_LTDC_Init_display1(void);
186 189
187 190
188 /* Exported functions --------------------------------------------------------*/ 191 /* Exported functions --------------------------------------------------------*/
189 192
190 uint8_t GFX_logoStatus(void) 193 uint8_t GFX_logoStatus(void)
3321 return result; 3324 return result;
3322 } 3325 }
3323 3326
3324 void GFX_LTDC_Init(void) 3327 void GFX_LTDC_Init(void)
3325 { 3328 {
3326 /* 3329 if (hardwareDisplay == 1)
3327 HSYNC=10 (9+1) 3330 {
3328 HBP=10 (19-10+1) 3331 GFX_LTDC_Init_display1();
3329 ActiveW=480 (499-10-10+1) 3332 }
3330 HFP=8 (507-480-10-10+1) 3333 else
3331 3334 {
3332 VSYNC=2 (1+1) 3335 GFX_LTDC_Init_display0();
3333 VBP=2 (3-2+1) 3336 }
3334 ActiveH=800 (803-2-2+1) 3337 }
3335 VFP=2 (805-800-2-2+1) 3338
3336 */ 3339 void GFX_LTDC_Init_display0(void)
3337 3340 {
3338 /* Timing configuration */ 3341 /* Timing configuration */
3342
3343 #define ActiveH 800
3344 #define ActiveW 480
3345
3346 #define Hsync 10
3347 #define HFP 8
3348 #define HBP 10
3349
3350 #define Vsync 2
3351 #define VFP 2
3352 #define VBP 2
3353
3354
3339 /* Horizontal synchronization width = Hsync - 1 */ 3355 /* Horizontal synchronization width = Hsync - 1 */
3340 LtdcHandle.Init.HorizontalSync = 9; 3356 LtdcHandle.Init.HorizontalSync = Hsync - 1;
3341 /* Vertical synchronization height = Vsync - 1 */ 3357 /* Vertical synchronization height = Vsync - 1 */
3342 LtdcHandle.Init.VerticalSync = 1; 3358 LtdcHandle.Init.VerticalSync = Vsync -1;
3343 /* Accumulated horizontal back porch = Hsync + HBP - 1 */ 3359 /* Accumulated horizontal back porch = Hsync + HBP - 1 */
3344 LtdcHandle.Init.AccumulatedHBP = 19; 3360 LtdcHandle.Init.AccumulatedHBP = Hsync + HBP - 1;
3345 /* Accumulated vertical back porch = Vsync + VBP - 1 */ 3361 /* Accumulated vertical back porch = Vsync + VBP - 1 */
3346 LtdcHandle.Init.AccumulatedVBP = 3; 3362 LtdcHandle.Init.AccumulatedVBP = Vsync + VBP - 1;
3347 /* Accumulated active width = Hsync + HBP + Active Width - 1 */ 3363 /* Accumulated active width = Hsync + HBP + Active Width - 1 */
3348 LtdcHandle.Init.AccumulatedActiveW = 499;//500;//499; 3364 LtdcHandle.Init.AccumulatedActiveW = Hsync + HBP + ActiveW- 1;
3349 /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */ 3365 /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */
3350 LtdcHandle.Init.AccumulatedActiveH = 803; 3366 LtdcHandle.Init.AccumulatedActiveH = Vsync + VBP + ActiveH - 1;
3351 /* Total width = Hsync + HBP + Active Width + HFP - 1 */ 3367 /* Total width = Hsync + HBP + Active Width + HFP - 1 */
3352 LtdcHandle.Init.TotalWidth = 507;//508;//507; 3368 LtdcHandle.Init.TotalWidth = Hsync + HBP + ActiveW + HFP - 1;
3353 /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */ 3369 /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */
3354 LtdcHandle.Init.TotalHeigh = 805; 3370 LtdcHandle.Init.TotalHeigh = Vsync + VBP + ActiveH + VFP - 1;
3355 3371
3356 /* Configure R,G,B component values for LCD background color */ 3372 /* Configure R,G,B component values for LCD background color */
3357 LtdcHandle.Init.Backcolor.Red= 0; 3373 LtdcHandle.Init.Backcolor.Red= 0;
3358 LtdcHandle.Init.Backcolor.Blue= 0; 3374 LtdcHandle.Init.Backcolor.Blue= 0;
3359 LtdcHandle.Init.Backcolor.Green= 0; 3375 LtdcHandle.Init.Backcolor.Green= 0;
3362 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ 3378 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
3363 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ 3379 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */
3364 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */ 3380 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */
3365 /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */ 3381 /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */
3366 3382
3367 /* done in main.c SystemClockConfig 3383 /* done in base.c SystemClockConfig
3368 3384
3369 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; 3385 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
3370 PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; 3386 PeriphClkInitStruct.PLLSAI.PLLSAIN = 192;
3371 PeriphClkInitStruct.PLLSAI.PLLSAIR = 4; 3387 PeriphClkInitStruct.PLLSAI.PLLSAIR = 4;
3372 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8; 3388 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8;
3379 LtdcHandle.Init.PCPolarity = LTDC_PCPOLARITY_IIPC;//LTDC_PCPOLARITY_IPC; 3395 LtdcHandle.Init.PCPolarity = LTDC_PCPOLARITY_IIPC;//LTDC_PCPOLARITY_IPC;
3380 3396
3381 LtdcHandle.Instance = LTDC; 3397 LtdcHandle.Instance = LTDC;
3382 3398
3383 /* Configure the LTDC */ 3399 /* Configure the LTDC */
3384 if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // auch init der GPIO Pins 3400 if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // initialize GPIO Pins, too
3401 {
3402 /* Initialization Error */
3403 GFX_Error_Handler();
3404 }
3405 }
3406
3407
3408 void GFX_LTDC_Init_display1(void)
3409 {
3410 /* Timing configuration */
3411 #define ActiveH_d1 800
3412 #define ActiveW_d1 480
3413
3414 #define Hsync_d1 2
3415 #define HFP_d1 8
3416 #define HBP_d1 8
3417
3418 #define Vsync_d1 2
3419 #define VFP_d1 4 // make sure this value * VSYNC is also set in display.c for OLED_VFP_SET
3420 #define VBP_d1 4 // make sure this value * VSYNC is also set in display.c for OLED_VBP_SET
3421
3422 /* Horizontal synchronization width = Hsync - 1 */
3423 LtdcHandle.Init.HorizontalSync = Hsync_d1 - 1;
3424 /* Vertical synchronization height = Vsync - 1 */
3425 LtdcHandle.Init.VerticalSync = Vsync_d1 -1;
3426 /* Accumulated horizontal back porch = Hsync + HBP - 1 */
3427 LtdcHandle.Init.AccumulatedHBP = Hsync_d1 + HBP_d1 - 1;
3428 /* Accumulated vertical back porch = Vsync + VBP - 1 */
3429 LtdcHandle.Init.AccumulatedVBP = Vsync_d1 + VBP_d1 - 1;
3430 /* Accumulated active width = Hsync + HBP + Active Width - 1 */
3431 LtdcHandle.Init.AccumulatedActiveW = Hsync_d1 + HBP_d1 + ActiveW_d1 - 1;
3432 /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */
3433 LtdcHandle.Init.AccumulatedActiveH = Vsync_d1 + VBP_d1 + ActiveH_d1 - 1;
3434 /* Total width = Hsync + HBP + Active Width + HFP - 1 */
3435 LtdcHandle.Init.TotalWidth = Hsync_d1 + HBP_d1 + ActiveW_d1 + HFP_d1 - 1;
3436 /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */
3437 LtdcHandle.Init.TotalHeigh = Vsync_d1 + VBP_d1 + ActiveH_d1 + VFP_d1 - 1;
3438
3439 /* Configure R,G,B component values for LCD background color */
3440 LtdcHandle.Init.Backcolor.Red= 0;
3441 LtdcHandle.Init.Backcolor.Blue= 0;
3442 LtdcHandle.Init.Backcolor.Green= 0;
3443
3444 /* LCD clock configuration */
3445 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
3446 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */
3447 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */
3448 /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */
3449
3450 /* done in base.c SystemClockConfig
3451
3452 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
3453 PeriphClkInitStruct.PLLSAI.PLLSAIN = 192;
3454 PeriphClkInitStruct.PLLSAI.PLLSAIR = 4;
3455 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8;
3456 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
3457 */
3458 /* Polarity */
3459 LtdcHandle.Init.HSPolarity = LTDC_HSPOLARITY_AL;
3460 LtdcHandle.Init.VSPolarity = LTDC_VSPOLARITY_AL;
3461 LtdcHandle.Init.DEPolarity = LTDC_DEPOLARITY_AL;
3462 LtdcHandle.Init.PCPolarity = LTDC_PCPOLARITY_IIPC;//LTDC_PCPOLARITY_IPC;
3463
3464 LtdcHandle.Instance = LTDC;
3465
3466 /* Configure the LTDC */
3467 if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // initialize GPIO Pins, too
3385 { 3468 {
3386 /* Initialization Error */ 3469 /* Initialization Error */
3387 GFX_Error_Handler(); 3470 GFX_Error_Handler();
3388 } 3471 }
3389 } 3472 }