mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 14:58:13 +08:00
rpmsg_port_spi: add spi transport layer
Add Rpmsg-Port-SPI transport layer. Rpmsg Port SPI is a new rpmsg transport layer based on the Rpmsg Port, it provides the capability for two SPI-connected (and two extra GPIO) chips to communicate with each other using Rpmsg. All already implemented Rpmsg Services can be used with this new transport layer without any modifications. Signed-off-by: liaoao <liaoao@xiaomi.com>
This commit is contained in:
@@ -33,6 +33,10 @@ if(CONFIG_RPMSG)
|
||||
PRIVATE ${NUTTX_DIR}/openamp/open-amp/lib)
|
||||
endif()
|
||||
|
||||
if(CONFIG_RPMSG_PORT_SPI)
|
||||
list(APPEND SRCS rpmsg_port_spi.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_RPMSG_VIRTIO)
|
||||
list(APPEND SRCS rpmsg_virtio.c)
|
||||
endif()
|
||||
|
||||
@@ -27,6 +27,34 @@ config RPMSG_PORT
|
||||
---help---
|
||||
Rpmsg port transport layer used for cross chip communication.
|
||||
|
||||
config RPMSG_PORT_SPI
|
||||
bool "Rpmsg SPI Port Driver Support"
|
||||
default n
|
||||
select RPMSG_PORT
|
||||
---help---
|
||||
Rpmsg SPI Port driver used for cross chip communication.
|
||||
|
||||
if RPMSG_PORT_SPI
|
||||
|
||||
config RPMSG_PORT_SPI_THREAD_PRIORITY
|
||||
int "Rpmsg SPI Port Thread Priority"
|
||||
default 224
|
||||
|
||||
config RPMSG_PORT_SPI_THREAD_STACKSIZE
|
||||
int "Rpmsg SPI Port Stack Size"
|
||||
default DEFAULT_TASK_STACKSIZE
|
||||
|
||||
config RPMSG_PORT_SPI_CRC
|
||||
bool "Rpmsg SPI Port Use CRC Check"
|
||||
default n
|
||||
|
||||
config RPMSG_PORT_SPI_RX_THRESHOLD
|
||||
int "Rpmsg SPI Port Rx Buffer Threshold"
|
||||
default 50
|
||||
range 0 100
|
||||
|
||||
endif # RPMSG_PORT_SPI
|
||||
|
||||
endif # RPMSG
|
||||
|
||||
config RPMSG_VIRTIO
|
||||
|
||||
@@ -33,6 +33,10 @@ CSRCS += rpmsg_port.c
|
||||
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)openamp$(DELIM)open-amp$(DELIM)lib
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_RPMSG_PORT_SPI),y)
|
||||
CSRCS += rpmsg_port_spi.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_RPMSG_VIRTIO),y)
|
||||
CSRCS += rpmsg_virtio.c
|
||||
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)openamp$(DELIM)open-amp$(DELIM)lib
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,9 @@
|
||||
#include <nuttx/config.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <nuttx/ioexpander/ioexpander.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
|
||||
#ifdef CONFIG_RPMSG_PORT
|
||||
|
||||
/****************************************************************************
|
||||
@@ -50,5 +53,79 @@ struct rpmsg_port_config_s
|
||||
FAR void *rxbuf;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_RPMSG_PORT_SPI
|
||||
|
||||
/* There are two gpios used for communication between two chips. At the SPI
|
||||
* master side, mreq is an output gpio pin which is used to notify the
|
||||
* slave side there is a data packet to be sent. it actually transfers the
|
||||
* data only when it receives an interrupt from sreq pin. and at the SPI
|
||||
* slave side, it prepares the data to be sent, and activates the sreq to
|
||||
* the master side, master will initiate a transfer immediately when it
|
||||
* receives an interrupt from sreq pin to receive the data.
|
||||
*
|
||||
* If IOEXPANDER_OPTION_INVERT option of pin is set to be 0, then it will
|
||||
* be triggered an interrupt at the rising edge. or it will be triggered
|
||||
* at the falling edge.
|
||||
*/
|
||||
|
||||
struct rpmsg_port_spi_config_s
|
||||
{
|
||||
/* GPIO configurations of pins used for communication between two chips. */
|
||||
|
||||
uint8_t mreq_pin;
|
||||
uint8_t sreq_pin;
|
||||
int mreq_invert;
|
||||
int sreq_invert; /* Pin options described in ioexpander.h */
|
||||
|
||||
enum spi_mode_e mode;
|
||||
uint32_t devid; /* Device ID of enum spi_devtype_e */
|
||||
uint32_t freq; /* SPI frequency (Hz) */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RPMSG_PORT_SPI
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rpmsg_port_spi_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize a rpmsg_port_spi device to communicate between two chips.
|
||||
*
|
||||
* Input Parameters:
|
||||
* cfg - Configuration of buffers needed for communication.
|
||||
* spicfg - SPI device's configuration.
|
||||
* spi - SPI device used for transfer data between two chips.
|
||||
* ioe - ioexpander used to config gpios.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero on success or an negative value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int
|
||||
rpmsg_port_spi_initialize(FAR const struct rpmsg_port_config_s *cfg,
|
||||
FAR const struct rpmsg_port_spi_config_s *spicfg,
|
||||
FAR struct spi_dev_s *spi,
|
||||
FAR struct ioexpander_dev_s *ioe);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_RPMSG_PORT */
|
||||
#endif /* __INCLUDE_NUTTX_RPMSG_RPMSG_PORT_H */
|
||||
|
||||
Reference in New Issue
Block a user