Exemplo n.º 1
0
static FAR void *board_composite1_connect(int port)
{
  /* REVISIT:  This configuration currently fails.  stm32_epallocpma() fails
   * allocate a buffer for the 6th endpoint.  Currenlty it supports 7x64 byte
   * buffers, two required for EP0, leaving only buffers for 5 additional
   * endpoints.
   */

#if 0
  struct composite_devdesc_s dev[2];
  int strbase = COMPOSITE_NSTRIDS;
  int ifnobase = 0;
  int epno;
  int i;

  for (i = 0, epno = 1; i < 2; i++)
    {
      /* Ask the cdcacm driver to fill in the constants we didn't know here */

      cdcacm_get_composite_devdesc(&dev[i]);

      /* Overwrite and correct some values... */
      /* The callback functions for the CDC/ACM class */

      dev[i].classobject = cdcacm_classobject;
      dev[i].uninitialize = cdcacm_uninitialize;

      dev[i].minor = i;                         /* The minor interface number */

      /* Interfaces */

      dev[i].devinfo.ifnobase = ifnobase;        /* Offset to Interface-IDs */

      /* Strings */

      dev[i].devinfo.strbase = strbase;          /* Offset to String Numbers */

      /* Endpoints */

      dev[i].devinfo.epno[CDCACM_EP_INTIN_IDX]   = epno++;
      dev[i].devinfo.epno[CDCACM_EP_BULKIN_IDX]  = epno++;
      dev[i].devinfo.epno[CDCACM_EP_BULKOUT_IDX] = epno++;

      ifnobase += dev[i].devinfo.ninterfaces;
      strbase  += dev[i].devinfo.nstrings;
    }

  return composite_initialize(2, dev);
#else
  return NULL;
#endif
}
Exemplo n.º 2
0
int conn_main(int argc, char *argv[])
#endif
{
  int ret;

  /* If this program is implemented as the NSH 'msconn' command, then we need to
   * do a little error checking to assure that we are not being called re-entrantly.
   */

#ifdef CONFIG_NSH_BUILTIN_APPS

   /* Check if there is a non-NULL USB mass storage device handle (meaning that the
    * USB mass storage device is already configured).
    */

   if (g_composite.cmphandle)
     {
       printf("conn_main: ERROR: Already connected\n");
       return 1;
     }
#endif

#ifdef CONFIG_SYSTEM_COMPOSITE_DEBUGMM
#  ifdef CONFIG_CAN_PASS_STRUCTS
  g_composite.mmstart    = mallinfo();
  g_composite.mmprevious = g_composite.mmstart;
#  else
  (void)mallinfo(&g_composite.mmstart);
  memcpy(&g_composite.mmprevious, &g_composite.mmstart, sizeof(struct mallinfo));
#  endif
#endif

  /* Perform architecture-specific initialization */

  printf("conn_main: Performing architecture-specific intialization\n");
  ret = composite_archinitialize();
  if (ret < 0)
    {
      printf("conn_main: composite_archinitialize failed: %d\n", -ret);
      return 1;
    }

  check_test_memory_usage("After composite_archinitialize()");

  /* Initialize the USB composite device device */

  g_composite.cmphandle = composite_initialize();
  if (!g_composite.cmphandle)
    {
      printf("conn_main: composite_initialize failed\n");
      return 1;
    }

  check_test_memory_usage("After composite_initialize()");

#if CONFIG_USBDEV_TRACE && CONFIG_USBDEV_TRACE_INITIALIDSET != 0
  /* If USB tracing is enabled and tracing of initial USB events is specified,
   * then dump all collected trace data to stdout
   */

  sleep(5);
  ret = dumptrace();
  if (ret < 0)
    {
      goto errout;
    }
#endif

  /* It this program was configued as an NSH command, then just exit now.
   * Also, if signals are not enabled (and, hence, sleep() is not supported.
   * then we have not real option but to exit now.
   */

#if !defined(CONFIG_NSH_BUILTIN_APPS) && !defined(CONFIG_DISABLE_SIGNALS)

  /* Otherwise, this thread will hang around and monitor the USB activity */

  /* Open the serial driver */

  ret = open_serial();
  if (ret < 0)
    {
      goto errout;
    }

  /* Now looping */

  for (;;)
    {
      /* Sleep for a bit */

      fflush(stdout);
      sleep(5);

      /* Echo any serial data */

      ret = echo_serial();
      if (ret < 0)
        {
          goto errout;
        }

      /* Dump trace data */

#  ifdef CONFIG_USBDEV_TRACE
      printf("\n" "conn_main: USB TRACE DATA:\n");
      ret = dumptrace();
      if (ret < 0)
        {
          goto errout;
        }

      check_test_memory_usage("After usbtrace_enumerate()");
#  else
      printf("conn_main: Still alive\n");
#  endif
    }
#else

   printf("conn_main: Connected\n");
   check_test_memory_usage("After composite device connection");
#endif

   /* Dump debug memory usage */

   printf("conn_main: Exiting\n");
#if !defined(CONFIG_NSH_BUILTIN_APPS) && !defined(CONFIG_DISABLE_SIGNALS)
   close(g_composite.infd);
   close(g_composite.outfd);
#endif
#ifdef CONFIG_NSH_BUILTIN_APPS
#endif
   final_memory_usage("Final memory usage");
   return 0;

errout:
#if !defined(CONFIG_NSH_BUILTIN_APPS) && !defined(CONFIG_DISABLE_SIGNALS)
  close(g_composite.infd);
  close(g_composite.outfd);
#endif
  composite_uninitialize(g_composite.cmphandle);
  final_memory_usage("Final memory usage");
  return 1;
}
Exemplo n.º 3
0
static FAR void *board_composite0_connect(int port)
{
  /* Here we are composing the configuration of the usb composite device.
   *
   * The standard is to use one CDC/ACM and one USB mass storage device.
   */

  struct composite_devdesc_s dev[2];
  int ifnobase = 0;
  int strbase  = COMPOSITE_NSTRIDS;

  /* Configure the CDC/ACM device */

  /* Ask the cdcacm driver to fill in the constants we didn't
   * know here.
   */

  cdcacm_get_composite_devdesc(&dev[0]);

  /* Overwrite and correct some values... */
  /* The callback functions for the CDC/ACM class */

  dev[0].classobject  = cdcacm_classobject;
  dev[0].uninitialize = cdcacm_uninitialize;

  /* Interfaces */

  dev[0].devinfo.ifnobase = ifnobase;             /* Offset to Interface-IDs */
  dev[0].minor = 0;                               /* The minor interface number */

  /* Strings */

  dev[0].devinfo.strbase = strbase;               /* Offset to String Numbers */

  /* Endpoints */

  dev[0].devinfo.epno[CDCACM_EP_INTIN_IDX]   = 1;
  dev[0].devinfo.epno[CDCACM_EP_BULKIN_IDX]  = 2;
  dev[0].devinfo.epno[CDCACM_EP_BULKOUT_IDX] = 3;

  /* Count up the base numbers */

  ifnobase += dev[0].devinfo.ninterfaces;
  strbase  += dev[0].devinfo.nstrings;

  /* Configure the mass storage device device */
  /* Ask the usbmsc driver to fill in the constants we didn't
   * know here.
   */

  usbmsc_get_composite_devdesc(&dev[1]);

  /* Overwrite and correct some values... */
  /* The callback functions for the USBMSC class */

  dev[1].classobject  = board_mscclassobject;
  dev[1].uninitialize = board_mscuninitialize;

  /* Interfaces */

  dev[1].devinfo.ifnobase = ifnobase;               /* Offset to Interface-IDs */
  dev[1].minor = 0;                                 /* The minor interface number */

  /* Strings */

  dev[1].devinfo.strbase = strbase;   /* Offset to String Numbers */

  /* Endpoints */

  dev[1].devinfo.epno[USBMSC_EP_BULKIN_IDX]  = 5;
  dev[1].devinfo.epno[USBMSC_EP_BULKOUT_IDX] = 4;

  /* Count up the base numbers */

  ifnobase += dev[1].devinfo.ninterfaces;
  strbase  += dev[1].devinfo.nstrings;

  return composite_initialize(2, dev);
}