Skip to content

Commit

Permalink
drivers/serial: add ram uart driver
Browse files Browse the repository at this point in the history
It uses the memory block as the serial communication medium, which can communicate between different processes or different CPUs

Using the following configuration, the cross-core communication rate of 200MHz cortex-M55 is about 461KB/s
RAM_UART_BUFSIZE=1024
RAM_UART_POLLING_INTERVAL=100

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
  • Loading branch information
Gary-Hobson authored and xiaoxiang781216 committed Sep 19, 2023
1 parent 1d9097f commit 1d8e697
Show file tree
Hide file tree
Showing 5 changed files with 699 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/drivers_initialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <nuttx/segger/rtt.h>
#include <nuttx/sensors/sensor.h>
#include <nuttx/serial/pty.h>
#include <nuttx/serial/uart_ram.h>
#include <nuttx/syslog/syslog.h>
#include <nuttx/syslog/syslog_console.h>
#include <nuttx/trace.h>
Expand Down Expand Up @@ -118,6 +119,10 @@ void drivers_initialize(void)
rpmsg_serialinit();
#endif

#ifdef CONFIG_RAM_UART
ram_serialinit();
#endif

/* Initialize the console device driver (if it is other than the standard
* serial driver).
*/
Expand Down
69 changes: 69 additions & 0 deletions drivers/serial/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,75 @@ source "drivers/serial/Kconfig-lpuart"
source "drivers/serial/Kconfig-usart"
source "drivers/serial/Kconfig-sci"

config RAM_UART
bool "RAM uart driver"
select SERIAL_RXDMA
select SERIAL_TXDMA
default n
---help---
It uses the memory block in the kernel as a communication medium,
which can communicate between different processes or different CPUs

if RAM_UART
config RAM_UART_POLLING_INTERVAL
int "RAM uart buffer check interval"
default USEC_PER_TICK
---help---
Interval in milliseconds to check for new data on uart ram buffer

config RAM_UART_BUFSIZE
int "RAM_UART buffer size"
default 1024
---help---
The size of the RAM_UART buffer in bytes

config RAM_UART0
bool "RAM uart driver 0"
default n
---help---
RAM_UART device 0

config RAM_UART0_SLAVE
bool "RAM_UART0 is slave"
depends on RAM_UART0
default n
---help---
The RAM uart0 is slave

config RAM_UART1
bool "RAM uart driver 1"
default n
---help---
RAM uart device 1

config RAM_UART1_SLAVE
bool "RAM uart1 is slave"
depends on RAM_UART1
default n
---help---
The RAM uart1 is slave

config RAM_UART2
bool "RAM uart driver 2"
default n
---help---
RAM uart device 2

config RAM_UART2_SLAVE
bool "RAM uart2 is slave"
depends on RAM_UART2
default n
---help---
The RAM uart2 is slave

config RAM_UART_BUFFER_SECTION
string "RAM uart buffer section name"
depends on RAM_UART0 || RAM_UART1 || RAM_UART2
---help---
The name of the section in the kernel memory block

endif # RAM_UART

menuconfig PSEUDOTERM
bool "Pseudo-Terminal (PTY) support"
default n
Expand Down
5 changes: 5 additions & 0 deletions drivers/serial/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ ifeq ($(CONFIG_UART_BTH5),y)
CSRCS += uart_bth5.c
endif

# RAM uart support

ifeq ($(CONFIG_RAM_UART),y)
CSRCS += uart_ram.c
endif

# Include serial build support

Expand Down

0 comments on commit 1d8e697

Please sign in to comment.