Exemplo n.º 1
0
//{{{
DSTATUS SD_initialize (BYTE lun) {

  Stat = STA_NOINIT;
  if (BSP_SD_Init() == MSD_OK)
    Stat &= ~STA_NOINIT;
  return Stat;
  }
Exemplo n.º 2
0
/**
  * @brief  Initializes the SD Storage.
  * @param  None
  * @retval Status
  */
uint8_t SD_StorageInit(void)
{
  /*Initializes the SD card device*/
  BSP_SD_Init();
  
  /* Check if the SD card is plugged in the slot */
  if(BSP_SD_IsDetected() == SD_PRESENT )
  {
    /* Link the SD Card disk I/O driver */
    if(FATFS_LinkDriver(&SD_Driver, SD_Path) == 0)
    {
      if((f_mount(&SD_FatFs, (TCHAR const*)SD_Path, 0) != FR_OK))
      {
        /* FatFs Initialization Error */
        LCD_ErrLog("Cannot Initialize FatFs! \n");
        return 1;
      }
      else
      {
        LCD_DbgLog ("INFO : FatFs Initialized! \n");
      }
    }  
  }
  else
  {
    LCD_ErrLog("SD card NOT plugged \n");
    return 1;
  }
  return 0;
}
Exemplo n.º 3
0
/**
  * @brief  Callback function of the File Control page
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbFileControl(WM_MESSAGE * pMsg)
{
  WM_HWIN hItem;
  int     NCode;
  int     Id;
  int     result;  
  
  switch (pMsg->MsgId)
  {
  case WM_INIT_DIALOG:
    /* Initialization of 'Brightness' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_FOLDER_CAPTION);
    TEXT_SetFont(hItem, GUI_FONT_13B_1);
    hItem = WM_GetDialogItem(pMsg->hWin, ID_FOLDER);
    EDIT_SetText(hItem, (char *)capture_folder);

    break;
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id)
    {
    case ID_BROWSE: /* Notifications sent by 'Radio' */
      switch(NCode)
      {
      case WM_NOTIFICATION_RELEASED:
        pFileInfo->pfGetData = k_GetData;
        pFileInfo->pMask = acMask_folder;
        BSP_SD_Init();
        SD_Configured = 1;
        
        chooser_select_folder = CHOOSEFILE_Create(CAMERA_hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "Select a folder", 0, pFileInfo);

        result = GUI_ExecCreatedDialog(chooser_select_folder);
        if (result == 0) 
        {  
          if(((pFileInfo->pRoot[0] == '0' ) || (pFileInfo->pRoot[0] == '1' )))
          {
            hItem = WM_GetDialogItem(hDialogFileControl, ID_FOLDER);
            EDIT_SetText(hItem, (char *)pFileInfo->pRoot);
            chooser_select_folder = 0;
            WM_InvalidateWindow(hDialogFileControl);
            WM_Paint(hDialogFileControl);
            strncpy((char *)(CAMERA_SAVE_PATH),pFileInfo->pRoot , FILEMGR_FULL_PATH_SIZE);
            strncpy((char *)capture_folder,pFileInfo->pRoot , FILEMGR_FULL_PATH_SIZE);
          }          
        }

        break;
      }
      break;
    }
    break;
    
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Exemplo n.º 4
0
/**
  * @brief  SD Card Configuration.
  * @param  None
  * @retval None
  */
static void SDCard_Config(void)
{
  uint32_t counter = 0;
  
  if(FATFS_LinkDriver(&SD_Driver, SD_Path) == 0)
  {
    /* Initialize the SD mounted on adafruit 1.8" TFT shield */
    if(BSP_SD_Init() != MSD_OK)
    {
      TFT_DisplayErrorMessage(BSP_SD_INIT_FAILED);
    }  
    
    /* Check the mounted device */
    if(f_mount(&SD_FatFs, (TCHAR const*)"/", 0) != FR_OK)
    {
      TFT_DisplayErrorMessage(FATFS_NOT_MOUNTED);
    }  
    else
    {
      /* Initialize the Directory Files pointers (heap) */
      for (counter = 0; counter < MAX_BMP_FILES; counter++)
      {
        pDirectoryFiles[counter] = malloc(11); 
      }
    }
  }
}
Exemplo n.º 5
0
/**
  * @brief  Storage drives initialization
  * @param  None 
  * @retval None
  */
