Beispiel #1
0
/**
  * @brief  DeInitializes the LCD.
  * @param  None
  * @retval None
  */
void LCD_DeInit(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;

  /*!< LCD Display Off */
  LCD_DisplayOff();

  /*!< LCD_SPI disable */
  SPI_Cmd(LCD_SPI, DISABLE);
  
  /*!< LCD_SPI DeInit */
  SPI_I2S_DeInit(LCD_SPI);
   
  /*!< Disable SPI clock  */
  RCC_APB1PeriphClockCmd(LCD_SPI_CLK, DISABLE);

  /* Configure NCS in Output Push-Pull mode */
  GPIO_InitStructure.GPIO_Pin = LCD_NCS_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(LCD_NCS_GPIO_PORT, &GPIO_InitStructure);
   
  /* Configure SPI pins: SCK, MISO and MOSI */
  GPIO_InitStructure.GPIO_Pin = LCD_SPI_SCK_PIN;
  GPIO_Init(LCD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure);

  GPIO_InitStructure.GPIO_Pin = LCD_SPI_MISO_PIN;
  GPIO_Init(LCD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure);
  
  GPIO_InitStructure.GPIO_Pin = LCD_SPI_MOSI_PIN;
  GPIO_Init(LCD_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure);
}
Beispiel #2
0
void LCD_Init( uint8_t numLines, uint8_t numCols )
{
    if ( numLines > 4 )
    {
        numLines = 4;
    }
    gNumLines = numLines;

    if ( numCols > 40 )
    {
        numCols = 40;
    }
    gNumCols = numCols;

    // Let the low level HAL do most of the initialization

    LCD_HAL_Init();

    LCD_DisplayOff();

    LCD_Clear();

    LCD_WriteCommand( LCD_ENTRY_MODE | LCD_ENTRY_INC );

    LCD_HideCursor();   // also turns on display

} // LCD_Init
/**
  * @brief  DeInitializes the LCD.
  * @param  None
  * @retval None
  */
void LCD_DeInit(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;

	/* LCD Display Off */
	LCD_DisplayOff();

	/* BANK 4 (of NOR/SRAM Bank 1~4) is disabled */
	FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);

	/* LCD_SPI DeInit */
	FSMC_NORSRAMDeInit(FSMC_Bank1_NORSRAM4);

	/* Set PD.00(D2), PD.01(D3), PD.04(NOE), PD.05(NWE), PD.08(D13), PD.09(D14),
	   PD.10(D15), PD.14(D0), PD.15(D1) as input floating */
	GPIO_InitStructure.GPIO_Pin =
	    GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_8 |
	    GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
	GPIO_Init(GPIOD, &GPIO_InitStructure);
	/* Set PE.07(D4), PE.08(D5), PE.09(D6), PE.10(D7), PE.11(D8), PE.12(D9), PE.13(D10),
	   PE.14(D11), PE.15(D12) as alternate function push pull */
	GPIO_InitStructure.GPIO_Pin =
	    GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 |
	    GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
	GPIO_Init(GPIOE, &GPIO_InitStructure);
	/* Set PF.00(A0 (RS)) as alternate function push pull */
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
	GPIO_Init(GPIOF, &GPIO_InitStructure);
	/* Set PG.12(NE4 (LCD/CS)) as alternate function push pull - CE3(LCD /CS) */
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
	GPIO_Init(GPIOG, &GPIO_InitStructure);
}
Beispiel #4
0
/**
 * @brief  Switches the backlight either ON or OFF
 * @param  state. This parameter can be one of the following values:
 *     @arg   GL_ON
 *     @arg   GL_OFF
 * @retval None
 */
void GL_BackLightSwitch(uint8_t u8_State)
{
	if (u8_State == GL_OFF) {
		LCD_DisplayOff();
	}
	else if (u8_State == GL_ON) {
		LCD_DisplayOn();
	}
}
/**
  * @brief  LCD Default FSMC Init
  * @param  None
  * @retval None
  */
void BSP_LCD_DeInit(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;

  /*!< LCD Display Off */
  LCD_DisplayOff();

  /* BANK 3 (of NOR/SRAM Bank 1~4) is disabled */
  hsram1_ssd2119.Init.NSBank = FSMC_NORSRAM_BANK3;
  __FMC_NORSRAM_ENABLE(hsram1_ssd2119.Instance, hsram1_ssd2119.Init.NSBank);

  /*!< LCD_SPI DeInit */
  HAL_SRAM_DeInit(&hsram1_ssd2119);

  /*-- GPIO Configuration ------------------------------------------------------*/
  /** FSMC GPIO Configuration
  PE3   ------> FSMC_A19
  PE7   ------> FSMC_D4
  PE8   ------> FSMC_D5
  PE9   ------> FSMC_D6
  PE10   ------> FSMC_D7
  PE11   ------> FSMC_D8
  PE12   ------> FSMC_D9
  PE13   ------> FSMC_D10
  PE14   ------> FSMC_D11
  PE15   ------> FSMC_D12
  PD8   ------> FSMC_D13
  PD9   ------> FSMC_D14
  PD10   ------> FSMC_D15
  PD14   ------> FSMC_D0
  PD15   ------> FSMC_D1
  PD0   ------> FSMC_D2
  PD1   ------> FSMC_D3
  PD4   ------> FSMC_NOE
  PD5   ------> FSMC_NWE
  PD7   ------> FSMC_NE1
  */
  /* SRAM Data lines configuration */

  HAL_GPIO_DeInit(GPIOE, GPIO_PIN_3|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9
                          |GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13
                          |GPIO_PIN_14|GPIO_PIN_15);

  HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14
                          |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4
                          |GPIO_PIN_5|GPIO_PIN_7);
}
Beispiel #6
0
/*******************************************************************************
* Function Name: LCD_Stop
********************************************************************************
*
* Summary:
*  Turns off the display of the LCD screen.
*
* Parameters:
*  None.
*
* Return:
*  None.
*
* Reentrant:
*  No.
*
*******************************************************************************/
void LCD_Stop(void) 
{
    /* Calls LCD Off Macro */
    LCD_DisplayOff();
    LCD_enableState = 0u;
}
/**
  * @brief  Disables the display.
  * @param  None
  * @retval None
  */
