chardriver upperCAN: support to independent set TX/RX FIFO size.

support to independent set TX/RX FIFO size.

Signed-off-by: zhaohaiyang1 <zhaohaiyang1@xiaomi.com>
This commit is contained in:
zhaohaiyang1 2024-06-19 14:41:34 +08:00 committed by Lup Yuen Lee
parent 9b698b2304
commit 63515d584b
16 changed files with 101 additions and 31 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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"

View File

@ -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;
@ -1044,7 +1044,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;
}
@ -1235,7 +1235,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;
}
@ -1405,7 +1405,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;
}

View File

@ -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)
@ -622,7 +633,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
@ -632,7 +643,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