pin assignments for mDot
Dependents: iks01a1_acc LoRaWAN-demo-72_mdotIKS01A1 MTDOT-UDKDemo_Senet MTDOT-UDKDemo
Fork of X_NUCLEO_IKS01A1 by
Components/lsm6ds3/lsm6ds3_class.h@76:b5b8e7cab622, 2016-03-04 (annotated)
- Committer:
- dudmuck
- Date:
- Fri Mar 04 21:16:34 2016 +0000
- Revision:
- 76:b5b8e7cab622
- Parent:
- 57:04563dd74269
add pin assignments for mDot
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Wolfgang Betz |
44:d757094f6229 | 1 | /** |
Wolfgang Betz |
44:d757094f6229 | 2 | ****************************************************************************** |
Wolfgang Betz |
44:d757094f6229 | 3 | * @file lsm6ds3_class.h |
Wolfgang Betz |
44:d757094f6229 | 4 | * @author AST / EST |
Wolfgang Betz |
44:d757094f6229 | 5 | * @version V0.0.1 |
Wolfgang Betz |
44:d757094f6229 | 6 | * @date 14-April-2015 |
Wolfgang Betz |
44:d757094f6229 | 7 | * @brief Header file for component LSM6DS3 |
Wolfgang Betz |
44:d757094f6229 | 8 | ****************************************************************************** |
Wolfgang Betz |
44:d757094f6229 | 9 | * @attention |
Wolfgang Betz |
44:d757094f6229 | 10 | * |
Wolfgang Betz |
44:d757094f6229 | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
Wolfgang Betz |
44:d757094f6229 | 12 | * |
Wolfgang Betz |
44:d757094f6229 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
Wolfgang Betz |
44:d757094f6229 | 14 | * are permitted provided that the following conditions are met: |
Wolfgang Betz |
44:d757094f6229 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
Wolfgang Betz |
44:d757094f6229 | 16 | * this list of conditions and the following disclaimer. |
Wolfgang Betz |
44:d757094f6229 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
Wolfgang Betz |
44:d757094f6229 | 18 | * this list of conditions and the following disclaimer in the documentation |
Wolfgang Betz |
44:d757094f6229 | 19 | * and/or other materials provided with the distribution. |
Wolfgang Betz |
44:d757094f6229 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
Wolfgang Betz |
44:d757094f6229 | 21 | * may be used to endorse or promote products derived from this software |
Wolfgang Betz |
44:d757094f6229 | 22 | * without specific prior written permission. |
Wolfgang Betz |
44:d757094f6229 | 23 | * |
Wolfgang Betz |
44:d757094f6229 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
Wolfgang Betz |
44:d757094f6229 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
Wolfgang Betz |
44:d757094f6229 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Wolfgang Betz |
44:d757094f6229 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
Wolfgang Betz |
44:d757094f6229 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
Wolfgang Betz |
44:d757094f6229 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
Wolfgang Betz |
44:d757094f6229 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
Wolfgang Betz |
44:d757094f6229 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
Wolfgang Betz |
44:d757094f6229 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
Wolfgang Betz |
44:d757094f6229 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Wolfgang Betz |
44:d757094f6229 | 34 | * |
Wolfgang Betz |
44:d757094f6229 | 35 | ****************************************************************************** |
Wolfgang Betz |
44:d757094f6229 | 36 | */ |
Wolfgang Betz |
44:d757094f6229 | 37 | |
Wolfgang Betz |
44:d757094f6229 | 38 | #ifndef __LSM6DS3_CLASS_H |
Wolfgang Betz |
44:d757094f6229 | 39 | #define __LSM6DS3_CLASS_H |
Wolfgang Betz |
44:d757094f6229 | 40 | |
Wolfgang Betz |
44:d757094f6229 | 41 | /* Includes ------------------------------------------------------------------*/ |
Wolfgang Betz |
44:d757094f6229 | 42 | #include "mbed.h" |
Wolfgang Betz |
44:d757094f6229 | 43 | #include "DevI2C.h" |
Wolfgang Betz |
57:04563dd74269 | 44 | #include "lsm6ds3.h" |
Wolfgang Betz |
44:d757094f6229 | 45 | #include "../Interfaces/GyroSensor.h" |
Wolfgang Betz |
44:d757094f6229 | 46 | #include "../Interfaces/MotionSensor.h" |
Wolfgang Betz |
44:d757094f6229 | 47 | |
Wolfgang Betz |
44:d757094f6229 | 48 | /* Classes -------------------------------------------------------------------*/ |
Wolfgang Betz |
44:d757094f6229 | 49 | /** Class representing a LSM6DS3 sensor component |
Wolfgang Betz |
44:d757094f6229 | 50 | */ |
Wolfgang Betz |
44:d757094f6229 | 51 | class LSM6DS3 : public GyroSensor, public MotionSensor { |
Wolfgang Betz |
44:d757094f6229 | 52 | public: |
Wolfgang Betz |
44:d757094f6229 | 53 | /** Constructor |
Wolfgang Betz |
54:2a676c734b30 | 54 | * @param[in] i2c device I2C to be used for communication |
Wolfgang Betz |
54:2a676c734b30 | 55 | * @param[in] irq_pin pin name for free fall detection interrupt |
Wolfgang Betz |
44:d757094f6229 | 56 | */ |
Wolfgang Betz |
52:54553fd15b50 | 57 | LSM6DS3(DevI2C &i2c, PinName irq_pin) : GyroSensor(), MotionSensor(), |
Wolfgang Betz |
52:54553fd15b50 | 58 | dev_i2c(i2c), free_fall(irq_pin) { |
Wolfgang Betz |
44:d757094f6229 | 59 | } |
Wolfgang Betz |
44:d757094f6229 | 60 | |
Wolfgang Betz |
44:d757094f6229 | 61 | /** Destructor |
Wolfgang Betz |
44:d757094f6229 | 62 | */ |
Wolfgang Betz |
44:d757094f6229 | 63 | virtual ~LSM6DS3() {} |
Wolfgang Betz |
44:d757094f6229 | 64 | |
Wolfgang Betz |
44:d757094f6229 | 65 | /*** Interface Methods ***/ |
Wolfgang Betz |
44:d757094f6229 | 66 | virtual int Init(void *init_struct) { |
Wolfgang Betz |
44:d757094f6229 | 67 | return LSM6DS3_Init((IMU_6AXES_InitTypeDef*)init_struct); |
Wolfgang Betz |
44:d757094f6229 | 68 | } |
Wolfgang Betz |
44:d757094f6229 | 69 | |
Wolfgang Betz |
44:d757094f6229 | 70 | virtual int ReadID(uint8_t *xg_id) { |
Wolfgang Betz |
44:d757094f6229 | 71 | return LSM6DS3_Read_XG_ID(xg_id); |
Wolfgang Betz |
44:d757094f6229 | 72 | } |
Wolfgang Betz |
44:d757094f6229 | 73 | |
Wolfgang Betz |
44:d757094f6229 | 74 | virtual int Get_X_Axes(int32_t *pData) { |
Wolfgang Betz |
44:d757094f6229 | 75 | return LSM6DS3_X_GetAxes(pData); |
Wolfgang Betz |
44:d757094f6229 | 76 | } |
Wolfgang Betz |
44:d757094f6229 | 77 | |
Wolfgang Betz |
44:d757094f6229 | 78 | virtual int Get_X_AxesRaw(int16_t *pData) { |
Wolfgang Betz |
44:d757094f6229 | 79 | return LSM6DS3_X_GetAxesRaw(pData); |
Wolfgang Betz |
44:d757094f6229 | 80 | } |
Wolfgang Betz |
44:d757094f6229 | 81 | |
Wolfgang Betz |
44:d757094f6229 | 82 | virtual int Get_G_Axes(int32_t *pData) { |
Wolfgang Betz |
44:d757094f6229 | 83 | return LSM6DS3_G_GetAxes(pData); |
Wolfgang Betz |
44:d757094f6229 | 84 | } |
Wolfgang Betz |
44:d757094f6229 | 85 | |
Wolfgang Betz |
44:d757094f6229 | 86 | virtual int Get_G_AxesRaw(int16_t *pData) { |
Wolfgang Betz |
44:d757094f6229 | 87 | return LSM6DS3_G_GetAxesRaw(pData); |
Wolfgang Betz |
44:d757094f6229 | 88 | } |
Wolfgang Betz |
44:d757094f6229 | 89 | |
Wolfgang Betz |
44:d757094f6229 | 90 | virtual int Get_X_ODR(float *odr) { |
Wolfgang Betz |
44:d757094f6229 | 91 | return LSM6DS3_X_Get_ODR(odr); |
Wolfgang Betz |
44:d757094f6229 | 92 | } |
Wolfgang Betz |
44:d757094f6229 | 93 | |
Wolfgang Betz |
44:d757094f6229 | 94 | virtual int Set_X_ODR(float odr) { |
Wolfgang Betz |
44:d757094f6229 | 95 | return LSM6DS3_X_Set_ODR(odr); |
Wolfgang Betz |
44:d757094f6229 | 96 | } |
Wolfgang Betz |
44:d757094f6229 | 97 | |
Wolfgang Betz |
44:d757094f6229 | 98 | virtual int Get_X_Sensitivity(float *pfData) { |
Wolfgang Betz |
44:d757094f6229 | 99 | return LSM6DS3_X_GetSensitivity(pfData); |
Wolfgang Betz |
44:d757094f6229 | 100 | } |
Wolfgang Betz |
44:d757094f6229 | 101 | |
Wolfgang Betz |
44:d757094f6229 | 102 | virtual int Get_X_FS(float *fullScale) { |
Wolfgang Betz |
44:d757094f6229 | 103 | return LSM6DS3_X_Get_FS(fullScale); |
Wolfgang Betz |
44:d757094f6229 | 104 | } |
Wolfgang Betz |
44:d757094f6229 | 105 | |
Wolfgang Betz |
44:d757094f6229 | 106 | virtual int Set_X_FS(float fullScale) { |
Wolfgang Betz |
44:d757094f6229 | 107 | return LSM6DS3_X_Set_FS(fullScale); |
Wolfgang Betz |
44:d757094f6229 | 108 | } |
Wolfgang Betz |
44:d757094f6229 | 109 | |
Wolfgang Betz |
44:d757094f6229 | 110 | virtual int Get_G_ODR(float *odr) { |
Wolfgang Betz |
44:d757094f6229 | 111 | return LSM6DS3_G_Get_ODR(odr); |
Wolfgang Betz |
44:d757094f6229 | 112 | } |
Wolfgang Betz |
44:d757094f6229 | 113 | |
Wolfgang Betz |
44:d757094f6229 | 114 | virtual int Set_G_ODR(float odr) { |
Wolfgang Betz |
44:d757094f6229 | 115 | return LSM6DS3_G_Set_ODR(odr); |
Wolfgang Betz |
44:d757094f6229 | 116 | } |
Wolfgang Betz |
44:d757094f6229 | 117 | |
Wolfgang Betz |
44:d757094f6229 | 118 | virtual int Get_G_Sensitivity(float *pfData) { |
Wolfgang Betz |
44:d757094f6229 | 119 | return LSM6DS3_G_GetSensitivity(pfData); |
Wolfgang Betz |
44:d757094f6229 | 120 | } |
Wolfgang Betz |
44:d757094f6229 | 121 | |
Wolfgang Betz |
44:d757094f6229 | 122 | virtual int Get_G_FS(float *fullScale) { |
Wolfgang Betz |
44:d757094f6229 | 123 | return LSM6DS3_G_Get_FS(fullScale); |
Wolfgang Betz |
44:d757094f6229 | 124 | } |
Wolfgang Betz |
44:d757094f6229 | 125 | |
Wolfgang Betz |
44:d757094f6229 | 126 | virtual int Set_G_FS(float fullScale) { |
Wolfgang Betz |
44:d757094f6229 | 127 | return LSM6DS3_G_Set_FS(fullScale); |
Wolfgang Betz |
44:d757094f6229 | 128 | } |
Wolfgang Betz |
44:d757094f6229 | 129 | |
Wolfgang Betz |
44:d757094f6229 | 130 | /* Additional Public Methods */ |
Wolfgang Betz |
54:2a676c734b30 | 131 | /** |
Wolfgang Betz |
54:2a676c734b30 | 132 | * @brief Enable free fall detection |
Wolfgang Betz |
54:2a676c734b30 | 133 | * @return IMU_6AXES_OK in case of success, an error code otherwise |
Wolfgang Betz |
54:2a676c734b30 | 134 | */ |
Wolfgang Betz |
44:d757094f6229 | 135 | IMU_6AXES_StatusTypeDef Enable_Free_Fall_Detection(void) { |
Wolfgang Betz |
44:d757094f6229 | 136 | return LSM6DS3_Enable_Free_Fall_Detection(); |
Wolfgang Betz |
44:d757094f6229 | 137 | } |
Wolfgang Betz |
44:d757094f6229 | 138 | |
Wolfgang Betz |
54:2a676c734b30 | 139 | /** |
Wolfgang Betz |
54:2a676c734b30 | 140 | * @brief Disable free fall detection |
Wolfgang Betz |
54:2a676c734b30 | 141 | * @return IMU_6AXES_OK in case of success, an error code otherwise |
Wolfgang Betz |
54:2a676c734b30 | 142 | */ |
Wolfgang Betz |
44:d757094f6229 | 143 | IMU_6AXES_StatusTypeDef Disable_Free_Fall_Detection(void) { |
Wolfgang Betz |
44:d757094f6229 | 144 | return LSM6DS3_Disable_Free_Fall_Detection(); |
Wolfgang Betz |
44:d757094f6229 | 145 | } |
Wolfgang Betz |
44:d757094f6229 | 146 | |
Wolfgang Betz |
54:2a676c734b30 | 147 | /** |
Wolfgang Betz |
54:2a676c734b30 | 148 | * @brief Get status of free fall detection |
Wolfgang Betz |
54:2a676c734b30 | 149 | * @param[out] status the pointer where the status of free fall detection is stored; |
Wolfgang Betz |
54:2a676c734b30 | 150 | * 0 means no detection, 1 means detection happened |
Wolfgang Betz |
54:2a676c734b30 | 151 | * @return IMU_6AXES_OK in case of success, an error code otherwise |
Wolfgang Betz |
54:2a676c734b30 | 152 | */ |
Wolfgang Betz |
44:d757094f6229 | 153 | IMU_6AXES_StatusTypeDef Get_Status_Free_Fall_Detection(uint8_t *status) { |
Wolfgang Betz |
44:d757094f6229 | 154 | return LSM6DS3_Get_Status_Free_Fall_Detection(status); |
Wolfgang Betz |
44:d757094f6229 | 155 | } |
Wolfgang Betz |
52:54553fd15b50 | 156 | |
Wolfgang Betz |
52:54553fd15b50 | 157 | /** Attach a function to call when a free fall is detected |
Wolfgang Betz |
52:54553fd15b50 | 158 | * |
Wolfgang Betz |
54:2a676c734b30 | 159 | * @param[in] fptr A pointer to a void function, or 0 to set as none |
Wolfgang Betz |
52:54553fd15b50 | 160 | */ |
Wolfgang Betz |
52:54553fd15b50 | 161 | void Attach_Free_Fall_Detection_IRQ(void (*fptr)(void)) { |
Wolfgang Betz |
52:54553fd15b50 | 162 | free_fall.rise(fptr); |
Wolfgang Betz |
52:54553fd15b50 | 163 | } |
Wolfgang Betz |
52:54553fd15b50 | 164 | |
Wolfgang Betz |
52:54553fd15b50 | 165 | /** Enable Free Fall IRQ |
Wolfgang Betz |
52:54553fd15b50 | 166 | */ |
Wolfgang Betz |
52:54553fd15b50 | 167 | void Enable_Free_Fall_Detection_IRQ(void) { |
Wolfgang Betz |
52:54553fd15b50 | 168 | free_fall.enable_irq(); |
Wolfgang Betz |
52:54553fd15b50 | 169 | } |
Wolfgang Betz |
52:54553fd15b50 | 170 | |
Wolfgang Betz |
52:54553fd15b50 | 171 | /** Disable free Fall IRQ |
Wolfgang Betz |
52:54553fd15b50 | 172 | */ |
Wolfgang Betz |
52:54553fd15b50 | 173 | void Disable_Free_Fall_Detection_IRQ(void) { |
Wolfgang Betz |
52:54553fd15b50 | 174 | free_fall.disable_irq(); |
Wolfgang Betz |
52:54553fd15b50 | 175 | } |
Wolfgang Betz |
44:d757094f6229 | 176 | |
Wolfgang Betz |
44:d757094f6229 | 177 | protected: |
Wolfgang Betz |
44:d757094f6229 | 178 | /*** Methods ***/ |
Wolfgang Betz |
44:d757094f6229 | 179 | IMU_6AXES_StatusTypeDef LSM6DS3_Init(IMU_6AXES_InitTypeDef *LSM6DS3_Init); |
Wolfgang Betz |
44:d757094f6229 | 180 | IMU_6AXES_StatusTypeDef LSM6DS3_Read_XG_ID(uint8_t *xg_id); |
Wolfgang Betz |
44:d757094f6229 | 181 | IMU_6AXES_StatusTypeDef LSM6DS3_X_GetAxes(int32_t *pData); |
Wolfgang Betz |
44:d757094f6229 | 182 | IMU_6AXES_StatusTypeDef LSM6DS3_X_GetAxesRaw(int16_t *pData); |
Wolfgang Betz |
44:d757094f6229 | 183 | IMU_6AXES_StatusTypeDef LSM6DS3_G_GetAxes(int32_t *pData); |
Wolfgang Betz |
44:d757094f6229 | 184 | IMU_6AXES_StatusTypeDef LSM6DS3_G_GetAxesRaw(int16_t *pData); |
Wolfgang Betz |
44:d757094f6229 | 185 | IMU_6AXES_StatusTypeDef LSM6DS3_X_Get_ODR( float *odr ); |
Wolfgang Betz |
44:d757094f6229 | 186 | IMU_6AXES_StatusTypeDef LSM6DS3_X_Set_ODR( float odr ); |
Wolfgang Betz |
44:d757094f6229 | 187 | IMU_6AXES_StatusTypeDef LSM6DS3_X_GetSensitivity( float *pfData ); |
Wolfgang Betz |
44:d757094f6229 | 188 | IMU_6AXES_StatusTypeDef LSM6DS3_X_Get_FS( float *fullScale ); |
Wolfgang Betz |
44:d757094f6229 | 189 | IMU_6AXES_StatusTypeDef LSM6DS3_X_Set_FS( float fullScale ); |
Wolfgang Betz |
44:d757094f6229 | 190 | IMU_6AXES_StatusTypeDef LSM6DS3_G_Get_ODR( float *odr ); |
Wolfgang Betz |
44:d757094f6229 | 191 | IMU_6AXES_StatusTypeDef LSM6DS3_G_Set_ODR( float odr ); |
Wolfgang Betz |
44:d757094f6229 | 192 | IMU_6AXES_StatusTypeDef LSM6DS3_G_GetSensitivity( float *pfData ); |
Wolfgang Betz |
44:d757094f6229 | 193 | IMU_6AXES_StatusTypeDef LSM6DS3_G_Get_FS( float *fullScale ); |
Wolfgang Betz |
44:d757094f6229 | 194 | IMU_6AXES_StatusTypeDef LSM6DS3_G_Set_FS( float fullScale ); |
Wolfgang Betz |
44:d757094f6229 | 195 | IMU_6AXES_StatusTypeDef LSM6DS3_Enable_Free_Fall_Detection( void ); |
Wolfgang Betz |
44:d757094f6229 | 196 | IMU_6AXES_StatusTypeDef LSM6DS3_Disable_Free_Fall_Detection( void ); |
Wolfgang Betz |
44:d757094f6229 | 197 | IMU_6AXES_StatusTypeDef LSM6DS3_Get_Status_Free_Fall_Detection( uint8_t *status ); |
Wolfgang Betz |
44:d757094f6229 | 198 | |
Wolfgang Betz |
44:d757094f6229 | 199 | IMU_6AXES_StatusTypeDef LSM6DS3_Common_Sensor_Enable(void); |
Wolfgang Betz |
44:d757094f6229 | 200 | IMU_6AXES_StatusTypeDef LSM6DS3_X_Set_Axes_Status(uint8_t enableX, uint8_t enableY, uint8_t enableZ); |
Wolfgang Betz |
44:d757094f6229 | 201 | IMU_6AXES_StatusTypeDef LSM6DS3_G_Set_Axes_Status(uint8_t enableX, uint8_t enableY, uint8_t enableZ); |
Wolfgang Betz |
44:d757094f6229 | 202 | |
Wolfgang Betz |
44:d757094f6229 | 203 | /** |
Wolfgang Betz |
44:d757094f6229 | 204 | * @brief Configures LSM6DS3 interrupt lines for NUCLEO boards |
Wolfgang Betz |
44:d757094f6229 | 205 | */ |
Wolfgang Betz |
44:d757094f6229 | 206 | void LSM6DS3_IO_ITConfig(void) |
Wolfgang Betz |
44:d757094f6229 | 207 | { |
Wolfgang Betz |
57:04563dd74269 | 208 | free_fall.mode(PullNone); /* be precise about pin mode */ |
Wolfgang Betz |
44:d757094f6229 | 209 | } |
Wolfgang Betz |
44:d757094f6229 | 210 | |
Wolfgang Betz |
44:d757094f6229 | 211 | /** |
Wolfgang Betz |
44:d757094f6229 | 212 | * @brief Configures LSM6DS3 I2C interface |
Wolfgang Betz |
57:04563dd74269 | 213 | * @return IMU_6AXES_OK in case of success, an error code otherwise |
Wolfgang Betz |
44:d757094f6229 | 214 | */ |
Wolfgang Betz |
44:d757094f6229 | 215 | IMU_6AXES_StatusTypeDef LSM6DS3_IO_Init(void) |
Wolfgang Betz |
44:d757094f6229 | 216 | { |
Wolfgang Betz |
44:d757094f6229 | 217 | return IMU_6AXES_OK; /* done in constructor */ |
Wolfgang Betz |
44:d757094f6229 | 218 | } |
Wolfgang Betz |
44:d757094f6229 | 219 | |
Wolfgang Betz |
44:d757094f6229 | 220 | /** |
Wolfgang Betz |
57:04563dd74269 | 221 | * @brief Utility function to read data from LSM6DS3 |
Wolfgang Betz |
57:04563dd74269 | 222 | * @param[out] pBuffer pointer to the byte-array to read data in to |
Wolfgang Betz |
57:04563dd74269 | 223 | * @param[in] RegisterAddr specifies internal address register to read from. |
Wolfgang Betz |
57:04563dd74269 | 224 | * @param[in] NumByteToRead number of bytes to be read. |
Wolfgang Betz |
57:04563dd74269 | 225 | * @retval IMU_6AXES_OK if ok, |
Wolfgang Betz |
57:04563dd74269 | 226 | * @retval IMU_6AXES_ERROR if an I2C error has occured |
Wolfgang Betz |
44:d757094f6229 | 227 | */ |
Wolfgang Betz |
44:d757094f6229 | 228 | IMU_6AXES_StatusTypeDef LSM6DS3_IO_Read(uint8_t* pBuffer, |
Wolfgang Betz |
44:d757094f6229 | 229 | uint8_t RegisterAddr, uint16_t NumByteToRead) |
Wolfgang Betz |
44:d757094f6229 | 230 | { |
Wolfgang Betz |
44:d757094f6229 | 231 | int ret = dev_i2c.i2c_read(pBuffer, |
Wolfgang Betz |
44:d757094f6229 | 232 | LSM6DS3_XG_MEMS_ADDRESS, |
Wolfgang Betz |
44:d757094f6229 | 233 | RegisterAddr, |
Wolfgang Betz |
44:d757094f6229 | 234 | NumByteToRead); |
Wolfgang Betz |
44:d757094f6229 | 235 | if(ret != 0) { |
Wolfgang Betz |
44:d757094f6229 | 236 | return IMU_6AXES_ERROR; |
Wolfgang Betz |
44:d757094f6229 | 237 | } |
Wolfgang Betz |
44:d757094f6229 | 238 | return IMU_6AXES_OK; |
Wolfgang Betz |
44:d757094f6229 | 239 | } |
Wolfgang Betz |
44:d757094f6229 | 240 | |
Wolfgang Betz |
44:d757094f6229 | 241 | /** |
Wolfgang Betz |
57:04563dd74269 | 242 | * @brief Utility function to write data to LSM6DS3 |
Wolfgang Betz |
57:04563dd74269 | 243 | * @param[in] pBuffer pointer to the byte-array data to send |
Wolfgang Betz |
57:04563dd74269 | 244 | * @param[in] RegisterAddr specifies internal address register to read from. |
Wolfgang Betz |
57:04563dd74269 | 245 | * @param[in] NumByteToWrite number of bytes to write. |
Wolfgang Betz |
57:04563dd74269 | 246 | * @retval IMU_6AXES_OK if ok, |
Wolfgang Betz |
57:04563dd74269 | 247 | * @retval IMU_6AXES_ERROR if an I2C error has occured |
Wolfgang Betz |
44:d757094f6229 | 248 | */ |
Wolfgang Betz |
44:d757094f6229 | 249 | IMU_6AXES_StatusTypeDef LSM6DS3_IO_Write(uint8_t* pBuffer, |
Wolfgang Betz |
44:d757094f6229 | 250 | uint8_t RegisterAddr, uint16_t NumByteToWrite) |
Wolfgang Betz |
44:d757094f6229 | 251 | { |
Wolfgang Betz |
44:d757094f6229 | 252 | int ret = dev_i2c.i2c_write(pBuffer, |
Wolfgang Betz |
44:d757094f6229 | 253 | LSM6DS3_XG_MEMS_ADDRESS, |
Wolfgang Betz |
44:d757094f6229 | 254 | RegisterAddr, |
Wolfgang Betz |
44:d757094f6229 | 255 | NumByteToWrite); |
Wolfgang Betz |
44:d757094f6229 | 256 | if(ret != 0) { |
Wolfgang Betz |
44:d757094f6229 | 257 | return IMU_6AXES_ERROR; |
Wolfgang Betz |
44:d757094f6229 | 258 | } |
Wolfgang Betz |
44:d757094f6229 | 259 | return IMU_6AXES_OK; |
Wolfgang Betz |
44:d757094f6229 | 260 | } |
Wolfgang Betz |
44:d757094f6229 | 261 | |
Wolfgang Betz |
44:d757094f6229 | 262 | /*** Instance Variables ***/ |
Wolfgang Betz |
44:d757094f6229 | 263 | /* IO Device */ |
Wolfgang Betz |
44:d757094f6229 | 264 | DevI2C &dev_i2c; |
Wolfgang Betz |
52:54553fd15b50 | 265 | |
Wolfgang Betz |
52:54553fd15b50 | 266 | /* Free Fall Detection IRQ */ |
Wolfgang Betz |
52:54553fd15b50 | 267 | InterruptIn free_fall; |
Wolfgang Betz |
44:d757094f6229 | 268 | }; |
Wolfgang Betz |
44:d757094f6229 | 269 | |
Wolfgang Betz |
44:d757094f6229 | 270 | #endif // __LSM6DS3_CLASS_H |