This is an automated email from the ASF dual-hosted git repository.

anchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 16bf06606823c44bd2cd33c8d05de72ee6dccbe4
Author: Ricard Rosson <[email protected]>
AuthorDate: Tue Oct 27 12:27:49 2026 +0000

    boards/arm/rp23xx/common: Add CDC-NCM to the composite device.
    
    Add a CDC-NCM network function to the common board_composite_connect(),
    after the mass storage and CDC-ACM functions, on endpoints 6/7/8.  The
    CDC-ACM function now also counts up the interface and string base
    numbers, so that a function after it does not reuse them.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Ricard Rosson <[email protected]>
---
 boards/arm/rp23xx/common/src/rp23xx_composite.c | 38 ++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/boards/arm/rp23xx/common/src/rp23xx_composite.c 
b/boards/arm/rp23xx/common/src/rp23xx_composite.c
index ac9c117ec9e..3aa6583a9b4 100644
--- a/boards/arm/rp23xx/common/src/rp23xx_composite.c
+++ b/boards/arm/rp23xx/common/src/rp23xx_composite.c
@@ -32,6 +32,10 @@
 #include <nuttx/usb/usbmsc.h>
 #include <nuttx/usb/composite.h>
 
+#ifdef CONFIG_CDCNCM_COMPOSITE
+#  include <nuttx/usb/cdcncm.h>
+#endif
+
 #if defined(CONFIG_BOARDCTL_USBDEVCTRL) && defined(CONFIG_USBDEV_COMPOSITE)
 
 /****************************************************************************
@@ -186,11 +190,12 @@ void *board_composite_connect(int port, int configid)
   /* 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.
+   * A CDC/NCM network device can be added after them.
    */
 
   if (configid == 0)
     {
-      struct composite_devdesc_s dev[2];
+      struct composite_devdesc_s dev[3];
       int ifnobase = 0;
       int strbase  = COMPOSITE_NSTRIDS;
       int n = 0;
@@ -262,6 +267,37 @@ void *board_composite_connect(int port, int configid)
       dev[n].devinfo.epno[CDCACM_EP_INTIN_IDX]   = 3;
       dev[n].devinfo.epno[CDCACM_EP_BULKIN_IDX]  = 4;
       dev[n].devinfo.epno[CDCACM_EP_BULKOUT_IDX] = 5;
+
+      /* Count up the base numbers */
+
+      ifnobase += dev[n].devinfo.ninterfaces;
+      strbase  += dev[n].devinfo.nstrings;
+      n++;
+#endif
+
+#ifdef CONFIG_CDCNCM_COMPOSITE
+      /* Configure the CDC/NCM network device */
+
+      /* Ask the cdcncm driver to fill in the constants we didn't
+       * know here.
+       */
+
+      cdcncm_get_composite_devdesc(&dev[n]);
+
+      /* Interfaces */
+
+      dev[n].devinfo.ifnobase = ifnobase;             /* Offset to 
Interface-IDs */
+      dev[n].minor = 0;                               /* The minor interface 
number */
+
+      /* Strings */
+
+      dev[n].devinfo.strbase = strbase;               /* Offset to String 
Numbers */
+
+      /* Endpoints */
+
+      dev[n].devinfo.epno[CDCNCM_EP_INTIN_IDX]   = 6;
+      dev[n].devinfo.epno[CDCNCM_EP_BULKIN_IDX]  = 7;
+      dev[n].devinfo.epno[CDCNCM_EP_BULKOUT_IDX] = 8;
       n++;
 #endif
 

Reply via email to