From c978f2f0f4a59b12e82c7276bc91130ede7a48dd Mon Sep 17 00:00:00 2001 From: haizhouyang Date: Wed, 20 Apr 2022 14:45:24 +0800 Subject: [PATCH] optimize cs keeping logic for spi transfer Signed-off-by: haizhouyang --- include/platform/spi_if.h | 6 +++--- test/unittest/platform/common/spi_test.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/platform/spi_if.h b/include/platform/spi_if.h index 10755960..0a90d032 100644 --- a/include/platform/spi_if.h +++ b/include/platform/spi_if.h @@ -123,7 +123,7 @@ struct SpiDevInfo { * @brief Defines the custom SPI transfer message. * * @attention The specific SPI controller determines whether speed, delayUs, - * and csChange are supported. + * and keepCs are supported. * * @since 1.0 */ @@ -137,8 +137,8 @@ struct SpiMsg { uint16_t delayUs; /**< Delay (in microseconds) before starting the next transfer. * The value 0 indicates there is no delay between transfers. */ - uint8_t csChange; /**< Whether to switch off the CS before the next transfer when the current transfer has been - * completed. 1 indicates to switch off the CS; 0 indicates to switch on the CS. + uint8_t keepCs; /**< Whether to keep CS active after current transfer has been + * completed. 1 indicates to keeps CS; 0 indicates to switch off the CS. */ }; diff --git a/test/unittest/platform/common/spi_test.c b/test/unittest/platform/common/spi_test.c index 3ab52453..3ba875de 100644 --- a/test/unittest/platform/common/spi_test.c +++ b/test/unittest/platform/common/spi_test.c @@ -243,7 +243,7 @@ static int32_t SpiTransferTest(struct SpiTester *tester) msg.rbuf = tester->config.rbuf; msg.wbuf = tester->config.wbuf; msg.len = tester->config.len; - msg.csChange = 1; // switch off the CS after transfer + msg.keepCs = 0; // switch off the CS after transfer msg.delayUs = 0; msg.speed = 0; // use default speed @@ -291,7 +291,7 @@ static int32_t SpiMultiTransferTest(struct SpiTester *tester) msgs[SPI_TEST_MSG_2].rbuf = tester->config.rbuf; msgs[SPI_TEST_MSG_2].len = tester->config.len; msgs[SPI_TEST_MSG_2].speed = 0; - msgs[SPI_TEST_MSG_2].csChange = 1; // switch off the CS after transfer + msgs[SPI_TEST_MSG_2].keepCs = 0; // switch off the CS after transfer ret = SpiSetCfg(tester->handle, &g_spiCfg); if (ret != HDF_SUCCESS) { @@ -339,8 +339,8 @@ static int32_t SpiSetDmaIntMsg(struct SpiMsg *msg, uint32_t len) msg->wbuf = wbuf; msg->rbuf = rbuf; msg->len = len; - msg->csChange = 1; - msg->delayUs = 0, // switch off the CS after transfer + msg->keepCs= 0, // switch off the CS after transfer + msg->delayUs = 0; msg->speed = 0; // using default speed return HDF_SUCCESS; }