void k_StorageInit(void)
{
  /* Link the USB Host disk I/O driver */
   FATFS_LinkDriver(&USBH_Driver, USBDISK_Drive);
  
  /* Link the micro SD disk I/O driver */
   FATFS_LinkDriver(&SD_Driver, mSDDISK_Drive);  

  /* Create USB background task */
  osThreadDef(STORAGE_Thread, StorageThread, osPriorityBelowNormal, 0, 2 * configMINIMAL_STACK_SIZE);
  osThreadCreate (osThread(STORAGE_Thread), NULL);
  
  /* Create Storage Message Queue */
  osMessageQDef(osqueue, 10, uint16_t);
  StorageEvent = osMessageCreate (osMessageQ(osqueue), NULL);
  
  /* Init Host Library */
  USBH_Init(&hUSB_Host, USBH_UserProcess, 0);
  
  /* Add Supported Class */
  USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS);
  
  /* Start Host Process */
  USBH_Start(&hUSB_Host);
  
  /* Enable SD Interrupt mode */
  BSP_SD_Init();
  BSP_SD_ITConfig();
  
  if(BSP_SD_IsDetected())
  {
    osMessagePut ( StorageEvent, MSDDISK_CONNECTION_EVENT, 0);
  }
}
Exemplo n.º 6
0
/**
  * @brief  SDCARD Initialization for FatFs
  * @param  None
  * @retval err : Error status (0=> success, 1=> fail)
  */
uint32_t Storage_Init(void)
{
  BSP_SD_Init();
  
  /****************** FatFs Volume Access ******************************/
  if(f_mount(&fs, (TCHAR const*)"",0))
  {
    return 1;
  }
  return 0;
}
Exemplo n.º 7
0
/**
  * @brief  SDCARD Initialization for FatFs
  * @param  None
  * @retval err : Error status (0=> success, 1=> fail)
  */
uint32_t Storage_Init(void)
{
  BSP_SD_Init();
  
  /****************** FatFs Volume Acess ******************************/
  if (f_mount(0, &fs))
  {
    return 1;
  }
  return 0;
}
/**
  * @brief  Save the data to specified file.
  * @param  path: pointer to the saving path
  * @retval File saved
  */
uint8_t  CAMERA_SaveToFile(uint8_t *path)
{
  RTC_TimeTypeDef   Time;
  RTC_DateTypeDef   Date;
  FIL               file;
  uint32_t  NumWrittenData;
  uint8_t ret = 1;

  char filename[FILEMGR_FILE_NAME_SIZE];
  char fullpath[FILEMGR_FILE_NAME_SIZE];

    /* Create filename */
    k_GetTime(&Time);
    k_GetDate(&Date);
    sprintf((char *)filename, "/Camera_%02d%02d%04d_%02d%02d%02d.bmp",
            Date.Date,
            Date.Month,
            Date.Year + 2015,
            Time.Hours,
            Time.Minutes,
            Time.Seconds);
    strcpy((char *)fullpath, (char *)path);
    strcat ((char *)fullpath, (char *)filename);

    BSP_CAMERA_Suspend();

    BSP_SD_Init();


    /* Can not create file */
    if (f_open(&file, (char *)fullpath, FA_CREATE_NEW | FA_WRITE) == FR_OK)
    {
      /* Write the received data into the file */
      if (f_write(&file, (char *)BMPHeader_QQVGA24Bit, RGB_HEADER_SIZE, (UINT *)&NumWrittenData) == FR_OK)
      {
        f_sync(&file);
        /* Convert RGB16 image to RGB24 */
        RGB16toRGB24((uint8_t *)CAMERA_CVRT_BUFFER, (uint8_t *)&buffer_camera);

        if (f_write(&file, (char *)CAMERA_CVRT_BUFFER, MAX_IMAGE_SIZE, (UINT*)&NumWrittenData)== FR_OK)
        {
          /*File Written correctly */
          ret = 0;
        }

      }
      f_close(&file);
    }

    BSP_CAMERA_Init(RESOLUTION_R160x120);
    CAMERA_Configured = 1;
    BSP_CAMERA_Resume();
    return ret;
}
DSTATUS TM_FATFS_SD_SDIO_disk_initialize(void) {
	Stat = STA_NOINIT;

	/* Configure the SDCARD device */
	if (BSP_SD_Init() == MSD_OK) {
		Stat &= ~STA_NOINIT;
	} else {
		Stat |= STA_NOINIT;
	}

	return Stat;
}
Exemplo n.º 10
0
/**
  * @brief  Initializes a Drive
  * @param  None
  * @retval DSTATUS: Operation status
  */
DSTATUS SD_initialize(void)
{
  Stat = STA_NOINIT;
  
  /* Configure the uSD device */
  if(BSP_SD_Init() == MSD_OK)
  {
    Stat &= ~STA_NOINIT;
  }

  return Stat;
}
Exemplo n.º 11
0
int main(void){

	uint8_t  lcd_status = LCD_OK;

	CPU_CACHE_Enable();

	HAL_Init();

	/* Configura el reloj del sistema en 200 Mhz */
	SystemClock_Config();

	BSP_LED_Init(LED1);

	/*Configura el botón de usuario en modo GPIO*/
	BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);

	/*Inicializar LCD*/
	lcd_status = BSP_LCD_Init();
	if(lcd_status != LCD_OK)
		while(1);

	/*Inicializa LCD Layers*/
	BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, SDRAM_DEVICE_ADDR);

	Display_Description();

	uint8_t detectSD = 0;
	uint8_t SD_state = MSD_OK;

	while(1){
		if(BSP_PB_GetState(BUTTON_KEY) != 0){
			HAL_Delay(500);
			Display_Description();
			detectSD = 1;
		}
		if(detectSD){
			detectSD = 0;
			SD_state = BSP_SD_Init();
			if(SD_state != MSD_OK){
				BSP_LCD_ClearStringLine(11);
				BSP_LCD_ClearStringLine(12);
				BSP_LCD_DisplayStringAt(0, (BSP_LCD_GetYSize()/2.5)+25, (uint8_t *)"Tarjeta SD no encontrada", CENTER_MODE);
			}
			else{
				BSP_LCD_ClearStringLine(11);
				BSP_LCD_ClearStringLine(12);
				BSP_LCD_DisplayStringAt(0, (BSP_LCD_GetYSize()/2.5)+25, (uint8_t *)"Tarjeta SD encontrada", CENTER_MODE);
			}
		}
	}
}
Exemplo n.º 12
0
/**
  * @brief  SD detect callback
  * @param  None
  * @retval None
  */ 
