mirror of
https://github.com/apache/nuttx.git
synced 2026-05-20 04:16:35 +08:00
drivers/serial: add ram uart driver
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>
This commit is contained in:
@@ -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>
|
||||
@@ -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).
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,82 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/serial/uart_ram.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_SERIAL_UART_RAM_H
|
||||
#define __INCLUDE_NUTTX_SERIAL_UART_RAM_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifdef CONFIG_RAM_UART
|
||||
|
||||
#include <stdatomic.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
struct uart_rambuf_s
|
||||
{
|
||||
char buffer[CONFIG_RAM_UART_BUFSIZE];
|
||||
atomic_uint wroff;
|
||||
atomic_uint rdoff;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: uart_ram_register
|
||||
****************************************************************************/
|
||||
|
||||
int uart_ram_register(FAR const char *devname,
|
||||
FAR struct uart_rambuf_s buffer[2], bool slave);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ram_serialinit
|
||||
****************************************************************************/
|
||||
|
||||
void ram_serialinit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user