/** * @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(); /* 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(); } }
void UsbKey::init(struct OneSynthParams*timbre1, struct OneSynthParams*timbre2, struct OneSynthParams*timbre3, struct OneSynthParams*timbre4) { Storage::init(timbre1, timbre2, timbre3, timbre4); USBH_Init(&usbOTGHost, USB_OTG_HS_CORE_ID, &usbHost, &USBH_MSC_cb, &USR_Callbacks); commandParams.commandState = COMMAND_INIT; usbProcess(); #ifndef BOOTLOADER dx7NumberOfBanks = 0; dx7BankInitialized = false; for (int k=0; k< NUMBEROFDX7BANKS; k++) { dx7Bank[k].name[0] = '\0'; dx7Bank[k].name[12] = '\0'; dx7Bank[k].fileType = FILE_EMPTY; } for (int k=0; k<NUMBEROFPREENFMBANKS; k++) { preenFMBank[k].fileType = FILE_EMPTY; } for (int k=0; k<NUMBEROFPREENFMCOMBOS; k++) { preenFMCombo[k].fileType = FILE_EMPTY; } char empty[] = "<Empty>\0"; for (int k=0; k< 8; k++) { errorDX7Bank.name[k] = empty[k]; errorPreenFMBank.name[k] = empty[k]; errorPreenFMCombo.name[k] = empty[k]; } errorPreenFMBank.fileType = FILE_EMPTY; errorPreenFMCombo.fileType = FILE_EMPTY; errorDX7Bank.fileType = FILE_EMPTY; #endif }
/** * @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); } }
/** * @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 Audio Application */ Audio_InitApplication(); /* Init Host Library */ USBH_Init(&hUSBHost, USBH_UserProcess, 0); /* Add Supported Class */ USBH_RegisterClass(&hUSBHost, USBH_AUDIO_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(); } }
/** * @brief Main program * @param None * @retval None */ int main(void) { /* STM32F446xx HAL library initialization */ HAL_Init(); /* Configure the system clock to 180 Mhz */ SystemClock_Config(); /* Initialize IO expander */ BSP_IO_Init(); /* Init HID Application */ HID_InitApplication(); /* Init Host Library */ USBH_Init(&hUSBHost, USBH_UserProcess, 0); /* Add Supported Class */ USBH_RegisterClass(&hUSBHost, USBH_HID_CLASS); /* Start Host Process */ USBH_Start(&hUSBHost); /* Run Application (Blocking mode) */ while (1) { /* USB Host Background task */ USBH_Process(&hUSBHost); /* HID Menu Process */ HID_MenuProcess(); } }
/** * @brief main * Main routine for IAP application * @param None * @retval int */ int main(void) { /* STM32 evalboard user initialization */ BSP_Init(); /* Flash unlock */ FLASH_If_FlashUnlock(); /* Test if User button on the Discovery kit is pressed */ if (STM_EVAL_PBGetState(BUTTON_USER) == Bit_RESET) { /* Check Vector Table: Test if user code is programmed starting from address "APPLICATION_ADDRESS" */ if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 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(); } } /* Init Host Library */ USBH_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USB_Host, &USBH_MSC_cb, &USR_Callbacks); while (1) { /* Host Task handler */ USBH_Process(&USB_OTG_Core, &USB_Host); } }
/* * Main function. Called when startup code is done with * copying memory and setting up clocks. */ int main(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); // Initialize LEDS (12:Green/13:Orange/14:Red/15:Blue) // 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(;;) { USBH_Process(&USB_OTG_Core, &USB_Host); if (enum_done >= 2) { enum_done = 0; put_file_directory("", 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 Dynamic Switch Application */ DynamicSwitch_InitApplication(); /* Init Host Library */ USBH_Init(&hUSBHost, USBH_UserProcess, 0); /* Add Supported Class */ USBH_RegisterClass(&hUSBHost, USBH_MSC_CLASS); USBH_RegisterClass(&hUSBHost, USBH_HID_CLASS); /* Start Host Process */ USBH_Start(&hUSBHost); while (1) { /* USB Host Background task */ USBH_Process(&hUSBHost); /* DS Menu Process */ DS_MenuProcess(); } }
void usb_init(void) { osal_sem_t *sem; osal_task_t *task; memset(&wifi_usb_adapter,0,sizeof(wifi_usb_adapter_t)); sem = osal_sem_create("usbh", 0); osal_assert(sem != NULL); USB_Host_Semphore = sem; sem = osal_sem_create("usbc", 0); osal_assert(sem != NULL); USB_CtrlReq_Semphore = sem; USBH_Init(&USB_OTG_Core_dev, USB_OTG_FS_CORE_ID, &USB_Host, &USBH_Class_Cb, &USBH_USR_Cb); /* Finally start USB host process thread */ task = osal_task_create("usbh", usbh_thread_entry, NULL, RT_USBH_THREAD_STACK_SIZE, \ RT_USBH_THREAD_PRIORITY); osal_assert(task != NULL); }
void MainTask(void) { USBH_Init(); OS_SetPriority(OS_GetTaskID(), TASK_PRIO_APP); // This task has highest prio for real-time application OS_CREATETASK(&_TCBMain, "USBH_Task", USBH_Task, TASK_PRIO_USBH_MAIN, _StackMain); // Start USBH main task OS_CREATETASK(&_TCBIsr, "USBH_isr", USBH_ISRTask, TASK_PRIO_USBH_ISR, _StackIsr); // Start USBH main task USBH_HID_Init(); while (1) { BSP_ToggleLED(1); if (USBH_HID_GetNumDevices(NULL, 0)) { USBH_HID_HANDLE hDevice; USBH_HID_DEVICE_INFO aDevInfo[20]; unsigned NumItems = COUNTOF(_aReportInfo); USBH_HID_GetNumDevices(aDevInfo, COUNTOF(aDevInfo)); hDevice = USBH_HID_Open("hid000"); if (hDevice) { USBH_HID_GetReportDescriptorParsed(hDevice, &_aReportInfo[0], &NumItems); USBH_HID_GetReport(hDevice, _aReport, sizeof(_aReport), NULL, NULL); USBH_HID_Close(hDevice); } } OS_Delay(100); } }
/** * @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(); } }
/** * @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) { } }
void pyb_usb_host_init(void) { if (!host_is_enabled) { // only init USBH once in the device's power-lifetime /* Init Host Library */ USBH_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USB_Host, &HID_cb, &USR_Callbacks); } host_is_enabled = 1; }
/** * @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(); } }
/* init function */ void MX_USB_HOST_Init(void) { /* Init Host Library,Add Supported Class and Start the library*/ USBH_Init(&hUsbHostFS, USBH_UserProcess, HOST_FS); USBH_RegisterClass(&hUsbHostFS, USBH_MSC_CLASS); USBH_Start(&hUsbHostFS); }
/** * @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(); } }
/** * @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); } }
/** * @brief Initialize the middleware libraries and stacks * @param None * @retval None */ void MOD_LibInit(void) { NVIC_InitTypeDef NVIC_InitStructure; MOD_GetParam(GLOBAL_SETTINGS_MEM , &Global_Config.d32); /* Force settings change to apply them */ Global_Config.b.Configuration_Changed = 1; /* Starting USB Init. Process */ GL_State_Message((uint8_t *)"USB Host Starting. "); /*Init USB Host */ USBH_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USB_Host, &USBH_MSC_cb, &USBH_USR_cb); GL_State_Message((uint8_t *)"USB Host Started."); GL_State_Message((uint8_t *)"RTC and backup Starting. "); /* Init RTC and Backup */ if ( RTC_Configuration() == 0) { GL_State_Message((uint8_t *)"RTC and backup Started."); CONSOLE_LOG((uint8_t *)"[SYSTEM] RTC and backup Started."); } else { GL_State_Message((uint8_t *)"ERR : RTC could not be started."); CONSOLE_LOG((uint8_t *)"[ERR] RTC start-up FAILED ."); } NVIC_InitStructure.NVIC_IRQChannel = SDIO_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); SD_Init(); if ( f_mount( 1, &MSD_fatfs ) != FR_OK ) { /* fatfs initialisation fails*/ CONSOLE_LOG((uint8_t *)"[FS] Cannot initialize FS on drive 1."); } else { CONSOLE_LOG((uint8_t *)"[FS] FS on drive 1 initialized."); } }
//------------------------------------------------------------------------------------------------------------------------------------------------------ void FDrive_Init(void) { if(FATFS_LinkDriver(&USBH_Driver, USBDISKPath) == FR_OK) { USBH_StatusTypeDef res = USBH_Init(&handleUSBH, USBH_UserProcess, 0); res = USBH_RegisterClass(&handleUSBH, USBH_MSC_CLASS); res = USBH_Start(&handleUSBH); } else { // —юда попадаем, если usbh driver не удалось инициализировать } }
//------------------------------------------------------------------------------------------------------------------------------------------------------ void FDrive_Init(void) { if(FATFS_LinkDriver(&USBH_Driver, USBDISKPath) == FR_OK) { USBH_StatusTypeDef res = USBH_Init(&handleUSBH, USBH_UserProcess, 0); res = USBH_RegisterClass(&handleUSBH, USBH_MSC_CLASS); res = USBH_Start(&handleUSBH); } else { LOG_ERROR("Can not %s", __FUNCTION__); } }
/** * @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; } } }
void _usb_msc_host_init(unsigned int instance, new_gpio* StatusLed) { //if(FATFS_LinkDriver(&USBH_Driver, USBDISKPath) == 0) //{ /*##-2- Init Host Library ################################################*/ USBH_Init(&usb_msc_host_param[instance], USBH_UserProcess, 0); /*##-3- Add Supported Class ##############################################*/ USBH_RegisterClass(&usb_msc_host_param[instance], USBH_MSC_CLASS); /*##-4- Start Host Process ###############################################*/ USBH_Start(&usb_msc_host_param[instance]); //} }
void MY_USBH_Init(void) { /* Init Host Library */ USBH_Init(&hUSBHost, USBH_UserProcess, 0); /* Add Supported Class */ /* highest priority first */ USBH_RegisterClass(&hUSBHost, USBH_VENDOR_CLASS); USBH_RegisterClass(&hUSBHost, USBH_MIDI_CLASS); USBH_RegisterClass(&hUSBHost, USBH_HID_CLASS); /* Start Host Process */ USBH_Start(&hUSBHost); }
/* * 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; } } }
/** * @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; } } }
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 Start task * @param pvParameters not used * @retval None */ static void StartThread(void const * argument) { osEvent event; /* 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"); } for( ;; ) { event = osMessageGet(AppliEvent, osWaitForever); if(event.status == osEventMessage) { switch(event.value.v) { case APPLICATION_DISCONNECT: Appli_state = APPLICATION_DISCONNECT; osSemaphoreRelease(MenuEvent); break; case APPLICATION_READY: Appli_state = APPLICATION_READY; default: break; } } } }
void setup(void) { BSP_init(); printf("\n\rWelcome to USB-Host-Dock project!\n\r"); #ifdef USE_UHS20 if (uhs_init() != -1) xprintf("\nUsb is initialized.\n"); #else USBH_Init(&USB_OTG_Core_dev, #ifdef USE_USB_OTG_FS USB_OTG_FS_CORE_ID, #else USB_OTG_HS_CORE_ID, #endif &USB_Host, &HID_cb, &USR_Callbacks); #endif }