void BSP_SD_DetectCallback(void)
{
  if((BSP_SD_IsDetected()))
  {  
    /* After sd disconnection, a SD Init is required */
    BSP_SD_Init();
        
    osMessagePut ( StorageEvent, MSDDISK_CONNECTION_EVENT, 0);
  }
  else
  {
    osMessagePut ( StorageEvent, MSDDISK_DISCONNECTION_EVENT, 0);
  }
}
Exemplo n.º 13
0
/**
  * @brief  Stop the camera capture.
  * @param  None
  * @retval None
  */
void CAMERA_Stop(void)
{
  if( CameraError != CAMERA_ERROR)
  {  
    /* Disable Camera request and Disable DCMI capture */
    BSP_CAMERA_Stop(); 
  }
  
  /* After SD disconnection, a SD Init is required */
  BSP_SD_Init();  
  
  /* Restore Audio configuration */
  k_BspAudioInit();
}
Exemplo n.º 14
0
/**
  * @brief EXTI line detection callbacks.
  * @param GPIO_Pin: Specifies the pins connected EXTI line
  * @retval None
  */
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
  if(GPIO_Pin == MFX_IRQOUT_PIN)
  {   
    if(BSP_SD_IsDetected())
    {
      if(CAMERA_Configured == 0)
      {
        BSP_SD_Init();
      }
        osMessagePut ( StorageEvent, MSDDISK_CONNECTION_EVENT, 0);     
    }
    else
    {
      osMessagePut ( StorageEvent, MSDDISK_DISCONNECTION_EVENT, 0);
    }
  }
}
Exemplo n.º 15
0
/**
  * @brief  Checks whether the medium is ready.  
  * @param  lun: Logical unit number
  * @retval Status (0: Ok / -1: Error)
  */
int8_t STORAGE_IsReady(uint8_t lun)
{
  int8_t ret = -1;
  
  if(k_StorageGetStatus (MSD_DISK_UNIT) == 1)
  {
    if(prev_state == 0)
    {     
        BSP_SD_Init();
    }
    prev_state = 1;
    ret = 0;
  }
  else if(prev_state == 1)
  {
    prev_state = 0; 
  }
  return ret;
}
Exemplo n.º 16
0
/**
  * @brief  SD Demo exti detection
  * @param  None
  * @retval None
  */
void SD_exti_demo (void)
{ 
  uint32_t ITstatus = 0;

  SD_main_test();

  if(BSP_SD_IsDetected() != SD_PRESENT)
  {
        BSP_SD_Init();
        BSP_LCD_SetTextColor(LCD_COLOR_RED);
        BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Not Connected", LEFT_MODE);
  }
  else 
  {
      BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
      BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30,   (uint8_t *)"SD Connected    ", LEFT_MODE);
  }

  BSP_SD_ITConfig();

  while (1)
  {
    if (MfxExtiReceived == 1)
    {
      MfxExtiReceived = 0;
      ITstatus = BSP_IO_ITGetStatus(SD_DETECT_PIN);
      if (ITstatus)
      {
        SD_Detection();
      }
      BSP_IO_ITClear();
      }
    
    if(CheckForUserInput() > 0)
    {
      BSP_SD_DeInit();
      return;
    }
  }
}
Exemplo n.º 17
0
/**
  * @brief  Checks whether the medium is ready.  
  * @param  lun: Logical unit number
  * @retval Status (0: OK / -1: Error)
  */
int8_t STORAGE_IsReady(uint8_t lun)
{
  static int8_t prev_status = 0;
  int8_t ret = -1;
  
//  if(BSP_SD_IsDetected() != SD_NOT_PRESENT)
  {
    if(prev_status < 0)
    {
      BSP_SD_Init();
      prev_status = 0;
      
    }
    if(BSP_SD_GetStatus() == MSD_OK)
    {
      ret = 0;
    }
  }
//  else if(prev_status == 0)
//  {
//    prev_status = -1;
//  }
  return ret;
}
Exemplo n.º 18
0
/**
  * @brief  Stop the camera capture.
  * @param  None
  * @retval None
  */
