3-axis MEMS ultra low power accelerometer
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: X_NUCLEO_IKS01A3 X_NUCLEO_IKS01A3
LIS2DW12Sensor.h@0:dff8803aace7, 2018-11-19 (annotated)
- Committer:
- cparata
- Date:
- Mon Nov 19 13:20:07 2018 +0000
- Revision:
- 0:dff8803aace7
- Child:
- 4:94c5d5546161
First release of LIS2DW12 driver
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cparata | 0:dff8803aace7 | 1 | /** |
cparata | 0:dff8803aace7 | 2 | ****************************************************************************** |
cparata | 0:dff8803aace7 | 3 | * @file LIS2DW12Sensor.h |
cparata | 0:dff8803aace7 | 4 | * @author CLab |
cparata | 0:dff8803aace7 | 5 | * @version V1.0.0 |
cparata | 0:dff8803aace7 | 6 | * @date 15 November 2018 |
cparata | 0:dff8803aace7 | 7 | * @brief Abstract Class of an LIS2DW12 Inertial Measurement Unit (IMU) 3 axes |
cparata | 0:dff8803aace7 | 8 | * sensor. |
cparata | 0:dff8803aace7 | 9 | ****************************************************************************** |
cparata | 0:dff8803aace7 | 10 | * @attention |
cparata | 0:dff8803aace7 | 11 | * |
cparata | 0:dff8803aace7 | 12 | * <h2><center>© COPYRIGHT(c) 2018 STMicroelectronics</center></h2> |
cparata | 0:dff8803aace7 | 13 | * |
cparata | 0:dff8803aace7 | 14 | * Redistribution and use in source and binary forms, with or without modification, |
cparata | 0:dff8803aace7 | 15 | * are permitted provided that the following conditions are met: |
cparata | 0:dff8803aace7 | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
cparata | 0:dff8803aace7 | 17 | * this list of conditions and the following disclaimer. |
cparata | 0:dff8803aace7 | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
cparata | 0:dff8803aace7 | 19 | * this list of conditions and the following disclaimer in the documentation |
cparata | 0:dff8803aace7 | 20 | * and/or other materials provided with the distribution. |
cparata | 0:dff8803aace7 | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
cparata | 0:dff8803aace7 | 22 | * may be used to endorse or promote products derived from this software |
cparata | 0:dff8803aace7 | 23 | * without specific prior written permission. |
cparata | 0:dff8803aace7 | 24 | * |
cparata | 0:dff8803aace7 | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
cparata | 0:dff8803aace7 | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
cparata | 0:dff8803aace7 | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
cparata | 0:dff8803aace7 | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
cparata | 0:dff8803aace7 | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
cparata | 0:dff8803aace7 | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
cparata | 0:dff8803aace7 | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
cparata | 0:dff8803aace7 | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
cparata | 0:dff8803aace7 | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
cparata | 0:dff8803aace7 | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
cparata | 0:dff8803aace7 | 35 | * |
cparata | 0:dff8803aace7 | 36 | ****************************************************************************** |
cparata | 0:dff8803aace7 | 37 | */ |
cparata | 0:dff8803aace7 | 38 | |
cparata | 0:dff8803aace7 | 39 | |
cparata | 0:dff8803aace7 | 40 | /* Prevent recursive inclusion -----------------------------------------------*/ |
cparata | 0:dff8803aace7 | 41 | |
cparata | 0:dff8803aace7 | 42 | #ifndef __LIS2DW12Sensor_H__ |
cparata | 0:dff8803aace7 | 43 | #define __LIS2DW12Sensor_H__ |
cparata | 0:dff8803aace7 | 44 | |
cparata | 0:dff8803aace7 | 45 | |
cparata | 0:dff8803aace7 | 46 | /* Includes ------------------------------------------------------------------*/ |
cparata | 0:dff8803aace7 | 47 | |
cparata | 0:dff8803aace7 | 48 | #include "DevI2C.h" |
cparata | 0:dff8803aace7 | 49 | #include "lis2dw12_reg.h" |
cparata | 0:dff8803aace7 | 50 | #include "MotionSensor.h" |
cparata | 0:dff8803aace7 | 51 | #include <assert.h> |
cparata | 0:dff8803aace7 | 52 | |
cparata | 0:dff8803aace7 | 53 | /* Defines -------------------------------------------------------------------*/ |
cparata | 0:dff8803aace7 | 54 | |
cparata | 0:dff8803aace7 | 55 | #define LIS2DW12_ACC_SENSITIVITY_FOR_FS_2G_LOPOW1_MODE 0.976f /**< Sensitivity value for 2g full scale, Low-power1 mode [mg/LSB] */ |
cparata | 0:dff8803aace7 | 56 | #define LIS2DW12_ACC_SENSITIVITY_FOR_FS_2G_OTHER_MODES 0.244f /**< Sensitivity value for 2g full scale, all other modes except Low-power1 [mg/LSB] */ |
cparata | 0:dff8803aace7 | 57 | |
cparata | 0:dff8803aace7 | 58 | #define LIS2DW12_ACC_SENSITIVITY_FOR_FS_4G_LOPOW1_MODE 1.952f /**< Sensitivity value for 4g full scale, Low-power1 mode [mg/LSB] */ |
cparata | 0:dff8803aace7 | 59 | #define LIS2DW12_ACC_SENSITIVITY_FOR_FS_4G_OTHER_MODES 0.488f /**< Sensitivity value for 4g full scale, all other modes except Low-power1 [mg/LSB] */ |
cparata | 0:dff8803aace7 | 60 | |
cparata | 0:dff8803aace7 | 61 | #define LIS2DW12_ACC_SENSITIVITY_FOR_FS_8G_LOPOW1_MODE 3.904f /**< Sensitivity value for 8g full scale, Low-power1 mode [mg/LSB] */ |
cparata | 0:dff8803aace7 | 62 | #define LIS2DW12_ACC_SENSITIVITY_FOR_FS_8G_OTHER_MODES 0.976f /**< Sensitivity value for 8g full scale, all other modes except Low-power1 [mg/LSB] */ |
cparata | 0:dff8803aace7 | 63 | |
cparata | 0:dff8803aace7 | 64 | #define LIS2DW12_ACC_SENSITIVITY_FOR_FS_16G_LOPOW1_MODE 7.808f /**< Sensitivity value for 16g full scale, Low-power1 mode [mg/LSB] */ |
cparata | 0:dff8803aace7 | 65 | #define LIS2DW12_ACC_SENSITIVITY_FOR_FS_16G_OTHER_MODES 1.952f /**< Sensitivity value for 16g full scale, all other modes except Low-power1 [mg/LSB] */ |
cparata | 0:dff8803aace7 | 66 | |
cparata | 0:dff8803aace7 | 67 | /* Typedefs ------------------------------------------------------------------*/ |
cparata | 0:dff8803aace7 | 68 | |
cparata | 0:dff8803aace7 | 69 | typedef struct |
cparata | 0:dff8803aace7 | 70 | { |
cparata | 0:dff8803aace7 | 71 | unsigned int WakeUpStatus : 1; |
cparata | 0:dff8803aace7 | 72 | unsigned int D6DOrientationStatus : 1; |
cparata | 0:dff8803aace7 | 73 | unsigned int SleepStatus : 1; |
cparata | 0:dff8803aace7 | 74 | } LIS2DW12_Event_Status_t; |
cparata | 0:dff8803aace7 | 75 | |
cparata | 0:dff8803aace7 | 76 | typedef enum |
cparata | 0:dff8803aace7 | 77 | { |
cparata | 0:dff8803aace7 | 78 | LIS2DW12_HIGH_PERFORMANCE_MODE, |
cparata | 0:dff8803aace7 | 79 | LIS2DW12_LOW_POWER_MODE4, |
cparata | 0:dff8803aace7 | 80 | LIS2DW12_LOW_POWER_MODE3, |
cparata | 0:dff8803aace7 | 81 | LIS2DW12_LOW_POWER_MODE2, |
cparata | 0:dff8803aace7 | 82 | LIS2DW12_LOW_POWER_MODE1 |
cparata | 0:dff8803aace7 | 83 | } LIS2DW12_Operating_Mode_t; |
cparata | 0:dff8803aace7 | 84 | |
cparata | 0:dff8803aace7 | 85 | typedef enum |
cparata | 0:dff8803aace7 | 86 | { |
cparata | 0:dff8803aace7 | 87 | LIS2DW12_LOW_NOISE_DISABLE, |
cparata | 0:dff8803aace7 | 88 | LIS2DW12_LOW_NOISE_ENABLE |
cparata | 0:dff8803aace7 | 89 | } LIS2DW12_Low_Noise_t; |
cparata | 0:dff8803aace7 | 90 | |
cparata | 0:dff8803aace7 | 91 | /* Class Declaration ---------------------------------------------------------*/ |
cparata | 0:dff8803aace7 | 92 | |
cparata | 0:dff8803aace7 | 93 | /** |
cparata | 0:dff8803aace7 | 94 | * Abstract class of an LIS2DW12 Inertial Measurement Unit (IMU) 3 axes |
cparata | 0:dff8803aace7 | 95 | * sensor. |
cparata | 0:dff8803aace7 | 96 | */ |
cparata | 0:dff8803aace7 | 97 | class LIS2DW12Sensor : public MotionSensor |
cparata | 0:dff8803aace7 | 98 | { |
cparata | 0:dff8803aace7 | 99 | public: |
cparata | 0:dff8803aace7 | 100 | enum SPI_type_t {SPI3W, SPI4W}; |
cparata | 0:dff8803aace7 | 101 | LIS2DW12Sensor(DevI2C *i2c, uint8_t address=LIS2DW12_I2C_ADD_H, PinName int1_pin=NC, PinName int2_pin=NC); |
cparata | 0:dff8803aace7 | 102 | LIS2DW12Sensor(SPI *spi, PinName cs_pin, PinName int1_pin=NC, PinName int2_pin=NC, SPI_type_t spi_type=SPI4W); |
cparata | 0:dff8803aace7 | 103 | virtual int init(void *init); |
cparata | 0:dff8803aace7 | 104 | virtual int read_id(uint8_t *id); |
cparata | 0:dff8803aace7 | 105 | virtual int get_x_axes(int32_t *pData); |
cparata | 0:dff8803aace7 | 106 | virtual int get_x_sensitivity(float *pfData); |
cparata | 0:dff8803aace7 | 107 | virtual int get_x_axes_raw(int16_t *pData); |
cparata | 0:dff8803aace7 | 108 | virtual int get_x_odr(float *odr); |
cparata | 0:dff8803aace7 | 109 | virtual int set_x_odr(float odr); |
cparata | 0:dff8803aace7 | 110 | virtual int get_x_fs(float *fullScale); |
cparata | 0:dff8803aace7 | 111 | virtual int set_x_fs(float fullScale); |
cparata | 0:dff8803aace7 | 112 | int set_x_odr_with_mode(float odr, LIS2DW12_Operating_Mode_t mode=LIS2DW12_HIGH_PERFORMANCE_MODE, LIS2DW12_Low_Noise_t noise=LIS2DW12_LOW_NOISE_DISABLE); |
cparata | 0:dff8803aace7 | 113 | int enable_x(void); |
cparata | 0:dff8803aace7 | 114 | int disable_x(void); |
cparata | 0:dff8803aace7 | 115 | int enable_wake_up_detection(void); |
cparata | 0:dff8803aace7 | 116 | int disable_wake_up_detection(void); |
cparata | 0:dff8803aace7 | 117 | int set_wake_up_threshold(uint8_t thr); |
cparata | 0:dff8803aace7 | 118 | int set_wake_up_duration(uint8_t dur); |
cparata | 0:dff8803aace7 | 119 | int enable_inactivity_detection(void); |
cparata | 0:dff8803aace7 | 120 | int disable_inactivity_detection(void); |
cparata | 0:dff8803aace7 | 121 | int set_sleep_duration(uint8_t dur); |
cparata | 0:dff8803aace7 | 122 | int enable_6d_orientation(void); |
cparata | 0:dff8803aace7 | 123 | int disable_6d_orientation(void); |
cparata | 0:dff8803aace7 | 124 | int set_6d_orientation_threshold(uint8_t thr); |
cparata | 0:dff8803aace7 | 125 | int get_6d_orientation_xl(uint8_t *xl); |
cparata | 0:dff8803aace7 | 126 | int get_6d_orientation_xh(uint8_t *xh); |
cparata | 0:dff8803aace7 | 127 | int get_6d_orientation_yl(uint8_t *yl); |
cparata | 0:dff8803aace7 | 128 | int get_6d_orientation_yh(uint8_t *yh); |
cparata | 0:dff8803aace7 | 129 | int get_6d_orientation_zl(uint8_t *zl); |
cparata | 0:dff8803aace7 | 130 | int get_6d_orientation_zh(uint8_t *zh); |
cparata | 0:dff8803aace7 | 131 | int get_event_status(LIS2DW12_Event_Status_t *status); |
cparata | 0:dff8803aace7 | 132 | int get_fifo_num_samples(uint16_t *num_samples); |
cparata | 0:dff8803aace7 | 133 | int set_fifo_mode(uint8_t mode); |
cparata | 0:dff8803aace7 | 134 | int read_reg(uint8_t reg, uint8_t *data); |
cparata | 0:dff8803aace7 | 135 | int write_reg(uint8_t reg, uint8_t data); |
cparata | 0:dff8803aace7 | 136 | |
cparata | 0:dff8803aace7 | 137 | /** |
cparata | 0:dff8803aace7 | 138 | * @brief Attaching an interrupt handler to the INT1 interrupt. |
cparata | 0:dff8803aace7 | 139 | * @param fptr An interrupt handler. |
cparata | 0:dff8803aace7 | 140 | * @retval None. |
cparata | 0:dff8803aace7 | 141 | */ |
cparata | 0:dff8803aace7 | 142 | void attach_int1_irq(void (*fptr)(void)) |
cparata | 0:dff8803aace7 | 143 | { |
cparata | 0:dff8803aace7 | 144 | _int1_irq.rise(fptr); |
cparata | 0:dff8803aace7 | 145 | } |
cparata | 0:dff8803aace7 | 146 | |
cparata | 0:dff8803aace7 | 147 | /** |
cparata | 0:dff8803aace7 | 148 | * @brief Enabling the INT1 interrupt handling. |
cparata | 0:dff8803aace7 | 149 | * @param None. |
cparata | 0:dff8803aace7 | 150 | * @retval None. |
cparata | 0:dff8803aace7 | 151 | */ |
cparata | 0:dff8803aace7 | 152 | void enable_int1_irq(void) |
cparata | 0:dff8803aace7 | 153 | { |
cparata | 0:dff8803aace7 | 154 | _int1_irq.enable_irq(); |
cparata | 0:dff8803aace7 | 155 | } |
cparata | 0:dff8803aace7 | 156 | |
cparata | 0:dff8803aace7 | 157 | /** |
cparata | 0:dff8803aace7 | 158 | * @brief Disabling the INT1 interrupt handling. |
cparata | 0:dff8803aace7 | 159 | * @param None. |
cparata | 0:dff8803aace7 | 160 | * @retval None. |
cparata | 0:dff8803aace7 | 161 | */ |
cparata | 0:dff8803aace7 | 162 | void disable_int1_irq(void) |
cparata | 0:dff8803aace7 | 163 | { |
cparata | 0:dff8803aace7 | 164 | _int1_irq.disable_irq(); |
cparata | 0:dff8803aace7 | 165 | } |
cparata | 0:dff8803aace7 | 166 | |
cparata | 0:dff8803aace7 | 167 | /** |
cparata | 0:dff8803aace7 | 168 | * @brief Attaching an interrupt handler to the INT2 interrupt. |
cparata | 0:dff8803aace7 | 169 | * @param fptr An interrupt handler. |
cparata | 0:dff8803aace7 | 170 | * @retval None. |
cparata | 0:dff8803aace7 | 171 | */ |
cparata | 0:dff8803aace7 | 172 | void attach_int2_irq(void (*fptr)(void)) |
cparata | 0:dff8803aace7 | 173 | { |
cparata | 0:dff8803aace7 | 174 | _int2_irq.rise(fptr); |
cparata | 0:dff8803aace7 | 175 | } |
cparata | 0:dff8803aace7 | 176 | |
cparata | 0:dff8803aace7 | 177 | /** |
cparata | 0:dff8803aace7 | 178 | * @brief Enabling the INT2 interrupt handling. |
cparata | 0:dff8803aace7 | 179 | * @param None. |
cparata | 0:dff8803aace7 | 180 | * @retval None. |
cparata | 0:dff8803aace7 | 181 | */ |
cparata | 0:dff8803aace7 | 182 | void enable_int2_irq(void) |
cparata | 0:dff8803aace7 | 183 | { |
cparata | 0:dff8803aace7 | 184 | _int2_irq.enable_irq(); |
cparata | 0:dff8803aace7 | 185 | } |
cparata | 0:dff8803aace7 | 186 | |
cparata | 0:dff8803aace7 | 187 | /** |
cparata | 0:dff8803aace7 | 188 | * @brief Disabling the INT2 interrupt handling. |
cparata | 0:dff8803aace7 | 189 | * @param None. |
cparata | 0:dff8803aace7 | 190 | * @retval None. |
cparata | 0:dff8803aace7 | 191 | */ |
cparata | 0:dff8803aace7 | 192 | void disable_int2_irq(void) |
cparata | 0:dff8803aace7 | 193 | { |
cparata | 0:dff8803aace7 | 194 | _int2_irq.disable_irq(); |
cparata | 0:dff8803aace7 | 195 | } |
cparata | 0:dff8803aace7 | 196 | |
cparata | 0:dff8803aace7 | 197 | /** |
cparata | 0:dff8803aace7 | 198 | * @brief Utility function to read data. |
cparata | 0:dff8803aace7 | 199 | * @param pBuffer: pointer to data to be read. |
cparata | 0:dff8803aace7 | 200 | * @param RegisterAddr: specifies internal address register to be read. |
cparata | 0:dff8803aace7 | 201 | * @param NumByteToRead: number of bytes to be read. |
cparata | 0:dff8803aace7 | 202 | * @retval 0 if ok, an error code otherwise. |
cparata | 0:dff8803aace7 | 203 | */ |
cparata | 0:dff8803aace7 | 204 | uint8_t io_read(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead) |
cparata | 0:dff8803aace7 | 205 | { |
cparata | 0:dff8803aace7 | 206 | if (_dev_spi) { |
cparata | 0:dff8803aace7 | 207 | /* Write Reg Address */ |
cparata | 0:dff8803aace7 | 208 | _dev_spi->lock(); |
cparata | 0:dff8803aace7 | 209 | _cs_pin = 0; |
cparata | 0:dff8803aace7 | 210 | if (_spi_type == SPI4W) { |
cparata | 0:dff8803aace7 | 211 | _dev_spi->write(RegisterAddr | 0x80); |
cparata | 0:dff8803aace7 | 212 | for (int i=0; i<NumByteToRead; i++) { |
cparata | 0:dff8803aace7 | 213 | *(pBuffer+i) = _dev_spi->write(0x00); |
cparata | 0:dff8803aace7 | 214 | } |
cparata | 0:dff8803aace7 | 215 | } else if (_spi_type == SPI3W){ |
cparata | 0:dff8803aace7 | 216 | /* Write RD Reg Address with RD bit*/ |
cparata | 0:dff8803aace7 | 217 | uint8_t TxByte = RegisterAddr | 0x80; |
cparata | 0:dff8803aace7 | 218 | _dev_spi->write((char *)&TxByte, 1, (char *)pBuffer, (int) NumByteToRead); |
cparata | 0:dff8803aace7 | 219 | } |
cparata | 0:dff8803aace7 | 220 | _cs_pin = 1; |
cparata | 0:dff8803aace7 | 221 | _dev_spi->unlock(); |
cparata | 0:dff8803aace7 | 222 | return 0; |
cparata | 0:dff8803aace7 | 223 | } |
cparata | 0:dff8803aace7 | 224 | if (_dev_i2c) return (uint8_t) _dev_i2c->i2c_read(pBuffer, _address, RegisterAddr, NumByteToRead); |
cparata | 0:dff8803aace7 | 225 | return 1; |
cparata | 0:dff8803aace7 | 226 | } |
cparata | 0:dff8803aace7 | 227 | |
cparata | 0:dff8803aace7 | 228 | /** |
cparata | 0:dff8803aace7 | 229 | * @brief Utility function to write data. |
cparata | 0:dff8803aace7 | 230 | * @param pBuffer: pointer to data to be written. |
cparata | 0:dff8803aace7 | 231 | * @param RegisterAddr: specifies internal address register to be written. |
cparata | 0:dff8803aace7 | 232 | * @param NumByteToWrite: number of bytes to write. |
cparata | 0:dff8803aace7 | 233 | * @retval 0 if ok, an error code otherwise. |
cparata | 0:dff8803aace7 | 234 | */ |
cparata | 0:dff8803aace7 | 235 | uint8_t io_write(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite) |
cparata | 0:dff8803aace7 | 236 | { |
cparata | 0:dff8803aace7 | 237 | if (_dev_spi) { |
cparata | 0:dff8803aace7 | 238 | _dev_spi->lock(); |
cparata | 0:dff8803aace7 | 239 | _cs_pin = 0; |
cparata | 0:dff8803aace7 | 240 | _dev_spi->write(RegisterAddr); |
cparata | 0:dff8803aace7 | 241 | _dev_spi->write((char *)pBuffer, (int) NumByteToWrite, NULL, 0); |
cparata | 0:dff8803aace7 | 242 | _cs_pin = 1; |
cparata | 0:dff8803aace7 | 243 | _dev_spi->unlock(); |
cparata | 0:dff8803aace7 | 244 | return 0; |
cparata | 0:dff8803aace7 | 245 | } |
cparata | 0:dff8803aace7 | 246 | if (_dev_i2c) return (uint8_t) _dev_i2c->i2c_write(pBuffer, _address, RegisterAddr, NumByteToWrite); |
cparata | 0:dff8803aace7 | 247 | return 1; |
cparata | 0:dff8803aace7 | 248 | } |
cparata | 0:dff8803aace7 | 249 | |
cparata | 0:dff8803aace7 | 250 | private: |
cparata | 0:dff8803aace7 | 251 | int set_x_odr_when_enabled(float odr, LIS2DW12_Operating_Mode_t mode, LIS2DW12_Low_Noise_t noise); |
cparata | 0:dff8803aace7 | 252 | int set_x_odr_when_disabled(float odr, LIS2DW12_Operating_Mode_t mode, LIS2DW12_Low_Noise_t noise); |
cparata | 0:dff8803aace7 | 253 | |
cparata | 0:dff8803aace7 | 254 | /* Helper classes. */ |
cparata | 0:dff8803aace7 | 255 | DevI2C *_dev_i2c; |
cparata | 0:dff8803aace7 | 256 | SPI *_dev_spi; |
cparata | 0:dff8803aace7 | 257 | |
cparata | 0:dff8803aace7 | 258 | /* Configuration */ |
cparata | 0:dff8803aace7 | 259 | uint8_t _address; |
cparata | 0:dff8803aace7 | 260 | DigitalOut _cs_pin; |
cparata | 0:dff8803aace7 | 261 | InterruptIn _int1_irq; |
cparata | 0:dff8803aace7 | 262 | InterruptIn _int2_irq; |
cparata | 0:dff8803aace7 | 263 | SPI_type_t _spi_type; |
cparata | 0:dff8803aace7 | 264 | |
cparata | 0:dff8803aace7 | 265 | uint8_t _x_is_enabled; |
cparata | 0:dff8803aace7 | 266 | float _x_last_odr; |
cparata | 0:dff8803aace7 | 267 | LIS2DW12_Operating_Mode_t _x_last_operating_mode; |
cparata | 0:dff8803aace7 | 268 | LIS2DW12_Low_Noise_t _x_last_noise; |
cparata | 0:dff8803aace7 | 269 | |
cparata | 0:dff8803aace7 | 270 | lis2dw12_ctx_t _reg_ctx; |
cparata | 0:dff8803aace7 | 271 | }; |
cparata | 0:dff8803aace7 | 272 | |
cparata | 0:dff8803aace7 | 273 | #ifdef __cplusplus |
cparata | 0:dff8803aace7 | 274 | extern "C" { |
cparata | 0:dff8803aace7 | 275 | #endif |
cparata | 0:dff8803aace7 | 276 | int32_t LIS2DW12_io_write( void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite ); |
cparata | 0:dff8803aace7 | 277 | int32_t LIS2DW12_io_read( void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead ); |
cparata | 0:dff8803aace7 | 278 | #ifdef __cplusplus |
cparata | 0:dff8803aace7 | 279 | } |
cparata | 0:dff8803aace7 | 280 | #endif |
cparata | 0:dff8803aace7 | 281 | |
cparata | 0:dff8803aace7 | 282 | #endif |