Beispiel #1
0
//! @brief In host mode, display basic low level information about the device connected
//!
//! @note The device should be supported by the host (configured)
//!
void ushell_cmdusb_ls(void)
{
   uint8_t i,j;

   // Check USB host status
   if( (!Is_host_ready()) && (!Is_host_suspended()) )
   {
      fputs(MSG_NO_DEVICE, stdout);
      return;
   }
   if( Is_host_suspended() )
   {
      fputs(MSG_USB_SUSPENDED, stdout);
   }

   printf("VID:%04X, PID:%04X, ",Get_VID(),Get_PID());
   printf("MaxPower is %imA, ",2*Get_maxpower());
   if (Is_device_self_powered())
   {  fputs(MSG_SELF_POWERED, stdout);}
   else
   {  fputs(MSG_BUS_POWERED, stdout); }
   if (Is_usb_full_speed_mode())
   {  fputs(MSG_DEVICE_FULL_SPEED, stdout);}
   else
#if (USB_HIGH_SPEED_SUPPORT==false)
   {  fputs(MSG_DEVICE_LOW_SPEED, stdout); }
#else
   {  fputs(MSG_DEVICE_HIGH_SPEED, stdout); }
#endif
   if (Is_device_supports_remote_wakeup())
   {  fputs(MSG_REMOTE_WAKEUP_OK, stdout);}
   else
   {  fputs(MSG_REMOTE_WAKEUP_KO, stdout); }
   printf("Supported interface(s):%02i\n\r",Get_nb_supported_interface());
   for(i=0;i<Get_nb_supported_interface();i++)
   {
      printf("Interface nb:%02i, AltS nb:%02i, Class:%02i, SubClass:%02i, Protocol:%02i\n\r",\
         Get_interface_number(i), Get_altset_nb(i), Get_class(i), Get_subclass(i), Get_protocol(i));
      printf(" Endpoint(s) Addr:");
      if(Get_nb_ep(i))
      {
         for(j=0;j<Get_nb_ep(i);j++)
         {
            printf(" %02lX", Get_ep_nbr(i,j));
         }
      }
      else
      {
         printf("None");
      }
      putchar(ASCII_CR);putchar(ASCII_LF);
   }
}
Beispiel #2
0
/*!
 *  \brief Common synchronization function between the Control Panel and a USB key.
 *
 *  \param xModId             Input. The module that is calling this function.
 *  \param FsNavId            Input. The file system navigator id to use.
 *  \param ppcStringReply     Input/Output. The response string.
 *                            If Input is NULL, no response string will be output.
 *                            Else a malloc for the response string may be performed
 *                            here; the caller must thus free this string.
 *  \param pcStringMsgAction  Input. The message to display when performing the
 *                            action.
 *  \param sync_direction     Input. The direction of the synchonization(DEVICE_TO_HOST
 *                            or HOST_TO_DEVICE)
 *  \param pcdir_name         Input. The name of the directory to synchronize.
 *  \param bDeleteSrc         Input. Flag to perform a copy(false) or a move(true).
 *
 *  \return the status of the command execution. If the status is SHELL_EXECSTATUS_KO,
 *  the caller MUST NOT FREE the response string. If the status is SHELL_EXECSTATUS_OK
 *  and the response string is not NULL, the caller MUST free the response string.
 */
static eExecStatus prv_e_usbsys_sync_cp_ukey( eModId xModId, signed short FsNavId,
                                              signed portCHAR **ppcStringReply,
                                              signed portCHAR *pcStringMsgAction,
                                              U8 sync_direction, const char *pcdir_name,
                                              bool bDeleteSrc )
{
   if( NULL != ppcStringReply )
      *ppcStringReply = NULL;

#if USB_HOST_FEATURE == true
   if (!Is_host_ready() && !Is_host_suspended())
   {
      v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)MSG_NO_DEVICE );
      return SHELL_EXECSTATUS_KO;
   }

   v_shell_Print_String_To_Requester_Stream( xModId, pcStringMsgAction );

   if( false == host_mass_storage_task_sync_drives( FsNavId, sync_direction, pcdir_name, bDeleteSrc ) )
   {
      v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)MSG_KO );
   }
   else
   {
      v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)MSG_OK );
   }