void CAMERA_Stop(void)
{
  GPIO_InitTypeDef GPIO_InitStruct;
  if( CameraError != CAMERA_ERROR)
  {
    /* Disable Camera request and Disable DCMI capture */
    BSP_CAMERA_Stop();

    /* QSPI CLK GPIO pin reconfiguration  */
    GPIO_InitStruct.Pin       = QSPI_CS_PIN;
    GPIO_InitStruct.Mode      = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Speed     = GPIO_SPEED_HIGH;

    GPIO_InitStruct.Pin       = QSPI_CLK_PIN;
    GPIO_InitStruct.Pull      = GPIO_NOPULL;
    GPIO_InitStruct.Alternate = GPIO_AF9_QSPI;
    HAL_GPIO_Init(QSPI_CLK_GPIO_PORT, &GPIO_InitStruct);

    /* Msp SD initialization */
    BSP_SD_Init();

    CAMERA_Configured = 0;
  }
}
Exemplo n.º 19
0
/**
  * @brief  Checks whether the medium is ready.  
  * @param  lun: Logical unit number
  * @retval Status (0: Ok / -1: Error)
  */
int8_t STORAGE_IsReady(uint8_t lun)
{
  static int8_t prev_status = 0;
  int8_t ret = -1;
  
  if(BSP_SD_IsDetected() != SD_NOT_PRESENT)
  {
    if(prev_status < 0)
    {
      BSP_SD_Init();
      prev_status = 0;
      
    }
    if(BSP_SD_GetStatus() == SD_TRANSFER_OK)
    {
      ret = 0;
    }
  }
  else if(prev_status == 0)
  {
    prev_status = -1;
  }
  return ret;
}
Exemplo n.º 20
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{  
  uint32_t counter = 0;
  uint8_t str[30];

  uwInternelBuffer = (uint8_t *)0xC0260000;

  /* 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
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();
  
  /* Configure the system clock to 200 MHz */
  SystemClock_Config();

  /* Configure LED3 */
  BSP_LED_Init(LED3);
  
  /*##-1- Configure LCD ######################################################*/
  LCD_Config();  

  BSP_SD_Init();
    
  while(BSP_SD_IsDetected() != SD_PRESENT)
  {
        BSP_LCD_SetTextColor(LCD_COLOR_RED);
        BSP_LCD_DisplayStringAtLine(8, (uint8_t*)"  Please insert SD Card                  ");
  }
  
  BSP_LCD_Clear(LCD_COLOR_BLACK);
  
  /*##-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 transparency */
    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)
        {
        }    
      }
    }
  }
}
Exemplo n.º 21
0
bool _mmcsd_idle(unsigned int unit_nr)
{
	if(card_detect != NULL)
	{
		gpio_idle(card_detect);
		if(card_detect->event.state_up)
		{
			card_detect->event.state_up = false;
			card_detected = false;
		}
	}
	if(card_detect == NULL || card_detect->event.state_dn)
	{
		HAL_SD_ErrorTypedef res = SD_OK;
		res =  BSP_SD_Init();
		if(res != SD_OK)
		{
			if(card_detect != NULL)
				card_detect->event.state_dn = false;
			//if(DebugCom)
				//UARTprintf(DebugCom,   "MMCSD%d ERROR initializing card.\n\r" , 0);
			card_detected = false;
			return false;
		}
		if(card_detect != NULL)
			card_detect->event.state_dn = false;
        MmcSdFatFs.drv_rw_func.DriveStruct = (void *)&uSdCardInfo;//SdStruct;
        MmcSdFatFs.drv_rw_func.drv_r_func = _mmcsd_read;
        MmcSdFatFs.drv_rw_func.drv_w_func = _mmcsd_write;
#if (_FFCONF == 82786)
        if(!f_mount(2, &MmcSdFatFs))
#else
        if(!f_mount(&MmcSdFatFs,"SD1:", 1))
#endif
        {
                    if(f_opendir(&g_sDirObject, g_cCwdBuf0) == FR_OK)
                    {
#ifdef MMCSD_DEBUG_EN
						if(DebugCom)
						{
							uart.printf(DebugCom,   "MMCSD%d drive %d mounted\n\r" , 0 , 0);
							uart.printf(DebugCom,   "MMCSD%d Fat fs detected\n\r" , 0);
							uart.printf(DebugCom, "MMCSD%d Fs type:                 " , 0);
							if(MmcSdFatFs.fs_type == FS_FAT12)	{
								uart.printf(DebugCom, "Fat12");}
							else if(MmcSdFatFs.fs_type == FS_FAT16){
								uart.printf(DebugCom, "Fat16");}
							else if(MmcSdFatFs.fs_type == FS_FAT32){
								uart.printf(DebugCom, "Fat32");}
							else if(MmcSdFatFs.fs_type == FS_EXFAT){
								uart.printf(DebugCom, "exFat");}
							else								{ 				uart.printf(DebugCom, "None");}
							uart.printf(DebugCom, "\n\r");
																				//UARTprintf(DebugCom, "MMCSD0 BootSectorAddress:       %u \n\r",(unsigned int)g_sFatFs.);
							uart.printf(DebugCom, "MMCSD%d BytesPerSector:          %d \n\r",0, /*(int)g_sFatFs.s_size*/512);
							uart.printf(DebugCom, "MMCSD%d SectorsPerCluster:       %d \n\r",0, (int)MmcSdFatFs.csize);
																				//UARTprintf(DebugCom, "MMCSD0 AllocTable1Begin:        %u \n\r",(unsigned int)g_sFatFs.fatbase);
																				//UARTprintf(DebugCom, "MMCSD%d NumberOfFats:            %d \n\r",0, (int)MmcSdFatFs.n_fats);
																				//UARTprintf(DebugCom, "MMCSD0 MediaType:               %d \n\r",Drives_Table[0]->DiskInfo_MediaType);
																				//UARTprintf(DebugCom, "MMCSD0 AllocTableSize:          %u \n\r",Drives_Table[0]->DiskInfo_AllocTableSize);
																				//UARTprintf(DebugCom, "MMCSD%d DataSectionBegin:        %d \n\r",0, (int)MmcSdFatFs.fatbase);
							uart.printf(DebugCom, "MMCSD%d uSD DiskCapacity:        %uMB\n\r",0, (unsigned long)((unsigned long long)((unsigned long long)MmcSdFatFs.n_fatent * (unsigned long long)/*g_sFatFs.s_size*/512 *(unsigned long long)MmcSdFatFs.csize) / 1000000));
						}
#endif
			        	card_detected = true;
                    } else
                    {
                    	if(DebugCom)										uart.printf(DebugCom,   "MMCSD%d ERROR oppening path\n\r" , 0);
                    	card_detected = false;
                    }
        }
        else
        {
        	if(DebugCom)												uart.printf(DebugCom,   "MMCSD%d ERROR mounting disk\n\r" , 0);
        	card_detected = false;
        }
	}
	return card_detected;
}
Exemplo n.º 22
0
/**
  * @brief  Initailizes the storage unit (medium)       
  * @param  lun: Logical unit number
  * @retval Status (0 : Ok / -1 : Error)
  */
