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

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


The following commit(s) were added to refs/heads/master by this push:
     new 32b25849fe chardriver upperCAN: support to independent set TX/RX FIFO 
size.
32b25849fe is described below

commit 32b25849fef97fb2ceaa14f6cb82cbc47df2213f
Author: zhaohaiyang1 <[email protected]>
AuthorDate: Wed Jun 19 14:41:34 2024 +0800

    chardriver upperCAN: support to independent set TX/RX FIFO size.
    
    support to independent set TX/RX FIFO size.
    
    Signed-off-by: zhaohaiyang1 <[email protected]>
---
 .../arm/samv7/boards/same70-xplained/README.txt    |  3 ++-
 .../arm/samv7/boards/samv71-xult/README.txt        |  3 ++-
 .../arm/stm32f1/boards/cloudctrl/index.rst         |  6 ++++-
 .../arm/stm32f1/boards/fire-stm32v2/index.rst      |  6 ++++-
 .../arm/stm32f1/boards/hymini-stm32/index.rst      |  6 ++++-
 .../arm/stm32f1/boards/shenzhou/index.rst          |  6 ++++-
 .../arm/stm32f1/boards/stm3210e-eval/index.rst     |  6 ++++-
 .../arm/stm32f1/boards/stm32_tiny/index.rst        |  6 ++++-
 .../arm/stm32f1/boards/stm32f103-minimum/index.rst |  6 ++++-
 Documentation/platforms/arm/stm32f2/index.rst      |  7 +++++-
 Documentation/platforms/arm/stm32f3/index.rst      |  7 +++++-
 Documentation/platforms/arm/stm32f4/index.rst      |  7 +++++-
 Documentation/platforms/arm/stm32f7/index.rst      |  8 ++++++-
 drivers/can/Kconfig                                | 14 ++++++++---
 drivers/can/can.c                                  | 14 +++++------
 include/nuttx/can/can.h                            | 27 +++++++++++++++-------
 16 files changed, 101 insertions(+), 31 deletions(-)

diff --git 
a/Documentation/platforms/arm/samv7/boards/same70-xplained/README.txt 
b/Documentation/platforms/arm/samv7/boards/same70-xplained/README.txt
index 916b1d3456..650b3a9c41 100644
--- a/Documentation/platforms/arm/samv7/boards/same70-xplained/README.txt
+++ b/Documentation/platforms/arm/samv7/boards/same70-xplained/README.txt
@@ -695,7 +695,8 @@ MCAN1 Loopback Test
 
     Device Drivers -> CAN Driver support
        CONFIG_CAN=y                            # Enable the upper-half CAN 
driver
-       CONFIG_CAN_FIFOSIZE=8
+       CONFIG_CAN_TXFIFOSIZE=8
+       CONFIG_CAN_RXFIFOSIZE=8
        CONFIG_CAN_NPENDINGRTR=4
 
     System Type -> SAMV7 Peripheral Selections
diff --git a/Documentation/platforms/arm/samv7/boards/samv71-xult/README.txt 
b/Documentation/platforms/arm/samv7/boards/samv71-xult/README.txt
index 30b2871dc8..29881da3a5 100644
--- a/Documentation/platforms/arm/samv7/boards/samv71-xult/README.txt
+++ b/Documentation/platforms/arm/samv7/boards/samv71-xult/README.txt
@@ -1288,7 +1288,8 @@ MCAN1 Loopback Test
 
     Device Drivers -> CAN Driver support
        CONFIG_CAN=y                            # Enable the upper-half CAN 
driver
-       CONFIG_CAN_FIFOSIZE=8
+       CONFIG_CAN_TXFIFOSIZE=8
+       CONFIG_CAN_RXFIFOSIZE=8
        CONFIG_CAN_NPENDINGRTR=4
 
     System Type -> SAMV7 Peripheral Selections
diff --git a/Documentation/platforms/arm/stm32f1/boards/cloudctrl/index.rst 
b/Documentation/platforms/arm/stm32f1/boards/cloudctrl/index.rst
index 653c357dc6..fb05c88956 100644
--- a/Documentation/platforms/arm/stm32f1/boards/cloudctrl/index.rst
+++ b/Documentation/platforms/arm/stm32f1/boards/cloudctrl/index.rst
@@ -385,7 +385,11 @@ Cloudctrl-specific Configuration Options
 
    CONFIG_CAN - Enables CAN support (one or both of CONFIG_STM32_CAN1 or
    CONFIG_STM32_CAN2 must also be defined)
