Exemple #1
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();

  /* Init MTP Application */
  MTP_InitApplication();
  
  /* Init Host Library */
  USBH_Init(&hUSBHost, USBH_UserProcess, 0);

  /* Add Supported Class */
  USBH_RegisterClass(&hUSBHost, USBH_MTP_CLASS);
  
  /* Start Host Process */
  USBH_Start(&hUSBHost);
  
  /* Run Application (Blocking mode) */
  while (1)
  {
    /* USB Host Background task */
    USBH_Process(&hUSBHost);
    
    /* MTP Menu Process */
    MTP_MenuProcess();
  }
}
Exemple #2
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F469xx HAL library initialization */
  HAL_Init();
  
  /* Configure the System clock to have a frequency of 180 MHz */
  SystemClock_Config();
  
  /* Init CDC Application */
  CDC_InitApplication();

  /* Init Host Library */
  USBH_Init(&hUSBHost, USBH_UserProcess, 0);
  
  /* Add Supported Class */
  USBH_RegisterClass(&hUSBHost, USBH_CDC_CLASS);
  
  /* Start Host Process */
  USBH_Start(&hUSBHost);
  
  while (1)
  {
    /* USB Host Background task */
    USBH_Process(&hUSBHost); 
    
    /* CDC Menu Process */
    CDC_MenuProcess(); 
  }
}
Exemple #3
0
USBH_Status USBH_Dev_Hub_Task(USB_OTG_CORE_HANDLE *pcore , USBH_DEV *pdev)
{
	Hub_Data_t* Hub_Data = pdev->Usr_Data;
	dbg_obj = Hub_Data->intInEpIo;
	USBH_DevIO_Task(Hub_Data->intInEpIo);

	if (Hub_Data->intInEpIo->state != UIOSTATE_WAIT_DATA)
	{
		// iterate all the ports
		if (Hub_Data->children != 0)
		{
			for (int pn = 0; pn < Hub_Data->num_ports; pn++)
			{
				if (Hub_Data->children[pn] != 0 && (Hub_Data->port_busy == (pn + 1) || Hub_Data->port_busy == 0)) {
					USBH_Process(pcore, Hub_Data->children[pn]);
				}
			}
		}
	}

	if (Hub_Data->port_busy == 0 && (pdev->Control.hc_num_in >= 0 || pdev->Control.hc_num_out >= 0)) {
		USBH_Dev_FreeControl(pcore, pdev);
	}

	return USBH_OK;
}
/**
  * @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();
  
  /* Init Dual Core Application */
  DUAL_InitApplication();
  
  /* Init HS Core */
  USBH_Init(&hUSBHost_HS, USBH_HS_UserProcess, 1);
  
  /* Init FS Core */
  USBH_Init(&hUSBHost_FS, USBH_FS_UserProcess, 0);
  
  /* Add Supported Classes */
  USBH_RegisterClass(&hUSBHost_HS, USBH_MSC_CLASS);
  USBH_RegisterClass(&hUSBHost_FS, USBH_HID_CLASS);
  
  /* Start Host Process */
  USBH_Start(&hUSBHost_FS);
  USBH_Start(&hUSBHost_HS);
 
  /* Register the file system object to the FatFs module */
  if(f_mount(&USBH_fatfs, "", 0) != FR_OK)
  {  
    LCD_ErrLog("ERROR : Cannot Initialize FatFs! \n");
  }
  
  /* Run Application (Blocking mode)*/
  while (1)
  {
    /* USB Host Background tasks */
    USBH_Process(&hUSBHost_FS); 
    USBH_Process(&hUSBHost_HS);
    
    /* DUAL Menu Process */
    DUAL_MenuProcess(); 
  } 
}
Exemple #5
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();
  
  /*Initialize the IO module*/
  BSP_IO_Init ();
  
  /* Configure LED1 and LED3 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED3);  
  
  /*##-1- Link the USB Host disk I/O driver ##################################*/
  if(FATFS_LinkDriver(&USBH_Driver, USBDISKPath) == 0)
  {
    /*##-2- Init Host Library ################################################*/
    USBH_Init(&hUSB_Host, USBH_UserProcess, 0);
    
    /*##-3- Add Supported Class ##############################################*/
    USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS);
    
    /*##-4- Start Host Process ###############################################*/
    USBH_Start(&hUSB_Host);
    
    /*##-5- Run Application (Blocking mode) ##################################*/
    while (1)
    {
      /* USB Host Background task */
      USBH_Process(&hUSB_Host);
      
      /* Mass Storage Application State Machine */
      switch(Appli_state)
      {
      case APPLICATION_START:
        MSC_Application();
        Appli_state = APPLICATION_IDLE;
        break;
         
      case APPLICATION_IDLE:
      default:
        break;      
      }
    }
  }

  /* Infinite loop */
  while (1)
  {
  }
    
}
Exemple #6
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* Configure Key Button */
  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO); 
  
  /* Unlock the Flash to enable the flash control register access */ 
  FLASH_If_FlashUnlock();
  
  /* Test if User button on the STM324x9I_EVAL is pressed */
  if (BSP_PB_GetState(BUTTON_KEY) != GPIO_PIN_RESET)
  {
    /* Check Vector Table: Test if user code is programmed starting from address 
    "APPLICATION_ADDRESS" */
    if ((((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0xFF000000 ) == 0x20000000) || \
      (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0xFF000000 ) == 0x10000000))
    {
      /* Jump to user application */
      JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
      Jump_To_Application = (pFunction) JumpAddress;
      /* Initialize user application's Stack Pointer */
      __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
      Jump_To_Application();
    }
  }
  
  /* 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();
  
  /* Init FW upgrade Application */
  FW_InitApplication();
  
  /* Init Host Library */
  USBH_Init(&hUSBHost, USBH_UserProcess, 0);
  
  /* Add Supported Class */
  USBH_RegisterClass(&hUSBHost, USBH_MSC_CLASS);
  
  /* Start Host Process */
  USBH_Start(&hUSBHost);
  
  /* Run Application (Blocking mode)*/
  while (1)
  {
    /* USB Host Background task */
    USBH_Process(&hUSBHost);
    
    /* FW Menu Process */
    FW_UPGRADE_Process();
  } 
}
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F4xx HAL library initialization */
  HAL_Init();

  /* Configure the system clock to 180 Mhz */
  SystemClock_Config();

  /* Initialize IO expander */
  BSP_IO_Init();

  /* Init Dual Core Application */
  DUAL_InitApplication();

  /* Init HS Core */
  USBH_Init(&hUSBHost_HS, USBH_HS_UserProcess, 1);

  /* Init FS Core */
  USBH_Init(&hUSBHost_FS, USBH_FS_UserProcess, 0);

  /* Add Supported Classes */
  USBH_RegisterClass(&hUSBHost_HS, USBH_MSC_CLASS);
  USBH_RegisterClass(&hUSBHost_FS, USBH_HID_CLASS);

  /* Start Host Process */
  USBH_Start(&hUSBHost_FS);
  USBH_Start(&hUSBHost_HS);

  /* Register the file system object to the FatFs module */
  if(f_mount(&USBH_fatfs, "", 0) != FR_OK)
  {
    LCD_ErrLog("ERROR : Cannot Initialize FatFs! \n");
  }

  /* Run Application (Blocking mode)*/
  while (1)
  {
    /* USB Host Background tasks */
    USBH_Process(&hUSBHost_FS);
    USBH_Process(&hUSBHost_HS);

    /* DUAL Menu Process */
    DUAL_MenuProcess();
  }
}
Exemple #8
0
void USBH_USR_BackgroundProcess(void)
{
	if ((	USBH_USR_ApplicationState != USH_USR_READY
		&&	USBH_USR_ApplicationState != USH_USR_PROCESS
			)
	||  HCD_IsDeviceConnected(&USB_OTG_Core) == 0
		)
		USBH_Process(&USB_OTG_Core, &USB_Host);
}
usb_msc_host_status_t usb_msc_host_main (void)
{
	if (usb_msc_host_status != USB_MSC_DEV_NOT_SUPPORTED)
	{
		USBH_Process (&USB_OTG_Core, &USB_Host);
	}

	return usb_msc_host_status;
}
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* Configure Key Button */
  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);

  /* Unlock the Flash to enable the flash control register access */
  FLASH_If_FlashUnlock();

  /* Test if User button on the STM32446E_EVAL is pressed */
  if (BSP_PB_GetState(BUTTON_KEY) != GPIO_PIN_SET)
  {
    /* Check Vector Table: Test if user code is programmed starting from address
    "APPLICATION_ADDRESS" */
    if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0xFF000000 ) == 0x20000000)
    {
      /* Jump to user application */
      JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
      Jump_To_Application = (pFunction) JumpAddress;
      /* Initialize user application's Stack Pointer */
      __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
      Jump_To_Application();
    }
  }

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

  /* Configure the system clock to 180 Mhz */
  SystemClock_Config();

  /* Initialize IO expander */
  BSP_IO_Init();

  /* Init FW upgrade Application */
  FW_InitApplication();

  /* Init Host Library */
  USBH_Init(&hUSBHost, USBH_UserProcess, 0);

  /* Add Supported Class */
  USBH_RegisterClass(&hUSBHost, USBH_MSC_CLASS);

  /* Start Host Process */
  USBH_Start(&hUSBHost);

  /* Run Application (Blocking mode)*/
  while (1)
  {
    /* USB Host Background task */
    USBH_Process(&hUSBHost);

    /* FW Menu Process */
    FW_UPGRADE_Process();
  }
}
Exemple #11
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);
  }
}
/*------------------------------------------------------------
 * Function Name  : USB_ReadyCycle
 * Description    : USB准备
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void USB_ReadyCycle( void )
{
	uint32_t num = 0;
	const uint32_t USB_STATUS_CYCLE_NUM = 100000;		//USB循环体必须达到此次数才能操作
	
	while (num < USB_STATUS_CYCLE_NUM)
	{
		num++;
		
		USBH_Process(&USB_OTG_Core, &USB_Host);	//执行一定次数才可以改变读写U盘状态位
	}
}
Exemple #13
0
static void usbh_thread_entry(void *parameter)
{
    rt_err_t err = 0;

    DBGPRINT(WHED_DEBUG_TRACE, "%s: ---->\n", __FUNCTION__);

    err = err;
    
    while (1) {
        /* Host Task handler. */
        USBH_Process(&USB_OTG_Core_dev , &USB_Host);
    }
}
Exemple #14
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* 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(); 

  /* Init Audio Application */
  AUDIO_InitApplication();

  /* Init Host Library */
  USBH_Init(&hUSBHost, USBH_UserProcess, 0);

  /* Add Supported Class */
  USBH_RegisterClass(&hUSBHost, USBH_MSC_CLASS);
  
  /* Start Host Process */
  USBH_Start(&hUSBHost);
  
  /* Run Application (Blocking mode) */
  while (1)
  {
    /* USB Host Background task */
    USBH_Process(&hUSBHost);
    
    /* AUDIO Menu Process */
    AUDIO_MenuProcess();

    if ( MfxToggleLed == 1)
    { 
#if defined(USE_STM32756G_EVAL_REVA)
      /* On RevA board, as LED1 is connected to MFX, the toggle is performed in main loop */
      BSP_LED_Toggle(LED1);
#else
      /* On RevB board, as LED1 is connected to GPIO, it is toggled in ISR,
       * the LED4 is toggled in main loop as it is connected to MFX */
      BSP_LED_Toggle(LED4);
#endif
      MfxToggleLed = 0;
    }
  }
}
Exemple #15
0
/**
  * @brief  USB Host Thread task
  * @param  pvParameters not used
  * @retval None
  */
