for my students set_m_axes_offset
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Diff: lis3mdl_class.h
- Revision:
- 7:fa19aa1a666d
- Parent:
- 4:00493226e59f
--- a/lis3mdl_class.h Wed Oct 18 11:14:26 2017 +0200 +++ b/lis3mdl_class.h Sat Feb 08 09:11:31 2020 +0000 @@ -51,9 +51,9 @@ */ class LIS3MDL : public MagneticSensor { public: - enum SPI_type_t {SPI3W, SPI4W}; + //my enum SPI_type_t {SPI3W, SPI4W}; - LIS3MDL(SPI *spi, PinName cs_pin, PinName int_pin=NC, SPI_type_t spi_type=SPI4W); + //my LIS3MDL(SPI *spi, PinName cs_pin, PinName int_pin=NC, SPI_type_t spi_type=SPI4W); /** Constructor * @param[in] i2c device I2C to be used for communication @@ -81,15 +81,18 @@ virtual int get_m_axes_raw(int16_t *pData) { return LIS3MDL_M_GetAxesRaw(pData); } - + + virtual int set_m_axes_offset(uint8_t axe,int16_t offset) { //my + return LIS3MDL_M_SetAxeOffset(axe,offset); + } protected: /*** Methods ***/ MAGNETO_StatusTypeDef LIS3MDL_Init(MAGNETO_InitTypeDef *LIS3MDL_Init); MAGNETO_StatusTypeDef LIS3MDL_Read_M_ID(uint8_t *m_id); MAGNETO_StatusTypeDef LIS3MDL_M_GetAxes(int32_t *pData); MAGNETO_StatusTypeDef LIS3MDL_M_GetAxesRaw(int16_t *pData); - MAGNETO_StatusTypeDef LIS3MDL_Set_SpiInterface (void *handle, LIS3MDL_SPIMode_t spimode); - + //my MAGNETO_StatusTypeDef LIS3MDL_Set_SpiInterface (void *handle, LIS3MDL_SPIMode_t spimode); + MAGNETO_StatusTypeDef LIS3MDL_M_SetAxeOffset(uint8_t axe,int16_t offset);//my /** * @brief Configures LIS3MDL interrupt lines for NUCLEO boards */ @@ -118,8 +121,9 @@ MAGNETO_StatusTypeDef LIS3MDL_IO_Read(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead) { +/*my if (_dev_spi) { - /* Write Reg Address */ + // Write Reg Address _dev_spi->lock(); _cs_pin = 0; if (_spi_type == SPI4W) { @@ -128,14 +132,15 @@ *(pBuffer+i) = _dev_spi->write(0x00); } } else if (_spi_type == SPI3W){ - /* Write RD Reg Address with RD bit*/ + // 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 MAGNETO_OK; - } + } +*/ if (!_dev_i2c) return MAGNETO_ERROR; int ret = _dev_i2c->i2c_read(pBuffer, _address, @@ -158,7 +163,7 @@ MAGNETO_StatusTypeDef LIS3MDL_IO_Write(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite) { - +/* if (_dev_spi) { _dev_spi->lock(); _cs_pin = 0; @@ -168,7 +173,7 @@ _dev_spi->unlock(); return MAGNETO_OK; } - +*/ if (!_dev_i2c) return MAGNETO_ERROR; int ret = _dev_i2c->i2c_write(pBuffer, _address, RegisterAddr, NumByteToWrite); if(ret != 0) { @@ -180,11 +185,11 @@ /*** Instance Variables ***/ /* IO Device */ DevI2C *_dev_i2c; - SPI *_dev_spi; + //my SPI *_dev_spi; uint8_t _address; DigitalOut _cs_pin; InterruptIn _int_pin; - SPI_type_t _spi_type; + //my SPI_type_t _spi_type; }; #endif // __LIS3MDL_CLASS_H