-   CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
+   CONFIG_CAN_TXFIFOSIZE - The size of the circular tx buffer
+   of CAN messages.
+   Default: 8
+   CONFIG_CAN_RXFIFOSIZE - The size of the circular rx buffer
+   of CAN messages.
    Default: 8
    CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
    Default: 4
diff --git a/Documentation/platforms/arm/stm32f1/boards/fire-stm32v2/index.rst 
b/Documentation/platforms/arm/stm32f1/boards/fire-stm32v2/index.rst
index 304a0c29f5..ad1dae3a7f 100644
--- a/Documentation/platforms/arm/stm32f1/boards/fire-stm32v2/index.rst
+++ b/Documentation/platforms/arm/stm32f1/boards/fire-stm32v2/index.rst
@@ -501,7 +501,11 @@ M3 Wildfire-specific Configuration Options
    CONFIG_STM32_CAN2 must also be defined)
    CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID.  Default
    Standard 11-bit IDs.
-   CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
+   CONFIG_CAN_TXFIFOSIZE - The size of the circular tx buffer
+   of CAN messages.
+   Default: 8
+   CONFIG_CAN_RXFIFOSIZE - The size of the circular rx buffer
+   of CAN messages.
    Default: 8
    CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
    Default: 4
diff --git a/Documentation/platforms/arm/stm32f1/boards/hymini-stm32/index.rst 
b/Documentation/platforms/arm/stm32f1/boards/hymini-stm32/index.rst
index e130abc105..ffae6170a7 100644
--- a/Documentation/platforms/arm/stm32f1/boards/hymini-stm32/index.rst
+++ b/Documentation/platforms/arm/stm32f1/boards/hymini-stm32/index.rst
@@ -282,7 +282,11 @@ HY-Mini specific Configuration Options
          CONFIG_STM32_CAN2 must also be defined)
        CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID.  Default
          Standard 11-bit IDs.
-       CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
+       CONFIG_CAN_TXFIFOSIZE - The size of the circular tx buffer
+         of CAN messages.
+         Default: 8
+       CONFIG_CAN_RXFIFOSIZE - The size of the circular rx buffer
+         of CAN messages.
          Default: 8
        CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
          Default: 4
diff --git a/Documentation/platforms/arm/stm32f1/boards/shenzhou/index.rst 
b/Documentation/platforms/arm/stm32f1/boards/shenzhou/index.rst
index 4556641f89..ecdb3d49cf 100644
--- a/Documentation/platforms/arm/stm32f1/boards/shenzhou/index.rst
+++ b/Documentation/platforms/arm/stm32f1/boards/shenzhou/index.rst
@@ -395,7 +395,11 @@ Shenzhou-specific Configuration Options
 
    CONFIG_CAN - Enables CAN support (one or both of CONFIG_STM32_CAN1 or
    CONFIG_STM32_CAN2 must also be defined)
-   CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
+   CONFIG_CAN_TXFIFOSIZE - The size of the circular tx buffer
+   of CAN messages.
+   Default: 8
+   CONFIG_CAN_RXFIFOSIZE - The size of the circular rx buffer
+   of CAN messages.
    Default: 8
    CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
    Default: 4
diff --git a/Documentation/platforms/arm/stm32f1/boards/stm3210e-eval/index.rst 
b/Documentation/platforms/arm/stm32f1/boards/stm3210e-eval/index.rst
index 46567e01ec..3f506d6276 100644
--- a/Documentation/platforms/arm/stm32f1/boards/stm3210e-eval/index.rst
+++ b/Documentation/platforms/arm/stm32f1/boards/stm3210e-eval/index.rst
@@ -444,7 +444,11 @@ STM3210E-EVAL-specific Configuration Options
    CONFIG_STM32_CAN2 must also be defined)
    CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID.  Default
    Standard 11-bit IDs.