static void USBH_Process_OS(void const * argument)
{
  osEvent event;
  
  for(;;)
  {
    event = osMessageGet(((USBH_HandleTypeDef *)argument)->os_event, osWaitForever );
    
    if( event.status == osEventMessage )
    {
      USBH_Process((USBH_HandleTypeDef *)argument);
    }
   }
}
Exemple #16
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* 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 200 Mhz */
  SystemClock_Config();
  
  /* Initialize IO expander */
  BSP_IO_Init();
  
  /* Init MSC Application */
  MSC_InitApplication();
  
  /* Init Host Library */
  USBH_Init(&hUSBHost, USBH_UserProcess, 0);
  
  /* Add Supported Class */
  USBH_RegisterClass(&hUSBHost, USBH_MSC_CLASS);
  
  /* Start Host Process */
  USBH_Start(&hUSBHost);
  
  /* Register the file system object to the FatFs module */
  if(f_mount(&USBH_fatfs, "", 0) != FR_OK)
  {  
    LCD_ErrLog("ERROR : Cannot Initialize FatFs! \n");
  }
  
  /* Run Application (Blocking mode) */
  while (1)
  {
    /* USB Host Background task */
    USBH_Process(&hUSBHost);
    
    /* MSC Menu Process */
    MSC_MenuProcess();
  }
}
Exemple #17
0
/*
 * Main function. Called when startup code is done with
 * copying memory and setting up clocks.
 */
