コード例 #1
0
ファイル: explorer.c プロジェクト: acrepina/STM32F7_serverWEB
/**
  * @brief  Copies disk content in the explorer list.
  * @param  None
  * @retval Operation result
  */
FRESULT AUDIO_StorageParse(void)
{
  FRESULT res = FR_OK;
  FILINFO fno;
  DIR dir;
  char *fn;
  
#if _USE_LFN
  static char lfn[_MAX_LFN];
  fno.lfname = lfn;
  fno.lfsize = sizeof(lfn);
#endif
  
  res = f_opendir(&dir, USBKey_Path);
  FileList.ptr = 0;
  
  if(res == FR_OK)
  {
    while(USBH_MSC_IsReady(&hUSBHost))
    {
      res = f_readdir(&dir, &fno);
      if(res != FR_OK || fno.fname[0] == 0)
      {
        break;
      }
      if(fno.fname[0] == '.')
      {
        continue;
      }
#if _USE_LFN
      fn = *fno.lfname ? fno.lfname : fno.fname;
#else
      fn = fno.fname;
#endif
      
      if(FileList.ptr < FILEMGR_LIST_DEPDTH)
      {
        if((fno.fattrib & AM_DIR) == 0)
        {
          if((strstr(fn, "wav")) || (strstr(fn, "WAV")))
          {
            strncpy((char *)FileList.file[FileList.ptr].name, (char *)fn, FILEMGR_FILE_NAME_SIZE);
            FileList.file[FileList.ptr].type = FILETYPE_FILE;
            FileList.ptr++;
          }
        }
      }   
    }
  }
  NumObs = FileList.ptr;
  f_closedir(&dir);
  return res;
}
コード例 #2
0
ファイル: explorer.c プロジェクト: Lembed/STM32CubeF1-mirrors
/**
  * @brief  Displays disk content.
  * @param  path: Pointer to root path
  * @param  recu_level: Disk content level 
  * @retval Operation result
  */
FRESULT Explore_Disk(char *path, uint8_t recu_level)
{
  FRESULT res = FR_OK;
  FILINFO fno;
  DIR dir;
  char *fn;
  char tmp[14];
  uint8_t line_idx = 0;
  
#if _USE_LFN
  static char lfn[_MAX_LFN + 1];   /* Buffer to store the LFN */
  fno.lfname = lfn;
  fno.lfsize = sizeof lfn;
#endif
  
  res = f_opendir(&dir, path);
  if(res == FR_OK) 
  {
    while(USBH_MSC_IsReady(&hUSBHost))
    {
      res = f_readdir(&dir, &fno);
      if(res != FR_OK || fno.fname[0] == 0) 
      {
        break;
      }
      if(fno.fname[0] == '.')
      {
        continue;
      }
      
#if _USE_LFN
      fn = *fno.lfname ? fno.lfname : fno.fname;
#else
      fn = fno.fname;
#endif
      strcpy(tmp, fn); 
      
      line_idx++;
      if(line_idx > 9)
      {
        line_idx = 0;
        LCD_UsrLog("> Press [Key] To Continue.\n");
        
        /* KEY Button in polling */
        while(BSP_PB_GetState(BUTTON_KEY) != RESET)
        {
          /* Wait for User Input */
        }
      } 
      
      if(recu_level == 1)
      {
        LCD_DbgLog("   |__");
      }
      else if(recu_level == 2)
      {
        LCD_DbgLog("   |   |__");
      }
      if((fno.fattrib & AM_MASK) == AM_DIR)
      {
        strcat(tmp, "\n"); 
        LCD_UsrLog((void *)tmp);
        Explore_Disk(fn, 2);
      }
      else
      {
        strcat(tmp, "\n"); 
        LCD_DbgLog((void *)tmp);
      }
      
      if(((fno.fattrib & AM_MASK) == AM_DIR)&&(recu_level == 2))
      {
        Explore_Disk(fn, 2);
      }
    }
    f_closedir(&dir);
	LCD_UsrLog("> Select an operation to Continue.\n" );
  }
  return res;
}
コード例 #3
0
/**
  * @brief  Demo application for IAP through USB mass storage.   
  * @param  None
  * @retval None
  */
void FW_UPGRADE_Process(void)
{
  switch(Demo_State)
  {
  case DEMO_INIT:
    /* Register the file system object to the FatFs module */
    if(f_mount(&USBH_fatfs, "", 0 ) != FR_OK )
    {
      /* FatFs initialization fails */
      /* Toggle LED3 and LED4 in infinite loop */
      FatFs_Fail_Handler();
    }
    
    /* TO DO */
    
    //    /* Flash Disk is write protected: Turn LED4 On and Toggle LED3 in infinite loop */
    //    if(USBH_MSC_Param.MSWriteProtect == DISK_WRITE_PROTECTED)
    //    {
    //      /* Turn LED4 On */
    //      BSP_LED_On(LED4);
    //      /* Toggle LED3 in infinite loop */
    //      Fail_Handler();
    //    }
    
    /* Go to IAP menu */
    Demo_State = DEMO_IAP;
    break;
    
  case DEMO_IAP:
    while(USBH_MSC_IsReady(&hUSBHost))
    {  
      /* Control BUFFER_SIZE value */
      USBH_USR_BufferSizeControl();
      
      /* Keep LED1 Off when Device connected */
      BSP_LED_Off(LED1);  
      
      /* KEY Button pressed Delay */
      IAP_UploadTimeout();
      
      /* Writes Flash memory */
      COMMAND_Download();
      
      /* Check if KEY Button is already pressed */
      if((UploadCondition == 0x01))
      {
        /* Reads all flash memory */
        COMMAND_Upload();
      }
      else
      {
        /* Turn LED1 On: Waiting KEY button pressed */
        BSP_LED_On(LED1); 
      }
      
      /* Waiting KEY Button Released */
      while((BSP_PB_GetState(BUTTON_KEY) == GPIO_PIN_RESET) && (Appli_state == APPLICATION_READY))
      {}
      
      /* Waiting KEY Button Pressed */
      while((BSP_PB_GetState(BUTTON_KEY) != GPIO_PIN_RESET) && (Appli_state == APPLICATION_READY))
      {}
      
      /* Waiting KEY Button Released */
      while((BSP_PB_GetState(BUTTON_KEY) == GPIO_PIN_RESET) && (Appli_state == APPLICATION_READY))
      {}
      
      if(Appli_state == APPLICATION_READY)
      {
        /* Jump to user application code located in the internal Flash memory */
        COMMAND_Jump();
      }
    }     
    break;
    
  default:
    break;
  }
  if(Appli_state == APPLICATION_DISCONNECT)
  {
    /* Toggle LED1: USB device disconnected */
    BSP_LED_Toggle(LED1);
    HAL_Delay(100);
  }
}