Added SPI3w support through DevSPI

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON_3W

Fork of LPS22HB by ST

Revision:
2:fba15124c67b
Parent:
1:8813c9be1720
--- a/LPS22HBSensor.h	Fri Sep 22 09:26:25 2017 +0000
+++ b/LPS22HBSensor.h	Tue Sep 26 08:18:06 2017 +0000
@@ -58,7 +58,8 @@
 class LPS22HBSensor : public PressureSensor, public TempSensor
 {
   public:
-    LPS22HBSensor(DevSPI *spi, PinName cs_pin, PinName int_pin=NC);                
+enum SPI_type_t {SPI3W, SPI4W};  
+    LPS22HBSensor(SPI *spi, PinName cs_pin, PinName int_pin=NC, SPI_type_t spi_type=SPI4W);                
     LPS22HBSensor(DevI2C *i2c, uint8_t address=LPS22HB_ADDRESS_HIGH, PinName int_pin=NC);
     virtual int init(void *init);
     virtual int read_id(uint8_t *id);
@@ -85,12 +86,12 @@
         /* Write Reg Address */
             _dev_spi->lock();
             _cs_pin = 0;           
-            if (!_dev_spi->isSPI3w()) {            
+            if (_spi_type == SPI4W) {            
                 _dev_spi->write(RegisterAddr | 0x80);
                 for (int i=0; i<NumByteToRead; i++) {
                     *(pBuffer+i) = _dev_spi->write(0x00);
                 }
-            } else {
+            } else if (_spi_type == SPI3W){
                 /* Write RD Reg Address with RD bit*/
                 uint8_t TxByte = RegisterAddr | 0x80;    
                 _dev_spi->write((char *)&TxByte, 1, (char *)pBuffer, (int) NumByteToRead);
@@ -134,7 +135,7 @@
 
     /* Helper classes. */
     DevI2C   *_dev_i2c;
-    DevSPI   *_dev_spi; 
+    SPI      *_dev_spi; 
     
     /* Configuration */
     uint8_t _address;
@@ -143,6 +144,7 @@
     
     uint8_t _is_enabled;
     float _last_odr;
+    SPI_type_t _spi_type;
 };
 
 #ifdef __cplusplus