int audioToMp3(void) {
	GPIO_InitTypeDef  GPIO_InitStructure;

	// SysTick interrupt each 1ms
	RCC_GetClocksFreq(&RCC_Clocks);
	SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);

	// GPIOD Peripheral clock enable
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

	// Configure PD12, PD13, PD14 and PD15 in output pushpull mode
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
	GPIO_Init(GPIOD, &GPIO_InitStructure);

	// Initialize USB Host Library
	USBH_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USB_Host, &USBH_MSC_cb, &USR_Callbacks);

	for(;;) {
		if(0==exitMp3)
		{
			USBH_Process(&USB_OTG_Core, &USB_Host);

			if (enum_done >= 2) {
				enum_done = 0;
				play_directory("", 0);
			}
		}
		//exit and disable peripherals
		else
		{
			//RTC_AlarmCmd(RTC_Alarm_A,DISABLE);
			DAC_Cmd(DAC_Channel_1, DISABLE);
			DAC_DMACmd(DAC_Channel_1, DISABLE); //DMAEN1
			DMA_Cmd(DMA1_Stream5, DISABLE);
			TIM_Cmd(TIM6, DISABLE);


			exitMp3 = 0;
			mp3PlayingFlag = 0;
			break;
		}
	}
}
Exemple #18
0
/**
* @brief  Main routine for MSC class application
* @param  None
* @retval int
*/
int main(void)
{
  __IO uint32_t i = 0;
  __IO uint32_t flag = 0;

  /*!< At this stage the microcontroller clock setting is already configured,
  this is done through SystemInit() function which is called from startup
  file (startup_stm32fxxx_xx.s) before to branch to application main.
  To reconfigure the default setting of SystemInit() function, refer to
  system_stm32fxxx.c file
  */

  /* Init Host Library */
  USBH_Init(&USB_OTG_Core,
#ifdef USE_USB_OTG_FS
            USB_OTG_FS_CORE_ID,
#else
            USB_OTG_HS_CORE_ID,
#endif
            &USB_Host,
            &USBH_MSC_cb,
            &USR_cb);

  while (1)
  {
    /* Host Task handler */
    USBH_Process(&USB_OTG_Core, &USB_Host);

    if (i++ >= 0x10000) {
      STM_EVAL_LEDToggle(LED4);

#ifdef USE_USB_OTG_HS
      /* check the ID pin */
      if ((!flag)
          && (Get_OTG_HS_ID_State()==(uint8_t)Bit_RESET) ){
        flag = 1;
        Enable_OTG_HS_PWR();
      } else if ((flag)
                 && (Get_OTG_HS_ID_State()==(uint8_t)Bit_SET) ) {
        flag = 0;
        Disable_OTG_HS_PWR();
      }
#endif
      i = 0;
    }
  }
}
Exemple #19
0
static void rt_thread_entry_usbmsc(void* parameter)
{
	int ret;

	dfs_init();
    elm_init();

	USBH_Init(&USB_OTG_Core,
			  USB_OTG_FS_CORE_ID,
			  &USB_Host,
			  &USBH_MSC_cb, 
			  &USR_cb);
	
	rt_kprintf("\r\nUSBH_Init\r\n");


#if defined(RT_USING_DFS_ROMFS) 
		dfs_romfs_init(); 
		if (dfs_mount(RT_NULL, "/", "rom", 0, &romfs_root) == 0) 
		{ 
			rt_kprintf("Root File System initialized!\n"); 
		} 
		else 
			rt_kprintf("Root File System initialzation failed!\n"); 
#endif







	//USB_OTG_Core.regs.GREGS->GUSBCFG|=(1<<29);

	//USB_OTG_WRITE_REG32(USB_OTG_Core.regs.GREGS->GUSBCFG,value)
	rt_thread_delay(RT_TICK_PER_SECOND);
	
    while (1)
    {
    	//GPIO_SetBits(GPIOD, GPIO_Pin_15);
		USBH_Process(&USB_OTG_Core,&USB_Host);
		rt_thread_delay(RT_TICK_PER_SECOND/20);    // 根据写入速度调整
		//GPIO_ResetBits(GPIOD, GPIO_Pin_15);
    }

}
/**
  * @brief  Main program.
  * @param  None
  * @retval None
*/
int main(void)
{ 
  
  /* Initialize LEDS */
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);
  STM_EVAL_LEDInit(LED5);
  STM_EVAL_LEDInit(LED6);
 
  /* Green Led On: start of application */
  STM_EVAL_LEDOn(LED4);
       
  /* SysTick end of count event each 10ms */
  RCC_GetClocksFreq(&RCC_Clocks);
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
  
  /* Configure TIM4 Peripheral to manage LEDs lighting */
  TIM_LED_Config();
  
  /* Initialize the repeat status */
  RepeatState = 0;
  LED_Toggle = 7;
  
