BSP hacked to work with lvgl
Revision 4:d8e068ff1ba1, committed 2019-07-19
- Comitter:
- stepansnigirev
- Date:
- Fri Jul 19 15:34:05 2019 +0000
- Parent:
- 3:3cdfcc4f7c9d
- Commit message:
- BSP hacked to work with lvgl
Changed in this revision
diff -r 3cdfcc4f7c9d -r d8e068ff1ba1 Drivers/BSP/STM32469I-Discovery/stm32469i_discovery_lcd.c --- a/Drivers/BSP/STM32469I-Discovery/stm32469i_discovery_lcd.c Wed Feb 28 13:17:15 2018 +0100 +++ b/Drivers/BSP/STM32469I-Discovery/stm32469i_discovery_lcd.c Fri Jul 19 15:34:05 2019 +0000 @@ -184,7 +184,7 @@ } /** - * @brief Initializes the DSI LCD. + * @brief Initializes the DSI LCD. * The ititialization is done as below: * - DSI PLL ititialization * - DSI ititialization @@ -198,7 +198,7 @@ DSI_PHY_TimerTypeDef PhyTimings; static RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; uint32_t LcdClock = 27429; /*!< LcdClk = 27429 kHz */ - + uint32_t laneByteClk_kHz = 0; uint32_t VSA; /*!< Vertical start active time in units of lines */ uint32_t VBP; /*!< Vertical Back Porch time in units of lines */ @@ -208,12 +208,12 @@ uint32_t HBP; /*!< Horizontal Back Porch time in units of lcdClk */ uint32_t HFP; /*!< Horizontal Front Porch time in units of lcdClk */ uint32_t HACT; /*!< Horizontal Active time in units of lcdClk = imageSize X in pixels to display */ - - + + /* Toggle Hardware Reset of the DSI LCD using * its XRES signal (active low) */ BSP_LCD_Reset(); - + /* Call first MSP Initialize only in case of first initialization * This will set IP blocks LTDC, DSI and DMA2D * - out of reset @@ -221,51 +221,51 @@ * - NVIC IRQ related to IP blocks enabled */ BSP_LCD_MspInit(); - -/*************************DSI Initialization***********************************/ - + +/*************************DSI Initialization***********************************/ + /* Base address of DSI Host/Wrapper registers to be set before calling De-Init */ hdsi_eval.Instance = DSI; - + HAL_DSI_DeInit(&(hdsi_eval)); - + #if !defined(USE_STM32469I_DISCO_REVA) dsiPllInit.PLLNDIV = 125; dsiPllInit.PLLIDF = DSI_PLL_IN_DIV2; dsiPllInit.PLLODF = DSI_PLL_OUT_DIV1; -#else +#else dsiPllInit.PLLNDIV = 100; dsiPllInit.PLLIDF = DSI_PLL_IN_DIV5; dsiPllInit.PLLODF = DSI_PLL_OUT_DIV1; #endif laneByteClk_kHz = 62500; /* 500 MHz / 8 = 62.5 MHz = 62500 kHz */ - + /* Set number of Lanes */ hdsi_eval.Init.NumberOfLanes = DSI_TWO_DATA_LANES; - + /* TXEscapeCkdiv = f(LaneByteClk)/15.62 = 4 */ - hdsi_eval.Init.TXEscapeCkdiv = laneByteClk_kHz/15620; - + hdsi_eval.Init.TXEscapeCkdiv = laneByteClk_kHz/15620; + HAL_DSI_Init(&(hdsi_eval), &(dsiPllInit)); - + /* Timing parameters for all Video modes * Set Timing parameters of LTDC depending on its chosen orientation */ if(orientation == LCD_ORIENTATION_PORTRAIT) { lcd_x_size = OTM8009A_480X800_WIDTH; /* 480 */ - lcd_y_size = OTM8009A_480X800_HEIGHT; /* 800 */ + lcd_y_size = OTM8009A_480X800_HEIGHT; /* 800 */ } else { /* lcd_orientation == LCD_ORIENTATION_LANDSCAPE */ lcd_x_size = OTM8009A_800X480_WIDTH; /* 800 */ - lcd_y_size = OTM8009A_800X480_HEIGHT; /* 480 */ + lcd_y_size = OTM8009A_800X480_HEIGHT; /* 480 */ } - + HACT = lcd_x_size; VACT = lcd_y_size; - + /* The following values are same for portrait and landscape orientations */ VSA = OTM8009A_480X800_VSYNC; VBP = OTM8009A_480X800_VBP; @@ -273,17 +273,17 @@ HSA = OTM8009A_480X800_HSYNC; HBP = OTM8009A_480X800_HBP; HFP = OTM8009A_480X800_HFP; - - + + hdsivideo_handle.VirtualChannelID = LCD_OTM8009A_ID; hdsivideo_handle.ColorCoding = LCD_DSI_PIXEL_DATA_FMT_RBG888; hdsivideo_handle.VSPolarity = DSI_VSYNC_ACTIVE_HIGH; hdsivideo_handle.HSPolarity = DSI_HSYNC_ACTIVE_HIGH; - hdsivideo_handle.DEPolarity = DSI_DATA_ENABLE_ACTIVE_HIGH; + hdsivideo_handle.DEPolarity = DSI_DATA_ENABLE_ACTIVE_HIGH; hdsivideo_handle.Mode = DSI_VID_MODE_BURST; /* Mode Video burst ie : one LgP per line */ hdsivideo_handle.NullPacketSize = 0xFFF; hdsivideo_handle.NumberOfChunks = 0; - hdsivideo_handle.PacketSize = HACT; /* Value depending on display orientation choice portrait/landscape */ + hdsivideo_handle.PacketSize = HACT; /* Value depending on display orientation choice portrait/landscape */ hdsivideo_handle.HorizontalSyncActive = (HSA * laneByteClk_kHz) / LcdClock; hdsivideo_handle.HorizontalBackPorch = (HBP * laneByteClk_kHz) / LcdClock; hdsivideo_handle.HorizontalLine = ((HACT + HSA + HBP + HFP) * laneByteClk_kHz) / LcdClock; /* Value depending on display orientation choice portrait/landscape */ @@ -291,19 +291,19 @@ hdsivideo_handle.VerticalBackPorch = VBP; hdsivideo_handle.VerticalFrontPorch = VFP; hdsivideo_handle.VerticalActive = VACT; /* Value depending on display orientation choice portrait/landscape */ - + /* Enable or disable sending LP command while streaming is active in video mode */ hdsivideo_handle.LPCommandEnable = DSI_LP_COMMAND_ENABLE; /* Enable sending commands in mode LP (Low Power) */ - + /* Largest packet size possible to transmit in LP mode in VSA, VBP, VFP regions */ /* Only useful when sending LP packets is allowed while streaming is active in video mode */ hdsivideo_handle.LPLargestPacketSize = 16; - + /* Largest packet size possible to transmit in LP mode in HFP region during VACT period */ /* Only useful when sending LP packets is allowed while streaming is active in video mode */ hdsivideo_handle.LPVACTLargestPacketSize = 0; - - + + /* Specify for each region of the video frame, if the transmission of command in LP mode is allowed in this region */ /* while streaming is active in video mode */ hdsivideo_handle.LPHorizontalFrontPorchEnable = DSI_LP_HFP_ENABLE; /* Allow sending LP commands during HFP period */ @@ -312,7 +312,7 @@ hdsivideo_handle.LPVerticalFrontPorchEnable = DSI_LP_VFP_ENABLE; /* Allow sending LP commands during VFP period */ hdsivideo_handle.LPVerticalBackPorchEnable = DSI_LP_VBP_ENABLE; /* Allow sending LP commands during VBP period */ hdsivideo_handle.LPVerticalSyncActiveEnable = DSI_LP_VSYNC_ENABLE; /* Allow sending LP commands during VSync = VSA period */ - + /* Configure DSI Video mode timings with settings set above */ HAL_DSI_ConfigVideoMode(&(hdsi_eval), &(hdsivideo_handle)); @@ -325,22 +325,22 @@ PhyTimings.StopWaitTime = 10; HAL_DSI_ConfigPhyTimer(&hdsi_eval, &PhyTimings); -/*************************End DSI Initialization*******************************/ - - -/************************LTDC Initialization***********************************/ - - /* Timing Configuration */ +/*************************End DSI Initialization*******************************/ + + +/************************LTDC Initialization***********************************/ + + /* Timing Configuration */ hltdc_eval.Init.HorizontalSync = (HSA - 1); hltdc_eval.Init.AccumulatedHBP = (HSA + HBP - 1); hltdc_eval.Init.AccumulatedActiveW = (lcd_x_size + HSA + HBP - 1); hltdc_eval.Init.TotalWidth = (lcd_x_size + HSA + HBP + HFP - 1); - + /* Initialize the LCD pixel width and pixel height */ hltdc_eval.LayerCfg->ImageWidth = lcd_x_size; - hltdc_eval.LayerCfg->ImageHeight = lcd_y_size; - - + hltdc_eval.LayerCfg->ImageHeight = lcd_y_size; + + /* LCD clock configuration */ /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 384 Mhz */ @@ -350,45 +350,45 @@ PeriphClkInitStruct.PLLSAI.PLLSAIN = 384; PeriphClkInitStruct.PLLSAI.PLLSAIR = 7; PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2; - HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); - + HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); + /* Background value */ hltdc_eval.Init.Backcolor.Blue = 0; hltdc_eval.Init.Backcolor.Green = 0; hltdc_eval.Init.Backcolor.Red = 0; hltdc_eval.Init.PCPolarity = LTDC_PCPOLARITY_IPC; hltdc_eval.Instance = LTDC; - + /* Get LTDC Configuration from DSI Configuration */ HAL_LTDCEx_StructInitFromVideoConfig(&(hltdc_eval), &(hdsivideo_handle)); - - /* Initialize the LTDC */ + + /* Initialize the LTDC */ HAL_LTDC_Init(&hltdc_eval); /* Enable the DSI host and wrapper after the LTDC initialization To avoid any synchronization issue, the DSI shall be started after enabling the LTDC */ HAL_DSI_Start(&(hdsi_eval)); - + #if !defined(DATA_IN_ExtSDRAM) /* Initialize the SDRAM */ BSP_SDRAM_Init(); #endif /* DATA_IN_ExtSDRAM */ - + /* Initialize the font */ BSP_LCD_SetFont(&LCD_DEFAULT_FONT); - + /************************End LTDC Initialization*******************************/ - - -/***********************OTM8009A Initialization********************************/ - + + +/***********************OTM8009A Initialization********************************/ + /* Initialize the OTM8009A LCD Display IC Driver (KoD LCD IC Driver) * depending on configuration set in 'hdsivideo_handle'. */ OTM8009A_Init(OTM8009A_FORMAT_RGB888, orientation); - -/***********************End OTM8009A Initialization****************************/ - + +/***********************End OTM8009A Initialization****************************/ + return LCD_OK; } @@ -419,15 +419,15 @@ //HAL_Delay(20); /* wait 20 ms */ wait_ms(20); - + /* Desactivate XRES */ HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_SET); - + /* Wait for 10ms after releasing XRES before sending commands */ //HAL_Delay(10); - wait_ms(10); + wait_ms(10); #else - + #endif /* USE_STM32469I_DISCO_REVA == 0 */ } @@ -481,8 +481,8 @@ Layercfg.WindowX0 = 0; Layercfg.WindowX1 = BSP_LCD_GetXSize(); Layercfg.WindowY0 = 0; - Layercfg.WindowY1 = BSP_LCD_GetYSize(); - Layercfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; + Layercfg.WindowY1 = BSP_LCD_GetYSize(); + Layercfg.PixelFormat = OTM8009A_FORMAT_RBG565; Layercfg.FBStartAdress = FB_Address; Layercfg.Alpha = 255; Layercfg.Alpha0 = 0; @@ -493,9 +493,9 @@ Layercfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; Layercfg.ImageWidth = BSP_LCD_GetXSize(); Layercfg.ImageHeight = BSP_LCD_GetYSize(); - - HAL_LTDC_ConfigLayer(&hltdc_eval, &Layercfg, LayerIndex); - + + HAL_LTDC_ConfigLayer(&hltdc_eval, &Layercfg, LayerIndex); + DrawProp[LayerIndex].BackColor = LCD_COLOR_WHITE; DrawProp[LayerIndex].pFont = &Font24; DrawProp[LayerIndex].TextColor = LCD_COLOR_BLACK; @@ -530,7 +530,7 @@ __HAL_LTDC_LAYER_DISABLE(&(hltdc_eval), LayerIndex); } __HAL_LTDC_RELOAD_IMMEDIATE_CONFIG(&(hltdc_eval)); - + } /** @@ -541,9 +541,9 @@ */ void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency) { - + HAL_LTDC_SetAlpha(&(hltdc_eval), Transparency, LayerIndex); - + } /** @@ -553,9 +553,9 @@ */ void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address) { - + HAL_LTDC_SetAddress(&(hltdc_eval), Address, LayerIndex); - + } /** @@ -570,10 +570,10 @@ { /* Reconfigure the layer size */ HAL_LTDC_SetWindowSize(&(hltdc_eval), Width, Height, LayerIndex); - + /* Reconfigure the layer position */ HAL_LTDC_SetWindowPosition(&(hltdc_eval), Xpos, Ypos, LayerIndex); - + } /** @@ -1271,7 +1271,7 @@ DSI_DCS_SHORT_PKT_WRITE_P1, OTM8009A_CMD_DISPON, 0x00); - + } /** @@ -1286,7 +1286,7 @@ DSI_DCS_SHORT_PKT_WRITE_P1, OTM8009A_CMD_DISPOFF, 0x00); - + } /** @@ -1300,11 +1300,11 @@ { if(NbrParams <= 1) { - HAL_DSI_ShortWrite(&hdsi_eval, LCD_OTM8009A_ID, DSI_DCS_SHORT_PKT_WRITE_P1, pParams[0], pParams[1]); + HAL_DSI_ShortWrite(&hdsi_eval, LCD_OTM8009A_ID, DSI_DCS_SHORT_PKT_WRITE_P1, pParams[0], pParams[1]); } else { - HAL_DSI_LongWrite(&hdsi_eval, LCD_OTM8009A_ID, DSI_DCS_LONG_PKT_WRITE, NbrParams, pParams[NbrParams], pParams); + HAL_DSI_LongWrite(&hdsi_eval, LCD_OTM8009A_ID, DSI_DCS_LONG_PKT_WRITE, NbrParams, pParams[NbrParams], pParams); } } @@ -1645,4 +1645,4 @@ * @} */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ \ No newline at end of file
diff -r 3cdfcc4f7c9d -r d8e068ff1ba1 Drivers/BSP/STM32469I-Discovery/stm32469i_discovery_lcd.h --- a/Drivers/BSP/STM32469I-Discovery/stm32469i_discovery_lcd.h Wed Feb 28 13:17:15 2018 +0100 +++ b/Drivers/BSP/STM32469I-Discovery/stm32469i_discovery_lcd.h Fri Jul 19 15:34:05 2019 +0000 @@ -403,4 +403,4 @@ #endif /* __STM32469I_DISCOVERY_LCD_H */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ \ No newline at end of file