-   CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
+   CONFIG_CAN_TXFIFOSIZE - The size of the circular tx buffer
+   of CAN messages.
+   Default: 8
+   CONFIG_CAN_RXFIFOSIZE - The size of the circular rx buffer
+   of CAN messages.
    Default: 8
    CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
    Default: 4
diff --git a/Documentation/platforms/arm/stm32f1/boards/stm32_tiny/index.rst 
b/Documentation/platforms/arm/stm32f1/boards/stm32_tiny/index.rst
index be8e7d2c5f..92f2c488ee 100644
--- a/Documentation/platforms/arm/stm32f1/boards/stm32_tiny/index.rst
+++ b/Documentation/platforms/arm/stm32f1/boards/stm32_tiny/index.rst
@@ -231,7 +231,11 @@ STM32 Tiny - specific Configuration Options
          CONFIG_STM32_CAN2 must also be defined)
        CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID.  Default
          Standard 11-bit IDs.
-       CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
+       CONFIG_CAN_TXFIFOSIZE - The size of the circular tx buffer
+         of CAN messages.
+         Default: 8
+       CONFIG_CAN_RXFIFOSIZE - The size of the circular rx buffer
+         of CAN messages.
          Default: 8
        CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
          Default: 4
diff --git 
a/Documentation/platforms/arm/stm32f1/boards/stm32f103-minimum/index.rst 
b/Documentation/platforms/arm/stm32f1/boards/stm32f103-minimum/index.rst
index 601f22c38c..15b5abd7f8 100644
--- a/Documentation/platforms/arm/stm32f1/boards/stm32f103-minimum/index.rst
+++ b/Documentation/platforms/arm/stm32f1/boards/stm32f103-minimum/index.rst
@@ -740,7 +740,11 @@ STM32F103 Minimum - specific Configuration Options
             CONFIG_STM32_CAN2 must also be defined)
           CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID.  
Default
             Standard 11-bit IDs.
-          CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN 
messages.
+          CONFIG_CAN_TXFIFOSIZE - The size of the circular tx buffer
+            of CAN messages.
+            Default: 8
+          CONFIG_CAN_RXFIFOSIZE - The size of the circular rx buffer
+            of CAN messages.
             Default: 8
           CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR 
requests.
             Default: 4
diff --git a/Documentation/platforms/arm/stm32f2/index.rst 
b/Documentation/platforms/arm/stm32f2/index.rst
index 800d37c670..d69e7ccab4 100644
--- a/Documentation/platforms/arm/stm32f2/index.rst
+++ b/Documentation/platforms/arm/stm32f2/index.rst
@@ -93,7 +93,12 @@ CAN
 - CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID.
   Default Standard 11-bit IDs.
 
-- CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
+- CONFIG_CAN_TXFIFOSIZE - The size of the circular tx buffer
+  of CAN messages.
+  Default: 8
+   
+- CONFIG_CAN_RXFIFOSIZE - The size of the circular rx buffer
+  of CAN messages.
   Default: 8
 
 - CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
diff --git a/Documentation/platforms/arm/stm32f3/index.rst 
b/Documentation/platforms/arm/stm32f3/index.rst
index 2ab617c4b6..f0c0804dc0 100644
--- a/Documentation/platforms/arm/stm32f3/index.rst
+++ b/Documentation/platforms/arm/stm32f3/index.rst
@@ -140,7 +140,12 @@ CAN character device
 - CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID.  Default
   Standard 11-bit IDs.
 
-- CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
+- CONFIG_CAN_TXFIFOSIZE - The size of the circular tx buffer
+  of CAN messages.
+  Default: 8
+   
+- CONFIG_CAN_RXFIFOSIZE - The size of the circular rx buffer
+  of CAN messages.
   Default: 8
 
 - CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
diff --git a/Documentation/platforms/arm/stm32f4/index.rst 
b/Documentation/platforms/arm/stm32f4/index.rst
index 607024f956..280a4dd3e5 100644
--- a/Documentation/platforms/arm/stm32f4/index.rst
+++ b/Documentation/platforms/arm/stm32f4/index.rst
@@ -144,7 +144,12 @@ CAN
 - CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID.  Default
   Standard 11-bit IDs.
 
-- CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
+- CONFIG_CAN_TXFIFOSIZE - The size of the circular tx buffer
+  of CAN messages.
+  Default: 8
+   
+- CONFIG_CAN_RXFIFOSIZE - The size of the circular rx buffer
+  of CAN messages.
   Default: 8
 
 - CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
diff --git a/Documentation/platforms/arm/stm32f7/index.rst 
b/Documentation/platforms/arm/stm32f7/index.rst
index ca2c741aad..bb8abff95b 100644
--- a/Documentation/platforms/arm/stm32f7/index.rst
+++ b/Documentation/platforms/arm/stm32f7/index.rst
@@ -189,7 +189,13 @@ CAN
 
 - CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID.  Default 
Standard 11-bit IDs.
 
-- CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.  
Default: 8
+- CONFIG_CAN_TXFIFOSIZE - The size of the circular tx buffer
+  of CAN messages.
+  Default: 8
+   
+- CONFIG_CAN_RXFIFOSIZE - The size of the circular rx buffer
+  of CAN messages.
+  Default: 8
 
 - CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.  
Default: 4
 
diff --git a/drivers/can/Kconfig b/drivers/can/Kconfig
index d6a2b88a1d..2379a9c81a 100644
--- a/drivers/can/Kconfig
+++ b/drivers/can/Kconfig
@@ -39,11 +39,19 @@ config CAN_FD
        ---help---
                Enables support for the CAN_FD mode.
 
-config CAN_FIFOSIZE
-       int "CAN driver I/O buffer size"
+config CAN_TXFIFOSIZE
+       int "CAN driver I/O tx buffer size"
        default 8
+       range 1 255
        ---help---
-               The size of the circular buffer of CAN messages. Default: 8
+               The size of the circular tx buffer of CAN messages. Default: 8
+
+config CAN_RXFIFOSIZE
+       int "CAN driver I/O rx buffer size"
+       default 8
+       range 1 255
+       ---help---
+               The size of the circular rx buffer of CAN messages. Default: 8
 
 config CAN_NPENDINGRTR
        int "Number of pending RTRs"