#if defined MEDIA_IntFLASH
  
  WavePlayBack(I2S_AudioFreq_48k); 
  while (1);
  
#elif defined MEDIA_USB_KEY
  
  /* Initialize User Button */
  STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);
   
  /* Init Host Library */
  USBH_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USB_Host, &USBH_MSC_cb, &USR_Callbacks);
  IT_Lines_Init();
  while (1)
  {
    /* Host Task handler */
    USBH_Process(&USB_OTG_Core, &USB_Host);
  }
  
#endif
  
}
/**
  * @brief  USBH_TEMPLATE_Init 
  *         The function Initialize the TEMPLATE function
  * @param  phost: Host handle
  * @retval USBH Status
  */
USBH_StatusTypeDef USBH_TEMPLATE_Init (USBH_HandleTypeDef *phost)
{
  USBH_StatusTypeDef Status = USBH_BUSY;
#if (USBH_USE_OS == 1)
  osEvent event;
  
  event = osMessageGet( phost->class_ready_event, osWaitForever );
  
  if( event.status == osEventMessage )      
  {
    if(event.value.v == USBH_CLASS_EVENT)
    {
#else 
      
  while ((Status == USBH_BUSY) || (Status == USBH_FAIL))
  {
    /* Host background process */
    USBH_Process(phost);
    if(phost->gState == HOST_CLASS)
    {
#endif        
      Status = USBH_OK;
    }
  }
  return Status;   
}

/**
  * @brief  USBH_TEMPLATE_IOProcess 
  *         TEMPLATE TEMPLATE process
  * @param  phost: Host handle
  * @retval USBH Status
  */
USBH_StatusTypeDef USBH_TEMPLATE_IOProcess (USBH_HandleTypeDef *phost)
{
  if (phost->device.is_connected == 1)
  {
    if(phost->gState == HOST_CLASS)
    {
      USBH_TEMPLATE_Process(phost);
    }
  }
  
  return USBH_OK;
}
Exemple #22
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
    /* 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 200 Mhz */
    SystemClock_Config();

    /* Initialize IO expander */
    BSP_IO_Init();

    /* Init CDC Application */
    CDC_InitApplication();

    /* Init Host Library */
    USBH_Init(&hUSBHost, USBH_UserProcess, 0);

    /* Add Supported Class */
    USBH_RegisterClass(&hUSBHost, USBH_CDC_CLASS);

    /* Start Host Process */
    USBH_Start(&hUSBHost);

    /* Run Application (Blocking mode) */
    while (1)
    {
        /* USB Host Background task */
        USBH_Process(&hUSBHost);

        /* CDC Menu Process */
        CDC_MenuProcess();
    }
}
Exemple #23
0
int main(void) {
	HAL_Init();

	led_all_init();
	SystemClock_Config();

	if (BSP_ACCELERO_Init() != ACCELERO_OK) {
		Error_Handler();
	}
	BSP_ACCELERO_Click_ITConfig();
	TIM_LED_Config();

	isLooping = 1;
	ledState = LEDS_OFF;

	BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);

	// Link the USB Host disk I/O driver
	if (FATFS_LinkDriver(&USBH_Driver, usbDrivePath) == 0) {
		USBH_Init(&hUSBHost, usbUserProcess, 0);
		USBH_RegisterClass(&hUSBHost, USBH_MSC_CLASS);
		USBH_Start(&hUSBHost);

		while (1) {
			switch (appState) {
			case APP_START:
				startApp();
				break;
			case APP_IDLE:
			default:
				break;
			}
			USBH_Process(&hUSBHost);
		}
	}

	while (1) {
	}
}
Exemple #24
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F469xx HAL library initialization  */
  HAL_Init();
  
  /* Configure the System clock to have a frequency of 180 MHz */
  SystemClock_Config();
  
  /* Init MSC Application */
  MSC_InitApplication();
  
  /* Init Host Library */
  USBH_Init(&hUSBHost, USBH_UserProcess, 0);
  
  /* Add Supported Class */
  USBH_RegisterClass(&hUSBHost, USBH_MSC_CLASS);
  
  /* Start Host Process */
  USBH_Start(&hUSBHost);
  
  /* Register the file system object to the FatFs module */
  if(f_mount(&USBH_fatfs, "", 0) != FR_OK)
  {  
    LCD_ErrLog("ERROR : Cannot Initialize FatFs! \n");
  }
  
  /* Run Application (Blocking mode) */
  while (1)
  {
    /* USB Host Background task */
    USBH_Process(&hUSBHost);
    
    /* MSC Menu Process */
    MSC_MenuProcess();
  } 
}
Exemple #25
0
int main(void)
{

	SystemInit();

	/* GPIOD Periph clock enable */
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

	/* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
	GPIO_Init(GPIOD, &GPIO_InitStructure);

	USBH_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USB_Host, &USBH_MSC_cb, &USR_Callbacks);

    while(1)
    {

		USBH_Process(&USB_OTG_Core, &USB_Host);

		if (l==0) {
			l=0;
			//play_directory("", 0);
		//	Filewrite();
		}
                if (enum_done >= 2) {
                        enum_done = 0;
                        play_directory("", 0);
                }
    }


}
Exemple #26
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
  
  /* Configure the system clock to 72 Mhz */
  SystemClock_Config();
  
  /* Init MSC Application */
  MSC_InitApplication();
  
  /* Init Host Library */
  USBH_Init(&hUSBHost, USBH_UserProcess, 0);
  
  /* Add Supported Class */
  USBH_RegisterClass(&hUSBHost, USBH_MSC_CLASS);
  
  /* Start Host Process */
  USBH_Start(&hUSBHost);
  
  /* Register the file system object to the FatFs module */
  if(f_mount(&USBH_fatfs, "", 0) != FR_OK)
  {  
    LCD_ErrLog("ERROR : Cannot Initialize FatFs! \n");
  }
  
  /* Run Application (Blocking mode) */
  while (1)
  {
    /* USB Host Background task */
    USBH_Process(&hUSBHost);
    
    /* MSC Menu Process */
    MSC_MenuProcess();
  }
}
Exemple #27
0
void pyb_usb_host_process(void) {
    USBH_Process(&USB_OTG_Core, &USB_Host);
}
Exemple #28
0
/**
**===========================================================================
**
**  Abstract: main program
**
**===========================================================================
*/
int main(void)
{
	int i = 0;
	uint8_t msg[2];
	uint16_t len;
	RCC_ClocksTypeDef RCC_Clocks;

	/* Initialize LEDs and User_Button on STM32F4-Discovery --------------------*/
	STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
	STM_EVAL_LEDInit(LED3);
	STM_EVAL_LEDInit(LED4);

	/* SysTick end of count event each 1ms */
	RCC_GetClocksFreq(&RCC_Clocks);
	SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);

