发新帖本帖赏金 5.00元(功能说明)我要提问
返回列表
打印
[STM32F4]

mipi接口的屏移植emwin的问题

[复制链接]
4748|8
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
郡吻魍|  楼主 | 2015-7-17 17:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
屏是通过mipi接口连接的,在移植emwin的时候要用到LCD_Read_Point(u16 x,u16 y)这个函数,搞了好久还是不能正确读出数据,这个函数始终就是调不通,希望弄过这方面的可以知道下。。。
沙发
王七七| | 2015-7-17 18:09 | 只看该作者
专业消除0回复,帮你顶上去

使用特权

评论回复

打赏榜单

21小跑堂 打赏了 5.00 元 2015-08-06

评论
21小跑堂 2015-8-6 16:46 回复TA
你打赏我买单活动奖励发在这啦~~ 
板凳
郡吻魍|  楼主 | 2015-7-17 18:13 | 只看该作者
王七七 发表于 2015-7-17 18:09
专业消除0回复,帮你顶上去

3Q...

使用特权

评论回复
地板
stm32_guy| | 2015-7-24 16:57 | 只看该作者
你用的是什么芯片和那颗LCD驱动IC,我写过一些代码供你参考,希望能对你有些帮助.
static void LCD_LL_Init(void)
{   
  DSI_PLLInitTypeDef dsiPllInit;

  static RCC_PeriphCLKInitTypeDef  PeriphClkInitStruct;

  uint32_t LcdClock  = 27429; /*!< LcdClk = 27429 kHz */
  uint32_t Clockratio  = 0;
  uint32_t lcd_x_size = 0;
  uint32_t lcd_y_size = 0;
  uint32_t laneByteClk_kHz = 0;
  uint32_t VSA;
  uint32_t VBP;
  uint32_t VFP;
  uint32_t VACT;
  uint32_t HSA;
  uint32_t HBP;
  uint32_t HFP;
  uint32_t HACT;
  
  
  /* Toggle Hardware Reset of the DSI LCD using
  * its XRES signal (active low) */
  LCD_LL_Reset();
  
        /** @brief Enable the LTDC clock */
  __HAL_RCC_LTDC_CLK_ENABLE();

  /** @brief Toggle Sw reset of LTDC IP */
  __HAL_RCC_LTDC_FORCE_RESET();
  __HAL_RCC_LTDC_RELEASE_RESET();

  /** @brief Enable the DMA2D clock */
  __HAL_RCC_DMA2D_CLK_ENABLE();

  /** @brief Toggle Sw reset of DMA2D IP */
  __HAL_RCC_DMA2D_FORCE_RESET();
  __HAL_RCC_DMA2D_RELEASE_RESET();

  /** @brief Enable DSI Host and wrapper clocks */
  __HAL_RCC_DSI_CLK_ENABLE();

  /** @brief Soft Reset the DSI Host and wrapper */
  __HAL_RCC_DSI_FORCE_RESET();
  __HAL_RCC_DSI_RELEASE_RESET();

  /** @brief NVIC configuration for LTDC interrupt that is now enabled */
  HAL_NVIC_SetPriority(LTDC_IRQn, 3, 0);
  HAL_NVIC_EnableIRQ(LTDC_IRQn);

  /** @brief NVIC configuration for DSI interrupt that is now enabled */
  HAL_NVIC_SetPriority(DSI_IRQn, 3, 0);
  HAL_NVIC_EnableIRQ(DSI_IRQn);
   
  /* Base address of DSI Host/Wrapper registers to be set before calling De-Init */
  hdsi_eval.Instance = DSI;
  
  HAL_DSI_DeInit(&(hdsi_eval));
  
  dsiPllInit.PLLNDIV  = 100;
  dsiPllInit.PLLIDF   = DSI_PLL_IN_DIV5;
  dsiPllInit.PLLODF        = DSI_PLL_OUT_DIV1;
  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;
  
  HAL_DSI_Init(&(hdsi_eval), &(dsiPllInit));
  Clockratio = laneByteClk_kHz/LcdClock;
  /* Timing parameters for all Video modes
  * Set Timing parameters of LTDC depending on its chosen orientation
  */
  /* lcd_orientation == LCD_ORIENTATION_LANDSCAPE */
  VSA  = OTM8009A_800X480_VSYNC;        /* 12 */
  VBP  = OTM8009A_800X480_VBP;          /* 12 */
  VFP  = OTM8009A_800X480_VFP;          /* 12 */
  HSA  = OTM8009A_800X480_HSYNC;        /* 120 */
  HBP  = OTM8009A_800X480_HBP;          /* 120 */
  HFP  = OTM8009A_800X480_HFP;          /* 120 */
  lcd_x_size = OTM8009A_800X480_WIDTH;  /* 800 */
  lcd_y_size = OTM8009A_800X480_HEIGHT; /* 480 */                                
  
  HACT = lcd_x_size;
  VACT = lcd_y_size;
  
  
  hdsivideo_handle.VirtualChannelID = 0;
  hdsivideo_handle.ColorCoding = LCD_DSI_PIXEL_DATA_FMT_RBG565;
  hdsivideo_handle.VSPolarity = DSI_VSYNC_ACTIVE_HIGH;
  hdsivideo_handle.HSPolarity = DSI_HSYNC_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.HorizontalSyncActive      = HSA*Clockratio;
  hdsivideo_handle.HorizontalBackPorch       = HBP*Clockratio;
  hdsivideo_handle.HorizontalLine            = (HACT + HSA + HBP + HFP)*Clockratio; /* Value depending on display orientation choice portrait/landscape */
  hdsivideo_handle.VerticalSyncActive        = VSA;
  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 = 64;
  
  /* 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 = 64;
  
  
  /* 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 */
  hdsivideo_handle.LPHorizontalBackPorchEnable  = DSI_LP_HBP_ENABLE;   /* Allow sending LP commands during HBP period */
  hdsivideo_handle.LPVerticalActiveEnable = DSI_LP_VACT_ENABLE;  /* Allow sending LP commands during VACT period */
  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));
  
  /* Enable the DSI host and wrapper : but LTDC is not started yet at this stage */
  HAL_DSI_Start(&(hdsi_eval));
  
  /* 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;   
  
  
  /* LCD clock configuration */
  /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
  /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 384 Mhz */
  /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 384 MHz / 7 = 54.857 MHz */
  /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_2 = 54.857 MHz / 2 = 27.429 MHz */
  PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
  PeriphClkInitStruct.PLLSAI.PLLSAIN = 384;
  PeriphClkInitStruct.PLLSAI.PLLSAIR = 7;
  PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;
  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_LTDC_StructInitFromVideoConfig(&(hltdc_eval), &(hdsivideo_handle));
  
  /* Initialize the LTDC */  
  HAL_LTDC_Init(&hltdc_eval);
  
  OTM8009A_Init(hdsivideo_handle.ColorCoding, OTM8009A_ORIENTATION_LANDSCAPE );
  
  HAL_LTDC_ProgramLineEvent(&hltdc_eval, 0);  
}
void DSI_IO_WriteCmd(uint32_t NbrParams, uint8_t *pParams)
{
  if(NbrParams <= 1)
  {
   HAL_DSI_ShortWrite(&hdsi_eval, 0, DSI_DCS_SHORT_PKT_WRITE_P1, pParams[0], pParams[1]);
  }
  else
  {
   HAL_DSI_LongWrite(&hdsi_eval,  0, DSI_DCS_LONG_PKT_WRITE, NbrParams, pParams[NbrParams], pParams);
  }
}

使用特权

评论回复
5
zhou0214| | 2015-7-25 10:32 | 只看该作者
楼上这代码要是能稍微有些注释就好了。

使用特权

评论回复
6
stm32_guy| | 2015-9-7 17:54 | 只看该作者
关于MIPI的驱动例程,可以参考STM32最新的Cube库:
STM32Cube_FW_F4_V1.8.0\STM32Cube_FW_F4_V1.8.0\Projects\STM32469I_EVAL\Examples\LCD_DSI

使用特权

评论回复
7
Snow7| | 2015-9-7 19:04 | 只看该作者
楼上这代码要是能稍微有些注释就好了

这段程序有注释的,英文的

使用特权

评论回复
8
lwsn| | 2015-9-7 19:48 | 只看该作者
参考STM32Cube_FW_F4_V1.8.0\STM32Cube_FW_F4_V1.8.0\Projects\STM32469I_EVAL\Examples\LCD_DSI

使用特权

评论回复
发新帖 本帖赏金 5.00元(功能说明)我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

10

主题

38

帖子

1

粉丝