ADISense1000 Version 2.1 code base

Fork of AdiSense1000_V21 by Sean Wilson

Branch:
v2.0
Revision:
31:de49744b57a6
Parent:
27:567abf893938
diff -r 119ff4f3aef6 -r de49744b57a6 src/mbed/adi_sense_spi.cpp
--- a/src/mbed/adi_sense_spi.cpp	Tue Jun 12 21:27:34 2018 +0100
+++ b/src/mbed/adi_sense_spi.cpp	Fri Jun 22 09:29:24 2018 +0100
@@ -68,16 +68,6 @@
 private:
     SPI _spi;
     DigitalOut _cs;
-
-    event_callback_t _callback;
-    volatile int     _cbEvent;
-    volatile bool    _cbFired;
-
-    void _cbHandler(
-        int event);
-
-    int _waitForCallback(
-        void);
 };
 
 SpiContext::SpiContext(PinName mosiPin,
@@ -88,33 +78,11 @@
     : _spi(mosiPin, misoPin, sckPin),
       _cs(csPin, 1)
 {
-    _cbEvent = 0;
-    _cbFired = false;
-    _callback = callback(this, &SpiContext::_cbHandler);
 
     _spi.format(ADI_SENSE_SPI_FRAME_SIZE, ADI_SENSE_SPI_MODE);
     _spi.frequency(maxSpeed);
 }
 
-void SpiContext::_cbHandler(int event)
-{
-    _cbEvent = event;
-    _cbFired = true;
-}
-
-int SpiContext::_waitForCallback(void)
-{
-    int rc = 0;
-
-    while ((_cbFired != true) && (_cbEvent != SPI_EVENT_COMPLETE))
-    { ; }
-
-    _cbFired = false;
-    _cbEvent = 0;
-
-    return rc;
-}
-
 int SpiContext::transfer(
     void *pTxData,
     void *pRxData,
@@ -125,16 +93,9 @@
 
     _cs = 0;
 
-    rc  = _spi.transfer((uint8_t *)pTxData, nLength,
-                        (uint8_t *)pRxData, nLength,
-                        _callback, SPI_EVENT_COMPLETE);
-    if (rc < 0)
-    {
-        _cs = 1;
-        return rc;
-    }
+    rc  = _spi.write((char*)(pTxData), pTxData ? nLength : 0,
+                     (char*)(pRxData), pRxData ? nLength : 0);
 
-    rc = _waitForCallback();
     if ((rc < 0) || !bCsHold)
         _cs = 1;