#ifdef DEBUG
	/* Init Debug out setting(UART2) */
	uart_debug_init();
#endif

	/* Init Host Library */
	USBH_Init(	&USB_OTG_Core_dev,
				USB_OTG_FS_CORE_ID,
				&USB_Host,
				&USBH_ADK_cb,
				&USR_Callbacks
				);

	/* Init ADK Library */
	USBH_ADK_Init(	"ammlab.org",
					"HelloADK",
					"HelloADK for GR-SAKURA for STM32F4",
					"1.0",
					"https://play.google.com/store/apps/details?id=org.ammlab.android.helloadk",
					"1234567"
					);

	while (1)
	{
		/* Host Task handler */
		USBH_Process(&USB_OTG_Core_dev, &USB_Host);

		/* Accessory Mode enabled */
		if ( USBH_ADK_getStatus() == ADK_IDLE)
		{
			/* --------------------------------------------------------------------------- */
			// in
			len = USBH_ADK_read(&USB_OTG_Core_dev, msg, sizeof(msg));
			if ( len > 0 )
			{
				if ( msg[0] == 0x1)
				{
					if ( msg[1] == 0x1)
					{
						STM_EVAL_LEDOn(LED3);
					}
					else
					{
						STM_EVAL_LEDOff(LED3);
					}
				}
			}

			// out
			if ( STM_EVAL_PBGetState(BUTTON_USER) )
			{
				msg[0] = 1;
				msg[1] = 1;
				STM_EVAL_LEDOn(LED4);
			}
			else
			{
				msg[0] = 1;
				msg[1] = 0;
				STM_EVAL_LEDOff(LED4);
			}
			USBH_ADK_write(&USB_OTG_Core_dev, msg, sizeof(msg));
		}
		Delay(1);

		if (i++ == 100)
		{
			STM_EVAL_LEDToggle(LED3);
			i = 0;
		}
	}
}
Exemple #29
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 LED1 and LED3 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED3);
  
  /*##-1- LCD Initialization #################################################*/ 
  /* Initialize the LCD */
  BSP_LCD_Init();
  
  /* Foreground Layer Initialization */
  BSP_LCD_LayerDefaultInit(1, LCD_FRAME_BUFFER_LAYER1);
  /* Set Foreground Layer */
  BSP_LCD_SelectLayer(1);
  /* Clear the LCD Foreground layer */
  BSP_LCD_Clear(LCD_COLOR_WHITE);
  /* Enable the color Key for foreground layer */   
  BSP_LCD_SetColorKeying(1, LCD_COLOR_WHITE);
  BSP_LCD_SetLayerVisible(1, DISABLE);
  
  /* Background Layer Initialization */
  BSP_LCD_LayerDefaultInit(0, LCD_FRAME_BUFFER_LAYER0);
  
  /* Set Foreground Layer */
  BSP_LCD_SelectLayer(0);
  
  /* Enable the LCD */
  BSP_LCD_DisplayOn();
  
  /* Clear the LCD Background layer */
  BSP_LCD_Clear(LCD_COLOR_WHITE);
  
  /*##-2- Touch screen initialization ########################################*/
  Touchscreen_Calibration();
  
  /*##-3- USB Initialization #################################################*/ 
  /* 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();
  }
  
  /*##-4- Link the USB Mass Storage disk I/O driver ##########################*/
  if(FATFS_LinkDriver(&USBH_Driver, USB_Path) != 0) 
  {
    /* FatFs Initialization Error */
    Error_Handler();
  }
  
  /*##-5- Register the file system object to the FatFs module ################*/
  if(f_mount(&USBDISK_FatFs, (TCHAR const*)USB_Path, 0) != FR_OK)
  {
    /* FatFs Initialization Error */
    Error_Handler();
  }
  
  /*##-6- Draw the menu ######################################################*/
  Draw_Menu();  
  
  /* Infinite loop */  
  while (1)
  { 
    /*##-7- Configure the touch screen and Get the position ##################*/    
    GetPosition();
    
    USBH_Process(&hUSB_Host);
  }
}
void _usb_msc_host_idle(unsigned int instance)
{
    /* USB Host Background task */
    USBH_Process(&usb_msc_host_param[instance]);
    /* Mass Storage Application State Machine */
    switch(Appli_state)
    {
    case APPLICATION_START:
        g_sFatFs1.drv_rw_func.DriveStruct = (void*)&usb_msc_host_param[instance];
        g_sFatFs1.drv_rw_func.drv_r_func = USBMSCReadBlock;
        g_sFatFs1.drv_rw_func.drv_w_func = USBMSCWriteBlock;
#if (_FFCONF == 82786)
        if(!f_mount(instance, &g_sFatFs1))
#else
        char drv_name_buff[6];
        drv_name_buff[1] = 'U';
        drv_name_buff[1] = 'S';
        drv_name_buff[1] = 'B';
        drv_name_buff[0] = '1' + instance;
        drv_name_buff[1] = ':';
        drv_name_buff[2] = '\0';
        if(!f_mount(&g_sFatFs1, drv_name_buff, 1))
#endif
        {
        	if(f_opendir(&g_sDirObject, g_cCwdBuf1) == FR_OK)
            {
#ifdef USBH_MSC_DEBUG_EN
						if(DebugCom)
						{
							uart.printf(DebugCom,   "USBH MSC%d drive %d mounted\n\r" , 0 , 1);
							uart.printf(DebugCom,   "USBH MSC%d Fat fs detected\n\r" , 0);
							uart.printf(DebugCom, "USBH MSC%d Fs type:                 " , 0);
							if(g_sFatFs1.fs_type == FS_FAT12)	{
								uart.printf(DebugCom, "Fat12");}
							else if(g_sFatFs1.fs_type == FS_FAT16){
								uart.printf(DebugCom, "Fat16");}
							else if(g_sFatFs1.fs_type == FS_FAT32){
								uart.printf(DebugCom, "Fat32");}
							else if(g_sFatFs1.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, "USBH MSC%d BytesPerSector:          %d \n\r",0, /*(int)g_sFatFs.s_size*/512);
							uart.printf(DebugCom, "USBH MSC%d SectorsPerCluster:       %d \n\r",0, (int)g_sFatFs1.csize);
																				//UARTprintf(DebugCom, "MMCSD0 AllocTable1Begin:        %u \n\r",(unsigned int)g_sFatFs.fatbase);
																				//UARTprintf(DebugCom, "USBH MSC%d NumberOfFats:            %d \n\r",0, (int)g_sFatFs1.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, "USBH MSC%d DataSectionBegin:        %d \n\r",0, (int)g_sFatFs1.fatbase);
							uart.printf(DebugCom, "USBH MSC%d uSD DiskCapacity:        %uMB\n\r",0, (unsigned long)((unsigned long long)((unsigned long long)g_sFatFs1.n_fatent * (unsigned long long)/*g_sFatFs.s_size*/512 * (unsigned long long)g_sFatFs1.csize) / 1000000));
						}
#endif
            }
        	else  if(DebugCom)										uart.printf(DebugCom,   "USBH %d ERROR oppening path\n\r" , 0);
        }
        else  if(DebugCom)												uart.printf(DebugCom,   "USBH %d ERROR mounting disk\n\r" , 0);
        Appli_state = APPLICATION_IDLE;
        break;

    case APPLICATION_IDLE:
    	default:
    		break;
    }

}