Example #1
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();
  
  /* Configure the system clock to 180 MHz */
  SystemClock_Config();

  /* Configure LED3 */
  BSP_LED_Init(LED3);
  
  /*##-1- Configure TAMPER Button ############################################*/
  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);
  
  /*##-2- LCD Configuration ##################################################*/
  LCD_Config();

  /*##-3- Configure Color Keying  ############################################*/
  HAL_LTDC_ConfigColorKeying(&LtdcHandle, 0xFFFF, 1);  

  /* Infinite loop */
  while (1)
  {
    /* Wait for tamper button is pressed */
    while (BSP_PB_GetState(BUTTON_TAMPER) != RESET)
    {
    }

    /* Wait for tamper button is released */
    while (BSP_PB_GetState(BUTTON_TAMPER) != SET)
    {
    }
  
    if(ubPressedButton == PRESSED_FIRST)
    {
      /* Enable Color Keying */
      HAL_LTDC_EnableColorKeying(&LtdcHandle, 1);
      ubPressedButton = PRESSED_SECOND;  
    }
    else
    {
      /* Enable Color Keying */
      HAL_LTDC_DisableColorKeying(&LtdcHandle, 1);
      ubPressedButton = PRESSED_FIRST; 
    }  
  }
}
/**
  * @brief  Disables the color keying.
  * @param  LayerIndex: Layer foreground or background
  * @retval None
  */
void BSP_LCD_ResetColorKeying(uint32_t LayerIndex)
{   
  /* Disable the color Keying for LCD Layer */
  HAL_LTDC_DisableColorKeying(&hLtdcHandler, LayerIndex);
}
Example #3
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  RCC_PeriphCLKInitTypeDef  PeriphClkInitStruct;

  /* Enable the CPU Cache */
  CPU_CACHE_Enable();
  
  /* STM32F7xx HAL library initialization:
       - Configure the Flash ART accelerator on ITCM interface
       - Systick timer is configured by default as source of time base, but user 
         can eventually implement his proper time base source (a general purpose 
         timer for example or other time source), keeping in mind that Time base 
         duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 
         handled in milliseconds basis.
       - Set NVIC Group Priority to 4
       - Low Level Initialization
     */
  HAL_Init();
  
  /* Configure the system clock to 216 MHz */
  SystemClock_Config();
  
  /*## LTDC Clock Configuration ###########################################*/  
  if(stmpe811_ts_drv.ReadID(TS_I2C_ADDRESS) == STMPE811_ID)
  {
    /* LCD clock configuration */
    /* LCD clock configuration */
    /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
    /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */
    /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/5 = 38.4 Mhz */
    /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_4 = 38.4/4 = 9.6Mhz */
    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
    PeriphClkInitStruct.PLLSAI.PLLSAIN = 192;
    PeriphClkInitStruct.PLLSAI.PLLSAIR = 5;
    PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_4;
    HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);  
    
  }
  else
  {
    /* LCD clock configuration */
    /* LCD clock configuration */
    /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
    /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 151 Mhz */
    /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 151/3 = 50.3 Mhz */
    /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_2 = 50.3/2 = 25.16Mhz */
    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
    PeriphClkInitStruct.PLLSAI.PLLSAIN = 151;
    PeriphClkInitStruct.PLLSAI.PLLSAIR = 3;
    PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;
    HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);  
  } 
  
  /* Configure LED3 */
  BSP_LED_Init(LED3);   
  
  /*##-1- TAMPER button will be used #########################################*/
  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);
  
  /*##-2- LCD Configuration ##################################################*/
  LCD_Config();
  
  /*##-3- Configure Color Keying  ############################################*/
  HAL_LTDC_ConfigColorKeying(&LtdcHandle, ARGB4444_COLOR_KEY, LTDC_LAYER_1);  

  while (1)
  {
    /* Simple Polling on user button state */
	/* Wait for user button is pressed     */
    while (BSP_PB_GetState(BUTTON_TAMPER) != RESET)
    {
    }

    /* Wait for user button is released */
    while (BSP_PB_GetState(BUTTON_TAMPER) != SET)
    {
    }
  
    if(ubPressedButton == PRESSED_FIRST)
    {
      /* Enable Color Keying on layer 1 */
      HAL_LTDC_EnableColorKeying(&LtdcHandle, LTDC_LAYER_1);
      ubPressedButton = PRESSED_SECOND;  
    }
    else
    {
      /* Disable Color Keying on layer 1 */
      HAL_LTDC_DisableColorKeying(&LtdcHandle, LTDC_LAYER_1);
      ubPressedButton = PRESSED_FIRST; 
    }  
  }
}