Example #1
0
/**
  * @brief  Initializes LEDs, SDRAM, touch screen, CRC and SRAM.
  * @param  None 
  * @retval None
  */
void k_BspInit(void)
{
  
  BSP_IO_Init();
  
  /* Initialize the NOR */
  BSP_NOR_Init();
  
  /* Initialize the SDRAM */
  BSP_SDRAM_Init();  
  
  /* Initialize the Touch screen */
  BSP_TS_Init(640, 480);
  
  /* Enable CRC to Unlock GUI */
 __HAL_RCC_CRC_CLK_ENABLE();
  
 /* Enable Back up SRAM */
__HAL_RCC_BKPSRAM_CLK_ENABLE();
  
}
Example #2
0
/**
  * @brief  NOR Demo
  * @param  None
  * @retval None
  */
void NOR_demo(void)
{ 
  /* NOR IDs structure */
  static NOR_IDTypeDef pNOR_ID;

  NOR_SetHint();

  /* STM32F427x/437x/429x/439x "Revision 3" devices: FMC dynamic and static 
     bank switching is allowed  */
  if (HAL_GetREVID() >= 0x2000) {}
  else
  {
    /* Disable the LCD to avoid the refrech from the SDRAM */
    BSP_LCD_DisplayOff();
  }
  
  /*##-1- Configure the NOR device ###########################################*/
  /* NOR device configuration */ 
  if(BSP_NOR_Init() != NOR_STATUS_OK)
  {
    ubInitStatus++; 
  }
  
  /*##-2- Read & check the NOR device IDs ####################################*/
  /* Initialize the ID structure */
  pNOR_ID.Manufacturer_Code = (uint16_t)0x00;
  pNOR_ID.Device_Code1 = (uint16_t)0x00;
  pNOR_ID.Device_Code2 = (uint16_t)0x00;
  pNOR_ID.Device_Code3 = (uint16_t)0x00;
  
  /* Read the NOR memory ID */
  BSP_NOR_Read_ID(&pNOR_ID);
  
  /* Test the NOR ID correctness */
  if(pNOR_ID.Manufacturer_Code != (uint16_t)0x0020)
    ubIDStatus++;
  else if(pNOR_ID.Device_Code1 != (uint16_t)0x227E)
    ubIDStatus++;
  else if (pNOR_ID.Device_Code2 != (uint16_t)0x2221)
    ubIDStatus++;
  else if (pNOR_ID.Device_Code3 != (uint16_t)0x2200)
    ubIDStatus++;
    
  /*##-3- Erase NOR memory ###################################################*/ 
  /* Return to read mode */
  BSP_NOR_ReturnToReadMode();
    
  if(BSP_NOR_Erase_Block(WRITE_READ_ADDR) != NOR_STATUS_OK)
  {
    ubEraseStatus++; 
  }
  
  /*##-4- NOR memory read/write access  ######################################*/   
  /* Fill the buffer to write */
  Fill_Buffer(nor_aTxBuffer, BUFFER_SIZE, 0xC20F);   
  
  /* Write data to the NOR memory */
  if(BSP_NOR_WriteData(WRITE_READ_ADDR, nor_aTxBuffer, BUFFER_SIZE) != NOR_STATUS_OK)
  {
    ubWriteStatus++; 
  }
  
  /* Read back data from the NOR memory */
  if(BSP_NOR_ReadData(WRITE_READ_ADDR, nor_aRxBuffer, BUFFER_SIZE) != NOR_STATUS_OK)
  {
    ubReadStatus++; 
  }

  /*##-5- Checking data integrity ############################################*/  
  /* STM32F427x/437x/429x/439x "Revision 3" devices: FMC dynamic and static 
     bank switching is allowed  */
  if (HAL_GetREVID() >= 0x2000) {}
  else
  {
    /* Enable the LCD */
    BSP_LCD_DisplayOn();
    
    /* SDRAM initialization */
    BSP_SDRAM_Init();
  }
  
  if(ubIDStatus != 0)
  {
    BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"NOR Read ID : FAILED.", LEFT_MODE);
    BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"NOR Test Aborted.", LEFT_MODE);
  }
  else
  {
    if(ubInitStatus != 0)
    {
      BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"NOR Initialization : FAILED.", LEFT_MODE);
      BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"NOR Test Aborted.", LEFT_MODE);
    }
    else
    {
      BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"NOR Initialization : OK.", LEFT_MODE);
    }  
    if(ubEraseStatus != 0)
    {
      BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"NOR ERASE : FAILED.", LEFT_MODE);
      BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"NOR Test Aborted.", LEFT_MODE);
    }
    else
    {
      BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"NOR ERASE : OK.   ", LEFT_MODE);
    }
    if(ubWriteStatus != 0)
    {
      BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"NOR WRITE : FAILED.", LEFT_MODE);
      BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"NOR Test Aborted.", LEFT_MODE);
    }
    else
    {
      BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"NOR WRITE : OK.     ", LEFT_MODE);
    }
    if(ubReadStatus != 0)
    {
      BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"NOR READ : FAILED.", LEFT_MODE);
      BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"NOR Test Aborted.", LEFT_MODE);
    }
    else
    {
      BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"NOR READ :  OK.    ", LEFT_MODE);
    }    
    if(Buffercmp(nor_aRxBuffer, nor_aTxBuffer, BUFFER_SIZE) > 0)
    {
      BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"NOR COMPARE : FAILED.", LEFT_MODE);
      BSP_LCD_DisplayStringAt(20, 175, (uint8_t *)"NOR Test Aborted.", LEFT_MODE);
    }
    else
    {    
      BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"NOR Test : OK.     ", LEFT_MODE);
    }
  }
  
  while (1)
  {    
    if(CheckForUserInput() > 0)
    {
      return;
    }
  }
}