Ejemplo n.º 1
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
	/* Enable the CPU Cache */
	CPU_CACHE_Enable();

	/* STM32F7xx HAL library initialization */
	HAL_Init();

	/* Configure the system clock to 216 MHz */
	SystemClock_Config();

	/* Configure LCD : Only one layer is used */
	LCD_Config();

	/* Our main starts here */
	uint16_t ypos = 0, ymax = 0;
	int8_t yincr = 1;
	BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
	BSP_LCD_SetBackColor(LCD_COLOR_BLACK);

	while(1) {
	  if(ypos == 0) {
		  yincr = 1;
		  ymax = BSP_LCD_GetYSize();
	  } else {
		  yincr = -1;
		  ymax = 0;
	  }

	  for(;yincr == 1 ? ypos < BSP_LCD_GetYSize() - Font24.Height : ypos > 0; ypos+=yincr) {
		  BSP_LCD_DisplayStringAt(0, ypos, (uint8_t*)"Hello to everyone!", CENTER_MODE);
	  }
	}
}
Ejemplo n.º 2
0
/*==================================================================================
* 函 数 名: Set_System
* 参    数: None
* 功能描述:  初始化系统
* 返 回 值: None
* 备    注: 
* 作    者: gaodb
* 创建时间: 2012.10
==================================================================================*/
void Set_System(void)
{  
    rcc_init();
		
    peri_clk_init();  
		
  	NVIC_Configuration();  
  	
    pins_init();  
    
    systick_init();
		
    timer2_init();
    timer4_init(); 
    
    RAY12_ADC_Init();
    
    LCD_Config();    
    DispInit();
    
    uart1_init(BAUD_RATE_57600);	
		uart2_init(BAUD_RATE_57600);
		
		dac1_init();
		
    sys_variable_init();
}
Ejemplo n.º 3
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f429_439xx.s) before to branch to application main.
     */      
    
  /* Configure DMA2D : Configure foreground and background */
  DMA2D_Config();
  
  /* Start Transfer */ 
  DMA2D_StartTransfer();
  
  /* Wait for TC Flag activation */
  while(DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET)
  {
  } 

  /* Configure LCD */
  LCD_Config(); 
  
  /* LCD Display */
  LCD_DisplayOn();  

  while (1)
  {
  }
}
Ejemplo n.º 4
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 LED3 & LED4*/
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);  

  /* Configure the system clock */
  SystemClock_Config();    

  /*##-1- LCD Configuration ##################################################*/
  LCD_Config();    
  
  /*##-2- Configure DMA2D : Configure foreground and background ##############*/
  DMA2D_Config();

  /*##-3- Start DMA2D transfer ###############################################*/  
  if(HAL_DMA2D_BlendingStart_IT(&Dma2dHandle, (uint32_t)&aRGB565_1, (uint32_t)&aRGB565_2, (uint32_t)&aBlendedImage, 240, 160) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler(); 
  }
  
  while (1)
  {
  }
}
Ejemplo n.º 5
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f429_439xx.s) before to branch to application main.
     */     

  /* Configure LCD : Configure 2 layers w/ Blending and CLUT loading for layer 1 */
  LCD_Config(); 
    
  /* Enable CLUT for Layer 1 */
  LTDC_CLUTCmd(LTDC_Layer1, ENABLE);

  /* Enable Layer 1 */
  LTDC_LayerCmd(LTDC_Layer1, ENABLE);
  
  /* Enable Layer 2 */
  LTDC_LayerCmd(LTDC_Layer2, ENABLE);
  
  /* Reload LTDC configuration  */
  LTDC_ReloadConfig(LTDC_IMReload);
  
  /* Enable The LCD */
  LTDC_Cmd(ENABLE);

  while (1)
  {
  }
}
Ejemplo n.º 6
0
void lcd_init(void)
{    
    LCD_Config();

    LCD_BACKLIGHT_OFF();    

    lcd_delay(2);

    LCD_RST_LOW();
    lcd_delay(2);
    LCD_RST_HIGH();
    lcd_delay(2);

    lcd_write_cmd(0xe2); /*软复位*/
    lcd_delay(2);
    lcd_write_cmd(0x2c); /*升压步聚1*/
    lcd_delay(2);
    lcd_write_cmd(0x2e); /*升压步聚2*/
    lcd_delay(2);
    lcd_write_cmd(0x2f); /*升压步聚3*/
    lcd_delay(2);
    lcd_write_cmd(0x25); /*粗调对比度,可设置范围0x20~0x27*/
    lcd_write_cmd(0x81); /*微调对比度*/
    lcd_write_cmd(0x16); /*微调对比度的值,可设置范围0x00~0x3f*/
    lcd_write_cmd(0xa2); /*1/9 偏压比(bias)*/
    lcd_write_cmd(0xc8); /*行扫描顺序:从上到下*/
    lcd_write_cmd(0xa0); /*列扫描顺序:从左到右*/ 
    lcd_write_cmd(0x40); /*起始行:从第一行开始*/
    lcd_write_cmd(0xaf); /*开显示*/

    lcd_delay(2);

    lcd_clr_scr();
}
Ejemplo n.º 7
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  uint32_t tobuttom = 0;
  uint32_t totop = 0;

  /* 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- LCD Configuration ##################################################*/ 
  /* Configure 2 layers w/ Blending and CLUT loading for layer 1 */
  LCD_Config(); 

  /*##-2- CLUT Configuration #################################################*/
  HAL_LTDC_ConfigCLUT(&LtdcHandle, (uint32_t *)L8_320x240_CLUT, 256, 0); 
  
  /*##-3- Enable CLUT For Layer 1 ############################################*/
  HAL_LTDC_EnableCLUT(&LtdcHandle, 0);   

  /* Infinite loop */ 
  while (1)
  {
    for (tobuttom = 0; tobuttom < 32; tobuttom++)
    {
      /* move the picture */
      /* reconfigure the layer1 position */
      HAL_LTDC_SetWindowPosition(&LtdcHandle, (tobuttom*5), (tobuttom), 0); 
      /* reconfigure the layer2 position */
      HAL_LTDC_SetWindowPosition(&LtdcHandle, (160 - (tobuttom*5)), (32 - tobuttom), 1); 
      HAL_Delay(50);
    }
    HAL_Delay(500);
    for (totop = 0; totop < 32; totop++)
    {
      /* move the picture */
      /* reconfigure the layer1 position */
      HAL_LTDC_SetWindowPosition(&LtdcHandle, (160 - (totop*5)), (32 - (totop)), 0); 
      /* reconfigure the layer2 position */
      HAL_LTDC_SetWindowPosition(&LtdcHandle, (totop*5), totop, 1); 
      HAL_Delay(50);
    }
    HAL_Delay(500);

    
  }
}
Ejemplo n.º 8
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 168 MHz */
  SystemClock_Config();

  /* Configure LED3 and LED4 */
  BSP_LED_Init(LED3); 
  BSP_LED_Init(LED4); 
  
  /* Configure USER Button */
  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);
  
  /* Initialize LCD driver */
  LCD_Config();
  
  /* Link the USB Host disk I/O driver */
  USBDISK_Driver_Num = FATFS_LinkDriver(&USBH_Driver, "");
  
  /* Init Host Library */
  if (USBH_Init(&hUSB_Host, USBH_UserProcess, 0) != USBH_OK)
  {
    /* USB Initialization Error */
    Error_Handler();
  }

  /* Add Supported Class */
  USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS);
  
  /* Start Host Process */
  if (USBH_Start(&hUSB_Host) != USBH_OK)
  {
    /* USB Initialization Error */
    Error_Handler();
  }

  /* Infinite loop */
  while (1)
  {
    if (Appli_state == APPLICATION_START)
    {
      MSC_Application();
    }
    Toggle_Leds();
    USBH_Process(&hUSB_Host);
  }
}
Ejemplo n.º 9
0
/**
  * @brief Example  main entry point.
  * @param  None
  * @retval None
  */
