Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lains committed Jan 25, 2024
1 parent 85bd322 commit 8b6dd24
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 1,181 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ PROJECT_INCLUDE_DIRS += $(TICDECODECPP)/include
BSP_ASM_FILES += $(VENDOR_ROOT)/Drivers/CMSIS/Device/ST/STM32F7xx/Source/Templates/gcc/startup_stm32f769xx.s
#BSP_SRC_FILES += $(VENDOR_ROOT)/Drivers/CMSIS/Device/ST/STM32F7xx/Source/Templates/system_stm32f7xx.c # We already have a (different) copy in src/
BSP_SRC_FILES += $(VENDOR_ROOT)/Drivers/BSP/STM32F769I-Discovery/stm32f769i_discovery.c
BSP_SRC_FILES += $(VENDOR_ROOT)/Drivers/BSP/STM32F769I-Discovery/stm32f769i_discovery_audio.c
BSP_SRC_FILES += $(VENDOR_ROOT)/Drivers/BSP/STM32F769I-Discovery/stm32f769i_discovery_lcd.c
BSP_SRC_FILES += $(VENDOR_ROOT)/Drivers/BSP/STM32F769I-Discovery/stm32f769i_discovery_ts.c
BSP_SRC_FILES += $(VENDOR_ROOT)/Drivers/BSP/STM32F769I-Discovery/stm32f769i_discovery_sd.c
Expand Down
43 changes: 19 additions & 24 deletions src/hal/Stm32LcdDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ void HAL_DSI_EndOfRefreshCallback(DSI_HandleTypeDef *hdsi) {
*/
void LTDC_Init(LTDC_HandleTypeDef* hltdc) {
/* DeInit */
hltdc->Instance = LTDC;
HAL_LTDC_DeInit(hltdc);

/* LTDC Config */
/* Timing and polarity */
hltdc->Init.HorizontalSync = HSYNC;
Expand All @@ -88,12 +89,12 @@ void LTDC_Init(LTDC_HandleTypeDef* hltdc) {
hltdc->Init.AccumulatedActiveW = HSYNC+HBP+HACT;
hltdc->Init.TotalHeigh = VSYNC+VBP+VACT+VFP;
hltdc->Init.TotalWidth = HSYNC+HBP+HACT+HFP;

/* background value */
hltdc->Init.Backcolor.Blue = 0;
hltdc->Init.Backcolor.Green = 0;
hltdc->Init.Backcolor.Red = 0;

/* Polarity */
hltdc->Init.HSPolarity = LTDC_HSPOLARITY_AL;
hltdc->Init.VSPolarity = LTDC_VSPOLARITY_AL;
Expand All @@ -115,7 +116,7 @@ void LTDC_Init(LTDC_HandleTypeDef* hltdc) {
* @retval LCD state
*/
static uint8_t LCD_Init(DSI_HandleTypeDef* hdsi, LTDC_HandleTypeDef* hltdc) {
static DSI_PHY_TimerTypeDef PhyTimings;
static DSI_PHY_TimerTypeDef PhyTimings;
static DSI_CmdCfgTypeDef CmdCfg;
static DSI_LPCmdTypeDef LPCmd;
static DSI_PLLInitTypeDef dsiPllInit;
Expand All @@ -124,15 +125,15 @@ static uint8_t LCD_Init(DSI_HandleTypeDef* hdsi, LTDC_HandleTypeDef* hltdc) {
/* 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
* - clocked
* - NVIC IRQ related to IP blocks enabled
*/
BSP_LCD_MspInit();

/* LCD clock configuration */
/* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
/* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 417 Mhz */
Expand All @@ -143,20 +144,20 @@ static uint8_t LCD_Init(DSI_HandleTypeDef* hdsi, LTDC_HandleTypeDef* hltdc) {
PeriphClkInitStruct.PLLSAI.PLLSAIR = 5;
PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);

/* Base address of DSI Host/Wrapper registers to be set before calling De-Init */
hdsi->Instance = DSI;

HAL_DSI_DeInit(hdsi);

dsiPllInit.PLLNDIV = 100;
dsiPllInit.PLLIDF = DSI_PLL_IN_DIV5;
dsiPllInit.PLLODF = DSI_PLL_OUT_DIV1;

hdsi->Init.NumberOfLanes = DSI_TWO_DATA_LANES;
hdsi->Init.TXEscapeCkdiv = 0x4;
HAL_DSI_Init(hdsi, &(dsiPllInit));

/* Configure the DSI for Command mode */
CmdCfg.VirtualChannelID = 0;
CmdCfg.HSPolarity = DSI_HSYNC_ACTIVE_HIGH;
Expand All @@ -170,7 +171,7 @@ static uint8_t LCD_Init(DSI_HandleTypeDef* hdsi, LTDC_HandleTypeDef* hltdc) {
CmdCfg.AutomaticRefresh = DSI_AR_DISABLE;
CmdCfg.TEAcknowledgeRequest = DSI_TE_ACKNOWLEDGE_ENABLE;
HAL_DSI_ConfigAdaptedCommandMode(hdsi, &CmdCfg);

LPCmd.LPGenShortWriteNoP = DSI_LP_GSW0P_ENABLE;
LPCmd.LPGenShortWriteOneP = DSI_LP_GSW1P_ENABLE;
LPCmd.LPGenShortWriteTwoP = DSI_LP_GSW2P_ENABLE;
Expand Down Expand Up @@ -198,12 +199,12 @@ static uint8_t LCD_Init(DSI_HandleTypeDef* hdsi, LTDC_HandleTypeDef* hltdc) {
PhyTimings.DataLaneMaxReadTime = 0;
PhyTimings.StopWaitTime = 10;
HAL_DSI_ConfigPhyTimer(hdsi, &PhyTimings);

/* Initialize the OTM8009A LCD Display IC Driver (KoD LCD IC Driver)
* depending on configuration set in 'hdsivideo_handle'.
*/
OTM8009A_Init(OTM8009A_COLMOD_RGB888, LCD_ORIENTATION_LANDSCAPE);

LPCmd.LPGenShortWriteNoP = DSI_LP_GSW0P_DISABLE;
LPCmd.LPGenShortWriteOneP = DSI_LP_GSW1P_DISABLE;
LPCmd.LPGenShortWriteTwoP = DSI_LP_GSW2P_DISABLE;
Expand All @@ -216,7 +217,7 @@ static uint8_t LCD_Init(DSI_HandleTypeDef* hdsi, LTDC_HandleTypeDef* hltdc) {
LPCmd.LPDcsShortReadNoP = DSI_LP_DSR0P_DISABLE;
LPCmd.LPDcsLongWrite = DSI_LP_DLW_DISABLE;
HAL_DSI_ConfigCommand(hdsi, &LPCmd);

HAL_DSI_ConfigFlowControl(hdsi, DSI_FLOW_CONTROL_BTA);

/* Send Display Off DCS Command to display */
Expand All @@ -225,11 +226,11 @@ static uint8_t LCD_Init(DSI_HandleTypeDef* hdsi, LTDC_HandleTypeDef* hltdc) {
DSI_DCS_SHORT_PKT_WRITE_P1,
OTM8009A_CMD_DISPOFF,
0x00);

/* Refresh the display */
HAL_DSI_Refresh(hdsi);
return LCD_OK;

return LCD_OK;
}

} // extern "C"
Expand Down Expand Up @@ -266,16 +267,10 @@ bool Stm32LcdDriver::start() {
this->displayState = SwitchToDraftIsPending;

HAL_DSI_Refresh(&(this->hdsi));
BSP_LED_On(LED_RED);

// Currently hanging here...
while (this->displayState == SwitchToDraftIsPending); /* Wait until the LCD displays the draft framebuffer */
HAL_Delay(250);
BSP_LED_Off(LED_RED);
BSP_LED_On(LED_GREEN);
HAL_Delay(250);
BSP_LED_Off(LED_GREEN);

/* Send Display On DCS Command to display */
HAL_DSI_ShortWrite(&(this->hdsi),
0,
DSI_DCS_SHORT_PKT_WRITE_P1,
Expand Down
53 changes: 0 additions & 53 deletions src/hal/stm32f4xx_hal_msp.c.old

This file was deleted.

Loading

0 comments on commit 8b6dd24

Please sign in to comment.