int8_t STORAGE_Init(uint8_t lun)
{
  BSP_SD_Init();
  return 0;
}
Exemplo n.º 23
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  uint32_t counter = 0, transparency = 0;
  uint8_t str[30];
  uwInternelBuffer = (uint8_t *)0xC0260000;

  /* 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
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();
  
  /* Configure the system clock to 200 MHz */
  SystemClock_Config();
  
  /* Configure LED3 */
  BSP_LED_Init(LED3);
  
  /*##-1- Configure LCD ######################################################*/
  LCD_Config(); 
  
  /* Configure TAMPER Button */
  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);   

  BSP_SD_Init();

  while(BSP_SD_IsDetected() != SD_PRESENT)
  {
        BSP_LCD_SetTextColor(LCD_COLOR_RED);
        BSP_LCD_DisplayStringAtLine(8, (uint8_t*)"  Please insert SD Card                  ");
  }
  
  BSP_LCD_Clear(LCD_COLOR_BLACK);
  
  /*##-2- Link the SD Card disk I/O driver ###################################*/
  if(FATFS_LinkDriver(&SD_Driver, SD_Path) == 0)
  {
    /*##-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)
        {
        }       
      }
    }
    
    /* Get the BMP file names on root directory */
    ubNumberOfFiles = Storage_GetDirectoryBitmapFiles("/Media", pDirectoryFiles);
    
    if (ubNumberOfFiles == 0)
    {
      for (counter = 0; counter < MAX_BMP_FILES; counter++)
      {
        free(pDirectoryFiles[counter]);
      }
      BSP_LCD_DisplayStringAtLine(8, (uint8_t*)"  No Bitmap files...      ");
      while(1)
      {
      }
    }
  }
  else
  {
    /* FatFs Initialization Error */
    Error_Handler();    
  }
  while(1)
  {     
    counter = 0;
    
    while ((counter) < ubNumberOfFiles)
    {
      /* Step1 : Display on Foreground layer -------------------------------*/ 
      /* Format the string */
      sprintf ((char*)str, "Media/%-11.11s", pDirectoryFiles[counter]);
      
      if (Storage_CheckBitmapFile((const char*)str, &uwBmplen) == 0) 
      {  
        /* Format the string */        
        sprintf ((char*)str, "Media/%-11.11s", pDirectoryFiles[counter]);
        
        /* Set LCD foreground Layer */
        BSP_LCD_SelectLayer(1);
        
        /* Open a file and copy its content to an internal buffer */
        Storage_OpenReadFile(uwInternelBuffer, (const char*)str);
        
        /* Write bmp file on LCD frame buffer */
        BSP_LCD_DrawBitmap(0, 0, uwInternelBuffer);  
        
        /* Configure the transparency for background layer : Increase the transparency */
        for (transparency = 0; transparency < 255; (transparency++))
        {        
          BSP_LCD_SetTransparency(1, transparency);
          
          /* Insert a delay of display */
          HAL_Delay(2);
        }
        
        /* Wait for tamper button pressed */
        while (BSP_PB_GetState(BUTTON_TAMPER) == RESET)
        {
        }
        
        /* Configure the transparency for foreground layer : decrease the transparency */
        for (transparency = 255; transparency > 0; transparency--)
        {        
          BSP_LCD_SetTransparency(1, transparency);
          
          /* Insert a delay of display */
          HAL_Delay(2);
        }

        /* Clear the Foreground Layer */ 
        BSP_LCD_Clear(LCD_COLOR_BLACK);
        
        /* Jump to the next image */  
        counter++;
        
        /* Step2 : Display on Background layer -----------------------------*/
        /* Format the string */  
        sprintf ((char*)str, "Media/%-11.11s", pDirectoryFiles[counter]);
        
        if ((Storage_CheckBitmapFile((const char*)str, &uwBmplen) == 0) || (counter < (ubNumberOfFiles)))
        {         
          /* Connect the Output Buffer to LCD Background Layer  */
          BSP_LCD_SelectLayer(0);
          
          /* Format the string */  
          sprintf ((char*)str, "Media/%-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 */
          BSP_LCD_DrawBitmap(0, 0, uwInternelBuffer);
          
          /* Configure the transparency for background layer : decrease the transparency */  
          for (transparency = 0; transparency < 255; (transparency++))
          {        
            BSP_LCD_SetTransparency(0, transparency);
            
            /* Insert a delay of display */
            HAL_Delay(2);
          }
          
          /* wait for tamper button pressed */
          while (BSP_PB_GetState(BUTTON_TAMPER) == RESET)
          {
          }
          
          /* Step3 : -------------------------------------------------------*/              
          /* Configure the transparency for background layer : Increase the transparency */
          for (transparency = 255; transparency > 0; transparency--)
          {        
            BSP_LCD_SetTransparency(0, transparency);
            
            /* Insert a delay of display */
            HAL_Delay(2);
          }

          /* Clear the Background Layer */
          BSP_LCD_Clear(LCD_COLOR_BLACK);

          counter++;   
        }
        else if (Storage_CheckBitmapFile((const char*)str, &uwBmplen) == 0)
        {
          /* 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)
          {
          }      
        }        
      }  
    }      
  }
}
Exemplo n.º 24
0
/**
  * @brief  Main part of SD Demo Test
  * @param  None
  * @retval None
  */
void SD_main_test (void)
{ 
  uint8_t SD_state = SD_OK;

  SD_SetHint();
  SD_state = BSP_SD_Init();
  
  if(SD_state != SD_OK)
  {
    if(SD_state == MSD_ERROR_SD_NOT_PRESENT)
    {
      BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SD shall be inserted before running test", LEFT_MODE);
    }
    else
    {
      BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SD Initialization : FAIL.", LEFT_MODE);
    }
    BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
  }
  else
  {
    BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SD Initialization : OK.", LEFT_MODE);
    
    SD_state = BSP_SD_Erase(BLOCK_START_ADDR, (BLOCKSIZE * NUM_OF_BLOCKS));
    
    if(SD_state != SD_OK)
    {
      BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD ERASE : FAILED.", LEFT_MODE);
      BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
    }
    else
    {
      BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD ERASE : OK.", LEFT_MODE);
      
      /* Fill the buffer to write */
      Fill_Buffer(aTxBuffer, BUFFER_WORDS_SIZE, 0x22FF);
      SD_state = BSP_SD_WriteBlocks(aTxBuffer, BLOCK_START_ADDR, BLOCKSIZE, NUM_OF_BLOCKS);
      
      if(SD_state != SD_OK)
      {
        BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD WRITE : FAILED.", LEFT_MODE);
        BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
      }
      else
      {
        BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD WRITE : OK.", LEFT_MODE);
        SD_state = BSP_SD_ReadBlocks(aRxBuffer, BLOCK_START_ADDR, BLOCKSIZE, NUM_OF_BLOCKS);
        if(SD_state != SD_OK)
        {
          BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD READ : FAILED.", LEFT_MODE);
          BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
        }
        else
        {
          BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD READ : OK.", LEFT_MODE);
          if(Buffercmp(aTxBuffer, aRxBuffer, BUFFER_WORDS_SIZE) > 0)
          {
            BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD COMPARE : FAILED.", LEFT_MODE);
            BSP_LCD_DisplayStringAt(20, 175, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
          }
          else
          {
            BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD Test : OK.", LEFT_MODE);
            BSP_LCD_DisplayStringAt(20, 175, (uint8_t *)"SD can be removed.", LEFT_MODE);
          }
        }
      }
    }
  }
}
Exemplo n.º 25
0
/**
  * @brief  SD Demo
  * @param  None
  * @retval None
  */
void SD_demo(void)
{ 
  uint8_t SD_state = SD_OK;
  static uint8_t prev_status = 0; 
  
  SD_SetHint();
  SD_state = BSP_SD_Init();
  
  if(SD_state != SD_OK)
  {
    BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SD Initialization : FAIL.", LEFT_MODE);
    BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
  }
  else
  {
    BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SD Initialization : OK.", LEFT_MODE);
    
    SD_state = BSP_SD_Erase(BLOCK_START_ADDR, (BLOCKSIZE * NUM_OF_BLOCKS));
    
    if(SD_state != SD_OK)
    {
      BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD ERASE : FAILED.", LEFT_MODE);
      BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
    }
    else
    {
      BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD ERASE : OK.", LEFT_MODE);
      
      /* Fill the buffer to write */
      Fill_Buffer(aTxBuffer, BUFFER_WORDS_SIZE, 0x22FF);
      SD_state = BSP_SD_WriteBlocks(aTxBuffer, BLOCK_START_ADDR, BLOCKSIZE, NUM_OF_BLOCKS);
      
      if(SD_state != SD_OK)
      {
        BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD WRITE : FAILED.", LEFT_MODE);
        BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
      }
      else
      {
        BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD WRITE : OK.", LEFT_MODE);
        SD_state = BSP_SD_ReadBlocks(aRxBuffer, BLOCK_START_ADDR, BLOCKSIZE, NUM_OF_BLOCKS);
        if(SD_state != SD_OK)
        {
          BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD READ : FAILED.", LEFT_MODE);
          BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
        }
        else
        {
          BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD READ : OK.", LEFT_MODE);
          if(Buffercmp(aTxBuffer, aRxBuffer, BUFFER_WORDS_SIZE) > 0)
          {
            BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD COMPARE : FAILED.", LEFT_MODE);
            BSP_LCD_DisplayStringAt(20, 175, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
          }
          else
          {
            BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD Test : OK.", LEFT_MODE);
          }
        }
      }
    }
  }
  
  /* Check if the SD card is plugged in the slot */
  if(BSP_SD_IsDetected() == SD_PRESENT)
  {
    BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
    BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Connected    ", LEFT_MODE);
  }
  else 
  {
    BSP_LCD_SetTextColor(LCD_COLOR_RED);
    BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30,   (uint8_t *)"SD Not Connected", LEFT_MODE);
  }
  
  while (1)
  {
    /* Check if the SD card is plugged in the slot */
    if(BSP_SD_IsDetected() != SD_PRESENT)
    {
      if(prev_status == 0)
      {
        BSP_SD_Init();
        prev_status = 1; 
        BSP_LCD_SetTextColor(LCD_COLOR_RED);
        BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Not Connected", LEFT_MODE);
      }
    }
    else if (prev_status == 1)
    {
      BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
      BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30,   (uint8_t *)"SD Connected    ", LEFT_MODE);
      prev_status = 0;
    }
    
    if(CheckForUserInput() > 0)
    {
      return;
    }
  }
}
Exemplo n.º 26
0
/**
  * @brief  SD Demo
  * @param  None
  * @retval None
  */
void SD_demo(void)
{ 
  uint8_t SD_state = MSD_OK;

  SD_SetHint();
  SD_state = BSP_SD_Init();
  BSP_LCD_SetFont(&Font8);
  
  if(SD_state != MSD_OK)
  {
    BSP_LCD_DisplayStringAt(4, 88, (uint8_t *)"SD Initialization: FAIL", LEFT_MODE);
    BSP_LCD_DisplayStringAt(4, 100, (uint8_t *)"SD Test Aborted", LEFT_MODE);
  }
  else
  {
    BSP_LCD_DisplayStringAt(4, 88, (uint8_t *)"SD Initialization: OK", LEFT_MODE);
    
    SD_state = BSP_SD_Erase(BLOCK_START_ADDR, (BLOCKSIZE * NUM_OF_BLOCKS));
    
    if(SD_state != MSD_OK)
    {
      BSP_LCD_DisplayStringAt(4, 100, (uint8_t *)"SD ERASE: FAILED", LEFT_MODE);
      BSP_LCD_DisplayStringAt(4, 112, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
    }
    else
    {
      BSP_LCD_DisplayStringAt(4, 100, (uint8_t *)"SD ERASE: OK", LEFT_MODE);
      
      /* Fill the buffer to write */
      Fill_Buffer(aTxBuffer, BUFFER_WORDS_SIZE, 0x22FF);
      SD_state = BSP_SD_WriteBlocks(aTxBuffer, BLOCK_START_ADDR, BLOCKSIZE, NUM_OF_BLOCKS);
      
      if(SD_state != MSD_OK)
      {
        BSP_LCD_DisplayStringAt(4, 112, (uint8_t *)"SD WRITE: FAILED", LEFT_MODE);
        BSP_LCD_DisplayStringAt(4, 124, (uint8_t *)"SD Test Aborted", LEFT_MODE);
      }
      else
      {
        BSP_LCD_DisplayStringAt(4, 112, (uint8_t *)"SD WRITE: OK", LEFT_MODE);
        SD_state = BSP_SD_ReadBlocks(aRxBuffer, BLOCK_START_ADDR, BLOCKSIZE, NUM_OF_BLOCKS);
        if(SD_state != MSD_OK)
        {
          BSP_LCD_DisplayStringAt(4, 124, (uint8_t *)"SD READ: FAILED", LEFT_MODE);
          BSP_LCD_DisplayStringAt(4, 136, (uint8_t *)"SD Test Aborted", LEFT_MODE);
        }
        else
        {
          BSP_LCD_DisplayStringAt(4, 124, (uint8_t *)"SD READ: OK", LEFT_MODE);
          if(Buffercmp(aTxBuffer, aRxBuffer, BUFFER_WORDS_SIZE) > 0)
          {
            BSP_LCD_DisplayStringAt(4, 136, (uint8_t *)"SD COMPARE: FAILED.", LEFT_MODE);
            BSP_LCD_DisplayStringAt(4, 148, (uint8_t *)"SD Test Aborted", LEFT_MODE);
          }
          else
          {
            BSP_LCD_DisplayStringAt(4, 136, (uint8_t *)"SD Test: OK", LEFT_MODE);
          }
        }
      }
    }
  }
  
  while (1)
  {   
    if(CheckForUserInput() > 0)
    {
      return;
    }
  }
}
Exemplo n.º 27
0
/**
  * @brief  SD Demo
  * @param  None
  * @retval None
  */
void SD_demo (void)
{ 
  uint8_t SD_state = SD_RESPONSE_NO_ERROR;
  __IO uint8_t prev_status = 0; 

  SD_SetHint();

  SD_state = BSP_SD_Init();

   /* Check if the SD card is plugged in the slot */
  if(BSP_SD_IsDetected() == SD_PRESENT)
  {
    BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
    BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Connected    ", LEFT_MODE);
  }
  else 
  {
    BSP_LCD_SetTextColor(LCD_COLOR_RED);
    BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Not Connected", LEFT_MODE);
  }
  BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
  
  if(SD_state != SD_RESPONSE_NO_ERROR)
  {
    BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SD INITIALIZATION : FAIL.", LEFT_MODE);
    BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
  }
  else
  {
    BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SD INITIALIZATION : OK.", LEFT_MODE); 
    
    SD_state = BSP_SD_GetCardInfo(&CardInfo);
    
    if(SD_state != SD_RESPONSE_NO_ERROR)
    {
      BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD GET CARD INFO : FAIL.", LEFT_MODE);
      BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
    }
    else
    {
      BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD GET CARD INFO : OK.", LEFT_MODE);

      SD_state = BSP_SD_Erase(BLOCK_START_ADDR, (BLOCKSIZE * NUM_OF_BLOCKS));
    
      /* Verify that SD card is ready to use after the Erase */
      SD_state |= BSP_SD_GetStatus();

      if(SD_state != SD_RESPONSE_NO_ERROR)
      {
        BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD ERASE : FAILED.", LEFT_MODE);
        BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
      }
      else
      {
        BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD ERASE : OK.", LEFT_MODE);
      
        /* Fill the buffer to write */
        Fill_Buffer(aTxBuffer, BUFFER_WORDS_SIZE, 0x22FF);
        SD_state = BSP_SD_WriteBlocks((uint32_t *)aTxBuffer, BLOCK_START_ADDR, BLOCKSIZE, NUM_OF_BLOCKS);
      
        if(SD_state != SD_RESPONSE_NO_ERROR)
        {
          BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD WRITE : FAILED.", LEFT_MODE);
          BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
        }
        else
        {
          BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD WRITE : OK.", LEFT_MODE);
          SD_state = BSP_SD_ReadBlocks((uint32_t *)aRxBuffer, BLOCK_START_ADDR, BLOCKSIZE, NUM_OF_BLOCKS);
          if(SD_state != SD_RESPONSE_NO_ERROR)
          {
            BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD READ : FAILED.", LEFT_MODE);
            BSP_LCD_DisplayStringAt(20, 175, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
          }
          else
          {
            BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD READ : OK.", LEFT_MODE);
            if(Buffercmp(aTxBuffer, aRxBuffer, BUFFER_WORDS_SIZE) > 0)
            {
              BSP_LCD_DisplayStringAt(20, 175, (uint8_t *)"SD COMPARE : FAILED.", LEFT_MODE);
              BSP_LCD_DisplayStringAt(20, 190, (uint8_t *)"SD Test Aborted.", LEFT_MODE);
            }
            else
            {
              BSP_LCD_DisplayStringAt(20, 175, (uint8_t *)"SD TEST : OK.", LEFT_MODE);
            }
          }
        }
      }
    }
  }
  
  while (1)
  {
    /* Check if the SD card is plugged in the slot */
    if(BSP_SD_IsDetected() != SD_PRESENT)
    {
      if(prev_status == 0)
      {
        prev_status = 1; 
        BSP_LCD_SetTextColor(LCD_COLOR_RED);
        BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Not Connected", LEFT_MODE);
      }
    }
    else if (prev_status == 1)
    {
      BSP_SD_Init();
      BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
      BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Connected    ", LEFT_MODE);
      prev_status = 0;
    }
    
    if(CheckForUserInput() > 0)
    {
      return;
    }
  }
}