void main(void)
{
    uint8_t state = 0x00;

    /* GPIO Configuration  -----------------------------------------------------*/
    GPIO_Config();

    /* Configure LCD mounted on STM8-128 EVAL board ----------------------------*/
    LCD_Config();

    /* Clock configuration -----------------------------------------------------*/
    CLK_Config();

    enableInterrupts();

    while (1)
    {
        while(state == OscillatorStatus)
        {}
        state = OscillatorStatus; /* Update the selected master clock oscillator */

        /* joystick right */
        if(OscillatorStatus == 0x00)
        {
            CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSI, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE);

            /* Print on LCD line2*/
            LCD_SetCursorPos(LCD_LINE2, 0);
            LCD_Print("   CLK = HSI    ");
        }

        /* joystick up */
        if(OscillatorStatus == 0x01)
        {
            CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSE, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE);

            /* Print on LCD line2*/
            LCD_SetCursorPos(LCD_LINE2, 0);
            LCD_Print("   CLK = HSE    ");
        }

        /* joystick down */
        if(OscillatorStatus == 0x02)
        {
            CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_LSI, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE);

            /* Print on LCD line2*/
            LCD_SetCursorPos(LCD_LINE2, 0);
            LCD_Print("   CLK = LSI    ");
        }
    }
}
Ejemplo n.º 10
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; 
    }  
  }
}
Ejemplo n.º 11
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  uint32_t tobuttom = 0;
  uint32_t totop = 0;

  /* 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 */
  SystemClock_Config();

  /* Configure LED3 */
  BSP_LED_Init(LED3);   
  
  /*##-1- LCD Configuration ##################################################*/ 
  /* Configure 2 layers w/ Blending */
  LCD_Config(); 

  while (1)
  {
    for (tobuttom = 1; tobuttom < 41; tobuttom++)
    {
      /* move the picture */
      /* reconfigure the layer1 position */
      HAL_LTDC_SetWindowPosition(&LtdcHandle, 0, (tobuttom*4), 0); 
      /* reconfigure the layer2 position */
      HAL_LTDC_SetWindowPosition(&LtdcHandle, 0, (160 - (tobuttom*4)), 1); 
      HAL_Delay(50);
    }
    HAL_Delay(500);
    for (totop = 1; totop < 41; totop++)
    {
      /* move the picture */
      /* reconfigure the layer1 position */
      HAL_LTDC_SetWindowPosition(&LtdcHandle, 0, (160 - (totop*4)), 0); 
      /* reconfigure the layer2 position */
      HAL_LTDC_SetWindowPosition(&LtdcHandle, 0, (totop*4), 1); 
      HAL_Delay(50);
    }
    HAL_Delay(500);

    
  }
}
Ejemplo n.º 12
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{       
  /* Example description.
     ------------------------------------------
  This example provides a description of how to configure DMA2D periph in 
  Memory_to_Memory with pixel format conversion transfer mode and display the 
  result on LCD.
  In this case two images will be displayed on the LCD, original image before 
  the pixel format conversion and the transferred data after pixel format conversion
  In this example the pixel format conversion is done from RGB565 to ARGB8888 
  and you can see on LCD the difference between the two images
   */  

  /* 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 LED1, LED2 and LED3 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  
  /*##-1- LCD Configuration ##################################################*/
  LCD_Config();
  
  /*##-2- DMA2D configuration ################################################*/
  DMA2D_Config(); 
  
  /*##-3- Start DMA2D transfer ###############################################*/  
  if(HAL_DMA2D_Start_IT(&Dma2dHandle, (uint32_t)&RGB565_300x120, (uint32_t)&aBufferResult, 300, 120) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler(); 
  }

  /* Infinite loop */
  while (1)
  {
  }
}
Ejemplo n.º 13
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  uint32_t index = 0;

  /* 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- LCD Configuration ##################################################*/ 
  /* Configure 2 layers w/ Blending */
  LCD_Config(); 

  
  /*##-2- Configure line event ###############################################*/
  HAL_LTDC_ProgramLineEvent(&LtdcHandle, 0);  
  
  /* Infinite loop */
  while (1)
  { 
    for (index = 0; index < 41; index++)
    {
      /* calculate new picture position */
      PicturesPosition(&Xpos1, &Ypos1, &Xpos2, &Ypos2, (index+1));
      HAL_Delay(50);
    }
    HAL_Delay(500);
    
    for (index = 0; index < 41; index++)
    {
      /* calculate new picture position */
      PicturesPosition(&Xpos2, &Ypos2, &Xpos1, &Ypos1, (index+1));
      HAL_Delay(50);
    }
    HAL_Delay(500);
  }
}
Ejemplo n.º 14
0
int main(void)
{
	GUI_MEMDEV_Handle hMem0,hMem1;
	SysTick_Config(180000);
	SDRAM_Init();
	
	LCD_Config();
	
	GUI_Init();
	GUI_SetFont(&GUI_Font32B_ASCII);
	GUI_SetBkColor(GUI_BLUE);
	GUI_SetColor(GUI_YELLOW);
	GUI_Clear();

//	GUI_DispStringAt("blacklight",0,100);
	
//	GUIDEMO_Main();
	
	hMem0 = GUI_MEMDEV_CreateFixed(0,0,100,50,GUI_MEMDEV_NOTRANS,GUI_MEMDEV_APILIST_32,GUI_COLOR_CONV_888);
	hMem1 = GUI_MEMDEV_CreateFixed(0,0,100,50,GUI_MEMDEV_NOTRANS,GUI_MEMDEV_APILIST_32,GUI_COLOR_CONV_888);
	GUI_MEMDEV_Select(hMem0);
	GUI_Clear();
	GUI_DispString("Text");
	GUI_MEMDEV_CopyToLCDAt(hMem0,0,0);
	
	while(1)
	{	
		GUI_MEMDEV_Select(hMem1);
		GUI_MEMDEV_DrawPerspectiveX(hMem0,0,0,50,50-50*i/100,100-100*i/100,25*i/100);
		GUI_MEMDEV_CopyToLCDAt(hMem1,i,50+i);
		
		GUI_Delay(10);
		
		GUI_MEMDEV_Select(hMem1);
		GUI_Clear();
		GUI_MEMDEV_CopyToLCDAt(hMem1,i,50+i);
		
		i+=1;
		if(i>100)
		{
			i=0;
		}
	}
	
	while(1);
}
Ejemplo n.º 15
0
int main(void)
{
    RCC_PeriphCLKInitTypeDef  PeriphClkInitStruct;


    // Configure the MPU attributes as Write Through
    MPU_Config();

    // Enable the CPU Cache
    CPU_CACHE_Enable();

    // STM32F7xx HAL library initialization:
    // - Configure the Flash ART accelerator on ITCM interface
    // - Configure the Systick to generate an interrupt each 1 msec
    // - Set NVIC Group Priority to 4
    // - Low Level Initialization
    HAL_Init();

    // Configure the System clock to have a frequency of 216 MHz
    SystemClock_Config();

    // 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);

    BSP_LED_Init(LED1);
    LCD_Config();

    while (1)
    {
    }
}
Ejemplo n.º 16
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f429_439xx.s) before to branch to application main.
     */     
       
  /* Example description.
     ------------------------------------------
  This example provides a description of how to configure DMA2D periph in 
  Memory_to_Memory with pixel format conversion transfer mode and display the 
  result on LCD.
  In this case two images will be displayed on the LCD, original image before 
  the pixel format conversion and the transferred data after pixel format conversion
  In this example the pixel format conversion is done from ARGB8888 to ARGB4444 
  and you can see on LCD the difference between the two images
   */  
  
  /* DMA2D configuration */
  DMA2D_Config();
  
  /* Start Transfer */
  DMA2D_StartTransfer(); 
  
  /* Wait for CTC Flag activation */
  while(DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET)
  {
  }  

  /* Configure LCD */
  LCD_Config();
  
  /* LCD Display */
  LCD_DisplayOn();

  while (1)
  {
  }
}
Ejemplo n.º 17
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f429_439xx.s) before to branch to application main.
     */     

  /* Configure LCD : Only one layer is used */
  LCD_Config();

  /* Enable Layer 1 */
  LTDC_LayerCmd(LTDC_Layer1, ENABLE);
  
  /* Reload configuration of Layer 1 */
  LTDC_ReloadConfig(LTDC_IMReload);
  
  /* Enable The LCD */
  LTDC_Cmd(ENABLE);

  while (1)
  {
  }
}
Ejemplo n.º 18
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
void LTDC_Display_1Layer_example(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 */
  SystemClock_Config();

  /* Configure LED3 */
  BSP_LED_Init(LED3);  
  
  /* Configure LCD : Only one layer is used */
  LCD_Config();

  while (1)
  {
  }
}
Ejemplo n.º 19
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 LED1, LED2 and LED3 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  
  /*##-1- LCD Configuration ##################################################*/
  LCD_Config();  
  
  /*##-2- DMA2D configuration ################################################*/
  DMA2D_Config();
  
  /*##-3- Start DMA2D transfer ###############################################*/  
  if(HAL_DMA2D_Start_IT(&Dma2dHandle, (uint32_t)&RGB565_150x150, (uint32_t)&aBufferResult, 150, 150) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler(); 
  }

  /* Infinite loop */  
  while (1)
  {
  }
}
Ejemplo n.º 20
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{       
  RCC_PeriphCLKInitTypeDef  PeriphClkInitStruct;
  HAL_StatusTypeDef hal_status = HAL_OK;
  /* Configure the MPU attributes as Write Through */
  MPU_Config();

  /* Enable the CPU Cache */
  CPU_CACHE_Enable();
  
  /* STM32F7xx HAL library initialization:
       - Configure the Flash prefetch
       - 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 */
  SystemClock_Config();


  /*## LTDC 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);  
    
  /* Configure LED1 */
  BSP_LED_Init(LED1);
  
  /*##-1- LCD Configuration ##################################################*/
  LCD_Config();    
  
  /*##-2- DMA2D configuration ################################################*/
  DMA2D_Config(); 
  
  /*##-3- Start DMA2D transfer ###############################################*/  
  hal_status = HAL_DMA2D_Start_IT(&Dma2dHandle, 
                        (uint32_t)&ARGB8888_300x120, /* Input image 300x120 of format ARGB8888 (32 bpp) */
                        (uint32_t)&aBufferResult,    /* Output image of same size 300x120 after conversion by PFC in ARGB4444 (16 bpp) */
                        LAYER_SIZE_X,
                        LAYER_SIZE_Y);
  OnError_Handler(hal_status != HAL_OK);

  
  while (1) 
  { 
    ; 
  }
}
Ejemplo n.º 21
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  uint32_t counter = 0;
  uint8_t  str[30];

  /*!< At this stage the microcontroller clock setting is already configured,
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f429_439xx.s) before to branch to application main.
     */

  /* Example resources configuration -----------------------------------------*/
  /* Configure LCD */
  LCD_Config();

  /* Configure SD Card */
  SDCard_Config();

  /* Configure the File System */
  FileSystem_Config();

  /* Display Background picture ----------------------------------------------*/

  /* Set Background Layer  */
  LCD_SetLayer(LCD_BACKGROUND_LAYER);

  /* Open directory */
  if (f_opendir(&directory, "/BACK") != FR_OK)
  {
    /* Set the Text Color */
    LCD_SetTextColor(LCD_COLOR_RED);

    LCD_DisplayStringLine(LCD_LINE_8, (uint8_t*)"    Open directory.. fails");
    while(1)
    {
    }
  }

  if (Storage_CheckBitmapFile("BACK/image.bmp", &uwBmplen) == 0)
  {
    /* Format the string */
    Storage_OpenReadFile(uwInternelBuffer, "BACK/image.bmp");
    /* Write bmp file on LCD frame buffer */
    LCD_WriteBMP(uwInternelBuffer);
  }
  else
  {
    /* Set the Text Color */
    LCD_SetTextColor(LCD_COLOR_RED);

    LCD_DisplayStringLine(LCD_LINE_8, (uint8_t*)"    File type not supported. ");
    while(1)
    {
    }
  }


  /* Display Foreground pictures ---------------------------------------------*/
  /* Set Foreground Layer  */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);

  /* Decrease the foreground transprency */
  LCD_SetTransparency(200);

  /* Get the BMP file names on root directory */
  ubNumberOfFiles = Storage_GetDirectoryBitmapFiles("/TOP", pDirectoryFiles);

  if (ubNumberOfFiles == 0)
  {
    for (counter = 0; counter < MAX_BMP_FILES; counter++)
    {
      free(pDirectoryFiles[counter]);
    }
    /* Set the Text Color */
    LCD_SetTextColor(LCD_COLOR_RED);

    LCD_DisplayStringLine(LCD_LINE_8, (uint8_t*)"    No Bitmap files...      ");
    while(1)
    {
    }
  }

  while(1)
  {
    counter = 0;

    while (counter < ubNumberOfFiles)
    {
      /* Format the string */
      sprintf ((char*)str, "TOP/%-11.11s", pDirectoryFiles[counter]);

      if (Storage_CheckBitmapFile((const char*)str, &uwBmplen) == 0)
      {
        /* Format the string */
        sprintf ((char*)str, "TOP/%-11.11s", pDirectoryFiles[counter]);

        /* Open a file and copy its content to a buffer */
        Storage_OpenReadFile(uwInternelBuffer, (const char*)str);

        /* Write bmp file on LCD frame buffer */
        LCD_WriteBMP(uwInternelBuffer);

        /* jump to next image */
        counter++;
      }
      else
      {

        /* Set the Text Color */
        LCD_SetTextColor(LCD_COLOR_RED);

        LCD_DisplayStringLine(LCD_LINE_7, (uint8_t *) str);
        LCD_DisplayStringLine(LCD_LINE_8, (uint8_t*)"    File type not supported. ");
        while(1)
        {
        }
      }
    }
  }
}
Ejemplo n.º 22
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  RCC_PeriphCLKInitTypeDef  PeriphClkInitStruct;
  uint32_t toBottom = 0;
  uint32_t toTop = 0;

  /* 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 = 192 Mhz */
    /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/2 = 96 Mhz */
    /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_4 = 96/4 = 24Mhz */
    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
    PeriphClkInitStruct.PLLSAI.PLLSAIN = 192;
    PeriphClkInitStruct.PLLSAI.PLLSAIR = 2;
    PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_4;
    HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);  
  }
  
  /* Configure LED3 */
  BSP_LED_Init(LED3);   
  
  /*##-1- LCD Configuration ##################################################*/ 
  /* Configure 2 layers w/ Blending and CLUT loading for layer 1 */
  LCD_Config(); 

  /*##-2- CLUT Configuration #################################################*/
  HAL_LTDC_ConfigCLUT(&LtdcHandle, (uint32_t *)L8_320x240_CLUT, 256, 0); 
  
  /*##-3- Enable CLUT For Layer 1 ############################################*/
  HAL_LTDC_EnableCLUT(&LtdcHandle, 0);   

  while (1)
  {
    for (toBottom = 0; toBottom < 32; toBottom++)
    {
      /* move the picture */
      /* reconfigure the layer1 position */
      HAL_LTDC_SetWindowPosition(&LtdcHandle, (toBottom*5), (toBottom), 0);
      /* reconfigure the layer2 position */
      HAL_LTDC_SetWindowPosition(&LtdcHandle, (160 - (toBottom*5)), (32 - toBottom), 1);
      HAL_Delay(50);
    }
    HAL_Delay(500);
    for (toTop = 0; toTop < 32; toTop++)
    {
      /* move the picture */
      /* reconfigure the layer1 position */
      HAL_LTDC_SetWindowPosition(&LtdcHandle, (160 - (toTop*5)), (32 - (toTop)), 0);
      /* reconfigure the layer2 position */
      HAL_LTDC_SetWindowPosition(&LtdcHandle, (toTop*5), toTop, 1);
      HAL_Delay(50);
    }
    HAL_Delay(500);
  }
}
Ejemplo n.º 23
0
void main(void)
{
    CAN_TxStatus_TypeDef status = CAN_TxStatus_Failed;

    /* Transmit Parameters */
    CAN_Id_TypeDef Tx_IDE = CAN_Id_Standard;
    CAN_RTR_TypeDef Tx_RTR = CAN_RTR_Data;
    uint8_t Tx_DLC = 0;
    uint8_t Tx_Data[8] = {0};
    uint32_t Tx_Id = 0;

    /* Clock configuration --------------------------------------*/
    CLK_Config();

    /* GPIO Configuration ---------------------------------------*/
    GPIO_Config();

    /* Configure LCD mounted on STM8-128 EVAL board -------------*/
    LCD_Config();

    /* CAN configuration ----------------------------------------*/
    CAN_Config();

    /* Enable Interrupts*/
    enableInterrupts();

    /* Infinite loop*/
    while(1)
    {
        while(Key_status != Key_NoPressed)
        {

            if(Key_Pressed_Number == 0x0)
            {
                Key_Pressed_Number = 0x03;
            }
            else
            {
                Key_Pressed_Number--;
            }

            /* Sender Display*/
            LED_Display(Key_Pressed_Number);
            LCD_Display(Key_Pressed_Number);
            Delay(TIME);

            /* Transmit Parameters*/
            Tx_Id = 0x321;
            Tx_IDE = CAN_Id_Standard;
            Tx_RTR = CAN_RTR_Data;
            Tx_DLC = 1;
            Tx_Data[0] = Key_Pressed_Number;

            /* Sender send Frame */
            status = CAN_Transmit(Tx_Id,Tx_IDE,Tx_RTR,Tx_DLC,Tx_Data);

            /* while key is not pressed, loop*/
            Key_status= Key_NoPressed;
        }
    }
}
Ejemplo n.º 24
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{  
  uwInternelBuffer = (uint8_t *)0xC0260000;
  uint32_t counter = 0;
  uint8_t str[30];
  
  /* 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 175 MHz */
  SystemClock_Config();
  
  /* Configure LED3 */
  BSP_LED_Init(LED3);
  
  /*##-1- Configure LCD ######################################################*/
  LCD_Config();  
  
  /*##-2- Link the SD Card disk I/O driver ###################################*/
  if(FATFS_LinkDriver(&SD_Driver, SD_Path) != 0)
  {
    Error_Handler();
  }
  else
  {
    /*##-3- Initialize the Directory Files pointers (heap) ###################*/
    for (counter = 0; counter < MAX_BMP_FILES; counter++)
    {
      pDirectoryFiles[counter] = malloc(MAX_BMP_FILE_NAME);
      if(pDirectoryFiles[counter] == NULL)
      {
        /* Set the Text Color */
        BSP_LCD_SetTextColor(LCD_COLOR_RED);
        
        BSP_LCD_DisplayStringAtLine(8, (uint8_t*)"  Cannot allocate memory ");
        while(1)
        {
        }       
      }
    }
    
    /*##-4- Display Background picture #######################################*/
    /* Select Background Layer  */
    BSP_LCD_SelectLayer(0);
    
    /* Register the file system object to the FatFs module */
    if(f_mount(&SD_FatFs, (TCHAR const*)SD_Path, 0) != FR_OK)
    {
      /* FatFs Initialization Error */
      /* Set the Text Color */
      BSP_LCD_SetTextColor(LCD_COLOR_RED);
      
      BSP_LCD_DisplayStringAtLine(8, (uint8_t*)"  FatFs Initialization Error ");
    }
    else
    {    
      /* Open directory */
      if (f_opendir(&directory, (TCHAR const*)"/BACK") != FR_OK)
      {
        /* Set the Text Color */
        BSP_LCD_SetTextColor(LCD_COLOR_RED);
        
        BSP_LCD_DisplayStringAtLine(8, (uint8_t*)"    Open directory.. fails");
        while(1)
        {
        } 
      }
    }
    
    if (Storage_CheckBitmapFile("BACK/image.bmp", &uwBmplen) == 0)
    {
      /* Format the string */
      Storage_OpenReadFile(uwInternelBuffer, "BACK/image.bmp");
      /* Write bmp file on LCD frame buffer */
      BSP_LCD_DrawBitmap(0, 0, uwInternelBuffer);
    }
    else
    {
      /* Set the Text Color */
      BSP_LCD_SetTextColor(LCD_COLOR_RED);
      
      BSP_LCD_DisplayStringAtLine(8, (uint8_t*)"    File type not supported. "); 
      while(1)
      {
      }  
    }        
    
    /*##-5- Display Foreground picture #######################################*/
    /* Select Foreground Layer  */
    BSP_LCD_SelectLayer(1);
    
    /* Decrease the foreground transprency */
    BSP_LCD_SetTransparency(1, 200); 
    
    /* Get the BMP file names on root directory */
    ubNumberOfFiles = Storage_GetDirectoryBitmapFiles("/TOP", pDirectoryFiles);
    
    if (ubNumberOfFiles == 0)
    {
      for (counter = 0; counter < MAX_BMP_FILES; counter++)
      {
        free(pDirectoryFiles[counter]);
      }
      /* Set the Text Color */
      BSP_LCD_SetTextColor(LCD_COLOR_RED);
      
      BSP_LCD_DisplayStringAtLine(8, (uint8_t*)"    No Bitmap files...      ");
      while(1)
      {
      } 
    } 
  }
  
  /* Infinite loop */
  while(1)
  { 
    counter = 0;
    
    while (counter < ubNumberOfFiles)
    {
      /* Format the string */
      sprintf ((char*)str, "TOP/%-11.11s", pDirectoryFiles[counter]); 
      
      if (Storage_CheckBitmapFile((const char*)str, &uwBmplen) == 0)
      {
        /* Format the string */
        sprintf ((char*)str, "TOP/%-11.11s", pDirectoryFiles[counter]);
        
        /* Open a file and copy its content to a buffer */
        Storage_OpenReadFile(uwInternelBuffer, (const char*)str);
        
        HAL_Delay(100);
        
        /* Write bmp file on LCD frame buffer */
        BSP_LCD_DrawBitmap(0, 0, uwInternelBuffer);
        
        /* Jump to next image */
        counter++;   
      }
      else
      {
        /* Set the Text Color */
        BSP_LCD_SetTextColor(LCD_COLOR_RED); 
        
        BSP_LCD_DisplayStringAtLine(7, (uint8_t *) str);        
        BSP_LCD_DisplayStringAtLine(8, (uint8_t*)"    File type not supported. "); 
        while(1)
        {
        }    
      }
    }
  }
}
Ejemplo n.º 25
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
  this is done through SystemInit() function which is called from startup
  file (startup_stm32f429_439xx.s) before to branch to application main.
  To reconfigure the default setting of SystemInit() function, refer to
  system_stm32f4xx.c file
  */      
  
  /* User button will be used */
  STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
  
  /* LCD Configuration */
  LCD_Config();
  
  /* Enable Layer1 */
  LTDC_LayerCmd(LTDC_Layer1, ENABLE);
  
  /* Reload configuration of Layer1 */
  LTDC_ReloadConfig(LTDC_IMReload);
  
  /* Enable The LCD */
  LTDC_Cmd(ENABLE);
  
  while (1)
  {
    /* Wait for User push-button is pressed */
    while (STM_EVAL_PBGetState(BUTTON_USER) != Bit_RESET)
    {
    }
    
    /* Wait for User push-button is released */
    while (STM_EVAL_PBGetState(BUTTON_USER) != Bit_SET)
    {
    }
    
    if(ubPressedButton == PRESSED_1)
    {
      /* Set Color Keying to red (RGB = 0xFF0000) */
      LCD_SetColorKeying(0xFF0000);
      
      ubPressedButton = PRESSED_2;  
    }
    else if(ubPressedButton == PRESSED_2) 
    {
      /* Set Color Keying to blue (RGB = 0x0000FF) */
      LCD_SetColorKeying(0xFF);
      
      ubPressedButton = PRESSED_3; 
    }
    else if(ubPressedButton == PRESSED_3) 
    {
      /* Set Color Keying to green (RGB = 0x00FF00) */
      LCD_SetColorKeying(0xFF00);
      
      ubPressedButton = PRESSED_4; 
    }
    else if(ubPressedButton == PRESSED_4) 
    {
      /* Set Color Keying to blue and green (RGB = 0x00FFFF) */
      LCD_SetColorKeying(0xFFFF);
      
      ubPressedButton = PRESSED_5; 
    }
    else if(ubPressedButton == PRESSED_5) 
    {
      /* Set Color Keying to red and green (RGB = 0x00FFFF) */
      LCD_SetColorKeying(0xFFFF00);
      
      ubPressedButton = PRESSED_6; 
    }
    else
    {
      /* Set Color Keying to blue and red (RGB = 0x00FFFF) */ 
      LCD_SetColorKeying(0xFF00FF);
      
      ubPressedButton = PRESSED_1; 
    }      
  }
}
Ejemplo n.º 26
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; 
    }  
  }
}
Ejemplo n.º 27
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
  int main(void)
  {
    uint32_t counter = 0, transparency = 0;
    uint8_t str[30];
     
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f429_439xx.s) before to branch to application main.
     */ 
    
    /* TAMPER button will be used */
    STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE_GPIO); 
    
    /* SysTick end of count event each 10ms */
    SysTick_Config(SystemCoreClock / 1000);

    /* Configure LCD */
    LCD_Config();
    
    /* SD Card Configuration */
    SDCard_Config();    
        
    /* Configure the File System */
    FileSystem_Config();    
      
    /* Get the BMP file names on root directory */
    ubNumberOfFiles = Storage_GetDirectoryBitmapFiles("/PICT", pDirectoryFiles);
    
    if (ubNumberOfFiles == 0)
    {
      for (counter = 0; counter < MAX_BMP_FILES; counter++)
      {
        free(pDirectoryFiles[counter]);
      }
      LCD_DisplayStringLine(LCD_LINE_8, (uint8_t*)"  No Bitmap files...      ");
      while(1)
      {
      }
    }
      
    while(1)
    {     
      counter = 0;
       
      while ((counter) < ubNumberOfFiles)
      {
        /* Step1 : Display on Foreground layer -------------------------------*/ 
        /* Format the string */
        sprintf ((char*)str, "PICT/%-11.11s", pDirectoryFiles[counter]);
         
        if (Storage_CheckBitmapFile((const char*)str, &uwBmplen) == 0) 
        {  
          /* Format the string */        
          sprintf ((char*)str, "PICT/%-11.11s", pDirectoryFiles[counter]);
            
          /* Set LCD foreground Layer */
          LCD_SetLayer(LCD_FOREGROUND_LAYER);
            
          /* Open a file and copy its content to an internal buffer */
          Storage_OpenReadFile(uwInternelBuffer, (const char*)str);
            
          /* Write bmp file on LCD frame buffer */
          LCD_WriteBMP(uwInternelBuffer);  
          
          /* Configure the transparency for background layer : Increase the transparency */
          for (transparency = 0; transparency < 255; (transparency++))
          {        
            LCD_SetTransparency(transparency);
            
            /* Insert a delay of display */
            Delay(5);
          }
            
          /* Wait for tamper button pressed */
          while (STM_EVAL_PBGetState(BUTTON_TAMPER) == Bit_SET)
          {
          }
            
          /* Configure the transparency for foreground layer : decrease the transparency */
          for (transparency = 255; transparency > 0; transparency--)
          {        
            LCD_SetTransparency(transparency);
            
            /* Insert a delay of display */
            Delay(5);
          }
           
          /* Jump to the next image */  
          counter++;
          
          /* Step2 : Display on Background layer -----------------------------*/
          /* Format the string */  
          sprintf ((char*)str, "PICT/%-11.11s", pDirectoryFiles[counter]);
          
          if ((Storage_CheckBitmapFile((const char*)str, &uwBmplen) == 0) || (counter < (ubNumberOfFiles)))
          {         
            /* Connect the Output Buffer to LCD Background Layer  */
            LCD_SetLayer(LCD_BACKGROUND_LAYER);
            
            /* Format the string */  
            sprintf ((char*)str, "PICT/%-11.11s", pDirectoryFiles[counter]);
              
            /* Open a file and copy its content to an internal buffer */
            Storage_OpenReadFile(uwInternelBuffer, (const char*)str);
             
            /* Write bmp file on LCD frame buffer */
            LCD_WriteBMP(uwInternelBuffer);
              
            /* Configure the transparency for background layer : decrease the transparency */  
            for (transparency = 0; transparency < 255; (transparency++))
            {        
              LCD_SetTransparency(transparency);
              
              /* Insert a delay of display */
              Delay(5);
            }
              
            /* wait for tamper button pressed */
            while (STM_EVAL_PBGetState(BUTTON_TAMPER) == Bit_SET)
            {
            }
            
            /* Step3 : -------------------------------------------------------*/              
            /* Configure the transparency for background layer : Increase the transparency */
            for (transparency = 255; transparency > 0; transparency--)
            {        
              LCD_SetTransparency(transparency);
            
              /* Insert a delay of display */
              Delay(5);
            }
            counter++;   
          }
          else if (Storage_CheckBitmapFile((const char*)str, &uwBmplen) == 0)
          {
            /* Set the Text Color */
            LCD_SetTextColor(LCD_COLOR_RED); 
        
            LCD_DisplayStringLine(LCD_LINE_7, (uint8_t *) str);        
            LCD_DisplayStringLine(LCD_LINE_8, (uint8_t*)"    File type not supported. "); 
            while(1)
            {
            }      
          }        
        }  
      }      
    }      
  }
