pin assignments for mDot

Dependencies:   X_NUCLEO_COMMON

Dependents:   iks01a1_acc LoRaWAN-demo-72_mdotIKS01A1 MTDOT-UDKDemo_Senet MTDOT-UDKDemo

Fork of X_NUCLEO_IKS01A1 by ST

Committer:
Wolfgang Betz
Date:
Mon Jun 08 18:04:19 2015 +0200
Revision:
50:f507d4465c31
Parent:
46:badcff0675e8
Child:
52:54553fd15b50
Cleanup interfaces from not yet comfirmed methods

Potential generic methods to be put into interface classes from which to
derive other interfaces from are (among others):
- virtual int PowerOff(void) { /* not yet implemented */ return 0; }
- virtual int Reset(void) { /* not yet implemented */ return 0; }

- virtual void ConfigIT(uint16_t) { /* not yet implemented */ }
- virtual void EnableIT(uint8_t) { /* not yet implemented */ }
- virtual void DisableIT(uint8_t) { /* not yet implemented */ }
- virtual uint8_t ITStatus(uint16_t, uint16_t) { /* not yet implemented */ return 0; }
- virtual void ClearIT(uint16_t, uint16_t) { /* not yet implemented */ }
- virtual void AttachIT(void (*fptr)(void)) { /* not yet implemented */ }

Who changed what in which revision?

