From 40e34b5b5867fa47a136995a5de98432cc59c514 Mon Sep 17 00:00:00 2001 From: liaoao Date: Wed, 28 Feb 2024 19:13:49 +0800 Subject: [PATCH] spi_slave: keep consistent with the parameter of the spi_slave_receive function declaration Signed-off-by: liaoao --- drivers/spi/spi_slave_driver.c | 14 +++++++------- include/nuttx/spi/slave.h | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/spi/spi_slave_driver.c b/drivers/spi/spi_slave_driver.c index 7a52188dc0..a5ef0a9f8c 100644 --- a/drivers/spi/spi_slave_driver.c +++ b/drivers/spi/spi_slave_driver.c @@ -669,11 +669,11 @@ static size_t spi_slave_getdata(FAR struct spi_slave_dev_s *dev, * synchronization by several words. * * Input Parameters: - * dev - SPI Slave device interface instance - * data - Pointer to the new data that has been shifted in - * len - Length of the new data in units of nbits wide, - * nbits being the data width previously provided to the bind() - * method. + * dev - SPI Slave device interface instance + * data - Pointer to the new data that has been shifted in + * nwords - Length of the new data in units of nbits wide, + * nbits being the data width previously provided to the bind() + * method. * * Returned Value: * Number of units accepted by the device. In other words, @@ -688,10 +688,10 @@ static size_t spi_slave_getdata(FAR struct spi_slave_dev_s *dev, ****************************************************************************/ static size_t spi_slave_receive(FAR struct spi_slave_dev_s *dev, - FAR const void *data, size_t len) + FAR const void *data, size_t nwords) { FAR struct spi_slave_driver_s *priv = (FAR struct spi_slave_driver_s *)dev; - size_t recv_bytes = MIN(len, sizeof(priv->rx_buffer)); + size_t recv_bytes = MIN(WORDS2BYTES(nwords), sizeof(priv->rx_buffer)); memcpy(priv->rx_buffer, data, recv_bytes); diff --git a/include/nuttx/spi/slave.h b/include/nuttx/spi/slave.h index 11b7bde8c8..b3a2d1052d 100644 --- a/include/nuttx/spi/slave.h +++ b/include/nuttx/spi/slave.h @@ -273,11 +273,11 @@ * synchronization by several words. * * Input Parameters: - * dev - SPI Slave device interface instance - * data - Pointer to the new data that has been shifted in - * len - Length of the new data in units of nbits wide, - * nbits being the data width previously provided to the bind() - * method. + * dev - SPI Slave device interface instance + * data - Pointer to the new data that has been shifted in + * nwords - Length of the new data in units of nbits wide, + * nbits being the data width previously provided to the bind() + * method. * * Returned Value: * Number of units accepted by the device. In other words, @@ -291,7 +291,7 @@ * ****************************************************************************/ -#define SPIS_DEV_RECEIVE(d,v,l) ((d)->ops->receive(d,v,l)) +#define SPIS_DEV_RECEIVE(d,v,n) ((d)->ops->receive(d,v,n)) /**************************************************************************** * Name: SPIS_DEV_NOTIFY