#endif
   return( SHELL_EXECSTATUS_OK );
}
Beispiel #3
0
//! @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();
}
Beispiel #4
0
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
}
Beispiel #5
0
/*!
 *  \brief In host mode, display basic low-level information about the connected device.
 *  The device should be supported by the host (configured).
 *         No parameters.
 *         Format: lsusb
 *
 *  \note  This function must be of the type pfShellCmd defined by the shell module.
 *
 *  \param xModId         Input. The module that is calling this function.
 *  \param FsNavId        Ignored.
 *  \param ac             Input. The argument counter. Ignored.
 *  \param av             Input. The argument vector. Ignored
 *  \param ppcStringReply Input/Output. The response string.
 *                        If Input is NULL, no response string will be output.
 *                        Else a malloc for the response string is performed here;
 *                        the caller must free this string.
 *
 *  \return the status of the command execution.
 */
eExecStatus e_usbsys_lsusb( eModId xModId, signed short FsNavId,
                       int ac, signed portCHAR *av[],
                       signed portCHAR **ppcStringReply )
{
#if USB_HOST_FEATURE == true
   signed portCHAR *pcStringToPrint;
   U8 i, j;


   if( NULL != ppcStringReply )
      *ppcStringReply = NULL;

   if (!Is_host_ready() && !Is_host_suspended())
   {
      v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)MSG_NO_DEVICE );
      return SHELL_EXECSTATUS_KO;
   }

   pcStringToPrint = (signed portCHAR *)pvPortMalloc( SHELL_MAX_MSGOUT_LEN ); // Alloc
   if( NULL == pcStringToPrint )
   {
      return( SHELL_EXECSTATUS_KO );
   }

   if (Is_host_suspended())
   {
      v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)MSG_USB_SUSPENDED CRLF );
   }

   sprintf( (char *)pcStringToPrint, "VID: 0x%.4X, PID: 0x%.4X\r\n"
            "Device MaxPower is %d mA\r\n"
            "%s"
            "%s",
            Get_VID(), Get_PID(),
            2 * Get_maxpower(),
            Is_device_self_powered() ? MSG_SELF_POWERED : MSG_BUS_POWERED,
            Is_usb_full_speed_mode() ? MSG_DEVICE_FULL_SPEED : MSG_DEVICE_LOW_SPEED );
   v_shell_Print_String_To_Requester_Stream( xModId, pcStringToPrint );
   sprintf( (char *)pcStringToPrint, "%s"
            "Supported interface(s): %u",
            Is_device_supports_remote_wakeup() ? MSG_REMOTE_WAKEUP_OK : MSG_REMOTE_WAKEUP_KO,
            Get_nb_supported_interface() );
   v_shell_Print_String_To_Requester_Stream( xModId, pcStringToPrint );

   for (i = 0; i < Get_nb_supported_interface(); i++)
   {
      sprintf( (char *)pcStringToPrint, "\r\nInterface nb: %u, AltS nb: %u, Class: 0x%.2X,"
               " SubClass: 0x%.2X, Protocol: 0x%.2X\r\n" "\tAssociated Ep Nbrs:",
               Get_interface_number(i), Get_altset_nb(i), Get_class(i),
               Get_subclass(i), Get_protocol(i) );
      v_shell_Print_String_To_Requester_Stream( xModId, pcStringToPrint );

      if (Get_nb_ep(i))
      {
         for (j = 0; j < Get_nb_ep(i); j++)
         {
            sprintf( (char *)pcStringToPrint, " %u", (U16)Get_ep_nbr(i, j) );
            v_shell_Print_String_To_Requester_Stream( xModId, pcStringToPrint );
         }
      }
      else
      {
         v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)"None" );
      }
   }

   vPortFree( pcStringToPrint );

   v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)CRLF );
#else
   v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)MSG_NO_DEVICE );
#endif
   return( SHELL_EXECSTATUS_OK );
}