pelion-example-disco-iot01/sensors/LPS22HB/LPS22HBSensor.h
uint8_t io_read(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead)
    {
        if (_dev_spi) {
        /* Write Reg Address */
            _dev_spi->lock();
            _cs_pin = 0;           
            if (_spi_type == SPI4W) {            
                _dev_spi->write(RegisterAddr | 0x80);
                for (int i=0; i<NumByteToRead; i++) {
                    *(pBuffer+i) = _dev_spi->write(0x00);
                }
            } 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);
            }            
            _cs_pin = 1;
            _dev_spi->unlock(); 
            return 0;
        }                       
        if (_dev_i2c) return (uint8_t) _dev_i2c->i2c_read(pBuffer, _address, RegisterAddr, NumByteToRead);
        return 1;
    }
/**
     * @brief Utility function to read data.
     * @param  pBuffer: pointer to data to be read.
     * @param  RegisterAddr: specifies internal address register to be read.
     * @param  NumByteToRead: number of bytes to be read.
     * @retval 0 if ok, an error code otherwise.
     */
@brief Utility function to read data.
@param  pBuffer: pointer to data to be read.
@param  RegisterAddr: specifies internal address register to be read.
@param  NumByteToRead: number of bytes to be read.
@retval 0 if ok, an error code otherwise.
@brief Utility function to read data . @param pBuffer : pointer to data to be read . @param RegisterAddr : specifies internal address register to be read . @param NumByteToRead : number of bytes to be read . @retval 0 if ok an error code otherwise .
uint8_t io_read(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead)
    {
        if (_dev_spi) {
            _dev_spi->lock();
            _cs_pin = 0;           
            if (_spi_type == SPI4W) {            
                _dev_spi->write(RegisterAddr | 0x80);
                for (int i=0; i<NumByteToRead; i++) {
                    *(pBuffer+i) = _dev_spi->write(0x00);
                }
            } else if (_spi_type == SPI3W){
                uint8_t TxByte = RegisterAddr | 0x80;    
                _dev_spi->write((char *)&TxByte, 1, (char *)pBuffer, (int) NumByteToRead);
            }            
            _cs_pin = 1;
            _dev_spi->unlock(); 
            return 0;
        }                       
        if (_dev_i2c) return (uint8_t) _dev_i2c->i2c_read(pBuffer, _address, RegisterAddr, NumByteToRead);
        return 1;
    }
uint8_t io_read ( uint8_t * pBuffer , uint8_t RegisterAddr , uint16_t NumByteToRead ) { if ( _dev_spi ) { _dev_spi -> lock ( ) ; _cs_pin = 0 ; if ( _spi_type == SPI4W ) { _dev_spi -> write ( RegisterAddr | 0x80 ) ; for ( int i = 0 ; i < NumByteToRead ; i ++ ) { * ( pBuffer + i ) = _dev_spi -> write ( 0x00 ) ; } } else if ( _spi_type == SPI3W ) { uint8_t TxByte = RegisterAddr | 0x80 ; _dev_spi -> write ( ( char * ) & TxByte , 1 , ( char * ) pBuffer , ( int ) NumByteToRead ) ; } _cs_pin = 1 ; _dev_spi -> unlock ( ) ; return 0 ; } if ( _dev_i2c ) return ( uint8_t ) _dev_i2c -> i2c_read ( pBuffer , _address , RegisterAddr , NumByteToRead ) ; return 1 ; }
@brief Utility function to read data.
@brief Utility function to read data .
/* Write Reg Address */ /* Write RD Reg Address with RD bit*/