diff --git a/drivers/can/can.c b/drivers/can/can.c
index 9816a83fdb..22dfdc1f8d 100644
--- a/drivers/can/can.c
+++ b/drivers/can/can.c
@@ -465,7 +465,7 @@ static ssize_t can_read(FAR struct file *filep, FAR char 
*buffer,
 
           /* Increment the head of the circular message buffer */
 
-          if (++fifo->rx_head >= CONFIG_CAN_FIFOSIZE)
+          if (++fifo->rx_head >= CONFIG_CAN_RXFIFOSIZE)
             {
               fifo->rx_head = 0;
             }
@@ -549,7 +549,7 @@ static int can_xmit(FAR struct can_dev_s *dev)
        */
 
       tmpndx = dev->cd_xmit.tx_queue;
-      if (++dev->cd_xmit.tx_queue >= CONFIG_CAN_FIFOSIZE)
+      if (++dev->cd_xmit.tx_queue >= CONFIG_CAN_TXFIFOSIZE)
         {
           dev->cd_xmit.tx_queue = 0;
         }
@@ -615,7 +615,7 @@ static ssize_t can_write(FAR struct file *filep, FAR const 
char *buffer,
        */
 
       nexttail = fifo->tx_tail + 1;
-      if (nexttail >= CONFIG_CAN_FIFOSIZE)
+      if (nexttail >= CONFIG_CAN_TXFIFOSIZE)
         {
           nexttail = 0;
         }
@@ -885,7 +885,7 @@ static int can_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
 
       case FIONWRITE:
         {
-          *(FAR uint8_t *)arg = CONFIG_CAN_FIFOSIZE - 1 -
+          *(FAR uint8_t *)arg = CONFIG_CAN_TXFIFOSIZE - 1 -
                             (dev->cd_xmit.tx_tail - dev->cd_xmit.tx_head);
         }
         break;
@@ -997,7 +997,7 @@ static int can_poll(FAR struct file *filep, FAR struct 
pollfd *fds,
        */
 
       ndx = dev->cd_xmit.tx_tail + 1;
-      if (ndx >= CONFIG_CAN_FIFOSIZE)
+      if (ndx >= CONFIG_CAN_TXFIFOSIZE)
         {
           ndx = 0;
         }
@@ -1188,7 +1188,7 @@ int can_receive(FAR struct can_dev_s *dev, FAR struct 
can_hdr_s *hdr,
       fifo = &reader->fifo;
 
       nexttail = fifo->rx_tail + 1;
-      if (nexttail >= CONFIG_CAN_FIFOSIZE)
+      if (nexttail >= CONFIG_CAN_RXFIFOSIZE)
         {
           nexttail = 0;
         }
@@ -1358,7 +1358,7 @@ int can_txdone(FAR struct can_dev_s *dev)
 
       /* Remove the message at the head of the xmit FIFO */
 
-      if (++dev->cd_xmit.tx_head >= CONFIG_CAN_FIFOSIZE)
+      if (++dev->cd_xmit.tx_head >= CONFIG_CAN_TXFIFOSIZE)
         {
           dev->cd_xmit.tx_head = 0;
         }
diff --git a/include/nuttx/can/can.h b/include/nuttx/can/can.h
index 1d53e8442b..9ded0040f9 100644
--- a/include/nuttx/can/can.h
+++ b/include/nuttx/can/can.h
@@ -59,7 +59,11 @@
  * CONFIG_CAN_FD - Enable support for CAN FD mode.
  *   For the upper half driver, this just means handling encoded DLC values
  *   (for values of DLC > 9).
- * CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
+ * CONFIG_CAN_TXFIFOSIZE - The size of the circular tx buffer
+ *   of CAN messages.
+ *   Default: 8
+ * CONFIG_CAN_RXFIFOSIZE - The size of the circular rx buffer
+ *   of CAN messages.
  *   Default: 8
  * CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
  *   Default: 4
@@ -81,11 +85,18 @@
  * The configured size is limited to 255 to fit into a uint8_t.
  */
 
-#if !defined(CONFIG_CAN_FIFOSIZE)
-#  define CONFIG_CAN_FIFOSIZE 8
-#elif CONFIG_CAN_FIFOSIZE > 255
-#  undef  CONFIG_CAN_FIFOSIZE
-#  define CONFIG_CAN_FIFOSIZE 255
+#if !defined(CONFIG_CAN_TXFIFOSIZE)
+#  define CONFIG_CAN_TXFIFOSIZE 8
+#elif CONFIG_CAN_TXFIFOSIZE > 255
+#  undef  CONFIG_CAN_TXFIFOSIZE
+#  define CONFIG_CAN_TXFIFOSIZE 255
+#endif
+
+#if !defined(CONFIG_CAN_RXFIFOSIZE)
+#  define CONFIG_CAN_RXFIFOSIZE 8
+#elif CONFIG_CAN_RXFIFOSIZE > 255
+#  undef  CONFIG_CAN_RXFIFOSIZE
+#  define CONFIG_CAN_RXFIFOSIZE 255
 #endif
 
 #if !defined(CONFIG_CAN_NPENDINGRTR)
@@ -554,7 +565,7 @@ struct can_rxfifo_s
   uint8_t       rx_head;                 /* Index to the head [IN] in the 
circular buffer */
   uint8_t       rx_tail;                 /* Index to the tail [OUT] in the 
circular buffer */
                                          /* Circular buffer of CAN messages */
-  struct can_msg_s rx_buffer[CONFIG_CAN_FIFOSIZE];
+  struct can_msg_s rx_buffer[CONFIG_CAN_RXFIFOSIZE];
 };
 
 struct can_txfifo_s
@@ -564,7 +575,7 @@ struct can_txfifo_s
   uint8_t       tx_queue;                /* Index to next message to send */
   uint8_t       tx_tail;                 /* Index to the tail [OUT] in the 
circular buffer */
                                          /* Circular buffer of CAN messages */
-  struct can_msg_s tx_buffer[CONFIG_CAN_FIFOSIZE];
+  struct can_msg_s tx_buffer[CONFIG_CAN_TXFIFOSIZE];
 };
 
 /* The following structure define the logic to handle

Reply via email to