UserRevisionLine numberNew 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>&copy; 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 44:d757094f6229 44 #include "../Interfaces/GyroSensor.h"
Wolfgang Betz 44:d757094f6229 45 #include "../Interfaces/MotionSensor.h"
Wolfgang Betz 44:d757094f6229 46 #include "lsm6ds3.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 44:d757094f6229 54 * @param i2c device I2C to be used for communication
Wolfgang Betz 44:d757094f6229 55 */
Wolfgang Betz 44:d757094f6229 56 LSM6DS3(DevI2C &i2c) : GyroSensor(), MotionSensor(), dev_i2c(i2c) {
Wolfgang Betz 44:d757094f6229 57 }
Wolfgang Betz 44:d757094f6229 58
Wolfgang Betz 44:d757094f6229 59 /** Destructor
Wolfgang Betz 44:d757094f6229 60 */
Wolfgang Betz 44:d757094f6229 61 virtual ~LSM6DS3() {}
Wolfgang Betz 44:d757094f6229 62
Wolfgang Betz 44:d757094f6229 63 /*** Interface Methods ***/
Wolfgang Betz 44:d757094f6229 64 virtual int Init(void *init_struct) {
Wolfgang Betz 44:d757094f6229 65 return LSM6DS3_Init((IMU_6AXES_InitTypeDef*)init_struct);
Wolfgang Betz 44:d757094f6229 66 }
Wolfgang Betz 44:d757094f6229 67
Wolfgang Betz 44:d757094f6229 68 virtual int ReadID(uint8_t *xg_id) {
Wolfgang Betz 44:d757094f6229 69 return LSM6DS3_Read_XG_ID(xg_id);
Wolfgang Betz 44:d757094f6229 70 }
Wolfgang Betz 44:d757094f6229 71
Wolfgang Betz 44:d757094f6229 72 virtual int Get_X_Axes(int32_t *pData) {
Wolfgang Betz 44:d757094f6229 73 return LSM6DS3_X_GetAxes(pData);
Wolfgang Betz 44:d757094f6229 74 }
Wolfgang Betz 44:d757094f6229 75
Wolfgang Betz 44:d757094f6229 76 virtual int Get_X_AxesRaw(int16_t *pData) {
Wolfgang Betz 44:d757094f6229 77 return LSM6DS3_X_GetAxesRaw(pData);
Wolfgang Betz 44:d757094f6229 78 }
Wolfgang Betz 44:d757094f6229 79
Wolfgang Betz 44:d757094f6229 80 virtual int Get_G_Axes(int32_t *pData) {
Wolfgang Betz 44:d757094f6229 81 return LSM6DS3_G_GetAxes(pData);
Wolfgang Betz 44:d757094f6229 82 }
Wolfgang Betz 44:d757094f6229 83
Wolfgang Betz 44:d757094f6229 84 virtual int Get_G_AxesRaw(int16_t *pData) {
Wolfgang Betz 44:d757094f6229 85 return LSM6DS3_G_GetAxesRaw(pData);
Wolfgang Betz 44:d757094f6229 86 }
Wolfgang Betz 44:d757094f6229 87
Wolfgang Betz 44:d757094f6229 88 virtual int Get_X_ODR(float *odr) {
Wolfgang Betz 44:d757094f6229 89 return LSM6DS3_X_Get_ODR(odr);
Wolfgang Betz 44:d757094f6229 90 }
Wolfgang Betz 44:d757094f6229 91
Wolfgang Betz 44:d757094f6229 92 virtual int Set_X_ODR(float odr) {
Wolfgang Betz 44:d757094f6229 93 return LSM6DS3_X_Set_ODR(odr);
Wolfgang Betz 44:d757094f6229 94 }
Wolfgang Betz 44:d757094f6229 95
Wolfgang Betz 44:d757094f6229 96 virtual int Get_X_Sensitivity(float *pfData) {
Wolfgang Betz 44:d757094f6229 97 return LSM6DS3_X_GetSensitivity(pfData);
Wolfgang Betz 44:d757094f6229 98 }
Wolfgang Betz 44:d757094f6229 99
Wolfgang Betz 44:d757094f6229 100 virtual int Get_X_FS(float *fullScale) {
Wolfgang Betz 44:d757094f6229 101 return LSM6DS3_X_Get_FS(fullScale);
Wolfgang Betz 44:d757094f6229 102 }
Wolfgang Betz 44:d757094f6229 103
Wolfgang Betz 44:d757094f6229 104 virtual int Set_X_FS(float fullScale) {
Wolfgang Betz 44:d757094f6229 105 return LSM6DS3_X_Set_FS(fullScale);
Wolfgang Betz 44:d757094f6229 106 }
Wolfgang Betz 44:d757094f6229 107
Wolfgang Betz 44:d757094f6229 108 virtual int Get_G_ODR(float *odr) {
Wolfgang Betz 44:d757094f6229 109 return LSM6DS3_G_Get_ODR(odr);
Wolfgang Betz 44:d757094f6229 110 }
Wolfgang Betz 44:d757094f6229 111
Wolfgang Betz 44:d757094f6229 112 virtual int Set_G_ODR(float odr) {
Wolfgang Betz 44:d757094f6229 113 return LSM6DS3_G_Set_ODR(odr);
Wolfgang Betz 44:d757094f6229 114 }
Wolfgang Betz 44:d757094f6229 115
Wolfgang Betz 44:d757094f6229 116 virtual int Get_G_Sensitivity(float *pfData) {
Wolfgang Betz 44:d757094f6229 117 return LSM6DS3_G_GetSensitivity(pfData);
Wolfgang Betz 44:d757094f6229 118 }
Wolfgang Betz 44:d757094f6229 119
Wolfgang Betz 44:d757094f6229 120 virtual int Get_G_FS(float *fullScale) {
Wolfgang Betz 44:d757094f6229 121 return LSM6DS3_G_Get_FS(fullScale);
Wolfgang Betz 44:d757094f6229 122 }
Wolfgang Betz 44:d757094f6229 123
Wolfgang Betz 44:d757094f6229 124 virtual int Set_G_FS(float fullScale) {
Wolfgang Betz 44:d757094f6229 125 return LSM6DS3_G_Set_FS(fullScale);
Wolfgang Betz 44:d757094f6229 126 }
Wolfgang Betz 44:d757094f6229 127
Wolfgang Betz 44:d757094f6229 128 /* Additional Public Methods */
Wolfgang Betz 44:d757094f6229 129 IMU_6AXES_StatusTypeDef Enable_Free_Fall_Detection(void) {
Wolfgang Betz 44:d757094f6229 130 return LSM6DS3_Enable_Free_Fall_Detection();
Wolfgang Betz 44:d757094f6229 131 }
Wolfgang Betz 44:d757094f6229 132
Wolfgang Betz 44:d757094f6229 133 IMU_6AXES_StatusTypeDef Disable_Free_Fall_Detection(void) {
Wolfgang Betz 44:d757094f6229 134 return LSM6DS3_Disable_Free_Fall_Detection();
Wolfgang Betz 44:d757094f6229 135 }
Wolfgang Betz 44:d757094f6229 136
Wolfgang Betz 44:d757094f6229 137 IMU_6AXES_StatusTypeDef Get_Status_Free_Fall_Detection(uint8_t *status) {
Wolfgang Betz 44:d757094f6229 138 return LSM6DS3_Get_Status_Free_Fall_Detection(status);
Wolfgang Betz 44:d757094f6229 139 }
Wolfgang Betz 44:d757094f6229 140
Wolfgang Betz 44:d757094f6229 141 protected:
Wolfgang Betz 44:d757094f6229 142 /*** Methods ***/
Wolfgang Betz 44:d757094f6229 143 IMU_6AXES_StatusTypeDef LSM6DS3_Init(IMU_6AXES_InitTypeDef *LSM6DS3_Init);
Wolfgang Betz 44:d757094f6229 144 IMU_6AXES_StatusTypeDef LSM6DS3_Read_XG_ID(uint8_t *xg_id);
Wolfgang Betz 44:d757094f6229 145 IMU_6AXES_StatusTypeDef LSM6DS3_X_GetAxes(int32_t *pData);
Wolfgang Betz 44:d757094f6229 146 IMU_6AXES_StatusTypeDef LSM6DS3_X_GetAxesRaw(int16_t *pData);
Wolfgang Betz 44:d757094f6229 147 IMU_6AXES_StatusTypeDef LSM6DS3_G_GetAxes(int32_t *pData);
Wolfgang Betz 44:d757094f6229 148 IMU_6AXES_StatusTypeDef LSM6DS3_G_GetAxesRaw(int16_t *pData);
Wolfgang Betz 44:d757094f6229 149 IMU_6AXES_StatusTypeDef LSM6DS3_X_Get_ODR( float *odr );
Wolfgang Betz 44:d757094f6229 150 IMU_6AXES_StatusTypeDef LSM6DS3_X_Set_ODR( float odr );
Wolfgang Betz 44:d757094f6229 151 IMU_6AXES_StatusTypeDef LSM6DS3_X_GetSensitivity( float *pfData );
Wolfgang Betz 44:d757094f6229 152 IMU_6AXES_StatusTypeDef LSM6DS3_X_Get_FS( float *fullScale );
Wolfgang Betz 44:d757094f6229 153 IMU_6AXES_StatusTypeDef LSM6DS3_X_Set_FS( float fullScale );
Wolfgang Betz 44:d757094f6229 154 IMU_6AXES_StatusTypeDef LSM6DS3_G_Get_ODR( float *odr );
Wolfgang Betz 44:d757094f6229 155 IMU_6AXES_StatusTypeDef LSM6DS3_G_Set_ODR( float odr );
Wolfgang Betz 44:d757094f6229 156 IMU_6AXES_StatusTypeDef LSM6DS3_G_GetSensitivity( float *pfData );
Wolfgang Betz 44:d757094f6229 157 IMU_6AXES_StatusTypeDef LSM6DS3_G_Get_FS( float *fullScale );
Wolfgang Betz 44:d757094f6229 158 IMU_6AXES_StatusTypeDef LSM6DS3_G_Set_FS( float fullScale );
Wolfgang Betz 44:d757094f6229 159 IMU_6AXES_StatusTypeDef LSM6DS3_Enable_Free_Fall_Detection( void );
Wolfgang Betz 44:d757094f6229 160 IMU_6AXES_StatusTypeDef LSM6DS3_Disable_Free_Fall_Detection( void );
Wolfgang Betz 44:d757094f6229 161 IMU_6AXES_StatusTypeDef LSM6DS3_Get_Status_Free_Fall_Detection( uint8_t *status );
Wolfgang Betz 44:d757094f6229 162
Wolfgang Betz 44:d757094f6229 163 IMU_6AXES_StatusTypeDef LSM6DS3_Common_Sensor_Enable(void);
Wolfgang Betz 44:d757094f6229 164 IMU_6AXES_StatusTypeDef LSM6DS3_X_Set_Axes_Status(uint8_t enableX, uint8_t enableY, uint8_t enableZ);
Wolfgang Betz 44:d757094f6229 165 IMU_6AXES_StatusTypeDef LSM6DS3_G_Set_Axes_Status(uint8_t enableX, uint8_t enableY, uint8_t enableZ);
Wolfgang Betz 44:d757094f6229 166
Wolfgang Betz 44:d757094f6229 167 /**
Wolfgang Betz 44:d757094f6229 168 * @brief Configures LSM6DS3 interrupt lines for NUCLEO boards
Wolfgang Betz 44:d757094f6229 169 * @param None
Wolfgang Betz 44:d757094f6229 170 * @retval None
Wolfgang Betz 44:d757094f6229 171 */
Wolfgang Betz 44:d757094f6229 172 void LSM6DS3_IO_ITConfig(void)
Wolfgang Betz 44:d757094f6229 173 {
Wolfgang Betz 44:d757094f6229 174 /* To be implemented */
Wolfgang Betz 44:d757094f6229 175 }
Wolfgang Betz 44:d757094f6229 176
Wolfgang Betz 44:d757094f6229 177 /**
Wolfgang Betz 44:d757094f6229 178 * @brief Configures LSM6DS3 I2C interface
Wolfgang Betz 44:d757094f6229 179 * @param None
Wolfgang Betz 44:d757094f6229 180 * @retval IMU_6AXES_OK in case of success, an error code otherwise
Wolfgang Betz 44:d757094f6229 181 */
Wolfgang Betz 44:d757094f6229 182 IMU_6AXES_StatusTypeDef LSM6DS3_IO_Init(void)
Wolfgang Betz 44:d757094f6229 183 {
Wolfgang Betz 44:d757094f6229 184 return IMU_6AXES_OK; /* done in constructor */
Wolfgang Betz 44:d757094f6229 185 }
Wolfgang Betz 44:d757094f6229 186
Wolfgang Betz 44:d757094f6229 187 /**
Wolfgang Betz 44:d757094f6229 188 * @brief utility function to read data from STC3115
Wolfgang Betz 44:d757094f6229 189 * @param pBuffer: pointer to data to be read.
Wolfgang Betz 44:d757094f6229 190 * @param RegisterAddr: specifies internal address register to read from.
Wolfgang Betz 44:d757094f6229 191 * @param NumByteToRead: number of bytes to be read.
Wolfgang Betz 44:d757094f6229 192 * @retval IMU_6AXES_OK if ok, IMU_6AXES_ERROR if an I2C error has occured
Wolfgang Betz 44:d757094f6229 193 */
Wolfgang Betz 44:d757094f6229 194 IMU_6AXES_StatusTypeDef LSM6DS3_IO_Read(uint8_t* pBuffer,
Wolfgang Betz 44:d757094f6229 195 uint8_t RegisterAddr, uint16_t NumByteToRead)
Wolfgang Betz 44:d757094f6229 196 {
Wolfgang Betz 44:d757094f6229 197 int ret = dev_i2c.i2c_read(pBuffer,
Wolfgang Betz 44:d757094f6229 198 LSM6DS3_XG_MEMS_ADDRESS,
Wolfgang Betz 44:d757094f6229 199 RegisterAddr,
Wolfgang Betz 44:d757094f6229 200 NumByteToRead);
Wolfgang Betz 44:d757094f6229 201 if(ret != 0) {
Wolfgang Betz 44:d757094f6229 202 return IMU_6AXES_ERROR;
Wolfgang Betz 44:d757094f6229 203 }
Wolfgang Betz 44:d757094f6229 204 return IMU_6AXES_OK;
Wolfgang Betz 44:d757094f6229 205 }
Wolfgang Betz 44:d757094f6229 206
Wolfgang Betz 44:d757094f6229 207 /**
Wolfgang Betz 44:d757094f6229 208 * @brief utility function to write data to STC3115
Wolfgang Betz 44:d757094f6229 209 * @param pBuffer: pointer to buffer to be filled.
Wolfgang Betz 44:d757094f6229 210 * @param RegisterAddr: specifies internal address register to read from.
Wolfgang Betz 44:d757094f6229 211 * @param NumByteToWrite: number of bytes to write.
Wolfgang Betz 44:d757094f6229 212 * @retval 0 if ok, -1 if an I2C error has occured
Wolfgang Betz 44:d757094f6229 213 */
Wolfgang Betz 44:d757094f6229 214 IMU_6AXES_StatusTypeDef LSM6DS3_IO_Write(uint8_t* pBuffer,
Wolfgang Betz 44:d757094f6229 215 uint8_t RegisterAddr, uint16_t NumByteToWrite)
Wolfgang Betz 44:d757094f6229 216 {
Wolfgang Betz 44:d757094f6229 217 int ret = dev_i2c.i2c_write(pBuffer,
Wolfgang Betz 44:d757094f6229 218 LSM6DS3_XG_MEMS_ADDRESS,
Wolfgang Betz 44:d757094f6229 219 RegisterAddr,
Wolfgang Betz 44:d757094f6229 220 NumByteToWrite);
Wolfgang Betz 44:d757094f6229 221 if(ret != 0) {
Wolfgang Betz 44:d757094f6229 222 return IMU_6AXES_ERROR;
Wolfgang Betz 44:d757094f6229 223 }
Wolfgang Betz 44:d757094f6229 224 return IMU_6AXES_OK;
Wolfgang Betz 44:d757094f6229 225 }
Wolfgang Betz 44:d757094f6229 226
Wolfgang Betz 44:d757094f6229 227 /*** Instance Variables ***/
Wolfgang Betz 44:d757094f6229 228 /* IO Device */
Wolfgang Betz 44:d757094f6229 229 DevI2C &dev_i2c;
Wolfgang Betz 44:d757094f6229 230 };
Wolfgang Betz 44:d757094f6229 231
Wolfgang Betz 44:d757094f6229 232 #endif // __LSM6DS3_CLASS_H