//! @brief In host mode, resume host from suspend mode //! void ushell_cmdusb_resume(void) { if( !Is_host_suspended() ) { fputs(MSG_NO_DEVICE, stdout); } Host_request_resume(); }
void host_template_task(void) #endif { #if USB_HOST_PIPE_INTERRUPT_TRANSFER == DISABLE Status_t sta; U16 nb; #endif U8 i; #ifdef FREERTOS_USED portTickType xLastWakeTime; xLastWakeTime = xTaskGetTickCount(); while (true) { vTaskDelayUntil(&xLastWakeTime, configTSK_USB_HTP_PERIOD); #endif // FREERTOS_USED // First, check the host controller is in full operating mode with the // B-device attached and enumerated if (Is_host_ready()) { // Put here the code to execute in host mode #if BOARD == EVK1100 // For example, display Start-of-Frame counter on LEDs LED_Display_Field(LED_MONO0_GREEN | LED_MONO1_GREEN | LED_MONO2_GREEN | LED_MONO3_GREEN, sof_cnt >> 5); #elif BOARD == EVK1101 || BOARD == UC3C_EK || BOARD == EVK1104 || BOARD == EVK1105 // For example, display Start-of-Frame counter on LEDs LED_Display_Field(LED0 | LED1, sof_cnt >> 5); #else #error The display of the SOFs must be defined here. #endif // New device connection (executed only once after device connection) if (tpl_new_device_connected) { tpl_new_device_connected = false; #if USB_HOST_PIPE_INTERRUPT_TRANSFER == ENABLE // No more pipe interrupt transfer pending busy = false; #endif // For all supported interfaces for (i = 0; i < Get_nb_supported_interface(); i++) { // If vendor-specific class if (Get_class(i) == VENDOR_CLASS) { // Get correct physical pipes associated with IN/OUT endpoints if (Is_ep_in(i, 0)) { // Yes, associate it with the IN pipe pipe_in = Get_ep_pipe(i, 0); pipe_out = Get_ep_pipe(i, 1); } else { // No, invert... pipe_in = Get_ep_pipe(i, 1); pipe_out = Get_ep_pipe(i, 0); } break; } } } #if USB_HOST_PIPE_INTERRUPT_TRANSFER == DISABLE // The sample task sends 64 bytes through OUT pipe LED_On(LED_APPLI_0); sta = host_send_data(pipe_out, sizeof(buf), buf); LED_Off(LED_APPLI_0); // And receives 64 bytes from IN pipe nb = sizeof(buf); LED_On(LED_APPLI_1); sta = host_get_data(pipe_in, &nb, buf); LED_Off(LED_APPLI_1); #else // Similar applicative task under interrupt mode... if (!busy) { busy = true; LED_On(LED_APPLI_0); host_send_data_interrupt(pipe_out, sizeof(buf), buf, host_send_data_callback); LED_Off(LED_APPLI_0); } #endif // Here is an example of an applicative request to go to USB suspend ... if (false/* applicative conditions */) { host_set_feature_remote_wakeup(); Host_request_suspend(); } } // Here an applicative example of resume request... if (Is_host_suspended()/* && applicative conditions */) { Host_request_resume(); } #ifdef FREERTOS_USED } #endif }