Ejemplo n.º 28
0
int
main(int argc, char* argv[])
{
	volatile FATFS 		fatfs = {0};
	volatile FRESULT 	result;
	uint8_t 			fifo_command = 0;
	uint8_t				file_index = 0;



    ResetRCC();
    RCC_SetClockFrequency(PLLM_macro, PLLN_macro, PLLQ_macro, PLLP_macro);

    //  Enable clocks for the peripherals
    /*
     * 	GPIOA	-	NEC_CONTROLLER, TIM1 PWM, DAC
     * 	GPIOB	- 	SPI2
     * 	GPIOC	-	HD44780 Led Display
     * 	GPIOD	-	LED diodes, USART2(Log)
     */
    RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN | RCC_AHB1ENR_GPIOBEN |  RCC_AHB1ENR_GPIOCEN | RCC_AHB1ENR_GPIODEN;
    RCC->APB2ENR |= RCC_APB2ENR_TIM1EN;
    RCC->APB1ENR |= RCC_APB1ENR_TIM7EN | RCC_APB1ENR_SPI2EN | RCC_APB1ENR_USART2EN | RCC_APB1ENR_DACEN;


    /*< Configure board's leds to signal states */
    GPIO_OutputConfigure(GPIOD, PIN_12 | PIN_13 | PIN_14 | PIN_15, gpio_otyper_push_pull, gpio_speed_high, gpio_pupd_pull_down);
    /*< Configure NVIC Interrupt controller */
    //  Set two bits (out of four) as the main priority. The rest bits are used for preemptive priorities
    NVIC_SetPriorityGrouping(NVIC_PriorityGroup_2);
    NVIC_Enable_Interrupts();

    /*< Configure USART2 module to create program log */
    UART_Config(USART2, USART_CR1_UE | USART_CR1_TE, 19200,false);
    GPIO_AlternateFunctionPrepare(GPIOD, PIN_5, gpio_otyper_push_pull, gpio_speed_medium, gpio_pupd_pull_up);
    GPIO_AlternateFunctionSet(GPIOD,PIN_5, AF7);
    Log_Uart("##### LOG START #####\n\r");

    /*<	MCO2 Pin configuration to watch the CPU Clock signal with an oscilloscope*/
    Log_Uart("Clock output pin configuration in progress...\n\r");
    RCC->CFGR |= RCC_CFGR_MCO2PRE_2 | RCC_CFGR_MCO2PRE_1;
    RCC->CFGR &= ~RCC_CFGR_MCO2;
    GPIO_AlternateFunctionPrepare(GPIOC, PIN_9, gpio_otyper_push_pull, gpio_speed_fast, gpio_pupd_no_pull);
    GPIO_AlternateFunctionSet(GPIOC,PIN_9, AF0);

    /*<	SysTick configuration */
    Log_Uart("SysTick configuration in progress...\n\r");
    SysTick_Config(SYSTICK_CLK_DIVIDER);	//	Configure SysTick to make a tick every 1 us
    SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);


    /*< PWM signal configuration */
    Log_Uart("PWM generation module configuration in progress...\n\r");
    GPIO_AlternateFunctionPrepare(GPIOA, PIN_8, gpio_otyper_push_pull, gpio_speed_fast, gpio_pupd_pull_down);
    GPIO_AlternateFunctionSet(GPIOA, PIN_8, AF1);	//	Pin for PWM signal
    TIM_PWMConfigure(TIM1, 168, 5000, 4000, TIM_Channel_1);
    TIM_Start(TIM1);
    /*< HD44780 display configuration */
    LCD_Config();


    /*< Remote controller receiver initialization */
    Log_Uart("IR remote controller configuration in progress...\n\r");
    NEC_Remote_Init();
    TIM_Start(TIM6);

    /*< SPI Module configuration. It is used to communicate with the SD card */
    Log_Uart("SPI module configuration in progress...\n\r");
    SPI_Master_Init(SPI2, SPI_FREQ_PCLK_DIV_256, SPI_CPOL0_CPHA0, SPI_BIT_ORDER_MSB_FIRST, true);

    /*< DAC configuration */
    DAC_Init(dac_dual_channel_simultanous, dac_trigger_tim7, true);

    /*< Timer 7 used to trigger the DAC config */
    TIM_Basic_Continuous_Counting(TIM7, 12);

    /*< Remote Controller command fifo configuration */
    Log_Uart("FIFO configuration in progress...\n\r");
    Fifo_Init(&remote_command_fifo, remote_command_queue, sizeof(remote_command_queue));


    TIM6->CR1 |= TIM_CR1_CEN;	/*< Continuously ticking timer, used in NEC IR remote */

    Log_Uart("Configuration OK!\n\r");




    TCHAR disk[] = "0";
    UINT byte_number;
    result = f_mount(&fatfs, disk, 1);

    uint16_t bytes;
   /* result = SD_Find_File_Name_Containing("/", "*.wav");
    result = SD_Get_File_List("/");
    result = f_open(&sd_current_file, &sd_files_list[3], FA_READ);
    result = Wav_Get_File_Header(&sd_current_file);
*/
    //	Initially, get the files list
    state = STATE_GET_FILES_LIST;

  while(1)
  {
	  switch(state)
	  {
		 /* case STATE_WAIT:
			  break;*/

		  case	STATE_GET_FILES_LIST:
		  {
			  result = SD_Find_File_Name_Containing("/", "*.wav");
			  if(result == FR_NO_FILE)
			  {
				  LCD_WriteText("Brak plikow .wav");
				  // Go to sleep in this case
				  while(1)
				  {
					  __WFI();
				  }
			  }
			  else
			  {
				  LCD_WriteText(sd_files_list[0]);
			  }
			  state = STATE_EXECUTE_USER_REQUESTS;
			  break;
		  }

		  case STATE_READ_SAMPLES:
		  {
			  //	If we didn't get to the end of file yet...
			  if(!f_eof(&sd_current_file))
				  //	... Then read next sample chunk
				  f_read(&sd_current_file, empty_data_buf_ptr, 512, &read_data_byte_counter);
			  else
				  // 	...	Else set the end of file flag
				  wav_eof = true;
			  state = STATE_EXECUTE_USER_REQUESTS;
			  break;
		  }

		  case STATE_EXECUTE_USER_REQUESTS:
		  {
			  do
			  {
				  Fifo_Get(&remote_command_fifo, &fifo_command);

				  switch(fifo_command)
				  {
					  case NEC_CH_PLUS:
					  {
						  //	Disable when the wav_file is currently played
						  if(!wav_file_playing)
						  {
							  wav_file_chosen = false;
							  if(file_index < sd_number_of_files_in_dir-1)
								  file_index++;

							  LCD_WriteText(sd_files_list[file_index]);
						  }
						  break;
					  }
					  case NEC_CH_MINUS:
					  {
						  //	Disable when the wav_file is currently played
						  if(!wav_file_playing)
						  {
							  wav_file_chosen = false;
							  if(file_index > 0)
								  file_index--;
							  LCD_WriteText(sd_files_list[file_index]);
						  }
						  break;
					  }
					  case NEC_CH:
					  {
						  //	Disable when the wav_file is currently played
						  if(!wav_file_chosen)
						  {

							  //	If the file is already opened then close it
							  if(sd_current_file.fs != 0)
								  f_close(&sd_current_file);
							  //	...Open the chosen file
							  f_open(&sd_current_file, sd_files_list[file_index], FA_READ);
							  //	Get the chosen files header
							  WAV_Get_File_Header(&sd_current_file);
							  //	Prepare the triggering timer frequency
							 // WAV_Set_Trigger_Frequency(TIM7);
							  TIM_Set_Timer_Max_Count(TIM7, (uint16_t)(TIM7_FREQ/current_wave_header.byte_field.sample_rate));
							  //	Get the rest audio file info
							  //f_read(&sd_current_file, sd_data_buffer, current_wave_header.byte_field.subchunk_2_size, &read_data_byte_counter);
							  //	Get the first portion of data

							  //	Set the wav_file_chosen flag
							  wav_file_chosen = true;
							  //	Clear the wav_eof flag
							  wav_eof  = false;

						  }
						  break;
					  }
					  case NEC_PLAY_PAUSE:
					  {
						 if(!wav_file_playing && wav_file_chosen)
						 {
							//	Clear the timer's counter
							TIM_Clear(TIM7);
							TIM7->DIER |= TIM_DIER_UIE;
							empty_data_buf_ptr = sd_data_buffer;
							  f_read(&sd_current_file, sd_data_buffer, sizeof(sd_data_buffer), &read_data_byte_counter);

							  f_read(&sd_current_file, sd_data_buffer_additional, sizeof(sd_data_buffer_additional), &read_data_byte_counter);
							//	Start the DAC triggering timer
							TIM_Start(TIM7);
							//	Set the wav_file_playing_flag
							wav_file_playing = true;
						 }
						 else
						 {
							 //	Stop the DAC triggering timer
							 TIM_Stop(TIM7);

							 //	Clear the wav_file_playing_ flag
							 wav_file_playing = false;
						 }
						 break;
					  }

					  default:
						  break;
				  }
				  fifo_command = 0;
			  }while(!Fifo_Empty(&remote_command_fifo));
			  break;
		  }
	  }
  }
}
Ejemplo n.º 29
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 */
  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 LED1, LED2 and LED3 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  
  /*##-1- LCD Configuration ##################################################*/
  LCD_Config();  
  
  /*##-2- DMA2D configuration ################################################*/
  DMA2D_Config();
  
  /*##-3- Start DMA2D transfer ###############################################*/  
  if(HAL_DMA2D_Start_IT(&Dma2dHandle, 
                        (uint32_t)&ARGB4444_150x150, /* Source buffer in format ARGB4444 and size 150x150      */
                        (uint32_t)&aBufferResult,    /* Destination buffer in format ARGB4444 and size 150x150 */
                        LAYER_SIZE_X, /* width in pixels  */
                        LAYER_SIZE_Y) /* height in pixels */
     != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler(); 
  }
  
  while (1) { ; }
}
Ejemplo n.º 30
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 = 192 Mhz */
    /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/2 = 96 Mhz */
    /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_4 = 96/4 = 24Mhz */
    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
    PeriphClkInitStruct.PLLSAI.PLLSAIN = 192;
    PeriphClkInitStruct.PLLSAI.PLLSAIR = 2;
    PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_4;
    HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);  
  }
  
  /* Configure LED1, LED2 and LED3 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  
  /*##-1- LCD Configuration ##################################################*/
  LCD_Config();    
  
  
  /*##-2- Configure DMA2D : Configure foreground and background ##############*/
  DMA2D_Config();
  
  /*##-3- Start DMA2D transfer in interrupt mode ################################################*/
  /*## RGB565_240x130_1[] is the foreground layer and RGB565_240x130_2[] is the background layer */
  if(HAL_DMA2D_BlendingStart_IT(&Dma2dHandle, 
                                (uint32_t)&RGB565_240x130_1, 
                                (uint32_t)&RGB565_240x130_2, 
                                (uint32_t)&aBlendedImage, 
                                LAYER_SIZE_X, 
                                LAYER_SIZE_Y) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler(); 
  }
  
  while (1) { ; }
}