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
Components/lsm303c/LSM303C_ACC_driver.c@96:8cac3f3245b5, 2017-02-07 (annotated)
- Committer:
- Jeej
- Date:
- Tue Feb 07 13:20:43 2017 +0000
- Revision:
- 96:8cac3f3245b5
Adapted LSM303AGR driver from IKS01A2.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jeej | 96:8cac3f3245b5 | 1 | /** |
Jeej | 96:8cac3f3245b5 | 2 | ****************************************************************************** |
Jeej | 96:8cac3f3245b5 | 3 | * @file LSM303C_ACC_driver.c |
Jeej | 96:8cac3f3245b5 | 4 | * @author MEMS Application Team |
Jeej | 96:8cac3f3245b5 | 5 | * @version V1.1 |
Jeej | 96:8cac3f3245b5 | 6 | * @date 24-February-2016 |
Jeej | 96:8cac3f3245b5 | 7 | * @brief LSM303C Accelerometer driver file |
Jeej | 96:8cac3f3245b5 | 8 | ****************************************************************************** |
Jeej | 96:8cac3f3245b5 | 9 | * @attention |
Jeej | 96:8cac3f3245b5 | 10 | * |
Jeej | 96:8cac3f3245b5 | 11 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
Jeej | 96:8cac3f3245b5 | 12 | * |
Jeej | 96:8cac3f3245b5 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
Jeej | 96:8cac3f3245b5 | 14 | * are permitted provided that the following conditions are met: |
Jeej | 96:8cac3f3245b5 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
Jeej | 96:8cac3f3245b5 | 16 | * this list of conditions and the following disclaimer. |
Jeej | 96:8cac3f3245b5 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
Jeej | 96:8cac3f3245b5 | 18 | * this list of conditions and the following disclaimer in the documentation |
Jeej | 96:8cac3f3245b5 | 19 | * and/or other materials provided with the distribution. |
Jeej | 96:8cac3f3245b5 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
Jeej | 96:8cac3f3245b5 | 21 | * may be used to endorse or promote products derived from this software |
Jeej | 96:8cac3f3245b5 | 22 | * without specific prior written permission. |
Jeej | 96:8cac3f3245b5 | 23 | * |
Jeej | 96:8cac3f3245b5 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
Jeej | 96:8cac3f3245b5 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
Jeej | 96:8cac3f3245b5 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Jeej | 96:8cac3f3245b5 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
Jeej | 96:8cac3f3245b5 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
Jeej | 96:8cac3f3245b5 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
Jeej | 96:8cac3f3245b5 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
Jeej | 96:8cac3f3245b5 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
Jeej | 96:8cac3f3245b5 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
Jeej | 96:8cac3f3245b5 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Jeej | 96:8cac3f3245b5 | 34 | * |
Jeej | 96:8cac3f3245b5 | 35 | ****************************************************************************** |
Jeej | 96:8cac3f3245b5 | 36 | */ |
Jeej | 96:8cac3f3245b5 | 37 | |
Jeej | 96:8cac3f3245b5 | 38 | /* Includes ------------------------------------------------------------------*/ |
Jeej | 96:8cac3f3245b5 | 39 | #include "LSM303C_ACC_driver.h" |
Jeej | 96:8cac3f3245b5 | 40 | |
Jeej | 96:8cac3f3245b5 | 41 | /* Imported function prototypes ----------------------------------------------*/ |
Jeej | 96:8cac3f3245b5 | 42 | extern uint8_t LSM303C_ACC_IO_Write(void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite); |
Jeej | 96:8cac3f3245b5 | 43 | extern uint8_t LSM303C_ACC_IO_Read(void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead); |
Jeej | 96:8cac3f3245b5 | 44 | |
Jeej | 96:8cac3f3245b5 | 45 | /* Private typedef -----------------------------------------------------------*/ |
Jeej | 96:8cac3f3245b5 | 46 | |
Jeej | 96:8cac3f3245b5 | 47 | /* Private define ------------------------------------------------------------*/ |
Jeej | 96:8cac3f3245b5 | 48 | |
Jeej | 96:8cac3f3245b5 | 49 | /* Private macro -------------------------------------------------------------*/ |
Jeej | 96:8cac3f3245b5 | 50 | |
Jeej | 96:8cac3f3245b5 | 51 | /* Private variables ---------------------------------------------------------*/ |
Jeej | 96:8cac3f3245b5 | 52 | |
Jeej | 96:8cac3f3245b5 | 53 | /* Private functions ---------------------------------------------------------*/ |
Jeej | 96:8cac3f3245b5 | 54 | |
Jeej | 96:8cac3f3245b5 | 55 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 56 | * Function Name : LSM303C_ACC_ReadReg |
Jeej | 96:8cac3f3245b5 | 57 | * Description : Generic Reading function. It must be fullfilled with either |
Jeej | 96:8cac3f3245b5 | 58 | * : I2C or SPI reading functions |
Jeej | 96:8cac3f3245b5 | 59 | * Input : Register Address |
Jeej | 96:8cac3f3245b5 | 60 | * Output : Data REad |
Jeej | 96:8cac3f3245b5 | 61 | * Return : None |
Jeej | 96:8cac3f3245b5 | 62 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 63 | status_t LSM303C_ACC_ReadReg(void *handle, u8_t Reg, u8_t* Data) |
Jeej | 96:8cac3f3245b5 | 64 | { |
Jeej | 96:8cac3f3245b5 | 65 | |
Jeej | 96:8cac3f3245b5 | 66 | if (LSM303C_ACC_IO_Read(handle, Reg, Data, 1)) |
Jeej | 96:8cac3f3245b5 | 67 | { |
Jeej | 96:8cac3f3245b5 | 68 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 69 | } |
Jeej | 96:8cac3f3245b5 | 70 | else |
Jeej | 96:8cac3f3245b5 | 71 | { |
Jeej | 96:8cac3f3245b5 | 72 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 73 | } |
Jeej | 96:8cac3f3245b5 | 74 | } |
Jeej | 96:8cac3f3245b5 | 75 | |
Jeej | 96:8cac3f3245b5 | 76 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 77 | * Function Name : LSM303C_ACC_WriteReg |
Jeej | 96:8cac3f3245b5 | 78 | * Description : Generic Writing function. It must be fullfilled with either |
Jeej | 96:8cac3f3245b5 | 79 | * : I2C or SPI writing function |
Jeej | 96:8cac3f3245b5 | 80 | * Input : Register Address, Data to be written |
Jeej | 96:8cac3f3245b5 | 81 | * Output : None |
Jeej | 96:8cac3f3245b5 | 82 | * Return : None |
Jeej | 96:8cac3f3245b5 | 83 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 84 | status_t LSM303C_ACC_WriteReg(void *handle, u8_t Reg, u8_t Data) |
Jeej | 96:8cac3f3245b5 | 85 | { |
Jeej | 96:8cac3f3245b5 | 86 | |
Jeej | 96:8cac3f3245b5 | 87 | if (LSM303C_ACC_IO_Write(handle, Reg, &Data, 1)) |
Jeej | 96:8cac3f3245b5 | 88 | { |
Jeej | 96:8cac3f3245b5 | 89 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 90 | } |
Jeej | 96:8cac3f3245b5 | 91 | else |
Jeej | 96:8cac3f3245b5 | 92 | { |
Jeej | 96:8cac3f3245b5 | 93 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 94 | } |
Jeej | 96:8cac3f3245b5 | 95 | } |
Jeej | 96:8cac3f3245b5 | 96 | |
Jeej | 96:8cac3f3245b5 | 97 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 98 | * Function Name : SwapHighLowByte |
Jeej | 96:8cac3f3245b5 | 99 | * Description : Swap High/low byte in multiple byte values |
Jeej | 96:8cac3f3245b5 | 100 | * It works with minimum 2 byte for every dimension. |
Jeej | 96:8cac3f3245b5 | 101 | * Example x,y,z with 2 byte for every dimension |
Jeej | 96:8cac3f3245b5 | 102 | * |
Jeej | 96:8cac3f3245b5 | 103 | * Input : bufferToSwap -> buffer to swap |
Jeej | 96:8cac3f3245b5 | 104 | * numberOfByte -> the buffer length in byte |
Jeej | 96:8cac3f3245b5 | 105 | * dimension -> number of dimension |
Jeej | 96:8cac3f3245b5 | 106 | * |
Jeej | 96:8cac3f3245b5 | 107 | * Output : bufferToSwap -> buffer swapped |
Jeej | 96:8cac3f3245b5 | 108 | * Return : None |
Jeej | 96:8cac3f3245b5 | 109 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 110 | void LSM303C_ACC_SwapHighLowByte(u8_t *bufferToSwap, u8_t numberOfByte, u8_t dimension) |
Jeej | 96:8cac3f3245b5 | 111 | { |
Jeej | 96:8cac3f3245b5 | 112 | |
Jeej | 96:8cac3f3245b5 | 113 | u8_t numberOfByteForDimension, i, j; |
Jeej | 96:8cac3f3245b5 | 114 | u8_t tempValue[10]; |
Jeej | 96:8cac3f3245b5 | 115 | |
Jeej | 96:8cac3f3245b5 | 116 | numberOfByteForDimension=numberOfByte/dimension; |
Jeej | 96:8cac3f3245b5 | 117 | |
Jeej | 96:8cac3f3245b5 | 118 | for (i=0; i<dimension;i++ ) |
Jeej | 96:8cac3f3245b5 | 119 | { |
Jeej | 96:8cac3f3245b5 | 120 | for (j=0; j<numberOfByteForDimension;j++ ) |
Jeej | 96:8cac3f3245b5 | 121 | tempValue[j]=bufferToSwap[j+i*numberOfByteForDimension]; |
Jeej | 96:8cac3f3245b5 | 122 | for (j=0; j<numberOfByteForDimension;j++ ) |
Jeej | 96:8cac3f3245b5 | 123 | *(bufferToSwap+i*(numberOfByteForDimension)+j)=*(tempValue+(numberOfByteForDimension-1)-j); |
Jeej | 96:8cac3f3245b5 | 124 | } |
Jeej | 96:8cac3f3245b5 | 125 | } |
Jeej | 96:8cac3f3245b5 | 126 | |
Jeej | 96:8cac3f3245b5 | 127 | /* Exported functions ---------------------------------------------------------*/ |
Jeej | 96:8cac3f3245b5 | 128 | |
Jeej | 96:8cac3f3245b5 | 129 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 130 | * Function Name : LSM303C_ACC_R_WHO_AM_I |
Jeej | 96:8cac3f3245b5 | 131 | * Description : Read WHO_AM_I |
Jeej | 96:8cac3f3245b5 | 132 | * Input : Pointer to u8_t |
Jeej | 96:8cac3f3245b5 | 133 | * Output : Status of WHO_AM_I |
Jeej | 96:8cac3f3245b5 | 134 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 135 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 136 | |
Jeej | 96:8cac3f3245b5 | 137 | status_t LSM303C_ACC_R_WHO_AM_I(void *handle, u8_t *value) |
Jeej | 96:8cac3f3245b5 | 138 | { |
Jeej | 96:8cac3f3245b5 | 139 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_WHO_AM_I_REG_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 140 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 141 | |
Jeej | 96:8cac3f3245b5 | 142 | *value &= LSM303C_ACC_WHO_AM_I_MASK; //coerce |
Jeej | 96:8cac3f3245b5 | 143 | *value = *value >> LSM303C_ACC_WHO_AM_I_POSITION; //mask |
Jeej | 96:8cac3f3245b5 | 144 | |
Jeej | 96:8cac3f3245b5 | 145 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 146 | } |
Jeej | 96:8cac3f3245b5 | 147 | |
Jeej | 96:8cac3f3245b5 | 148 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 149 | * Function Name : LSM303C_ACC_W_XEN |
Jeej | 96:8cac3f3245b5 | 150 | * Description : Write XEN |
Jeej | 96:8cac3f3245b5 | 151 | * Input : LSM303C_ACC_XEN_t |
Jeej | 96:8cac3f3245b5 | 152 | * Output : None |
Jeej | 96:8cac3f3245b5 | 153 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 154 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 155 | status_t LSM303C_ACC_W_XEN(void *handle, LSM303C_ACC_XEN_t newValue) |
Jeej | 96:8cac3f3245b5 | 156 | { |
Jeej | 96:8cac3f3245b5 | 157 | u8_t value; |
Jeej | 96:8cac3f3245b5 | 158 | |
Jeej | 96:8cac3f3245b5 | 159 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG1_A, &value) ) |
Jeej | 96:8cac3f3245b5 | 160 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 161 | |
Jeej | 96:8cac3f3245b5 | 162 | value &= ~LSM303C_ACC_XEN_MASK; |
Jeej | 96:8cac3f3245b5 | 163 | value |= newValue; |
Jeej | 96:8cac3f3245b5 | 164 | |
Jeej | 96:8cac3f3245b5 | 165 | if( !LSM303C_ACC_WriteReg(handle, LSM303C_CTRL_REG1_A, value) ) |
Jeej | 96:8cac3f3245b5 | 166 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 167 | |
Jeej | 96:8cac3f3245b5 | 168 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 169 | } |
Jeej | 96:8cac3f3245b5 | 170 | |
Jeej | 96:8cac3f3245b5 | 171 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 172 | * Function Name : LSM303C_ACC_R_XEN |
Jeej | 96:8cac3f3245b5 | 173 | * Description : Read XEN |
Jeej | 96:8cac3f3245b5 | 174 | * Input : Pointer to LSM303C_ACC_XEN_t |
Jeej | 96:8cac3f3245b5 | 175 | * Output : Status of XEN see LSM303C_ACC_XEN_t |
Jeej | 96:8cac3f3245b5 | 176 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 177 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 178 | |
Jeej | 96:8cac3f3245b5 | 179 | status_t LSM303C_ACC_R_XEN(void *handle, LSM303C_ACC_XEN_t *value) |
Jeej | 96:8cac3f3245b5 | 180 | { |
Jeej | 96:8cac3f3245b5 | 181 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG1_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 182 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 183 | |
Jeej | 96:8cac3f3245b5 | 184 | *value &= LSM303C_ACC_XEN_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 185 | |
Jeej | 96:8cac3f3245b5 | 186 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 187 | } |
Jeej | 96:8cac3f3245b5 | 188 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 189 | * Function Name : LSM303C_ACC_W_YEN |
Jeej | 96:8cac3f3245b5 | 190 | * Description : Write YEN |
Jeej | 96:8cac3f3245b5 | 191 | * Input : LSM303C_ACC_YEN_t |
Jeej | 96:8cac3f3245b5 | 192 | * Output : None |
Jeej | 96:8cac3f3245b5 | 193 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 194 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 195 | status_t LSM303C_ACC_W_YEN(void *handle, LSM303C_ACC_YEN_t newValue) |
Jeej | 96:8cac3f3245b5 | 196 | { |
Jeej | 96:8cac3f3245b5 | 197 | u8_t value; |
Jeej | 96:8cac3f3245b5 | 198 | |
Jeej | 96:8cac3f3245b5 | 199 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG1_A, &value) ) |
Jeej | 96:8cac3f3245b5 | 200 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 201 | |
Jeej | 96:8cac3f3245b5 | 202 | value &= ~LSM303C_ACC_YEN_MASK; |
Jeej | 96:8cac3f3245b5 | 203 | value |= newValue; |
Jeej | 96:8cac3f3245b5 | 204 | |
Jeej | 96:8cac3f3245b5 | 205 | if( !LSM303C_ACC_WriteReg(handle, LSM303C_CTRL_REG1_A, value) ) |
Jeej | 96:8cac3f3245b5 | 206 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 207 | |
Jeej | 96:8cac3f3245b5 | 208 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 209 | } |
Jeej | 96:8cac3f3245b5 | 210 | |
Jeej | 96:8cac3f3245b5 | 211 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 212 | * Function Name : LSM303C_ACC_R_YEN |
Jeej | 96:8cac3f3245b5 | 213 | * Description : Read YEN |
Jeej | 96:8cac3f3245b5 | 214 | * Input : Pointer to LSM303C_ACC_YEN_t |
Jeej | 96:8cac3f3245b5 | 215 | * Output : Status of YEN see LSM303C_ACC_YEN_t |
Jeej | 96:8cac3f3245b5 | 216 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 217 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 218 | |
Jeej | 96:8cac3f3245b5 | 219 | status_t LSM303C_ACC_R_YEN(void *handle, LSM303C_ACC_YEN_t *value) |
Jeej | 96:8cac3f3245b5 | 220 | { |
Jeej | 96:8cac3f3245b5 | 221 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG1_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 222 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 223 | |
Jeej | 96:8cac3f3245b5 | 224 | *value &= LSM303C_ACC_YEN_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 225 | |
Jeej | 96:8cac3f3245b5 | 226 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 227 | } |
Jeej | 96:8cac3f3245b5 | 228 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 229 | * Function Name : LSM303C_ACC_W_ZEN |
Jeej | 96:8cac3f3245b5 | 230 | * Description : Write ZEN |
Jeej | 96:8cac3f3245b5 | 231 | * Input : LSM303C_ACC_ZEN_t |
Jeej | 96:8cac3f3245b5 | 232 | * Output : None |
Jeej | 96:8cac3f3245b5 | 233 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 234 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 235 | status_t LSM303C_ACC_W_ZEN(void *handle, LSM303C_ACC_ZEN_t newValue) |
Jeej | 96:8cac3f3245b5 | 236 | { |
Jeej | 96:8cac3f3245b5 | 237 | u8_t value; |
Jeej | 96:8cac3f3245b5 | 238 | |
Jeej | 96:8cac3f3245b5 | 239 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG1_A, &value) ) |
Jeej | 96:8cac3f3245b5 | 240 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 241 | |
Jeej | 96:8cac3f3245b5 | 242 | value &= ~LSM303C_ACC_ZEN_MASK; |
Jeej | 96:8cac3f3245b5 | 243 | value |= newValue; |
Jeej | 96:8cac3f3245b5 | 244 | |
Jeej | 96:8cac3f3245b5 | 245 | if( !LSM303C_ACC_WriteReg(handle, LSM303C_CTRL_REG1_A, value) ) |
Jeej | 96:8cac3f3245b5 | 246 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 247 | |
Jeej | 96:8cac3f3245b5 | 248 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 249 | } |
Jeej | 96:8cac3f3245b5 | 250 | |
Jeej | 96:8cac3f3245b5 | 251 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 252 | * Function Name : LSM303C_ACC_R_ZEN |
Jeej | 96:8cac3f3245b5 | 253 | * Description : Read ZEN |
Jeej | 96:8cac3f3245b5 | 254 | * Input : Pointer to LSM303C_ACC_ZEN_t |
Jeej | 96:8cac3f3245b5 | 255 | * Output : Status of ZEN see LSM303C_ACC_ZEN_t |
Jeej | 96:8cac3f3245b5 | 256 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 257 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 258 | |
Jeej | 96:8cac3f3245b5 | 259 | status_t LSM303C_ACC_R_ZEN(void *handle, LSM303C_ACC_ZEN_t *value) |
Jeej | 96:8cac3f3245b5 | 260 | { |
Jeej | 96:8cac3f3245b5 | 261 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG1_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 262 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 263 | |
Jeej | 96:8cac3f3245b5 | 264 | *value &= LSM303C_ACC_ZEN_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 265 | |
Jeej | 96:8cac3f3245b5 | 266 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 267 | } |
Jeej | 96:8cac3f3245b5 | 268 | |
Jeej | 96:8cac3f3245b5 | 269 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 270 | * Function Name : LSM303C_ACC_W_ODR |
Jeej | 96:8cac3f3245b5 | 271 | * Description : Write ODR |
Jeej | 96:8cac3f3245b5 | 272 | * Input : LSM303C_ACC_ODR_t |
Jeej | 96:8cac3f3245b5 | 273 | * Output : None |
Jeej | 96:8cac3f3245b5 | 274 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 275 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 276 | status_t LSM303C_ACC_W_ODR(void *handle, LSM303C_ACC_ODR_t newValue) |
Jeej | 96:8cac3f3245b5 | 277 | { |
Jeej | 96:8cac3f3245b5 | 278 | u8_t value; |
Jeej | 96:8cac3f3245b5 | 279 | |
Jeej | 96:8cac3f3245b5 | 280 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG1_A, &value) ) |
Jeej | 96:8cac3f3245b5 | 281 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 282 | |
Jeej | 96:8cac3f3245b5 | 283 | value &= ~LSM303C_ACC_ODR_MASK; |
Jeej | 96:8cac3f3245b5 | 284 | value |= newValue; |
Jeej | 96:8cac3f3245b5 | 285 | |
Jeej | 96:8cac3f3245b5 | 286 | if( !LSM303C_ACC_WriteReg(handle, LSM303C_CTRL_REG1_A, value) ) |
Jeej | 96:8cac3f3245b5 | 287 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 288 | |
Jeej | 96:8cac3f3245b5 | 289 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 290 | } |
Jeej | 96:8cac3f3245b5 | 291 | |
Jeej | 96:8cac3f3245b5 | 292 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 293 | * Function Name : LSM303C_ACC_R_ODR |
Jeej | 96:8cac3f3245b5 | 294 | * Description : Read ODR |
Jeej | 96:8cac3f3245b5 | 295 | * Input : Pointer to LSM303C_ACC_ODR_t |
Jeej | 96:8cac3f3245b5 | 296 | * Output : Status of ODR see LSM303C_ACC_ODR_t |
Jeej | 96:8cac3f3245b5 | 297 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 298 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 299 | |
Jeej | 96:8cac3f3245b5 | 300 | status_t LSM303C_ACC_R_ODR(void *handle, LSM303C_ACC_ODR_t *value) |
Jeej | 96:8cac3f3245b5 | 301 | { |
Jeej | 96:8cac3f3245b5 | 302 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG1_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 303 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 304 | |
Jeej | 96:8cac3f3245b5 | 305 | *value &= LSM303C_ACC_ODR_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 306 | |
Jeej | 96:8cac3f3245b5 | 307 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 308 | } |
Jeej | 96:8cac3f3245b5 | 309 | |
Jeej | 96:8cac3f3245b5 | 310 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 311 | * Function Name : LSM303C_ACC_W_Data_Filter |
Jeej | 96:8cac3f3245b5 | 312 | * Description : Write FDS |
Jeej | 96:8cac3f3245b5 | 313 | * Input : LSM303C_ACC_FDS_t |
Jeej | 96:8cac3f3245b5 | 314 | * Output : None |
Jeej | 96:8cac3f3245b5 | 315 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 316 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 317 | status_t LSM303C_ACC_W_Data_Filter(void *handle, LSM303C_ACC_FDS_t newValue) |
Jeej | 96:8cac3f3245b5 | 318 | { |
Jeej | 96:8cac3f3245b5 | 319 | u8_t value; |
Jeej | 96:8cac3f3245b5 | 320 | |
Jeej | 96:8cac3f3245b5 | 321 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG2_A, &value) ) |
Jeej | 96:8cac3f3245b5 | 322 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 323 | |
Jeej | 96:8cac3f3245b5 | 324 | value &= ~LSM303C_ACC_FDS_MASK; |
Jeej | 96:8cac3f3245b5 | 325 | value |= newValue; |
Jeej | 96:8cac3f3245b5 | 326 | |
Jeej | 96:8cac3f3245b5 | 327 | if( !LSM303C_ACC_WriteReg(handle, LSM303C_CTRL_REG2_A, value) ) |
Jeej | 96:8cac3f3245b5 | 328 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 329 | |
Jeej | 96:8cac3f3245b5 | 330 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 331 | } |
Jeej | 96:8cac3f3245b5 | 332 | |
Jeej | 96:8cac3f3245b5 | 333 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 334 | * Function Name : LSM303C_ACC_R_Data_Filter |
Jeej | 96:8cac3f3245b5 | 335 | * Description : Read FDS |
Jeej | 96:8cac3f3245b5 | 336 | * Input : Pointer to LSM303C_ACC_FDS_t |
Jeej | 96:8cac3f3245b5 | 337 | * Output : Status of FDS see LSM303C_ACC_FDS_t |
Jeej | 96:8cac3f3245b5 | 338 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 339 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 340 | |
Jeej | 96:8cac3f3245b5 | 341 | status_t LSM303C_ACC_R_Data_Filter(void *handle, LSM303C_ACC_FDS_t *value) |
Jeej | 96:8cac3f3245b5 | 342 | { |
Jeej | 96:8cac3f3245b5 | 343 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG2_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 344 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 345 | |
Jeej | 96:8cac3f3245b5 | 346 | *value &= LSM303C_ACC_FDS_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 347 | |
Jeej | 96:8cac3f3245b5 | 348 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 349 | } |
Jeej | 96:8cac3f3245b5 | 350 | |
Jeej | 96:8cac3f3245b5 | 351 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 352 | * Function Name : LSM303C_ACC_W_hpf_cutoff_freq |
Jeej | 96:8cac3f3245b5 | 353 | * Description : Write HPCF |
Jeej | 96:8cac3f3245b5 | 354 | * Input : LSM303C_ACC_DFC_t |
Jeej | 96:8cac3f3245b5 | 355 | * Output : None |
Jeej | 96:8cac3f3245b5 | 356 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 357 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 358 | status_t LSM303C_ACC_W_hpf_cutoff_freq(void *handle, LSM303C_ACC_DFC_t newValue) |
Jeej | 96:8cac3f3245b5 | 359 | { |
Jeej | 96:8cac3f3245b5 | 360 | u8_t value; |
Jeej | 96:8cac3f3245b5 | 361 | |
Jeej | 96:8cac3f3245b5 | 362 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG2_A, &value) ) |
Jeej | 96:8cac3f3245b5 | 363 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 364 | |
Jeej | 96:8cac3f3245b5 | 365 | value &= ~LSM303C_ACC_DFC_MASK; |
Jeej | 96:8cac3f3245b5 | 366 | value |= newValue; |
Jeej | 96:8cac3f3245b5 | 367 | |
Jeej | 96:8cac3f3245b5 | 368 | if( !LSM303C_ACC_WriteReg(handle, LSM303C_CTRL_REG2_A, value) ) |
Jeej | 96:8cac3f3245b5 | 369 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 370 | |
Jeej | 96:8cac3f3245b5 | 371 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 372 | } |
Jeej | 96:8cac3f3245b5 | 373 | |
Jeej | 96:8cac3f3245b5 | 374 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 375 | * Function Name : LSM303C_ACC_R_hpf_cutoff_freq |
Jeej | 96:8cac3f3245b5 | 376 | * Description : Read HPCF |
Jeej | 96:8cac3f3245b5 | 377 | * Input : Pointer to LSM303C_ACC_DFC_t |
Jeej | 96:8cac3f3245b5 | 378 | * Output : Status of HPCF see LSM303C_ACC_DFC_t |
Jeej | 96:8cac3f3245b5 | 379 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 380 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 381 | |
Jeej | 96:8cac3f3245b5 | 382 | status_t LSM303C_ACC_R_hpf_cutoff_freq(void *handle, LSM303C_ACC_DFC_t *value) |
Jeej | 96:8cac3f3245b5 | 383 | { |
Jeej | 96:8cac3f3245b5 | 384 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG2_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 385 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 386 | |
Jeej | 96:8cac3f3245b5 | 387 | *value &= LSM303C_ACC_DFC_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 388 | |
Jeej | 96:8cac3f3245b5 | 389 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 390 | } |
Jeej | 96:8cac3f3245b5 | 391 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 392 | * Function Name : LSM303C_ACC_W_hpf_mode |
Jeej | 96:8cac3f3245b5 | 393 | * Description : Write HPM |
Jeej | 96:8cac3f3245b5 | 394 | * Input : LSM303C_ACC_HPM_t |
Jeej | 96:8cac3f3245b5 | 395 | * Output : None |
Jeej | 96:8cac3f3245b5 | 396 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 397 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 398 | status_t LSM303C_ACC_W_hpf_mode(void *handle, LSM303C_ACC_HPM_t newValue) |
Jeej | 96:8cac3f3245b5 | 399 | { |
Jeej | 96:8cac3f3245b5 | 400 | u8_t value; |
Jeej | 96:8cac3f3245b5 | 401 | |
Jeej | 96:8cac3f3245b5 | 402 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG2_A, &value) ) |
Jeej | 96:8cac3f3245b5 | 403 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 404 | |
Jeej | 96:8cac3f3245b5 | 405 | value &= ~LSM303C_ACC_HPM_MASK; |
Jeej | 96:8cac3f3245b5 | 406 | value |= newValue; |
Jeej | 96:8cac3f3245b5 | 407 | |
Jeej | 96:8cac3f3245b5 | 408 | if( !LSM303C_ACC_WriteReg(handle, LSM303C_CTRL_REG2_A, value) ) |
Jeej | 96:8cac3f3245b5 | 409 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 410 | |
Jeej | 96:8cac3f3245b5 | 411 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 412 | } |
Jeej | 96:8cac3f3245b5 | 413 | |
Jeej | 96:8cac3f3245b5 | 414 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 415 | * Function Name : LSM303C_ACC_R_hpf_mode |
Jeej | 96:8cac3f3245b5 | 416 | * Description : Read HPM |
Jeej | 96:8cac3f3245b5 | 417 | * Input : Pointer to LSM303C_ACC_HPM_t |
Jeej | 96:8cac3f3245b5 | 418 | * Output : Status of HPM see LSM303C_ACC_HPM_t |
Jeej | 96:8cac3f3245b5 | 419 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 420 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 421 | |
Jeej | 96:8cac3f3245b5 | 422 | status_t LSM303C_ACC_R_hpf_mode(void *handle, LSM303C_ACC_HPM_t *value) |
Jeej | 96:8cac3f3245b5 | 423 | { |
Jeej | 96:8cac3f3245b5 | 424 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG2_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 425 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 426 | |
Jeej | 96:8cac3f3245b5 | 427 | *value &= LSM303C_ACC_HPM_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 428 | |
Jeej | 96:8cac3f3245b5 | 429 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 430 | } |
Jeej | 96:8cac3f3245b5 | 431 | |
Jeej | 96:8cac3f3245b5 | 432 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 433 | * Function Name : LSM303C_ACC_W_HiRes |
Jeej | 96:8cac3f3245b5 | 434 | * Description : Write HR |
Jeej | 96:8cac3f3245b5 | 435 | * Input : LSM303C_ACC_HR_t |
Jeej | 96:8cac3f3245b5 | 436 | * Output : None |
Jeej | 96:8cac3f3245b5 | 437 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 438 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 439 | status_t LSM303C_ACC_W_HiRes(void *handle, LSM303C_ACC_HR_t newValue) |
Jeej | 96:8cac3f3245b5 | 440 | { |
Jeej | 96:8cac3f3245b5 | 441 | u8_t value; |
Jeej | 96:8cac3f3245b5 | 442 | |
Jeej | 96:8cac3f3245b5 | 443 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG1_A, &value) ) |
Jeej | 96:8cac3f3245b5 | 444 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 445 | |
Jeej | 96:8cac3f3245b5 | 446 | value &= ~LSM303C_ACC_HR_MASK; |
Jeej | 96:8cac3f3245b5 | 447 | value |= newValue; |
Jeej | 96:8cac3f3245b5 | 448 | |
Jeej | 96:8cac3f3245b5 | 449 | if( !LSM303C_ACC_WriteReg(handle, LSM303C_CTRL_REG1_A, value) ) |
Jeej | 96:8cac3f3245b5 | 450 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 451 | |
Jeej | 96:8cac3f3245b5 | 452 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 453 | } |
Jeej | 96:8cac3f3245b5 | 454 | |
Jeej | 96:8cac3f3245b5 | 455 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 456 | * Function Name : LSM303C_ACC_R_HiRes |
Jeej | 96:8cac3f3245b5 | 457 | * Description : Read HR |
Jeej | 96:8cac3f3245b5 | 458 | * Input : Pointer to LSM303C_ACC_HR_t |
Jeej | 96:8cac3f3245b5 | 459 | * Output : Status of HR see LSM303C_ACC_HR_t |
Jeej | 96:8cac3f3245b5 | 460 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 461 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 462 | |
Jeej | 96:8cac3f3245b5 | 463 | status_t LSM303C_ACC_R_HiRes(void *handle, LSM303C_ACC_HR_t *value) |
Jeej | 96:8cac3f3245b5 | 464 | { |
Jeej | 96:8cac3f3245b5 | 465 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG1_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 466 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 467 | |
Jeej | 96:8cac3f3245b5 | 468 | *value &= LSM303C_ACC_HR_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 469 | |
Jeej | 96:8cac3f3245b5 | 470 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 471 | } |
Jeej | 96:8cac3f3245b5 | 472 | |
Jeej | 96:8cac3f3245b5 | 473 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 474 | * Function Name : LSM303C_ACC_W_FullScale |
Jeej | 96:8cac3f3245b5 | 475 | * Description : Write FS |
Jeej | 96:8cac3f3245b5 | 476 | * Input : LSM303C_ACC_FS_t |
Jeej | 96:8cac3f3245b5 | 477 | * Output : None |
Jeej | 96:8cac3f3245b5 | 478 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 479 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 480 | status_t LSM303C_ACC_W_FullScale(void *handle, LSM303C_ACC_FS_t newValue) |
Jeej | 96:8cac3f3245b5 | 481 | { |
Jeej | 96:8cac3f3245b5 | 482 | u8_t value; |
Jeej | 96:8cac3f3245b5 | 483 | |
Jeej | 96:8cac3f3245b5 | 484 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG4_A, &value) ) |
Jeej | 96:8cac3f3245b5 | 485 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 486 | |
Jeej | 96:8cac3f3245b5 | 487 | value &= ~LSM303C_ACC_FS_MASK; |
Jeej | 96:8cac3f3245b5 | 488 | value |= newValue; |
Jeej | 96:8cac3f3245b5 | 489 | |
Jeej | 96:8cac3f3245b5 | 490 | if( !LSM303C_ACC_WriteReg(handle, LSM303C_CTRL_REG4_A, value) ) |
Jeej | 96:8cac3f3245b5 | 491 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 492 | |
Jeej | 96:8cac3f3245b5 | 493 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 494 | } |
Jeej | 96:8cac3f3245b5 | 495 | |
Jeej | 96:8cac3f3245b5 | 496 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 497 | * Function Name : LSM303C_ACC_R_FullScale |
Jeej | 96:8cac3f3245b5 | 498 | * Description : Read FS |
Jeej | 96:8cac3f3245b5 | 499 | * Input : Pointer to LSM303C_ACC_FS_t |
Jeej | 96:8cac3f3245b5 | 500 | * Output : Status of FS see LSM303C_ACC_FS_t |
Jeej | 96:8cac3f3245b5 | 501 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 502 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 503 | |
Jeej | 96:8cac3f3245b5 | 504 | status_t LSM303C_ACC_R_FullScale(void *handle, LSM303C_ACC_FS_t *value) |
Jeej | 96:8cac3f3245b5 | 505 | { |
Jeej | 96:8cac3f3245b5 | 506 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG4_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 507 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 508 | |
Jeej | 96:8cac3f3245b5 | 509 | *value &= LSM303C_ACC_FS_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 510 | |
Jeej | 96:8cac3f3245b5 | 511 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 512 | } |
Jeej | 96:8cac3f3245b5 | 513 | |
Jeej | 96:8cac3f3245b5 | 514 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 515 | * Function Name : LSM303C_ACC_W_BlockDataUpdate |
Jeej | 96:8cac3f3245b5 | 516 | * Description : Write BDU |
Jeej | 96:8cac3f3245b5 | 517 | * Input : LSM303C_ACC_BDU_t |
Jeej | 96:8cac3f3245b5 | 518 | * Output : None |
Jeej | 96:8cac3f3245b5 | 519 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 520 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 521 | status_t LSM303C_ACC_W_BlockDataUpdate(void *handle, LSM303C_ACC_BDU_t newValue) |
Jeej | 96:8cac3f3245b5 | 522 | { |
Jeej | 96:8cac3f3245b5 | 523 | u8_t value; |
Jeej | 96:8cac3f3245b5 | 524 | |
Jeej | 96:8cac3f3245b5 | 525 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG1_A, &value) ) |
Jeej | 96:8cac3f3245b5 | 526 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 527 | |
Jeej | 96:8cac3f3245b5 | 528 | value &= ~LSM303C_ACC_BDU_MASK; |
Jeej | 96:8cac3f3245b5 | 529 | value |= newValue; |
Jeej | 96:8cac3f3245b5 | 530 | |
Jeej | 96:8cac3f3245b5 | 531 | if( !LSM303C_ACC_WriteReg(handle, LSM303C_CTRL_REG1_A, value) ) |
Jeej | 96:8cac3f3245b5 | 532 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 533 | |
Jeej | 96:8cac3f3245b5 | 534 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 535 | } |
Jeej | 96:8cac3f3245b5 | 536 | |
Jeej | 96:8cac3f3245b5 | 537 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 538 | * Function Name : LSM303C_ACC_R_BlockDataUpdate |
Jeej | 96:8cac3f3245b5 | 539 | * Description : Read BDU |
Jeej | 96:8cac3f3245b5 | 540 | * Input : Pointer to LSM303C_ACC_BDU_t |
Jeej | 96:8cac3f3245b5 | 541 | * Output : Status of BDU see LSM303C_ACC_BDU_t |
Jeej | 96:8cac3f3245b5 | 542 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 543 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 544 | |
Jeej | 96:8cac3f3245b5 | 545 | status_t LSM303C_ACC_R_BlockDataUpdate(void *handle, LSM303C_ACC_BDU_t *value) |
Jeej | 96:8cac3f3245b5 | 546 | { |
Jeej | 96:8cac3f3245b5 | 547 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_CTRL_REG1_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 548 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 549 | |
Jeej | 96:8cac3f3245b5 | 550 | *value &= LSM303C_ACC_BDU_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 551 | |
Jeej | 96:8cac3f3245b5 | 552 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 553 | } |
Jeej | 96:8cac3f3245b5 | 554 | |
Jeej | 96:8cac3f3245b5 | 555 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 556 | * Function Name : LSM303C_ACC_R_XDataAvail |
Jeej | 96:8cac3f3245b5 | 557 | * Description : Read XDA |
Jeej | 96:8cac3f3245b5 | 558 | * Input : Pointer to LSM303C_ACC_XDA_t |
Jeej | 96:8cac3f3245b5 | 559 | * Output : Status of XDA see LSM303C_ACC_XDA_t |
Jeej | 96:8cac3f3245b5 | 560 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 561 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 562 | |
Jeej | 96:8cac3f3245b5 | 563 | status_t LSM303C_ACC_R_XDataAvail(void *handle, LSM303C_ACC_XDA_t *value) |
Jeej | 96:8cac3f3245b5 | 564 | { |
Jeej | 96:8cac3f3245b5 | 565 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_STATUS_REG_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 566 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 567 | |
Jeej | 96:8cac3f3245b5 | 568 | *value &= LSM303C_ACC_XDA_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 569 | |
Jeej | 96:8cac3f3245b5 | 570 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 571 | } |
Jeej | 96:8cac3f3245b5 | 572 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 573 | * Function Name : LSM303C_ACC_R_YDataAvail |
Jeej | 96:8cac3f3245b5 | 574 | * Description : Read YDA |
Jeej | 96:8cac3f3245b5 | 575 | * Input : Pointer to LSM303C_ACC_YDA_t |
Jeej | 96:8cac3f3245b5 | 576 | * Output : Status of YDA see LSM303C_ACC_YDA_t |
Jeej | 96:8cac3f3245b5 | 577 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 578 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 579 | |
Jeej | 96:8cac3f3245b5 | 580 | status_t LSM303C_ACC_R_YDataAvail(void *handle, LSM303C_ACC_YDA_t *value) |
Jeej | 96:8cac3f3245b5 | 581 | { |
Jeej | 96:8cac3f3245b5 | 582 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_STATUS_REG_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 583 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 584 | |
Jeej | 96:8cac3f3245b5 | 585 | *value &= LSM303C_ACC_YDA_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 586 | |
Jeej | 96:8cac3f3245b5 | 587 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 588 | } |
Jeej | 96:8cac3f3245b5 | 589 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 590 | * Function Name : LSM303C_ACC_R_ZDataAvail |
Jeej | 96:8cac3f3245b5 | 591 | * Description : Read ZDA |
Jeej | 96:8cac3f3245b5 | 592 | * Input : Pointer to LSM303C_ACC_ZDA_t |
Jeej | 96:8cac3f3245b5 | 593 | * Output : Status of ZDA see LSM303C_ACC_ZDA_t |
Jeej | 96:8cac3f3245b5 | 594 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 595 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 596 | |
Jeej | 96:8cac3f3245b5 | 597 | status_t LSM303C_ACC_R_ZDataAvail(void *handle, LSM303C_ACC_ZDA_t *value) |
Jeej | 96:8cac3f3245b5 | 598 | { |
Jeej | 96:8cac3f3245b5 | 599 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_STATUS_REG_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 600 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 601 | |
Jeej | 96:8cac3f3245b5 | 602 | *value &= LSM303C_ACC_ZDA_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 603 | |
Jeej | 96:8cac3f3245b5 | 604 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 605 | } |
Jeej | 96:8cac3f3245b5 | 606 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 607 | * Function Name : LSM303C_ACC_R_XYZDataAvail |
Jeej | 96:8cac3f3245b5 | 608 | * Description : Read ZYXDA |
Jeej | 96:8cac3f3245b5 | 609 | * Input : Pointer to LSM303C_ACC_ZYXDA_t |
Jeej | 96:8cac3f3245b5 | 610 | * Output : Status of ZYXDA see LSM303C_ACC_ZYXDA_t |
Jeej | 96:8cac3f3245b5 | 611 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 612 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 613 | |
Jeej | 96:8cac3f3245b5 | 614 | status_t LSM303C_ACC_R_XYZDataAvail(void *handle, LSM303C_ACC_ZYXDA_t *value) |
Jeej | 96:8cac3f3245b5 | 615 | { |
Jeej | 96:8cac3f3245b5 | 616 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_STATUS_REG_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 617 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 618 | |
Jeej | 96:8cac3f3245b5 | 619 | *value &= LSM303C_ACC_ZYXDA_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 620 | |
Jeej | 96:8cac3f3245b5 | 621 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 622 | } |
Jeej | 96:8cac3f3245b5 | 623 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 624 | * Function Name : LSM303C_ACC_R_XDataOverrun |
Jeej | 96:8cac3f3245b5 | 625 | * Description : Read XOR |
Jeej | 96:8cac3f3245b5 | 626 | * Input : Pointer to LSM303C_ACC_XOR_t |
Jeej | 96:8cac3f3245b5 | 627 | * Output : Status of XOR see LSM303C_ACC_XOR_t |
Jeej | 96:8cac3f3245b5 | 628 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 629 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 630 | |
Jeej | 96:8cac3f3245b5 | 631 | status_t LSM303C_ACC_R_XDataOverrun(void *handle, LSM303C_ACC_XOR_t *value) |
Jeej | 96:8cac3f3245b5 | 632 | { |
Jeej | 96:8cac3f3245b5 | 633 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_STATUS_REG_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 634 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 635 | |
Jeej | 96:8cac3f3245b5 | 636 | *value &= LSM303C_ACC_XOR_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 637 | |
Jeej | 96:8cac3f3245b5 | 638 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 639 | } |
Jeej | 96:8cac3f3245b5 | 640 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 641 | * Function Name : LSM303C_ACC_R_YDataOverrun |
Jeej | 96:8cac3f3245b5 | 642 | * Description : Read YOR |
Jeej | 96:8cac3f3245b5 | 643 | * Input : Pointer to LSM303C_ACC_YOR_t |
Jeej | 96:8cac3f3245b5 | 644 | * Output : Status of YOR see LSM303C_ACC_YOR_t |
Jeej | 96:8cac3f3245b5 | 645 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 646 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 647 | |
Jeej | 96:8cac3f3245b5 | 648 | status_t LSM303C_ACC_R_YDataOverrun(void *handle, LSM303C_ACC_YOR_t *value) |
Jeej | 96:8cac3f3245b5 | 649 | { |
Jeej | 96:8cac3f3245b5 | 650 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_STATUS_REG_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 651 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 652 | |
Jeej | 96:8cac3f3245b5 | 653 | *value &= LSM303C_ACC_YOR_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 654 | |
Jeej | 96:8cac3f3245b5 | 655 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 656 | } |
Jeej | 96:8cac3f3245b5 | 657 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 658 | * Function Name : LSM303C_ACC_R_ZDataOverrun |
Jeej | 96:8cac3f3245b5 | 659 | * Description : Read ZOR |
Jeej | 96:8cac3f3245b5 | 660 | * Input : Pointer to LSM303C_ACC_ZOR_t |
Jeej | 96:8cac3f3245b5 | 661 | * Output : Status of ZOR see LSM303C_ACC_ZOR_t |
Jeej | 96:8cac3f3245b5 | 662 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 663 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 664 | |
Jeej | 96:8cac3f3245b5 | 665 | status_t LSM303C_ACC_R_ZDataOverrun(void *handle, LSM303C_ACC_ZOR_t *value) |
Jeej | 96:8cac3f3245b5 | 666 | { |
Jeej | 96:8cac3f3245b5 | 667 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_STATUS_REG_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 668 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 669 | |
Jeej | 96:8cac3f3245b5 | 670 | *value &= LSM303C_ACC_ZOR_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 671 | |
Jeej | 96:8cac3f3245b5 | 672 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 673 | } |
Jeej | 96:8cac3f3245b5 | 674 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 675 | * Function Name : LSM303C_ACC_R_XYZDataOverrun |
Jeej | 96:8cac3f3245b5 | 676 | * Description : Read ZYXOR |
Jeej | 96:8cac3f3245b5 | 677 | * Input : Pointer to LSM303C_ACC_ZYXOR_t |
Jeej | 96:8cac3f3245b5 | 678 | * Output : Status of ZYXOR see LSM303C_ACC_ZYXOR_t |
Jeej | 96:8cac3f3245b5 | 679 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 680 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 681 | |
Jeej | 96:8cac3f3245b5 | 682 | status_t LSM303C_ACC_R_XYZDataOverrun(void *handle, LSM303C_ACC_ZYXOR_t *value) |
Jeej | 96:8cac3f3245b5 | 683 | { |
Jeej | 96:8cac3f3245b5 | 684 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_STATUS_REG_A, (u8_t *)value) ) |
Jeej | 96:8cac3f3245b5 | 685 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 686 | |
Jeej | 96:8cac3f3245b5 | 687 | *value &= LSM303C_ACC_ZYXOR_MASK; //mask |
Jeej | 96:8cac3f3245b5 | 688 | |
Jeej | 96:8cac3f3245b5 | 689 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 690 | } |
Jeej | 96:8cac3f3245b5 | 691 | |
Jeej | 96:8cac3f3245b5 | 692 | /******************************************************************************* |
Jeej | 96:8cac3f3245b5 | 693 | * Function Name : status_t LSM303C_ACC_Get_Raw_Acceleration(u8_t *buff) |
Jeej | 96:8cac3f3245b5 | 694 | * Description : Read Acceleration output register |
Jeej | 96:8cac3f3245b5 | 695 | * Input : pointer to [u8_t] |
Jeej | 96:8cac3f3245b5 | 696 | * Output : Acceleration buffer u8_t |
Jeej | 96:8cac3f3245b5 | 697 | * Return : Status [MEMS_ERROR, MEMS_SUCCESS] |
Jeej | 96:8cac3f3245b5 | 698 | *******************************************************************************/ |
Jeej | 96:8cac3f3245b5 | 699 | status_t LSM303C_ACC_Get_Raw_Acceleration(void *handle, u8_t *buff) |
Jeej | 96:8cac3f3245b5 | 700 | { |
Jeej | 96:8cac3f3245b5 | 701 | u8_t i, j, k; |
Jeej | 96:8cac3f3245b5 | 702 | u8_t numberOfByteForDimension; |
Jeej | 96:8cac3f3245b5 | 703 | |
Jeej | 96:8cac3f3245b5 | 704 | numberOfByteForDimension=6/3; |
Jeej | 96:8cac3f3245b5 | 705 | |
Jeej | 96:8cac3f3245b5 | 706 | k=0; |
Jeej | 96:8cac3f3245b5 | 707 | for (i=0; i<3;i++ ) |
Jeej | 96:8cac3f3245b5 | 708 | { |
Jeej | 96:8cac3f3245b5 | 709 | for (j=0; j<numberOfByteForDimension;j++ ) |
Jeej | 96:8cac3f3245b5 | 710 | { |
Jeej | 96:8cac3f3245b5 | 711 | if( !LSM303C_ACC_ReadReg(handle, LSM303C_OUT_X_L_A+k, &buff[k])) |
Jeej | 96:8cac3f3245b5 | 712 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 713 | k++; |
Jeej | 96:8cac3f3245b5 | 714 | } |
Jeej | 96:8cac3f3245b5 | 715 | } |
Jeej | 96:8cac3f3245b5 | 716 | |
Jeej | 96:8cac3f3245b5 | 717 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 718 | } |
Jeej | 96:8cac3f3245b5 | 719 | |
Jeej | 96:8cac3f3245b5 | 720 | /* |
Jeej | 96:8cac3f3245b5 | 721 | * Following is the table of sensitivity values for each case. |
Jeej | 96:8cac3f3245b5 | 722 | * Values are espressed in ug/digit. |
Jeej | 96:8cac3f3245b5 | 723 | */ |
Jeej | 96:8cac3f3245b5 | 724 | const long long LSM303C_ACC_Sensitivity_List[3] = { |
Jeej | 96:8cac3f3245b5 | 725 | 980, /* FS @2g */ |
Jeej | 96:8cac3f3245b5 | 726 | 1950, /* FS @4g */ |
Jeej | 96:8cac3f3245b5 | 727 | 3900, /* FS @8g */ |
Jeej | 96:8cac3f3245b5 | 728 | }; |
Jeej | 96:8cac3f3245b5 | 729 | |
Jeej | 96:8cac3f3245b5 | 730 | /* |
Jeej | 96:8cac3f3245b5 | 731 | * Values returned are espressed in mg. |
Jeej | 96:8cac3f3245b5 | 732 | */ |
Jeej | 96:8cac3f3245b5 | 733 | status_t LSM303C_ACC_Get_Acceleration(void *handle, int *buff) |
Jeej | 96:8cac3f3245b5 | 734 | { |
Jeej | 96:8cac3f3245b5 | 735 | Type3Axis16bit_U raw_data_tmp; |
Jeej | 96:8cac3f3245b5 | 736 | u8_t fs_mode = 0, shift = 0; |
Jeej | 96:8cac3f3245b5 | 737 | LSM303C_ACC_FS_t fs; |
Jeej | 96:8cac3f3245b5 | 738 | |
Jeej | 96:8cac3f3245b5 | 739 | /* Determine the Full Scale the acc is set */ |
Jeej | 96:8cac3f3245b5 | 740 | if(!LSM303C_ACC_R_FullScale(handle, &fs)) { |
Jeej | 96:8cac3f3245b5 | 741 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 742 | } |
Jeej | 96:8cac3f3245b5 | 743 | |
Jeej | 96:8cac3f3245b5 | 744 | switch (fs) { |
Jeej | 96:8cac3f3245b5 | 745 | case LSM303C_ACC_FS_2G: |
Jeej | 96:8cac3f3245b5 | 746 | fs_mode = 0; |
Jeej | 96:8cac3f3245b5 | 747 | break; |
Jeej | 96:8cac3f3245b5 | 748 | |
Jeej | 96:8cac3f3245b5 | 749 | case LSM303C_ACC_FS_4G: |
Jeej | 96:8cac3f3245b5 | 750 | fs_mode = 1; |
Jeej | 96:8cac3f3245b5 | 751 | break; |
Jeej | 96:8cac3f3245b5 | 752 | |
Jeej | 96:8cac3f3245b5 | 753 | case LSM303C_ACC_FS_8G: |
Jeej | 96:8cac3f3245b5 | 754 | fs_mode = 2; |
Jeej | 96:8cac3f3245b5 | 755 | break; |
Jeej | 96:8cac3f3245b5 | 756 | } |
Jeej | 96:8cac3f3245b5 | 757 | |
Jeej | 96:8cac3f3245b5 | 758 | /* Read out raw accelerometer samples */ |
Jeej | 96:8cac3f3245b5 | 759 | if(!LSM303C_ACC_Get_Raw_Acceleration(handle, raw_data_tmp.u8bit)) { |
Jeej | 96:8cac3f3245b5 | 760 | return MEMS_ERROR; |
Jeej | 96:8cac3f3245b5 | 761 | } |
Jeej | 96:8cac3f3245b5 | 762 | |
Jeej | 96:8cac3f3245b5 | 763 | /* Apply proper shift and sensitivity */ |
Jeej | 96:8cac3f3245b5 | 764 | buff[0] = ((raw_data_tmp.i16bit[0] >> shift) * LSM303C_ACC_Sensitivity_List[fs_mode] + 500) / 1000; |
Jeej | 96:8cac3f3245b5 | 765 | buff[1] = ((raw_data_tmp.i16bit[1] >> shift) * LSM303C_ACC_Sensitivity_List[fs_mode] + 500) / 1000; |
Jeej | 96:8cac3f3245b5 | 766 | buff[2] = ((raw_data_tmp.i16bit[2] >> shift) * LSM303C_ACC_Sensitivity_List[fs_mode] + 500) / 1000; |
Jeej | 96:8cac3f3245b5 | 767 | |
Jeej | 96:8cac3f3245b5 | 768 | return MEMS_SUCCESS; |
Jeej | 96:8cac3f3245b5 | 769 | } |