void BSP_LCD_DisplayOff(void)
{
  LCD_DisplayOff();
}
Beispiel #8
0
/*
 ******************************************************************************
 *函数:void LCD_GPIOInit(void)
 *输入:void
 *输出:void
 *描述:LCD初始化
 ******************************************************************************
 */
void LCD_Init(void)
{
  LTDC_InitTypeDef       LTDC_InitStruct;
  LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct;
  LTDC_Layer_TypeDef     LTDC_Layerx;
  
	
  /* IO口初始化 */
  LCD_GPIOInit();
	
  LCD_DisplayOff();
  /* 使能LCD时钟 */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE);
  /* 使能DMA失踪*/
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE);
	
  /* 水平同步信号---低电平有效 */
  LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL;     
  /* 垂直同步信号---低电平有效 */  
  LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL;     
  /* 数据使能信号---低电平有效 */
  LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL;     
  /* 像素时钟配置--- */ 
  LTDC_InitStruct.LTDC_PCPolarity = LTDC_DEPolarity_AL;
	/* LCD背光设置 */
  LTDC_InitStruct.LTDC_BackgroundRedValue = 0;            
  LTDC_InitStruct.LTDC_BackgroundGreenValue = 0;          
  LTDC_InitStruct.LTDC_BackgroundBlueValue = 0;  	
  /*
   ****************************************************************************
   *PLLSAI_VCO = HSE*PLLSAI_N / PLL_M = 8 * 192 / 8 = 192MHz
   *PLLLCDCLK = PLLSAI_VCO / PLLSAI_R = 192 / 3 = 64 Mhz
   *LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 64 / 8 = 8 Mhz
   ****************************************************************************
   */
  RCC_PLLSAIConfig(192, 7, 3);
  RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div4);	
  /* 使能PLLSAI时钟 */
  RCC_PLLSAICmd(ENABLE);
  /* 等待PLLSAI时钟 */
  while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET){}
  /*  */
  LTDC_InitStruct.LTDC_HorizontalSync = 40;
  /*  */
  LTDC_InitStruct.LTDC_VerticalSync = 9;
  /*  */
  LTDC_InitStruct.LTDC_AccumulatedHBP = 42; 
  /*  */
  LTDC_InitStruct.LTDC_AccumulatedVBP = 11;  
  /*  */
  LTDC_InitStruct.LTDC_AccumulatedActiveW = 522;
  /*  */
  LTDC_InitStruct.LTDC_AccumulatedActiveH = 283;
  /*  */
  LTDC_InitStruct.LTDC_TotalWidth = 524; 
  /*  */
  LTDC_InitStruct.LTDC_TotalHeigh = 285;
            
  LTDC_Init(&LTDC_InitStruct);
		
  LTDC_Layer_InitStruct.LTDC_HorizontalStart = 43;
  LTDC_Layer_InitStruct.LTDC_HorizontalStop = (480 + 43 - 1); 
  LTDC_Layer_InitStruct.LTDC_VarticalStart = 12;
  LTDC_Layer_InitStruct.LTDC_VerticalStop = (272 + 12 - 1);	

  /* Pixel Format configuration*/            
  LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565;
  /* Alpha constant (255 totally opaque) */
  LTDC_Layer_InitStruct.LTDC_ConstantAlpha = 255; 
  /* Default Color configuration (configure A,R,G,B component values) */          
  LTDC_Layer_InitStruct.LTDC_DefaultColorBlue = 0;        
  LTDC_Layer_InitStruct.LTDC_DefaultColorGreen = 0;       
  LTDC_Layer_InitStruct.LTDC_DefaultColorRed = 0;         
  LTDC_Layer_InitStruct.LTDC_DefaultColorAlpha = 0;
  /* Configure blending factors */       
  LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA;    
  LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA;
  /* the length of one line of pixels in bytes + 3 then :
     Line Lenth = Active high width x number of bytes per pixel + 3 
     Active high width         = LCD_PIXEL_WIDTH 
     number of bytes per pixel = 2    (pixel_format : RGB565) 
  */
  LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((480 * 2) + 3);
  /*  the pitch is the increment from the start of one line of pixels to the 
      start of the next line in bytes, then :
      Pitch = Active high width x number of bytes per pixel     
  */ 
  LTDC_Layer_InitStruct.LTDC_CFBPitch = (480 * 2);
  /* configure the number of lines */  
  LTDC_Layer_InitStruct.LTDC_CFBLineNumber = 272;

  /* Input Address configuration */    
  LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER;
   
  LTDC_LayerInit(LTDC_Layer1, &LTDC_Layer_InitStruct);

  /* Configure Layer2 */
  LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER + BUFFER_OFFSET;
  LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA;    
  LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA;
  LTDC_LayerInit(LTDC_Layer2, &LTDC_Layer_InitStruct);
	
  LTDC_ReloadConfig(LTDC_IMReload);
  
  /* Enable foreground & background Layers */
  LTDC_LayerCmd(LTDC_Layer1, ENABLE);
//  LTDC_LayerCmd(LTDC_Layer2, ENABLE);
  LTDC_ReloadConfig(LTDC_IMReload);
	
  LCD_DisplayOn();
}