Suppressed conflicting destructor function.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: D7A_1x_TRAINING D7_MLX_AND_BAT D7A_1x_demo_sensors_v3
Fork of X_NUCLEO_IKS01A1 by
LSM303C_MAG_Sensor.h
00001 /** 00002 ****************************************************************************** 00003 * @file LSM303C_MAG_Sensor.h 00004 * @author CLab 00005 * @version V1.0.0 00006 * @date 5 August 2016 00007 * @brief Abstract Class of an LSM303C magnetometer sensor. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 00038 00039 /* Prevent recursive inclusion -----------------------------------------------*/ 00040 00041 #ifndef __LSM303C_MAG_Sensor_H__ 00042 #define __LSM303C_MAG_Sensor_H__ 00043 00044 00045 /* Includes ------------------------------------------------------------------*/ 00046 00047 #include "DevI2C.h" 00048 #include "LSM303C_MAG_driver.h" 00049 #include "MagneticSensor.h" 00050 00051 00052 /* Class Declaration ---------------------------------------------------------*/ 00053 00054 /** 00055 * Abstract class of an LSM303C Inertial Measurement Unit (IMU) 6 axes 00056 * sensor. 00057 */ 00058 class LSM303C_MAG_Sensor : public MagneticSensor 00059 { 00060 public: 00061 LSM303C_MAG_Sensor(DevI2C &i2c); 00062 LSM303C_MAG_Sensor(DevI2C &i2c, uint8_t address); 00063 virtual int Init(void *init); 00064 virtual int ReadID(uint8_t *id); 00065 virtual int Get_M_Axes(int32_t *pData); 00066 virtual int Get_M_AxesRaw(int16_t *pData); 00067 int Enable(void); 00068 int Disable(void); 00069 int Get_M_Sensitivity(float *pfData); 00070 int Get_M_ODR(float *odr); 00071 int Set_M_ODR(float odr); 00072 int Get_M_FS(float *fullScale); 00073 int Set_M_FS(float fullScale); 00074 int ReadReg(uint8_t reg, uint8_t *data); 00075 int WriteReg(uint8_t reg, uint8_t data); 00076 00077 /** 00078 * @brief Utility function to read data. 00079 * @param pBuffer: pointer to data to be read. 00080 * @param RegisterAddr: specifies internal address register to be read. 00081 * @param NumByteToRead: number of bytes to be read. 00082 * @retval 0 if ok, an error code otherwise. 00083 */ 00084 uint8_t IO_Read(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead) 00085 { 00086 return (uint8_t) dev_i2c.i2c_read(pBuffer, address, RegisterAddr, NumByteToRead); 00087 } 00088 00089 /** 00090 * @brief Utility function to write data. 00091 * @param pBuffer: pointer to data to be written. 00092 * @param RegisterAddr: specifies internal address register to be written. 00093 * @param NumByteToWrite: number of bytes to write. 00094 * @retval 0 if ok, an error code otherwise. 00095 */ 00096 uint8_t IO_Write(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite) 00097 { 00098 return (uint8_t) dev_i2c.i2c_write(pBuffer, address, RegisterAddr, NumByteToWrite); 00099 } 00100 00101 private: 00102 00103 /* Helper classes. */ 00104 DevI2C &dev_i2c; 00105 00106 /* Configuration */ 00107 uint8_t address; 00108 }; 00109 00110 #ifdef __cplusplus 00111 extern "C" { 00112 #endif 00113 uint8_t LSM303C_MAG_IO_Write( void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite ); 00114 uint8_t LSM303C_MAG_IO_Read( void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead ); 00115 #ifdef __cplusplus 00116 } 00117 #endif 00118 00119 #endif
Generated on Tue Jul 12 2022 17:30:06 by
1.7.2
