コード例 #1
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);
  }
}
コード例 #2
0
/** @brief  SD detect IT treatment.
  * @param  None
  * @retval None
  */
void BSP_SD_DetectIT(void)
{
  /* Clear all pending bits */
  BSP_IO_ITClear();
  
  /* To re-enable IT */
  BSP_SD_ITConfig();
  
  /* SD detect IT callback */
  BSP_SD_DetectCallback();
}
コード例 #3
0
ファイル: sd.c プロジェクト: 451506709/automated_machine
/**
  * @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;
    }
  }
}