Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: src/mbed/admw_spi.cpp
- Revision:
- 13:97cb32670539
- Parent:
- 5:0728bde67bdb
- Child:
- 23:bb685f35b08b
diff -r 8f21099b8028 -r 97cb32670539 src/mbed/admw_spi.cpp
--- a/src/mbed/admw_spi.cpp Wed Jul 24 08:51:31 2019 +0000
+++ b/src/mbed/admw_spi.cpp Thu Jul 25 06:38:45 2019 +0000
@@ -96,6 +96,45 @@
/*
* Execute a bi-directional data transfer on the SPI interface
*/
+ ADMW_RESULT
+admw_SpiReceive(
+ ADMW_SPI_HANDLE hDevice,
+ void *pTxData,
+ void *pRxData,
+ unsigned nLength,
+ bool bCsHold)
+{
+ SpiContext_t *pCtx = (SpiContext_t*)hDevice;
+
+ pCtx->_spi->format(ADMW_SPI_FRAME_SIZE, 1);
+
+ int rc = 0;
+
+ *(pCtx->_wakeup) = 0;
+
+ wait_us(60);
+
+ *(pCtx->_cs) = 0;
+
+ rc = pCtx->_spi->write((char*)(pTxData), pTxData ? nLength : 0,
+ (char*)(pRxData), pRxData ? nLength : 0);
+
+ if ((rc < 0) || !bCsHold)
+ *(pCtx->_cs) = 1;
+
+ *(pCtx->_wakeup) = 1;
+
+ if (rc < 0)
+ {
+ ADMW_LOG_ERROR("Failed to complete SPI transfer");
+ return ADMW_FAILURE;
+ }
+
+ pCtx->_spi->format(ADMW_SPI_FRAME_SIZE, ADMW_SPI_MODE);
+
+ return ADMW_SUCCESS;
+
+}
ADMW_RESULT
admw_SpiTransfer(
ADMW_SPI_HANDLE hDevice,