[工业类传感器] LSM6DSM设置WAKE_UP_SRC寄存器不成功

xieyj   2017-12-21 17:11 楼主
大家好再次来求助论坛了
这次想要用WAKE_UP功能输出中断,设置WAKE_UP_SRC寄存器,发现不成功读出的值一直是0
设置其他寄存器都OK,想请教下设置这个寄存器有特殊的流程吗?比如设置这个寄存器必须先设置另一个寄存器之类的
设置MD2_CFG和WAKE_UP_DUR这两个寄存器都是成功的。感谢啊!
        lsm6dsl_write_reg(&lsm6dsl_ctx, LSM6DSL_MD2_CFG, &num4, 1);
        lsm6dsl_read_reg(&lsm6dsl_ctx, LSM6DSL_MD2_CFG, &buffer, 1);
        LOG_I(LSM6,"Read LSM6DSL_MD2_CFG:%d\r\n",buffer);   /* set wakeup interrupt  */
       
       
        lsm6dsl_write_reg(&lsm6dsl_ctx, LSM6DSL_WAKE_UP_DUR, &num5, 1);
        lsm6dsl_read_reg(&lsm6dsl_ctx, LSM6DSL_WAKE_UP_DUR, &buffer, 1);
        LOG_I(LSM6,"Read LSM6DSL_WAKE_UP_DUR:%d\r\n",buffer);   /* set wakeup interrupt DUR  */
       
       
        lsm6dsl_write_reg(&lsm6dsl_ctx, LSM6DSL_WAKE_UP_SRC, &num6, 1);
        lsm6dsl_read_reg(&lsm6dsl_ctx, LSM6DSL_WAKE_UP_SRC, &buffer, 1);
        LOG_I(LSM6,"Read LSM6DSL_WAKE_UP_SRC:%d\r\n",buffer);   /* set wakeup event interrupt  */


回复评论 (8)

num6的数值是多少,我帮你试一下
虾扯蛋,蛋扯虾,虾扯蛋扯虾
点赞  2017-12-21 17:24
引用: littleshrimp 发表于 2017-12-21 17:24
num6的数值是多少,我帮你试一下

num6的值是15
点赞  2017-12-21 17:26
WAKE_UP_SRC是只读寄存器,不能写入
QQ图片20171221172713.png
虾扯蛋,蛋扯虾,虾扯蛋扯虾
点赞  2017-12-21 17:27
引用: littleshrimp 发表于 2017-12-21 17:27
WAKE_UP_SRC是只读寄存器,不能写入

明白,那我要用到WAKE_UP这个功能,将传感器网上抬希望INT2有中断输出,是不是设置MD2_CFG为00100000就是INT2_WU这个位吗
点赞  2017-12-21 17:34
我设置了MD2_CFG这个寄存器,开启wakeup中断使能,但是示波器就输出不了中断,而且读这个WAKE_UP_SRC也一直是0。
点赞  2017-12-21 17:48
引用: xieyj 发表于 2017-12-21 17:48
我设置了MD2_CFG这个寄存器,开启wakeup中断使能,但是示波器就输出不了中断,而且读这个WAKE_UP_SRC也一直 ...

试试官方的驱动库
lsm6dsm.rar (33.58 KB)
(下载次数: 9, 2017-12-21 18:14 上传)



  1. /******************** (C) COPYRIGHT 2015 STMicroelectronics ********************
  2. * File Name          : LSM6DSM_ACC_GYRO_driver.c
  3. * Author             : MSH Application Team
  4. * Version            : v1.3
  5. * Date               : 17 Nov 2015
  6. * Description        : LSM6DSM ACC_GYRO driver source file
  7. *                     
  8. * Reviewed by: MSH Application Team
  9. *-------------------------------------------------------------------------------
  10. *
  11. *
  12. ********************************************************************************
  13. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  14. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
  15. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
  16. * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
  17. * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
  18. * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  19. *
  20. * THIS SOFTWARE IS SPECIFICALLY DESIGNED FOR EXCLUSIVE USE WITH ST PARTS.
  21. *
  22. *******************************************************************************/

  23. /* Includes ------------------------------------------------------------------*/
  24. #include "LSM6DSM_ACC_GYRO_driver.h"

  25. /* Imported function prototypes ----------------------------------------------*/
  26. extern uint8_t Sensor_IO_Write(void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite);
  27. extern uint8_t Sensor_IO_Read(void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead);

  28. /* Private typedef -----------------------------------------------------------*/

  29. /* Private define ------------------------------------------------------------*/

  30. /* Private macro -------------------------------------------------------------*/

  31. /* Private variables ---------------------------------------------------------*/

  32. /* Private functions ---------------------------------------------------------*/

  33. /*******************************************************************************
  34. * Function Name                : LSM6DSM_ACC_GYRO_ReadReg
  35. * Description                : Generic Reading function. It must be fullfilled with either
  36. *                                        : I2C or SPI reading functions                                       
  37. * Input                                : Register Address
  38. * Output                        : Data REad
  39. * Return                        : None
  40. *******************************************************************************/
  41. status_t LSM6DSM_ACC_GYRO_ReadReg(void *handle, u8_t Reg, u8_t* Data)
  42. {
  43.   
  44.   if (Sensor_IO_Read(handle, Reg, Data, 1))
  45.   {
  46.     return MEMS_ERROR;
  47.   }
  48.   else
  49.   {
  50.     return MEMS_SUCCESS;
  51.   }
  52. }

  53. /*******************************************************************************
  54. * Function Name                : LSM6DSM_ACC_GYRO_WriteReg
  55. * Description                : Generic Writing function. It must be fullfilled with either
  56. *                                        : I2C or SPI writing function
  57. * Input                                : Register Address, Data to be written
  58. * Output                        : None
  59. * Return                        : None
  60. *******************************************************************************/
  61. status_t LSM6DSM_ACC_GYRO_WriteReg(void *handle, u8_t Reg, u8_t Data)
  62. {
  63.   if (Sensor_IO_Write(handle, Reg, &Data, 1))
  64.   {
  65.     return MEMS_ERROR;
  66.   }
  67.   else
  68.   {
  69.     return MEMS_SUCCESS;
  70.   }
  71. }

  72. /*******************************************************************************
  73. * Function Name                : LSM6DSM_ACC_GYRO_WriteMem
  74. * Description                : Generic Writing function. It must be fullfilled with either
  75. *                                        : I2C or SPI writing function
  76. * Input                                : Register Address, ptr to buffer to be written,
  77. *                                 length of buffer
  78. * Output                        : None
  79. * Return                        : None
  80. *******************************************************************************/
  81. u8_t LSM6DSM_ACC_GYRO_WriteMem(void *handle, u8_t Reg, u8_t *Bufp, u16_t len)
  82. {
  83.   if (Sensor_IO_Write(handle, Reg, Bufp, len))
  84.   {
  85.     return MEMS_ERROR;
  86.   }
  87.   else
  88.   {
  89.     return MEMS_SUCCESS;
  90.   }
  91. }

  92. /*******************************************************************************
  93. * Function Name                : LSM6DSM_ACC_GYRO_ReadMem
  94. * Description                : Generic Reading function. It must be fullfilled with either
  95. *                                        : I2C or SPI writing function
  96. * Input                                : Register Address, ptr to buffer to be read,
  97. *                                 length of buffer
  98. * Output                        : None
  99. * Return                        : None
  100. *******************************************************************************/
  101. u8_t LSM6DSM_ACC_GYRO_ReadMem(void *handle, u8_t Reg, u8_t *Bufp, u16_t len)
  102. {
  103.    
  104.   if (Sensor_IO_Read(handle, Reg, Bufp, len))
  105.   {
  106.     return MEMS_ERROR;
  107.   }
  108.   else
  109.   {
  110.     return MEMS_SUCCESS;
  111.   }
  112. }

  113. /*******************************************************************************
  114. * Function Name                : SwapHighLowByte
  115. * Description                : Swap High/low byte in multiple byte values
  116. *                     It works with minimum 2 byte for every dimension.
  117. *                     Example x,y,z with 2 byte for every dimension
  118. *
  119. * Input                                : bufferToSwap -> buffer to swap
  120. *                     numberOfByte -> the buffer length in byte
  121. *                     dimension -> number of dimension
  122. *
  123. * Output                        : bufferToSwap -> buffer swapped
  124. * Return                        : None
  125. *******************************************************************************/
  126. void LSM6DSM_ACC_GYRO_SwapHighLowByte(u8_t *bufferToSwap, u8_t numberOfByte, u8_t dimension)
  127. {

  128.   u8_t numberOfByteForDimension, i, j;
  129.   u8_t tempValue[10];
  130.   
  131.   numberOfByteForDimension=numberOfByte/dimension;
  132.   
  133.   for (i=0; i<dimension;i++ )
  134.   {
  135.         for (j=0; j<numberOfByteForDimension;j++ )
  136.                 tempValue[j]=bufferToSwap[j+i*numberOfByteForDimension];
  137.         for (j=0; j<numberOfByteForDimension;j++ )
  138.                 *(bufferToSwap+i*(numberOfByteForDimension)+j)=*(tempValue+(numberOfByteForDimension-1)-j);
  139.   }
  140. }

  141. /* Exported functions ---------------------------------------------------------*/

  142. /*******************************************************************************
  143. * Function Name  : LSM6DSM_ACC_GYRO_W_EmbeddedAccess
  144. * Description    : Write RAM_PAGE
  145. * Input          : LSM6DSM_ACC_GYRO_EMB_ACC_t
  146. * Output         : None
  147. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  148. *******************************************************************************/
  149. status_t  LSM6DSM_ACC_GYRO_W_EmbeddedAccess(void *handle, LSM6DSM_ACC_GYRO_EMB_ACC_t newValue)
  150. {
  151.   u8_t value;

  152.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FUNC_CFG_ACCESS, &value) )
  153.     return MEMS_ERROR;

  154.   value &= ~LSM6DSM_ACC_GYRO_EMB_ACC_MASK;
  155.   value |= newValue;
  156.   
  157.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FUNC_CFG_ACCESS, value) )
  158.     return MEMS_ERROR;

  159.   return MEMS_SUCCESS;
  160. }

  161. /*******************************************************************************
  162. * Function Name  : LSM6DSM_ACC_GYRO_R_EmbeddedAccess
  163. * Description    : Read RAM_PAGE
  164. * Input          : Pointer to LSM6DSM_ACC_GYRO_EMB_ACC_t
  165. * Output         : Status of RAM_PAGE see LSM6DSM_ACC_GYRO_EMB_ACC_t
  166. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  167. *******************************************************************************/

  168. status_t LSM6DSM_ACC_GYRO_R_EmbeddedAccess(void *handle, LSM6DSM_ACC_GYRO_EMB_ACC_t *value)
  169. {
  170. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FUNC_CFG_ACCESS, (u8_t *)value) )
  171.     return MEMS_ERROR;

  172.   *value &= LSM6DSM_ACC_GYRO_EMB_ACC_MASK; //mask

  173.   return MEMS_SUCCESS;
  174. }

  175. /*******************************************************************************
  176. * Function Name  : LSM6DSM_ACC_GYRO_W_SYNC_RES_RATIO
  177. * Description    : Write RR
  178. * Input          : LSM6DSM_ACC_GYRO_SYNC_RES_RATIO_t
  179. * Output         : None
  180. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  181. *******************************************************************************/
  182. status_t  LSM6DSM_ACC_GYRO_W_SYNC_RES_RATIO(void *handle, LSM6DSM_ACC_GYRO_SYNC_RES_RATIO_t newValue)
  183. {
  184.   u8_t value;

  185.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_SENSOR_RES_RATIO, &value) )
  186.     return MEMS_ERROR;

  187.   value &= ~LSM6DSM_ACC_GYRO_SYNC_RES_RATIO_MASK;
  188.   value |= newValue;
  189.   
  190.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_SENSOR_RES_RATIO, value) )
  191.     return MEMS_ERROR;

  192.   return MEMS_SUCCESS;
  193. }

  194. /*******************************************************************************
  195. * Function Name  : LSM6DSM_ACC_GYRO_R_SYNC_RES_RATIO
  196. * Description    : Read RR
  197. * Input          : Pointer to LSM6DSM_ACC_GYRO_SYNC_RES_RATIO_t
  198. * Output         : Status of RR see LSM6DSM_ACC_GYRO_SYNC_RES_RATIO_t
  199. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  200. *******************************************************************************/

  201. status_t LSM6DSM_ACC_GYRO_R_SYNC_RES_RATIO(void *handle, LSM6DSM_ACC_GYRO_SYNC_RES_RATIO_t *value)
  202. {
  203. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_SENSOR_RES_RATIO, (u8_t *)value) )
  204.     return MEMS_ERROR;

  205.   *value &= LSM6DSM_ACC_GYRO_SYNC_RES_RATIO_MASK; //mask

  206.   return MEMS_SUCCESS;
  207. }

  208. /*******************************************************************************
  209. * Function Name  : LSM6DSM_ACC_GYRO_W_Stamping_Time_Frame
  210. * Description    : Write TPH
  211. * Input          : u8_t
  212. * Output         : None
  213. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  214. *******************************************************************************/
  215. status_t  LSM6DSM_ACC_GYRO_W_Stamping_Time_Frame(void *handle, u8_t newValue)
  216. {
  217.   u8_t value;

  218.   newValue = newValue << LSM6DSM_ACC_GYRO_TPH_POSITION; //mask       
  219.   newValue &= LSM6DSM_ACC_GYRO_TPH_MASK; //coerce
  220.   
  221.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_SENSOR_SYNC_TIME, &value) )
  222.     return MEMS_ERROR;

  223.   value &= (u8_t)(~LSM6DSM_ACC_GYRO_TPH_MASK);
  224.   value |= newValue;
  225.   
  226.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_SENSOR_SYNC_TIME, value) )
  227.     return MEMS_ERROR;

  228.   return MEMS_SUCCESS;
  229. }

  230. /*******************************************************************************
  231. * Function Name  : LSM6DSM_ACC_GYRO_R_Stamping_Time_Frame
  232. * Description    : Read TPH
  233. * Input          : Pointer to u8_t
  234. * Output         : Status of TPH
  235. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  236. *******************************************************************************/

  237. status_t LSM6DSM_ACC_GYRO_R_Stamping_Time_Frame(void *handle, u8_t *value)
  238. {
  239. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_SENSOR_SYNC_TIME, (u8_t *)value) )
  240.     return MEMS_ERROR;

  241.   *value &= LSM6DSM_ACC_GYRO_TPH_MASK; //coerce       
  242.   *value = *value >> LSM6DSM_ACC_GYRO_TPH_POSITION; //mask       

  243.   return MEMS_SUCCESS;
  244. }

  245. /*******************************************************************************
  246. * Function Name  : LSM6DSM_ACC_GYRO_W_FIFO_Watermark
  247. * Description    : Write WTM_FIFO
  248. * Input          : u16_t
  249. * Output         : None
  250. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  251. *******************************************************************************/
  252. status_t  LSM6DSM_ACC_GYRO_W_FIFO_Watermark(void *handle, u16_t newValue)
  253. {
  254.   u8_t valueH, valueL;
  255.   u8_t value;

  256.   valueL = newValue & 0xFF;
  257.   valueH = (newValue >> 8) & 0xFF;
  258.   
  259.   /* Low part goes in FIFO_CTRL1 */
  260.   valueL = valueL << LSM6DSM_ACC_GYRO_WTM_FIFO_CTRL1_POSITION; //mask       
  261.   valueL &= LSM6DSM_ACC_GYRO_WTM_FIFO_CTRL1_MASK; //coerce
  262.   
  263.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL1, &value) )
  264.     return MEMS_ERROR;

  265.   value &= (u8_t)(~LSM6DSM_ACC_GYRO_WTM_FIFO_CTRL1_MASK);
  266.   value |= valueL;
  267.   
  268.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL1, value) )
  269.     return MEMS_ERROR;

  270.   /* High part goes in FIFO_CTRL2 */
  271.   valueH = valueH << LSM6DSM_ACC_GYRO_WTM_FIFO_CTRL2_POSITION; //mask       
  272.   valueH &= LSM6DSM_ACC_GYRO_WTM_FIFO_CTRL2_MASK; //coerce
  273.   
  274.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL2, &value) )
  275.     return MEMS_ERROR;

  276.   value &= ~LSM6DSM_ACC_GYRO_WTM_FIFO_CTRL2_MASK;
  277.   value |= valueH;
  278.   
  279.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL2, value) )
  280.     return MEMS_ERROR;

  281.   return MEMS_SUCCESS;
  282. }

  283. /*******************************************************************************
  284. * Function Name  : LSM6DSM_ACC_GYRO_R_FIFO_Watermark
  285. * Description    : Read WTM_FIFO
  286. * Input          : Pointer to u16_t
  287. * Output         : Status of WTM_FIFO
  288. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  289. *******************************************************************************/

  290. status_t LSM6DSM_ACC_GYRO_R_FIFO_Watermark(void *handle, u16_t *value)
  291. {
  292.   u8_t valueH, valueL;

  293.   /* Low part from FIFO_CTRL1 */
  294. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL1, (u8_t *)&valueL) )
  295.     return MEMS_ERROR;

  296.   valueL &= LSM6DSM_ACC_GYRO_WTM_FIFO_CTRL1_MASK; //coerce
  297.   valueL = valueL >> LSM6DSM_ACC_GYRO_WTM_FIFO_CTRL1_POSITION; //mask

  298.   /* High part from FIFO_CTRL2 */
  299. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL2, (u8_t *)&valueH) )
  300.     return MEMS_ERROR;

  301.   valueH &= LSM6DSM_ACC_GYRO_WTM_FIFO_CTRL2_MASK; //coerce
  302.   valueH = valueH >> LSM6DSM_ACC_GYRO_WTM_FIFO_CTRL2_POSITION; //mask

  303.   *value = ((valueH << 8) & 0xFF00) | valueL;

  304.   return MEMS_SUCCESS;
  305. }

  306. /*******************************************************************************
  307. * Function Name  : LSM6DSM_ACC_GYRO_W_FIFO_TEMP
  308. * Description    : Write FIFO_TEMP_EN
  309. * Input          : LSM6DSM_ACC_GYRO_FIFO_TEMP_t
  310. * Output         : None
  311. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  312. *******************************************************************************/
  313. status_t  LSM6DSM_ACC_GYRO_W_FIFO_TEMP(void *handle, LSM6DSM_ACC_GYRO_FIFO_TEMP_t newValue)
  314. {
  315.   u8_t value;

  316.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL2, &value) )
  317.     return MEMS_ERROR;

  318.   value &= ~LSM6DSM_ACC_GYRO_FIFO_TEMP_MASK;
  319.   value |= newValue;
  320.   
  321.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL2, value) )
  322.     return MEMS_ERROR;

  323.   return MEMS_SUCCESS;
  324. }

  325. /*******************************************************************************
  326. * Function Name  : LSM6DSM_ACC_GYRO_R_FIFO_TEMP
  327. * Description    : Read FIFO_TEMP_EN
  328. * Input          : Pointer to LSM6DSM_ACC_GYRO_FIFO_TEMP_t
  329. * Output         : Status of FIFO_TEMP_EN see LSM6DSM_ACC_GYRO_FIFO_TEMP_t
  330. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  331. *******************************************************************************/

  332. status_t LSM6DSM_ACC_GYRO_R_FIFO_TEMP(void *handle, LSM6DSM_ACC_GYRO_FIFO_TEMP_t *value)
  333. {
  334. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL2, (u8_t *)value) )
  335.     return MEMS_ERROR;

  336.   *value &= LSM6DSM_ACC_GYRO_FIFO_TEMP_MASK; //mask

  337.   return MEMS_SUCCESS;
  338. }

  339. /*******************************************************************************
  340. * Function Name  : LSM6DSM_ACC_GYRO_W_TIM_PEDO_FIFO_Write_En
  341. * Description    : Write TIM_PEDO_FIFO_DRDY
  342. * Input          : LSM6DSM_ACC_GYRO_TIM_PEDO_FIFO_DRDY_t
  343. * Output         : None
  344. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  345. *******************************************************************************/
  346. status_t  LSM6DSM_ACC_GYRO_W_TIM_PEDO_FIFO_Write_En(void *handle, LSM6DSM_ACC_GYRO_TIM_PEDO_FIFO_DRDY_t newValue)
  347. {
  348.   u8_t value;

  349.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL2, &value) )
  350.     return MEMS_ERROR;

  351.   value &= ~LSM6DSM_ACC_GYRO_TIM_PEDO_FIFO_DRDY_MASK;
  352.   value |= newValue;
  353.   
  354.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL2, value) )
  355.     return MEMS_ERROR;

  356.   return MEMS_SUCCESS;
  357. }

  358. /*******************************************************************************
  359. * Function Name  : LSM6DSM_ACC_GYRO_R_TIM_PEDO_FIFO_Write_En
  360. * Description    : Read TIM_PEDO_FIFO_DRDY
  361. * Input          : Pointer to LSM6DSM_ACC_GYRO_TIM_PEDO_FIFO_DRDY_t
  362. * Output         : Status of TIM_PEDO_FIFO_DRDY see LSM6DSM_ACC_GYRO_TIM_PEDO_FIFO_DRDY_t
  363. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  364. *******************************************************************************/

  365. status_t LSM6DSM_ACC_GYRO_R_TIM_PEDO_FIFO_Write_En(void *handle, LSM6DSM_ACC_GYRO_TIM_PEDO_FIFO_DRDY_t *value)
  366. {
  367. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL2, (u8_t *)value) )
  368.     return MEMS_ERROR;

  369.   *value &= LSM6DSM_ACC_GYRO_TIM_PEDO_FIFO_DRDY_MASK; //mask

  370.   return MEMS_SUCCESS;
  371. }
  372. /*******************************************************************************
  373. * Function Name  : LSM6DSM_ACC_GYRO_W_TIM_PEDO_FIFO_En
  374. * Description    : Write TIM_PEDO_FIFO_EN
  375. * Input          : LSM6DSM_ACC_GYRO_TIM_PEDO_FIFO_EN_t
  376. * Output         : None
  377. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  378. *******************************************************************************/
  379. status_t  LSM6DSM_ACC_GYRO_W_TIM_PEDO_FIFO_En(void *handle, LSM6DSM_ACC_GYRO_TIM_PEDO_FIFO_EN_t newValue)
  380. {
  381.   u8_t value;

  382.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL2, &value) )
  383.     return MEMS_ERROR;

  384.   value &= ~LSM6DSM_ACC_GYRO_TIM_PEDO_FIFO_EN_MASK;
  385.   value |= newValue;
  386.   
  387.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL2, value) )
  388.     return MEMS_ERROR;

  389.   return MEMS_SUCCESS;
  390. }

  391. /*******************************************************************************
  392. * Function Name  : LSM6DSM_ACC_GYRO_R_TIM_PEDO_FIFO_En
  393. * Description    : Read TIM_PEDO_FIFO_EN
  394. * Input          : Pointer to LSM6DSM_ACC_GYRO_TIM_PEDO_FIFO_EN_t
  395. * Output         : Status of TIM_PEDO_FIFO_EN see LSM6DSM_ACC_GYRO_TIM_PEDO_FIFO_EN_t
  396. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  397. *******************************************************************************/

  398. status_t LSM6DSM_ACC_GYRO_R_TIM_PEDO_FIFO_En(void *handle, LSM6DSM_ACC_GYRO_TIM_PEDO_FIFO_EN_t *value)
  399. {
  400. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL2, (u8_t *)value) )
  401.     return MEMS_ERROR;

  402.   *value &= LSM6DSM_ACC_GYRO_TIM_PEDO_FIFO_EN_MASK; //mask

  403.   return MEMS_SUCCESS;
  404. }
  405. /*******************************************************************************
  406. * Function Name  : LSM6DSM_ACC_GYRO_W_DEC_FIFO_XL
  407. * Description    : Write DEC_FIFO_XL
  408. * Input          : LSM6DSM_ACC_GYRO_DEC_FIFO_XL_t
  409. * Output         : None
  410. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  411. *******************************************************************************/
  412. status_t  LSM6DSM_ACC_GYRO_W_DEC_FIFO_XL(void *handle, LSM6DSM_ACC_GYRO_DEC_FIFO_XL_t newValue)
  413. {
  414.   u8_t value;

  415.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL3, &value) )
  416.     return MEMS_ERROR;

  417.   value &= ~LSM6DSM_ACC_GYRO_DEC_FIFO_XL_MASK;
  418.   value |= newValue;
  419.   
  420.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL3, value) )
  421.     return MEMS_ERROR;

  422.   return MEMS_SUCCESS;
  423. }

  424. /* Program XL decimation value from unsigned short */
  425. status_t  LSM6DSM_ACC_GYRO_W_DEC_FIFO_XL_val(void *handle, u16_t newValue)
  426. {
  427.   switch(newValue) {
  428.   case 0:
  429.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_XL(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_XL_DATA_NOT_IN_FIFO);
  430.     break;

  431.   case 1:
  432.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_XL(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_XL_NO_DECIMATION);
  433.     break;

  434.   case 2:
  435.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_XL(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_2);
  436.     break;

  437.   case 3:
  438.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_XL(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_3);
  439.     break;

  440.   case 4:
  441.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_XL(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_4);
  442.     break;

  443.   case 8:
  444.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_XL(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_8);
  445.     break;

  446.   case 16:
  447.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_XL(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_16);
  448.     break;

  449.   case 32:
  450.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_XL(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_32);
  451.     break;

  452.   default:
  453.     return MEMS_ERROR;
  454.   }

  455.   return MEMS_SUCCESS;
  456. }

  457. /*******************************************************************************
  458. * Function Name  : LSM6DSM_ACC_GYRO_R_DEC_FIFO_XL
  459. * Description    : Read DEC_FIFO_XL
  460. * Input          : Pointer to LSM6DSM_ACC_GYRO_DEC_FIFO_XL_t
  461. * Output         : Status of DEC_FIFO_XL see LSM6DSM_ACC_GYRO_DEC_FIFO_XL_t
  462. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  463. *******************************************************************************/

  464. status_t LSM6DSM_ACC_GYRO_R_DEC_FIFO_XL(void *handle, LSM6DSM_ACC_GYRO_DEC_FIFO_XL_t *value)
  465. {
  466. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL3, (u8_t *)value) )
  467.     return MEMS_ERROR;

  468.   *value &= LSM6DSM_ACC_GYRO_DEC_FIFO_XL_MASK; //mask

  469.   return MEMS_SUCCESS;
  470. }
  471. /*******************************************************************************
  472. * Function Name  : LSM6DSM_ACC_GYRO_W_DEC_FIFO_G
  473. * Description    : Write DEC_FIFO_G
  474. * Input          : LSM6DSM_ACC_GYRO_DEC_FIFO_G_t
  475. * Output         : None
  476. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  477. *******************************************************************************/
  478. status_t  LSM6DSM_ACC_GYRO_W_DEC_FIFO_G(void *handle, LSM6DSM_ACC_GYRO_DEC_FIFO_G_t newValue)
  479. {
  480.   u8_t value;

  481.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL3, &value) )
  482.     return MEMS_ERROR;

  483.   value &= ~LSM6DSM_ACC_GYRO_DEC_FIFO_G_MASK;
  484.   value |= newValue;
  485.   
  486.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL3, value) )
  487.     return MEMS_ERROR;

  488.   return MEMS_SUCCESS;
  489. }

  490. /* Program G decimation value from unsigned short */
  491. status_t  LSM6DSM_ACC_GYRO_W_DEC_FIFO_G_val(void *handle, u16_t newValue)
  492. {
  493.   switch(newValue) {
  494.   case 0:
  495.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_G(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_G_DATA_NOT_IN_FIFO);
  496.     break;

  497.   case 1:
  498.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_G(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_G_NO_DECIMATION);
  499.     break;

  500.   case 2:
  501.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_G(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_2);
  502.     break;

  503.   case 3:
  504.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_G(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_3);
  505.     break;

  506.   case 4:
  507.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_G(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_4);
  508.     break;

  509.   case 8:
  510.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_G(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_8);
  511.     break;

  512.   case 16:
  513.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_G(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_16);
  514.     break;

  515.   case 32:
  516.     LSM6DSM_ACC_GYRO_W_DEC_FIFO_G(handle, LSM6DSM_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_32);
  517.     break;

  518.   default:
  519.     return MEMS_ERROR;
  520.   }

  521.   return MEMS_SUCCESS;
  522. }

  523. /*******************************************************************************
  524. * Function Name  : LSM6DSM_ACC_GYRO_R_DEC_FIFO_G
  525. * Description    : Read DEC_FIFO_G
  526. * Input          : Pointer to LSM6DSM_ACC_GYRO_DEC_FIFO_G_t
  527. * Output         : Status of DEC_FIFO_G see LSM6DSM_ACC_GYRO_DEC_FIFO_G_t
  528. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  529. *******************************************************************************/

  530. status_t LSM6DSM_ACC_GYRO_R_DEC_FIFO_G(void *handle, LSM6DSM_ACC_GYRO_DEC_FIFO_G_t *value)
  531. {
  532. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL3, (u8_t *)value) )
  533.     return MEMS_ERROR;

  534.   *value &= LSM6DSM_ACC_GYRO_DEC_FIFO_G_MASK; //mask

  535.   return MEMS_SUCCESS;
  536. }
  537. /*******************************************************************************
  538. * Function Name  : LSM6DSM_ACC_GYRO_W_DEC_FIFO_DS3
  539. * Description    : Write DEC_DS3_FIFO
  540. * Input          : LSM6DSM_ACC_GYRO_DEC_FIFO_DS3_t
  541. * Output         : None
  542. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  543. *******************************************************************************/
  544. status_t  LSM6DSM_ACC_GYRO_W_DEC_FIFO_DS3(void *handle, LSM6DSM_ACC_GYRO_DEC_FIFO_DS3_t newValue)
  545. {
  546.   u8_t value;

  547.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL4, &value) )
  548.     return MEMS_ERROR;

  549.   value &= ~LSM6DSM_ACC_GYRO_DEC_FIFO_DS3_MASK;
  550.   value |= newValue;
  551.   
  552.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL4, value) )
  553.     return MEMS_ERROR;

  554.   return MEMS_SUCCESS;
  555. }

  556. /*******************************************************************************
  557. * Function Name  : LSM6DSM_ACC_GYRO_R_DEC_FIFO_DS3
  558. * Description    : Read DEC_DS3_FIFO
  559. * Input          : Pointer to LSM6DSM_ACC_GYRO_DEC_FIFO_DS3_t
  560. * Output         : Status of DEC_DS3_FIFO see LSM6DSM_ACC_GYRO_DEC_FIFO_DS3_t
  561. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  562. *******************************************************************************/

  563. status_t LSM6DSM_ACC_GYRO_R_DEC_FIFO_DS3(void *handle, LSM6DSM_ACC_GYRO_DEC_FIFO_DS3_t *value)
  564. {
  565. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL4, (u8_t *)value) )
  566.     return MEMS_ERROR;

  567.   *value &= LSM6DSM_ACC_GYRO_DEC_FIFO_DS3_MASK; //mask

  568.   return MEMS_SUCCESS;
  569. }
  570. /*******************************************************************************
  571. * Function Name  : LSM6DSM_ACC_GYRO_W_DEC_FIFO_DS4
  572. * Description    : Write DEC_DS4_FIFO
  573. * Input          : LSM6DSM_ACC_GYRO_DEC_FIFO_DS4_t
  574. * Output         : None
  575. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  576. *******************************************************************************/
  577. status_t  LSM6DSM_ACC_GYRO_W_DEC_FIFO_DS4(void *handle, LSM6DSM_ACC_GYRO_DEC_FIFO_DS4_t newValue)
  578. {
  579.   u8_t value;

  580.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL4, &value) )
  581.     return MEMS_ERROR;

  582.   value &= ~LSM6DSM_ACC_GYRO_DEC_FIFO_DS4_MASK;
  583.   value |= newValue;
  584.   
  585.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL4, value) )
  586.     return MEMS_ERROR;

  587.   return MEMS_SUCCESS;
  588. }

  589. /*******************************************************************************
  590. * Function Name  : LSM6DSM_ACC_GYRO_R_DEC_FIFO_DS4
  591. * Description    : Read DEC_DS4_FIFO
  592. * Input          : Pointer to LSM6DSM_ACC_GYRO_DEC_FIFO_DS4_t
  593. * Output         : Status of DEC_DS4_FIFO see LSM6DSM_ACC_GYRO_DEC_FIFO_DS4_t
  594. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  595. *******************************************************************************/

  596. status_t LSM6DSM_ACC_GYRO_R_DEC_FIFO_DS4(void *handle, LSM6DSM_ACC_GYRO_DEC_FIFO_DS4_t *value)
  597. {
  598. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL4, (u8_t *)value) )
  599.     return MEMS_ERROR;

  600.   *value &= LSM6DSM_ACC_GYRO_DEC_FIFO_DS4_MASK; //mask

  601.   return MEMS_SUCCESS;
  602. }
  603. /*******************************************************************************
  604. * Function Name  : LSM6DSM_ACC_GYRO_W_HI_DATA_ONLY
  605. * Description    : Write HI_DATA_ONLY
  606. * Input          : LSM6DSM_ACC_GYRO_HI_DATA_ONLY_t
  607. * Output         : None
  608. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  609. *******************************************************************************/
  610. status_t  LSM6DSM_ACC_GYRO_W_HI_DATA_ONLY(void *handle, LSM6DSM_ACC_GYRO_HI_DATA_ONLY_t newValue)
  611. {
  612.   u8_t value;

  613.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL4, &value) )
  614.     return MEMS_ERROR;

  615.   value &= ~LSM6DSM_ACC_GYRO_HI_DATA_ONLY_MASK;
  616.   value |= newValue;
  617.   
  618.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL4, value) )
  619.     return MEMS_ERROR;

  620.   return MEMS_SUCCESS;
  621. }

  622. /*******************************************************************************
  623. * Function Name  : LSM6DSM_ACC_GYRO_R_HI_DATA_ONLY
  624. * Description    : Read HI_DATA_ONLY
  625. * Input          : Pointer to LSM6DSM_ACC_GYRO_HI_DATA_ONLY_t
  626. * Output         : Status of HI_DATA_ONLY see LSM6DSM_ACC_GYRO_HI_DATA_ONLY_t
  627. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  628. *******************************************************************************/

  629. status_t LSM6DSM_ACC_GYRO_R_HI_DATA_ONLY(void *handle, LSM6DSM_ACC_GYRO_HI_DATA_ONLY_t *value)
  630. {
  631. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL4, (u8_t *)value) )
  632.     return MEMS_ERROR;

  633.   *value &= LSM6DSM_ACC_GYRO_HI_DATA_ONLY_MASK; //mask

  634.   return MEMS_SUCCESS;
  635. }

  636. /*******************************************************************************
  637. * Function Name  : LSM6DSM_ACC_GYRO_W_STOP_ON_FTH
  638. * Description    : Write STOP_ON_FTH
  639. * Input          : LSM6DSM_ACC_GYRO_STOP_ON_FTH_t
  640. * Output         : None
  641. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  642. *******************************************************************************/
  643. status_t  LSM6DSM_ACC_GYRO_W_STOP_ON_FTH(void *handle, LSM6DSM_ACC_GYRO_STOP_ON_FTH_t newValue)
  644. {
  645.   u8_t value;

  646.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL4, &value) )
  647.     return MEMS_ERROR;

  648.   value &= ~LSM6DSM_ACC_GYRO_STOP_ON_FTH_MASK;
  649.   value |= newValue;
  650.   
  651.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL4, value) )
  652.     return MEMS_ERROR;

  653.   return MEMS_SUCCESS;
  654. }

  655. /*******************************************************************************
  656. * Function Name  : LSM6DSM_ACC_GYRO_R_STOP_ON_FTH
  657. * Description    : Read STOP_ON_FTH
  658. * Input          : Pointer to LSM6DSM_ACC_GYRO_STOP_ON_FTH_t
  659. * Output         : Status of STOP_ON_FTH see LSM6DSM_ACC_GYRO_STOP_ON_FTH_t
  660. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  661. *******************************************************************************/

  662. status_t LSM6DSM_ACC_GYRO_R_STOP_ON_FTH(void *handle, LSM6DSM_ACC_GYRO_STOP_ON_FTH_t *value)
  663. {
  664. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL4, (u8_t *)value) )
  665.     return MEMS_ERROR;

  666.   *value &= LSM6DSM_ACC_GYRO_STOP_ON_FTH_MASK; //mask

  667.   return MEMS_SUCCESS;
  668. }

  669. /*******************************************************************************
  670. * Function Name  : LSM6DSM_ACC_GYRO_W_FIFO_MODE
  671. * Description    : Write FIFO_MODE
  672. * Input          : LSM6DSM_ACC_GYRO_FIFO_MODE_t
  673. * Output         : None
  674. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  675. *******************************************************************************/
  676. status_t  LSM6DSM_ACC_GYRO_W_FIFO_MODE(void *handle, LSM6DSM_ACC_GYRO_FIFO_MODE_t newValue)
  677. {
  678.   u8_t value;

  679.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL5, &value) )
  680.     return MEMS_ERROR;

  681.   value &= ~LSM6DSM_ACC_GYRO_FIFO_MODE_MASK;
  682.   value |= newValue;
  683.   
  684.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL5, value) )
  685.     return MEMS_ERROR;

  686.   return MEMS_SUCCESS;
  687. }

  688. /*******************************************************************************
  689. * Function Name  : LSM6DSM_ACC_GYRO_R_FIFO_MODE
  690. * Description    : Read FIFO_MODE
  691. * Input          : Pointer to LSM6DSM_ACC_GYRO_FIFO_MODE_t
  692. * Output         : Status of FIFO_MODE see LSM6DSM_ACC_GYRO_FIFO_MODE_t
  693. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  694. *******************************************************************************/

  695. status_t LSM6DSM_ACC_GYRO_R_FIFO_MODE(void *handle, LSM6DSM_ACC_GYRO_FIFO_MODE_t *value)
  696. {
  697. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL5, (u8_t *)value) )
  698.     return MEMS_ERROR;

  699.   *value &= LSM6DSM_ACC_GYRO_FIFO_MODE_MASK; //mask

  700.   return MEMS_SUCCESS;
  701. }
  702. /*******************************************************************************
  703. * Function Name  : LSM6DSM_ACC_GYRO_W_ODR_FIFO
  704. * Description    : Write ODR_FIFO
  705. * Input          : LSM6DSM_ACC_GYRO_ODR_FIFO_t
  706. * Output         : None
  707. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  708. *******************************************************************************/
  709. status_t  LSM6DSM_ACC_GYRO_W_ODR_FIFO(void *handle, LSM6DSM_ACC_GYRO_ODR_FIFO_t newValue)
  710. {
  711.   u8_t value;

  712.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL5, &value) )
  713.     return MEMS_ERROR;

  714.   value &= ~LSM6DSM_ACC_GYRO_ODR_FIFO_MASK;
  715.   value |= newValue;
  716.   
  717.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL5, value) )
  718.     return MEMS_ERROR;

  719.   return MEMS_SUCCESS;
  720. }

  721. /*******************************************************************************
  722. * Function Name  : LSM6DSM_ACC_GYRO_R_ODR_FIFO
  723. * Description    : Read ODR_FIFO
  724. * Input          : Pointer to LSM6DSM_ACC_GYRO_ODR_FIFO_t
  725. * Output         : Status of ODR_FIFO see LSM6DSM_ACC_GYRO_ODR_FIFO_t
  726. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  727. *******************************************************************************/

  728. status_t LSM6DSM_ACC_GYRO_R_ODR_FIFO(void *handle, LSM6DSM_ACC_GYRO_ODR_FIFO_t *value)
  729. {
  730. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_CTRL5, (u8_t *)value) )
  731.     return MEMS_ERROR;

  732.   *value &= LSM6DSM_ACC_GYRO_ODR_FIFO_MASK; //mask

  733.   return MEMS_SUCCESS;
  734. }

  735. /*******************************************************************************
  736. * Function Name  : LSM6DSM_ACC_GYRO_W_DRDY_PULSE
  737. * Description    : Write DRDY_PULSE
  738. * Input          : LSM6DSM_ACC_GYRO_DRDY_PULSE_t
  739. * Output         : None
  740. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  741. *******************************************************************************/
  742. status_t  LSM6DSM_ACC_GYRO_W_DRDY_PULSE(void *handle, LSM6DSM_ACC_GYRO_DRDY_PULSE_t newValue)
  743. {
  744.   u8_t value;

  745.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_DRDY_PULSE_CFG_G, &value) )
  746.     return MEMS_ERROR;

  747.   value &= ~LSM6DSM_ACC_GYRO_DRDY_PULSE_MASK;
  748.   value |= newValue;
  749.   
  750.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_DRDY_PULSE_CFG_G, value) )
  751.     return MEMS_ERROR;

  752.   return MEMS_SUCCESS;
  753. }

  754. /*******************************************************************************
  755. * Function Name  : LSM6DSM_ACC_GYRO_R_DRDY_PULSE
  756. * Description    : Read DRDY_PULSE
  757. * Input          : Pointer to LSM6DSM_ACC_GYRO_DRDY_PULSE_t
  758. * Output         : Status of DRDY_PULSE see LSM6DSM_ACC_GYRO_DRDY_PULSE_t
  759. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  760. *******************************************************************************/

  761. status_t LSM6DSM_ACC_GYRO_R_DRDY_PULSE(void *handle, LSM6DSM_ACC_GYRO_DRDY_PULSE_t *value)
  762. {
  763. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_DRDY_PULSE_CFG_G, (u8_t *)value) )
  764.     return MEMS_ERROR;

  765.   *value &= LSM6DSM_ACC_GYRO_DRDY_PULSE_MASK; //mask

  766.   return MEMS_SUCCESS;
  767. }



  768. /*******************************************************************************
  769. * Function Name  : LSM6DSM_ACC_GYRO_W_DRDY_XL_on_INT1
  770. * Description    : Write INT1_DRDY_XL
  771. * Input          : LSM6DSM_ACC_GYRO_INT1_DRDY_XL_t
  772. * Output         : None
  773. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  774. *******************************************************************************/
  775. status_t  LSM6DSM_ACC_GYRO_W_DRDY_XL_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_DRDY_XL_t newValue)
  776. {
  777.   u8_t value;

  778.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, &value) )
  779.     return MEMS_ERROR;

  780.   value &= ~LSM6DSM_ACC_GYRO_INT1_DRDY_XL_MASK;
  781.   value |= newValue;
  782.   
  783.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, value) )
  784.     return MEMS_ERROR;

  785.   return MEMS_SUCCESS;
  786. }

  787. /*******************************************************************************
  788. * Function Name  : LSM6DSM_ACC_GYRO_R_DRDY_XL_on_INT1
  789. * Description    : Read INT1_DRDY_XL
  790. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_DRDY_XL_t
  791. * Output         : Status of INT1_DRDY_XL see LSM6DSM_ACC_GYRO_INT1_DRDY_XL_t
  792. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  793. *******************************************************************************/

  794. status_t LSM6DSM_ACC_GYRO_R_DRDY_XL_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_DRDY_XL_t *value)
  795. {
  796. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, (u8_t *)value) )
  797.     return MEMS_ERROR;

  798.   *value &= LSM6DSM_ACC_GYRO_INT1_DRDY_XL_MASK; //mask

  799.   return MEMS_SUCCESS;
  800. }
  801. /*******************************************************************************
  802. * Function Name  : LSM6DSM_ACC_GYRO_W_DRDY_G_on_INT1
  803. * Description    : Write INT1_DRDY_G
  804. * Input          : LSM6DSM_ACC_GYRO_INT1_DRDY_G_t
  805. * Output         : None
  806. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  807. *******************************************************************************/
  808. status_t  LSM6DSM_ACC_GYRO_W_DRDY_G_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_DRDY_G_t newValue)
  809. {
  810.   u8_t value;

  811.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, &value) )
  812.     return MEMS_ERROR;

  813.   value &= ~LSM6DSM_ACC_GYRO_INT1_DRDY_G_MASK;
  814.   value |= newValue;
  815.   
  816.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, value) )
  817.     return MEMS_ERROR;

  818.   return MEMS_SUCCESS;
  819. }

  820. /*******************************************************************************
  821. * Function Name  : LSM6DSM_ACC_GYRO_R_DRDY_G_on_INT1
  822. * Description    : Read INT1_DRDY_G
  823. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_DRDY_G_t
  824. * Output         : Status of INT1_DRDY_G see LSM6DSM_ACC_GYRO_INT1_DRDY_G_t
  825. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  826. *******************************************************************************/

  827. status_t LSM6DSM_ACC_GYRO_R_DRDY_G_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_DRDY_G_t *value)
  828. {
  829. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, (u8_t *)value) )
  830.     return MEMS_ERROR;

  831.   *value &= LSM6DSM_ACC_GYRO_INT1_DRDY_G_MASK; //mask

  832.   return MEMS_SUCCESS;
  833. }
  834. /*******************************************************************************
  835. * Function Name  : LSM6DSM_ACC_GYRO_W_BOOT_on_INT1
  836. * Description    : Write INT1_BOOT
  837. * Input          : LSM6DSM_ACC_GYRO_INT1_BOOT_t
  838. * Output         : None
  839. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  840. *******************************************************************************/
  841. status_t  LSM6DSM_ACC_GYRO_W_BOOT_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_BOOT_t newValue)
  842. {
  843.   u8_t value;

  844.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, &value) )
  845.     return MEMS_ERROR;

  846.   value &= ~LSM6DSM_ACC_GYRO_INT1_BOOT_MASK;
  847.   value |= newValue;
  848.   
  849.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, value) )
  850.     return MEMS_ERROR;

  851.   return MEMS_SUCCESS;
  852. }

  853. /*******************************************************************************
  854. * Function Name  : LSM6DSM_ACC_GYRO_R_BOOT_on_INT1
  855. * Description    : Read INT1_BOOT
  856. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_BOOT_t
  857. * Output         : Status of INT1_BOOT see LSM6DSM_ACC_GYRO_INT1_BOOT_t
  858. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  859. *******************************************************************************/

  860. status_t LSM6DSM_ACC_GYRO_R_BOOT_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_BOOT_t *value)
  861. {
  862. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, (u8_t *)value) )
  863.     return MEMS_ERROR;

  864.   *value &= LSM6DSM_ACC_GYRO_INT1_BOOT_MASK; //mask

  865.   return MEMS_SUCCESS;
  866. }
  867. /*******************************************************************************
  868. * Function Name  : LSM6DSM_ACC_GYRO_W_FIFO_TSHLD_on_INT1
  869. * Description    : Write INT1_FTH
  870. * Input          : LSM6DSM_ACC_GYRO_INT1_FTH_t
  871. * Output         : None
  872. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  873. *******************************************************************************/
  874. status_t  LSM6DSM_ACC_GYRO_W_FIFO_TSHLD_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_FTH_t newValue)
  875. {
  876.   u8_t value;

  877.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, &value) )
  878.     return MEMS_ERROR;

  879.   value &= ~LSM6DSM_ACC_GYRO_INT1_FTH_MASK;
  880.   value |= newValue;
  881.   
  882.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, value) )
  883.     return MEMS_ERROR;

  884.   return MEMS_SUCCESS;
  885. }

  886. /*******************************************************************************
  887. * Function Name  : LSM6DSM_ACC_GYRO_R_FIFO_TSHLD_on_INT1
  888. * Description    : Read INT1_FTH
  889. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_FTH_t
  890. * Output         : Status of INT1_FTH see LSM6DSM_ACC_GYRO_INT1_FTH_t
  891. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  892. *******************************************************************************/

  893. status_t LSM6DSM_ACC_GYRO_R_FIFO_TSHLD_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_FTH_t *value)
  894. {
  895. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, (u8_t *)value) )
  896.     return MEMS_ERROR;

  897.   *value &= LSM6DSM_ACC_GYRO_INT1_FTH_MASK; //mask

  898.   return MEMS_SUCCESS;
  899. }
  900. /*******************************************************************************
  901. * Function Name  : LSM6DSM_ACC_GYRO_W_OVERRUN_on_INT1
  902. * Description    : Write INT1_OVR
  903. * Input          : LSM6DSM_ACC_GYRO_INT1_OVR_t
  904. * Output         : None
  905. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  906. *******************************************************************************/
  907. status_t  LSM6DSM_ACC_GYRO_W_OVERRUN_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_OVR_t newValue)
  908. {
  909.   u8_t value;

  910.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, &value) )
  911.     return MEMS_ERROR;

  912.   value &= ~LSM6DSM_ACC_GYRO_INT1_OVR_MASK;
  913.   value |= newValue;
  914.   
  915.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, value) )
  916.     return MEMS_ERROR;

  917.   return MEMS_SUCCESS;
  918. }

  919. /*******************************************************************************
  920. * Function Name  : LSM6DSM_ACC_GYRO_R_OVERRUN_on_INT1
  921. * Description    : Read INT1_OVR
  922. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_OVR_t
  923. * Output         : Status of INT1_OVR see LSM6DSM_ACC_GYRO_INT1_OVR_t
  924. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  925. *******************************************************************************/

  926. status_t LSM6DSM_ACC_GYRO_R_OVERRUN_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_OVR_t *value)
  927. {
  928. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, (u8_t *)value) )
  929.     return MEMS_ERROR;

  930.   *value &= LSM6DSM_ACC_GYRO_INT1_OVR_MASK; //mask

  931.   return MEMS_SUCCESS;
  932. }
  933. /*******************************************************************************
  934. * Function Name  : LSM6DSM_ACC_GYRO_W_FULL_FLAG_on_INT1
  935. * Description    : Write INT1_FULL_FLAG
  936. * Input          : LSM6DSM_ACC_GYRO_INT1_FULL_FLAG_t
  937. * Output         : None
  938. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  939. *******************************************************************************/
  940. status_t  LSM6DSM_ACC_GYRO_W_FULL_FLAG_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_FULL_FLAG_t newValue)
  941. {
  942.   u8_t value;

  943.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, &value) )
  944.     return MEMS_ERROR;

  945.   value &= ~LSM6DSM_ACC_GYRO_INT1_FULL_FLAG_MASK;
  946.   value |= newValue;
  947.   
  948.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, value) )
  949.     return MEMS_ERROR;

  950.   return MEMS_SUCCESS;
  951. }

  952. /*******************************************************************************
  953. * Function Name  : LSM6DSM_ACC_GYRO_R_FULL_FLAG_on_INT1
  954. * Description    : Read INT1_FULL_FLAG
  955. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_FULL_FLAG_t
  956. * Output         : Status of INT1_FULL_FLAG see LSM6DSM_ACC_GYRO_INT1_FULL_FLAG_t
  957. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  958. *******************************************************************************/

  959. status_t LSM6DSM_ACC_GYRO_R_FULL_FLAG_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_FULL_FLAG_t *value)
  960. {
  961. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, (u8_t *)value) )
  962.     return MEMS_ERROR;

  963.   *value &= LSM6DSM_ACC_GYRO_INT1_FULL_FLAG_MASK; //mask

  964.   return MEMS_SUCCESS;
  965. }
  966. /*******************************************************************************
  967. * Function Name  : LSM6DSM_ACC_GYRO_W_SIGN_MOT_on_INT1
  968. * Description    : Write INT1_SIGN_MOT
  969. * Input          : LSM6DSM_ACC_GYRO_INT1_SIGN_MOT_t
  970. * Output         : None
  971. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  972. *******************************************************************************/
  973. status_t  LSM6DSM_ACC_GYRO_W_SIGN_MOT_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_SIGN_MOT_t newValue)
  974. {
  975.   u8_t value;

  976.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, &value) )
  977.     return MEMS_ERROR;

  978.   value &= ~LSM6DSM_ACC_GYRO_INT1_SIGN_MOT_MASK;
  979.   value |= newValue;
  980.   
  981.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, value) )
  982.     return MEMS_ERROR;

  983.   return MEMS_SUCCESS;
  984. }

  985. /*******************************************************************************
  986. * Function Name  : LSM6DSM_ACC_GYRO_R_SIGN_MOT_on_INT1
  987. * Description    : Read INT1_SIGN_MOT
  988. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_SIGN_MOT_t
  989. * Output         : Status of INT1_SIGN_MOT see LSM6DSM_ACC_GYRO_INT1_SIGN_MOT_t
  990. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  991. *******************************************************************************/

  992. status_t LSM6DSM_ACC_GYRO_R_SIGN_MOT_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_SIGN_MOT_t *value)
  993. {
  994. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, (u8_t *)value) )
  995.     return MEMS_ERROR;

  996.   *value &= LSM6DSM_ACC_GYRO_INT1_SIGN_MOT_MASK; //mask

  997.   return MEMS_SUCCESS;
  998. }
  999. /*******************************************************************************
  1000. * Function Name  : LSM6DSM_ACC_GYRO_W_STEP_DET_on_INT1
  1001. * Description    : Write INT1_PEDO
  1002. * Input          : LSM6DSM_ACC_GYRO_INT1_PEDO_t
  1003. * Output         : None
  1004. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1005. *******************************************************************************/
  1006. status_t  LSM6DSM_ACC_GYRO_W_STEP_DET_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_PEDO_t newValue)
  1007. {
  1008.   u8_t value;

  1009.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, &value) )
  1010.     return MEMS_ERROR;

  1011.   value &= ~LSM6DSM_ACC_GYRO_INT1_PEDO_MASK;
  1012.   value |= newValue;
  1013.   
  1014.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, value) )
  1015.     return MEMS_ERROR;

  1016.   return MEMS_SUCCESS;
  1017. }

  1018. /*******************************************************************************
  1019. * Function Name  : LSM6DSM_ACC_GYRO_R_STEP_DET_on_INT1
  1020. * Description    : Read INT1_PEDO
  1021. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_PEDO_t
  1022. * Output         : Status of INT1_PEDO see LSM6DSM_ACC_GYRO_INT1_PEDO_t
  1023. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1024. *******************************************************************************/

  1025. status_t LSM6DSM_ACC_GYRO_R_STEP_DET_on_INT1(void *handle, LSM6DSM_ACC_GYRO_INT1_PEDO_t *value)
  1026. {
  1027. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT1_CTRL, (u8_t *)value) )
  1028.     return MEMS_ERROR;

  1029.   *value &= LSM6DSM_ACC_GYRO_INT1_PEDO_MASK; //mask

  1030.   return MEMS_SUCCESS;
  1031. }
  1032. /*******************************************************************************
  1033. * Function Name  : LSM6DSM_ACC_GYRO_W_DRDY_XL_on_INT2
  1034. * Description    : Write INT2_DRDY_XL
  1035. * Input          : LSM6DSM_ACC_GYRO_INT2_DRDY_XL_t
  1036. * Output         : None
  1037. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1038. *******************************************************************************/
  1039. status_t  LSM6DSM_ACC_GYRO_W_DRDY_XL_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_DRDY_XL_t newValue)
  1040. {
  1041.   u8_t value;

  1042.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, &value) )
  1043.     return MEMS_ERROR;

  1044.   value &= ~LSM6DSM_ACC_GYRO_INT2_DRDY_XL_MASK;
  1045.   value |= newValue;
  1046.   
  1047.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, value) )
  1048.     return MEMS_ERROR;

  1049.   return MEMS_SUCCESS;
  1050. }

  1051. /*******************************************************************************
  1052. * Function Name  : LSM6DSM_ACC_GYRO_R_DRDY_XL_on_INT2
  1053. * Description    : Read INT2_DRDY_XL
  1054. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_DRDY_XL_t
  1055. * Output         : Status of INT2_DRDY_XL see LSM6DSM_ACC_GYRO_INT2_DRDY_XL_t
  1056. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1057. *******************************************************************************/

  1058. status_t LSM6DSM_ACC_GYRO_R_DRDY_XL_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_DRDY_XL_t *value)
  1059. {
  1060. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, (u8_t *)value) )
  1061.     return MEMS_ERROR;

  1062.   *value &= LSM6DSM_ACC_GYRO_INT2_DRDY_XL_MASK; //mask

  1063.   return MEMS_SUCCESS;
  1064. }
  1065. /*******************************************************************************
  1066. * Function Name  : LSM6DSM_ACC_GYRO_W_DRDY_G_on_INT2
  1067. * Description    : Write INT2_DRDY_G
  1068. * Input          : LSM6DSM_ACC_GYRO_INT2_DRDY_G_t
  1069. * Output         : None
  1070. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1071. *******************************************************************************/
  1072. status_t  LSM6DSM_ACC_GYRO_W_DRDY_G_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_DRDY_G_t newValue)
  1073. {
  1074.   u8_t value;

  1075.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, &value) )
  1076.     return MEMS_ERROR;

  1077.   value &= ~LSM6DSM_ACC_GYRO_INT2_DRDY_G_MASK;
  1078.   value |= newValue;
  1079.   
  1080.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, value) )
  1081.     return MEMS_ERROR;

  1082.   return MEMS_SUCCESS;
  1083. }

  1084. /*******************************************************************************
  1085. * Function Name  : LSM6DSM_ACC_GYRO_R_DRDY_G_on_INT2
  1086. * Description    : Read INT2_DRDY_G
  1087. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_DRDY_G_t
  1088. * Output         : Status of INT2_DRDY_G see LSM6DSM_ACC_GYRO_INT2_DRDY_G_t
  1089. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1090. *******************************************************************************/

  1091. status_t LSM6DSM_ACC_GYRO_R_DRDY_G_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_DRDY_G_t *value)
  1092. {
  1093. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, (u8_t *)value) )
  1094.     return MEMS_ERROR;

  1095.   *value &= LSM6DSM_ACC_GYRO_INT2_DRDY_G_MASK; //mask

  1096.   return MEMS_SUCCESS;
  1097. }

  1098. /*******************************************************************************
  1099. * Function Name  : LSM6DSM_ACC_GYRO_W_DRDY_TEMP_on_INT2
  1100. * Description    : Write INT2_DRDY_TEMP
  1101. * Input          : LSM6DSM_ACC_GYRO_INT2_DRDY_TEMP_t
  1102. * Output         : None
  1103. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1104. *******************************************************************************/
  1105. status_t  LSM6DSM_ACC_GYRO_W_DRDY_TEMP_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_DRDY_TEMP_t newValue)
  1106. {
  1107.   u8_t value;

  1108.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, &value) )
  1109.     return MEMS_ERROR;

  1110.   value &= ~LSM6DSM_ACC_GYRO_INT2_DRDY_TEMP_MASK;
  1111.   value |= newValue;
  1112.   
  1113.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, value) )
  1114.     return MEMS_ERROR;

  1115.   return MEMS_SUCCESS;
  1116. }

  1117. /*******************************************************************************
  1118. * Function Name  : LSM6DSM_ACC_GYRO_R_DRDY_TEMP_on_INT2
  1119. * Description    : Read INT2_DRDY_TEMP
  1120. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_DRDY_TEMP_t
  1121. * Output         : Status of INT2_DRDY_TEMP see LSM6DSM_ACC_GYRO_INT2_DRDY_TEMP_t
  1122. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1123. *******************************************************************************/

  1124. status_t LSM6DSM_ACC_GYRO_R_DRDY_TEMP_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_DRDY_TEMP_t *value)
  1125. {
  1126. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, (u8_t *)value) )
  1127.     return MEMS_ERROR;

  1128.   *value &= LSM6DSM_ACC_GYRO_INT2_DRDY_TEMP_MASK; //mask

  1129.   return MEMS_SUCCESS;
  1130. }

  1131. /*******************************************************************************
  1132. * Function Name  : LSM6DSM_ACC_GYRO_W_FIFO_TSHLD_on_INT2
  1133. * Description    : Write INT2_FTH
  1134. * Input          : LSM6DSM_ACC_GYRO_INT2_FTH_t
  1135. * Output         : None
  1136. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1137. *******************************************************************************/
  1138. status_t  LSM6DSM_ACC_GYRO_W_FIFO_TSHLD_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_FTH_t newValue)
  1139. {
  1140.   u8_t value;

  1141.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, &value) )
  1142.     return MEMS_ERROR;

  1143.   value &= ~LSM6DSM_ACC_GYRO_INT2_FTH_MASK;
  1144.   value |= newValue;
  1145.   
  1146.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, value) )
  1147.     return MEMS_ERROR;

  1148.   return MEMS_SUCCESS;
  1149. }

  1150. /*******************************************************************************
  1151. * Function Name  : LSM6DSM_ACC_GYRO_R_FIFO_TSHLD_on_INT2
  1152. * Description    : Read INT2_FTH
  1153. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_FTH_t
  1154. * Output         : Status of INT2_FTH see LSM6DSM_ACC_GYRO_INT2_FTH_t
  1155. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1156. *******************************************************************************/

  1157. status_t LSM6DSM_ACC_GYRO_R_FIFO_TSHLD_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_FTH_t *value)
  1158. {
  1159. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, (u8_t *)value) )
  1160.     return MEMS_ERROR;

  1161.   *value &= LSM6DSM_ACC_GYRO_INT2_FTH_MASK; //mask

  1162.   return MEMS_SUCCESS;
  1163. }
  1164. /*******************************************************************************
  1165. * Function Name  : LSM6DSM_ACC_GYRO_W_OVERRUN_on_INT2
  1166. * Description    : Write INT2_OVR
  1167. * Input          : LSM6DSM_ACC_GYRO_INT2_OVR_t
  1168. * Output         : None
  1169. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1170. *******************************************************************************/
  1171. status_t  LSM6DSM_ACC_GYRO_W_OVERRUN_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_OVR_t newValue)
  1172. {
  1173.   u8_t value;

  1174.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, &value) )
  1175.     return MEMS_ERROR;

  1176.   value &= ~LSM6DSM_ACC_GYRO_INT2_OVR_MASK;
  1177.   value |= newValue;
  1178.   
  1179.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, value) )
  1180.     return MEMS_ERROR;

  1181.   return MEMS_SUCCESS;
  1182. }

  1183. /*******************************************************************************
  1184. * Function Name  : LSM6DSM_ACC_GYRO_R_OVERRUN_on_INT2
  1185. * Description    : Read INT2_OVR
  1186. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_OVR_t
  1187. * Output         : Status of INT2_OVR see LSM6DSM_ACC_GYRO_INT2_OVR_t
  1188. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1189. *******************************************************************************/

  1190. status_t LSM6DSM_ACC_GYRO_R_OVERRUN_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_OVR_t *value)
  1191. {
  1192. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, (u8_t *)value) )
  1193.     return MEMS_ERROR;

  1194.   *value &= LSM6DSM_ACC_GYRO_INT2_OVR_MASK; //mask

  1195.   return MEMS_SUCCESS;
  1196. }
  1197. /*******************************************************************************
  1198. * Function Name  : LSM6DSM_ACC_GYRO_W_FULL_FLAG_on_INT2
  1199. * Description    : Write INT2_FULL_FLAG
  1200. * Input          : LSM6DSM_ACC_GYRO_INT2_FULL_FLAG_t
  1201. * Output         : None
  1202. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1203. *******************************************************************************/
  1204. status_t  LSM6DSM_ACC_GYRO_W_FULL_FLAG_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_FULL_FLAG_t newValue)
  1205. {
  1206.   u8_t value;

  1207.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, &value) )
  1208.     return MEMS_ERROR;

  1209.   value &= ~LSM6DSM_ACC_GYRO_INT2_FULL_FLAG_MASK;
  1210.   value |= newValue;
  1211.   
  1212.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, value) )
  1213.     return MEMS_ERROR;

  1214.   return MEMS_SUCCESS;
  1215. }

  1216. /*******************************************************************************
  1217. * Function Name  : LSM6DSM_ACC_GYRO_R_FULL_FLAG_on_INT2
  1218. * Description    : Read INT2_FULL_FLAG
  1219. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_FULL_FLAG_t
  1220. * Output         : Status of INT2_FULL_FLAG see LSM6DSM_ACC_GYRO_INT2_FULL_FLAG_t
  1221. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1222. *******************************************************************************/

  1223. status_t LSM6DSM_ACC_GYRO_R_FULL_FLAG_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_FULL_FLAG_t *value)
  1224. {
  1225. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, (u8_t *)value) )
  1226.     return MEMS_ERROR;

  1227.   *value &= LSM6DSM_ACC_GYRO_INT2_FULL_FLAG_MASK; //mask

  1228.   return MEMS_SUCCESS;
  1229. }
  1230. /*******************************************************************************
  1231. * Function Name  : LSM6DSM_ACC_GYRO_W_STEP_COUNT_OV_on_INT2
  1232. * Description    : Write INT2_STEP_COUNT_OV
  1233. * Input          : LSM6DSM_ACC_GYRO_INT2_STEP_COUNT_OV_t
  1234. * Output         : None
  1235. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1236. *******************************************************************************/
  1237. status_t  LSM6DSM_ACC_GYRO_W_STEP_COUNT_OV_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_STEP_COUNT_OV_t newValue)
  1238. {
  1239.   u8_t value;

  1240.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, &value) )
  1241.     return MEMS_ERROR;

  1242.   value &= ~LSM6DSM_ACC_GYRO_INT2_STEP_COUNT_OV_MASK;
  1243.   value |= newValue;
  1244.   
  1245.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, value) )
  1246.     return MEMS_ERROR;

  1247.   return MEMS_SUCCESS;
  1248. }

  1249. /*******************************************************************************
  1250. * Function Name  : LSM6DSM_ACC_GYRO_R_STEP_COUNT_OV_on_INT2
  1251. * Description    : Read INT2_STEP_COUNT_OV
  1252. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_STEP_COUNT_OV_t
  1253. * Output         : Status of INT2_STEP_COUNT_OV see LSM6DSM_ACC_GYRO_INT2_STEP_COUNT_OV_t
  1254. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1255. *******************************************************************************/

  1256. status_t LSM6DSM_ACC_GYRO_R_STEP_COUNT_OV_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_STEP_COUNT_OV_t *value)
  1257. {
  1258. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, (u8_t *)value) )
  1259.     return MEMS_ERROR;

  1260.   *value &= LSM6DSM_ACC_GYRO_INT2_STEP_COUNT_OV_MASK; //mask

  1261.   return MEMS_SUCCESS;
  1262. }
  1263. /*******************************************************************************
  1264. * Function Name  : LSM6DSM_ACC_GYRO_W_STEP_DELTA_on_INT2
  1265. * Description    : Write INT2_STEP_DELTA
  1266. * Input          : LSM6DSM_ACC_GYRO_INT2_STEP_DELTA_t
  1267. * Output         : None
  1268. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1269. *******************************************************************************/
  1270. status_t  LSM6DSM_ACC_GYRO_W_STEP_DELTA_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_STEP_DELTA_t newValue)
  1271. {
  1272.   u8_t value;

  1273.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, &value) )
  1274.     return MEMS_ERROR;

  1275.   value &= ~LSM6DSM_ACC_GYRO_INT2_STEP_DELTA_MASK;
  1276.   value |= newValue;
  1277.   
  1278.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, value) )
  1279.     return MEMS_ERROR;

  1280.   return MEMS_SUCCESS;
  1281. }

  1282. /*******************************************************************************
  1283. * Function Name  : LSM6DSM_ACC_GYRO_R_STEP_DELTA_on_INT2
  1284. * Description    : Read INT2_STEP_DELTA
  1285. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_STEP_DELTA_t
  1286. * Output         : Status of INT2_STEP_DELTA see LSM6DSM_ACC_GYRO_INT2_STEP_DELTA_t
  1287. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1288. *******************************************************************************/

  1289. status_t LSM6DSM_ACC_GYRO_R_STEP_DELTA_on_INT2(void *handle, LSM6DSM_ACC_GYRO_INT2_STEP_DELTA_t *value)
  1290. {
  1291. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT2_CTRL, (u8_t *)value) )
  1292.     return MEMS_ERROR;

  1293.   *value &= LSM6DSM_ACC_GYRO_INT2_STEP_DELTA_MASK; //mask

  1294.   return MEMS_SUCCESS;
  1295. }
  1296. /*******************************************************************************
  1297. * Function Name  : LSM6DSM_ACC_GYRO_R_WHO_AM_I
  1298. * Description    : Read WHO_AM_I_BIT
  1299. * Input          : Pointer to u8_t
  1300. * Output         : Status of WHO_AM_I_BIT
  1301. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1302. *******************************************************************************/

  1303. status_t LSM6DSM_ACC_GYRO_R_WHO_AM_I(void *handle, u8_t *value)
  1304. {
  1305. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WHO_AM_I_REG, (u8_t *)value) )
  1306.     return MEMS_ERROR;

  1307.   *value &= LSM6DSM_ACC_GYRO_WHO_AM_I_BIT_MASK; //coerce       
  1308.   *value = *value >> LSM6DSM_ACC_GYRO_WHO_AM_I_BIT_POSITION; //mask       

  1309.   return MEMS_SUCCESS;
  1310. }
  1311. /*******************************************************************************
  1312. * Function Name  : LSM6DSM_ACC_GYRO_W_BW_SEL
  1313. * Description    : Write BW_SEL
  1314. * Input          : LSM6DSM_ACC_GYRO_BW_SEL_t
  1315. * Output         : None
  1316. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1317. *******************************************************************************/
  1318. status_t  LSM6DSM_ACC_GYRO_W_BW_SEL(void *handle, LSM6DSM_ACC_GYRO_BW_SEL_t newValue)
  1319. {
  1320.   u8_t value;

  1321.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL1_XL, &value) )
  1322.     return MEMS_ERROR;

  1323.   value &= ~LSM6DSM_ACC_GYRO_BW_SEL_MASK;
  1324.   value |= newValue;
  1325.   
  1326.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL1_XL, value) )
  1327.     return MEMS_ERROR;

  1328.   return MEMS_SUCCESS;
  1329. }

  1330. /*******************************************************************************
  1331. * Function Name  : LSM6DSM_ACC_GYRO_R_BW_SEL
  1332. * Description    : Read BW_SEL
  1333. * Input          : Pointer to LSM6DSM_ACC_GYRO_BW_SEL_t
  1334. * Output         : Status of BW_SEL see LSM6DSM_ACC_GYRO_BW_SEL_t
  1335. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1336. *******************************************************************************/

  1337. status_t LSM6DSM_ACC_GYRO_R_BW_SEL(void *handle, LSM6DSM_ACC_GYRO_BW_SEL_t *value)
  1338. {
  1339. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL1_XL, (u8_t *)value) )
  1340.     return MEMS_ERROR;

  1341.   *value &= LSM6DSM_ACC_GYRO_BW_SEL_MASK; //mask

  1342.   return MEMS_SUCCESS;
  1343. }
  1344. /*******************************************************************************
  1345. * Function Name  : LSM6DSM_ACC_GYRO_W_FS_XL
  1346. * Description    : Write FS_XL
  1347. * Input          : LSM6DSM_ACC_GYRO_FS_XL_t
  1348. * Output         : None
  1349. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1350. *******************************************************************************/
  1351. status_t  LSM6DSM_ACC_GYRO_W_FS_XL(void *handle, LSM6DSM_ACC_GYRO_FS_XL_t newValue)
  1352. {
  1353.   u8_t value;

  1354.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL1_XL, &value) )
  1355.     return MEMS_ERROR;

  1356.   value &= ~LSM6DSM_ACC_GYRO_FS_XL_MASK;
  1357.   value |= newValue;
  1358.   
  1359.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL1_XL, value) )
  1360.     return MEMS_ERROR;

  1361.   return MEMS_SUCCESS;
  1362. }

  1363. /*******************************************************************************
  1364. * Function Name  : LSM6DSM_ACC_GYRO_R_FS_XL
  1365. * Description    : Read FS_XL
  1366. * Input          : Pointer to LSM6DSM_ACC_GYRO_FS_XL_t
  1367. * Output         : Status of FS_XL see LSM6DSM_ACC_GYRO_FS_XL_t
  1368. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1369. *******************************************************************************/

  1370. status_t LSM6DSM_ACC_GYRO_R_FS_XL(void *handle, LSM6DSM_ACC_GYRO_FS_XL_t *value)
  1371. {
  1372. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL1_XL, (u8_t *)value) )
  1373.     return MEMS_ERROR;

  1374.   *value &= LSM6DSM_ACC_GYRO_FS_XL_MASK; //mask

  1375.   return MEMS_SUCCESS;
  1376. }
  1377. /*******************************************************************************
  1378. * Function Name  : LSM6DSM_ACC_GYRO_W_ODR_XL
  1379. * Description    : Write ODR_XL
  1380. * Input          : LSM6DSM_ACC_GYRO_ODR_XL_t
  1381. * Output         : None
  1382. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1383. *******************************************************************************/
  1384. status_t  LSM6DSM_ACC_GYRO_W_ODR_XL(void *handle, LSM6DSM_ACC_GYRO_ODR_XL_t newValue)
  1385. {
  1386.   u8_t value;

  1387.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL1_XL, &value) )
  1388.     return MEMS_ERROR;

  1389.   value &= ~LSM6DSM_ACC_GYRO_ODR_XL_MASK;
  1390.   value |= newValue;
  1391.   
  1392.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL1_XL, value) )
  1393.     return MEMS_ERROR;

  1394.   return MEMS_SUCCESS;
  1395. }

  1396. /*******************************************************************************
  1397. * Function Name  : LSM6DSM_ACC_GYRO_R_ODR_XL
  1398. * Description    : Read ODR_XL
  1399. * Input          : Pointer to LSM6DSM_ACC_GYRO_ODR_XL_t
  1400. * Output         : Status of ODR_XL see LSM6DSM_ACC_GYRO_ODR_XL_t
  1401. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1402. *******************************************************************************/

  1403. status_t LSM6DSM_ACC_GYRO_R_ODR_XL(void *handle, LSM6DSM_ACC_GYRO_ODR_XL_t *value)
  1404. {
  1405. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL1_XL, (u8_t *)value) )
  1406.     return MEMS_ERROR;

  1407.   *value &= LSM6DSM_ACC_GYRO_ODR_XL_MASK; //mask

  1408.   return MEMS_SUCCESS;
  1409. }

  1410. status_t LSM6DSM_ACC_GYRO_translate_ODR_XL(LSM6DSM_ACC_GYRO_ODR_XL_t value, u16_t *odr_hz_val)
  1411. {
  1412.   switch(value) {
  1413.   case LSM6DSM_ACC_GYRO_ODR_XL_POWER_DOWN:
  1414.     *odr_hz_val = 0;
  1415.     break;

  1416.   case LSM6DSM_ACC_GYRO_ODR_XL_13Hz:
  1417.     *odr_hz_val = 13;
  1418.     break;

  1419.   case LSM6DSM_ACC_GYRO_ODR_XL_26Hz:
  1420.     *odr_hz_val = 26;
  1421.     break;

  1422.   case LSM6DSM_ACC_GYRO_ODR_XL_52Hz:
  1423.     *odr_hz_val = 52;
  1424.     break;

  1425.   case LSM6DSM_ACC_GYRO_ODR_XL_104Hz:
  1426.     *odr_hz_val = 104;
  1427.     break;

  1428.   case LSM6DSM_ACC_GYRO_ODR_XL_208Hz:
  1429.     *odr_hz_val = 208;
  1430.     break;

  1431.   case LSM6DSM_ACC_GYRO_ODR_XL_416Hz:
  1432.     *odr_hz_val = 416;
  1433.     break;

  1434.   case LSM6DSM_ACC_GYRO_ODR_XL_833Hz:
  1435.     *odr_hz_val = 833;
  1436.     break;

  1437.   case LSM6DSM_ACC_GYRO_ODR_XL_1660Hz:
  1438.     *odr_hz_val = 1660;
  1439.     break;

  1440.   default:
  1441.     return MEMS_ERROR;
  1442.   }

  1443.   return MEMS_SUCCESS;
  1444. }

  1445. /*******************************************************************************
  1446. * Function Name  : LSM6DSM_ACC_GYRO_W_FS_125
  1447. * Description    : Write FS_125
  1448. * Input          : LSM6DSM_ACC_GYRO_FS_125_t
  1449. * Output         : None
  1450. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1451. *******************************************************************************/
  1452. status_t  LSM6DSM_ACC_GYRO_W_FS_125(void *handle, LSM6DSM_ACC_GYRO_FS_125_t newValue)
  1453. {
  1454.   u8_t value;

  1455.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL2_G, &value) )
  1456.     return MEMS_ERROR;

  1457.   value &= ~LSM6DSM_ACC_GYRO_FS_125_MASK;
  1458.   value |= newValue;
  1459.   
  1460.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL2_G, value) )
  1461.     return MEMS_ERROR;

  1462.   return MEMS_SUCCESS;
  1463. }

  1464. /*******************************************************************************
  1465. * Function Name  : LSM6DSM_ACC_GYRO_R_FS_125
  1466. * Description    : Read FS_125
  1467. * Input          : Pointer to LSM6DSM_ACC_GYRO_FS_125_t
  1468. * Output         : Status of FS_125 see LSM6DSM_ACC_GYRO_FS_125_t
  1469. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1470. *******************************************************************************/

  1471. status_t LSM6DSM_ACC_GYRO_R_FS_125(void *handle, LSM6DSM_ACC_GYRO_FS_125_t *value)
  1472. {
  1473. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL2_G, (u8_t *)value) )
  1474.     return MEMS_ERROR;

  1475.   *value &= LSM6DSM_ACC_GYRO_FS_125_MASK; //mask

  1476.   return MEMS_SUCCESS;
  1477. }
  1478. /*******************************************************************************
  1479. * Function Name  : LSM6DSM_ACC_GYRO_W_FS_G
  1480. * Description    : Write FS_G
  1481. * Input          : LSM6DSM_ACC_GYRO_FS_G_t
  1482. * Output         : None
  1483. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1484. *******************************************************************************/
  1485. status_t  LSM6DSM_ACC_GYRO_W_FS_G(void *handle, LSM6DSM_ACC_GYRO_FS_G_t newValue)
  1486. {
  1487.   u8_t value;

  1488.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL2_G, &value) )
  1489.     return MEMS_ERROR;

  1490.   value &= ~LSM6DSM_ACC_GYRO_FS_G_MASK;
  1491.   value |= newValue;
  1492.   
  1493.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL2_G, value) )
  1494.     return MEMS_ERROR;

  1495.   return MEMS_SUCCESS;
  1496. }

  1497. /*******************************************************************************
  1498. * Function Name  : LSM6DSM_ACC_GYRO_R_FS_G
  1499. * Description    : Read FS_G
  1500. * Input          : Pointer to LSM6DSM_ACC_GYRO_FS_G_t
  1501. * Output         : Status of FS_G see LSM6DSM_ACC_GYRO_FS_G_t
  1502. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1503. *******************************************************************************/

  1504. status_t LSM6DSM_ACC_GYRO_R_FS_G(void *handle, LSM6DSM_ACC_GYRO_FS_G_t *value)
  1505. {
  1506. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL2_G, (u8_t *)value) )
  1507.     return MEMS_ERROR;

  1508.   *value &= LSM6DSM_ACC_GYRO_FS_G_MASK; //mask

  1509.   return MEMS_SUCCESS;
  1510. }
  1511. /*******************************************************************************
  1512. * Function Name  : LSM6DSM_ACC_GYRO_W_ODR_G
  1513. * Description    : Write ODR_G
  1514. * Input          : LSM6DSM_ACC_GYRO_ODR_G_t
  1515. * Output         : None
  1516. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1517. *******************************************************************************/
  1518. status_t  LSM6DSM_ACC_GYRO_W_ODR_G(void *handle, LSM6DSM_ACC_GYRO_ODR_G_t newValue)
  1519. {
  1520.   u8_t value;

  1521.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL2_G, &value) )
  1522.     return MEMS_ERROR;

  1523.   value &= ~LSM6DSM_ACC_GYRO_ODR_G_MASK;
  1524.   value |= newValue;
  1525.   
  1526.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL2_G, value) )
  1527.     return MEMS_ERROR;

  1528.   return MEMS_SUCCESS;
  1529. }

  1530. /*******************************************************************************
  1531. * Function Name  : LSM6DSM_ACC_GYRO_R_ODR_G
  1532. * Description    : Read ODR_G
  1533. * Input          : Pointer to LSM6DSM_ACC_GYRO_ODR_G_t
  1534. * Output         : Status of ODR_G see LSM6DSM_ACC_GYRO_ODR_G_t
  1535. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1536. *******************************************************************************/

  1537. status_t LSM6DSM_ACC_GYRO_R_ODR_G(void *handle, LSM6DSM_ACC_GYRO_ODR_G_t *value)
  1538. {
  1539. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL2_G, (u8_t *)value) )
  1540.     return MEMS_ERROR;

  1541.   *value &= LSM6DSM_ACC_GYRO_ODR_G_MASK; //mask

  1542.   return MEMS_SUCCESS;
  1543. }

  1544. status_t LSM6DSM_ACC_GYRO_translate_ODR_G(LSM6DSM_ACC_GYRO_ODR_G_t value, u16_t *odr_hz_val)
  1545. {
  1546.   switch(value) {
  1547.   case LSM6DSM_ACC_GYRO_ODR_G_POWER_DOWN:
  1548.     *odr_hz_val = 0;
  1549.     break;

  1550.   case LSM6DSM_ACC_GYRO_ODR_G_13Hz:
  1551.     *odr_hz_val = 13;
  1552.     break;

  1553.   case LSM6DSM_ACC_GYRO_ODR_G_26Hz:
  1554.     *odr_hz_val = 26;
  1555.     break;

  1556.   case LSM6DSM_ACC_GYRO_ODR_G_52Hz:
  1557.     *odr_hz_val = 52;
  1558.     break;

  1559.   case LSM6DSM_ACC_GYRO_ODR_G_104Hz:
  1560.     *odr_hz_val = 104;
  1561.     break;

  1562.   case LSM6DSM_ACC_GYRO_ODR_G_208Hz:
  1563.     *odr_hz_val = 208;
  1564.     break;

  1565.   case LSM6DSM_ACC_GYRO_ODR_G_416Hz:
  1566.     *odr_hz_val = 416;
  1567.     break;

  1568.   case LSM6DSM_ACC_GYRO_ODR_G_833Hz:
  1569.     *odr_hz_val = 833;
  1570.     break;

  1571.   case LSM6DSM_ACC_GYRO_ODR_G_1660Hz:
  1572.     *odr_hz_val = 1660;
  1573.     break;

  1574.   default:
  1575.     return MEMS_ERROR;
  1576.   }

  1577.   return MEMS_SUCCESS;
  1578. }

  1579. /*******************************************************************************
  1580. * Function Name  : LSM6DSM_ACC_GYRO_W_SW_RESET
  1581. * Description    : Write SW_RESET
  1582. * Input          : LSM6DSM_ACC_GYRO_SW_RESET_t
  1583. * Output         : None
  1584. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1585. *******************************************************************************/
  1586. status_t  LSM6DSM_ACC_GYRO_W_SW_RESET(void *handle, LSM6DSM_ACC_GYRO_SW_RESET_t newValue)
  1587. {
  1588.   u8_t value;

  1589.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, &value) )
  1590.     return MEMS_ERROR;

  1591.   value &= ~LSM6DSM_ACC_GYRO_SW_RESET_MASK;
  1592.   value |= newValue;
  1593.   
  1594.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, value) )
  1595.     return MEMS_ERROR;

  1596.   return MEMS_SUCCESS;
  1597. }

  1598. /*******************************************************************************
  1599. * Function Name  : LSM6DSM_ACC_GYRO_R_SW_RESET
  1600. * Description    : Read SW_RESET
  1601. * Input          : Pointer to LSM6DSM_ACC_GYRO_SW_RESET_t
  1602. * Output         : Status of SW_RESET see LSM6DSM_ACC_GYRO_SW_RESET_t
  1603. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1604. *******************************************************************************/

  1605. status_t LSM6DSM_ACC_GYRO_R_SW_RESET(void *handle, LSM6DSM_ACC_GYRO_SW_RESET_t *value)
  1606. {
  1607. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, (u8_t *)value) )
  1608.     return MEMS_ERROR;

  1609.   *value &= LSM6DSM_ACC_GYRO_SW_RESET_MASK; //mask

  1610.   return MEMS_SUCCESS;
  1611. }
  1612. /*******************************************************************************
  1613. * Function Name  : LSM6DSM_ACC_GYRO_W_BLE
  1614. * Description    : Write BLE
  1615. * Input          : LSM6DSM_ACC_GYRO_BLE_t
  1616. * Output         : None
  1617. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1618. *******************************************************************************/
  1619. status_t  LSM6DSM_ACC_GYRO_W_BLE(void *handle, LSM6DSM_ACC_GYRO_BLE_t newValue)
  1620. {
  1621.   u8_t value;

  1622.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, &value) )
  1623.     return MEMS_ERROR;

  1624.   value &= ~LSM6DSM_ACC_GYRO_BLE_MASK;
  1625.   value |= newValue;
  1626.   
  1627.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, value) )
  1628.     return MEMS_ERROR;

  1629.   return MEMS_SUCCESS;
  1630. }

  1631. /*******************************************************************************
  1632. * Function Name  : LSM6DSM_ACC_GYRO_R_BLE
  1633. * Description    : Read BLE
  1634. * Input          : Pointer to LSM6DSM_ACC_GYRO_BLE_t
  1635. * Output         : Status of BLE see LSM6DSM_ACC_GYRO_BLE_t
  1636. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1637. *******************************************************************************/

  1638. status_t LSM6DSM_ACC_GYRO_R_BLE(void *handle, LSM6DSM_ACC_GYRO_BLE_t *value)
  1639. {
  1640. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, (u8_t *)value) )
  1641.     return MEMS_ERROR;

  1642.   *value &= LSM6DSM_ACC_GYRO_BLE_MASK; //mask

  1643.   return MEMS_SUCCESS;
  1644. }
  1645. /*******************************************************************************
  1646. * Function Name  : LSM6DSM_ACC_GYRO_W_IF_Addr_Incr
  1647. * Description    : Write IF_INC
  1648. * Input          : LSM6DSM_ACC_GYRO_IF_INC_t
  1649. * Output         : None
  1650. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1651. *******************************************************************************/
  1652. status_t  LSM6DSM_ACC_GYRO_W_IF_Addr_Incr(void *handle, LSM6DSM_ACC_GYRO_IF_INC_t newValue)
  1653. {
  1654.   u8_t value;

  1655.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, &value) )
  1656.     return MEMS_ERROR;

  1657.   value &= ~LSM6DSM_ACC_GYRO_IF_INC_MASK;
  1658.   value |= newValue;
  1659.   
  1660.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, value) )
  1661.     return MEMS_ERROR;

  1662.   return MEMS_SUCCESS;
  1663. }

  1664. /*******************************************************************************
  1665. * Function Name  : LSM6DSM_ACC_GYRO_R_IF_Addr_Incr
  1666. * Description    : Read IF_INC
  1667. * Input          : Pointer to LSM6DSM_ACC_GYRO_IF_INC_t
  1668. * Output         : Status of IF_INC see LSM6DSM_ACC_GYRO_IF_INC_t
  1669. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1670. *******************************************************************************/

  1671. status_t LSM6DSM_ACC_GYRO_R_IF_Addr_Incr(void *handle, LSM6DSM_ACC_GYRO_IF_INC_t *value)
  1672. {
  1673. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, (u8_t *)value) )
  1674.     return MEMS_ERROR;

  1675.   *value &= LSM6DSM_ACC_GYRO_IF_INC_MASK; //mask

  1676.   return MEMS_SUCCESS;
  1677. }
  1678. /*******************************************************************************
  1679. * Function Name  : LSM6DSM_ACC_GYRO_W_SPI_Mode
  1680. * Description    : Write SIM
  1681. * Input          : LSM6DSM_ACC_GYRO_SIM_t
  1682. * Output         : None
  1683. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1684. *******************************************************************************/
  1685. status_t  LSM6DSM_ACC_GYRO_W_SPI_Mode(void *handle, LSM6DSM_ACC_GYRO_SIM_t newValue)
  1686. {
  1687.   u8_t value;

  1688.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, &value) )
  1689.     return MEMS_ERROR;

  1690.   value &= ~LSM6DSM_ACC_GYRO_SIM_MASK;
  1691.   value |= newValue;
  1692.   
  1693.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, value) )
  1694.     return MEMS_ERROR;

  1695.   return MEMS_SUCCESS;
  1696. }

  1697. /*******************************************************************************
  1698. * Function Name  : LSM6DSM_ACC_GYRO_R_SPI_Mode
  1699. * Description    : Read SIM
  1700. * Input          : Pointer to LSM6DSM_ACC_GYRO_SIM_t
  1701. * Output         : Status of SIM see LSM6DSM_ACC_GYRO_SIM_t
  1702. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1703. *******************************************************************************/

  1704. status_t LSM6DSM_ACC_GYRO_R_SPI_Mode(void *handle, LSM6DSM_ACC_GYRO_SIM_t *value)
  1705. {
  1706. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, (u8_t *)value) )
  1707.     return MEMS_ERROR;

  1708.   *value &= LSM6DSM_ACC_GYRO_SIM_MASK; //mask

  1709.   return MEMS_SUCCESS;
  1710. }
  1711. /*******************************************************************************
  1712. * Function Name  : LSM6DSM_ACC_GYRO_W_PadSel
  1713. * Description    : Write PP_OD
  1714. * Input          : LSM6DSM_ACC_GYRO_PP_OD_t
  1715. * Output         : None
  1716. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1717. *******************************************************************************/
  1718. status_t  LSM6DSM_ACC_GYRO_W_PadSel(void *handle, LSM6DSM_ACC_GYRO_PP_OD_t newValue)
  1719. {
  1720.   u8_t value;

  1721.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, &value) )
  1722.     return MEMS_ERROR;

  1723.   value &= ~LSM6DSM_ACC_GYRO_PP_OD_MASK;
  1724.   value |= newValue;
  1725.   
  1726.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, value) )
  1727.     return MEMS_ERROR;

  1728.   return MEMS_SUCCESS;
  1729. }

  1730. /*******************************************************************************
  1731. * Function Name  : LSM6DSM_ACC_GYRO_R_PadSel
  1732. * Description    : Read PP_OD
  1733. * Input          : Pointer to LSM6DSM_ACC_GYRO_PP_OD_t
  1734. * Output         : Status of PP_OD see LSM6DSM_ACC_GYRO_PP_OD_t
  1735. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1736. *******************************************************************************/

  1737. status_t LSM6DSM_ACC_GYRO_R_PadSel(void *handle, LSM6DSM_ACC_GYRO_PP_OD_t *value)
  1738. {
  1739. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, (u8_t *)value) )
  1740.     return MEMS_ERROR;

  1741.   *value &= LSM6DSM_ACC_GYRO_PP_OD_MASK; //mask

  1742.   return MEMS_SUCCESS;
  1743. }
  1744. /*******************************************************************************
  1745. * Function Name  : LSM6DSM_ACC_GYRO_W_INT_ACT_LEVEL
  1746. * Description    : Write INT_ACT_LEVEL
  1747. * Input          : LSM6DSM_ACC_GYRO_INT_ACT_LEVEL_t
  1748. * Output         : None
  1749. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1750. *******************************************************************************/
  1751. status_t  LSM6DSM_ACC_GYRO_W_INT_ACT_LEVEL(void *handle, LSM6DSM_ACC_GYRO_INT_ACT_LEVEL_t newValue)
  1752. {
  1753.   u8_t value;

  1754.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, &value) )
  1755.     return MEMS_ERROR;

  1756.   value &= ~LSM6DSM_ACC_GYRO_INT_ACT_LEVEL_MASK;
  1757.   value |= newValue;
  1758.   
  1759.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, value) )
  1760.     return MEMS_ERROR;

  1761.   return MEMS_SUCCESS;
  1762. }

  1763. /*******************************************************************************
  1764. * Function Name  : LSM6DSM_ACC_GYRO_R_INT_ACT_LEVEL
  1765. * Description    : Read INT_ACT_LEVEL
  1766. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT_ACT_LEVEL_t
  1767. * Output         : Status of INT_ACT_LEVEL see LSM6DSM_ACC_GYRO_INT_ACT_LEVEL_t
  1768. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1769. *******************************************************************************/

  1770. status_t LSM6DSM_ACC_GYRO_R_INT_ACT_LEVEL(void *handle, LSM6DSM_ACC_GYRO_INT_ACT_LEVEL_t *value)
  1771. {
  1772. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, (u8_t *)value) )
  1773.     return MEMS_ERROR;

  1774.   *value &= LSM6DSM_ACC_GYRO_INT_ACT_LEVEL_MASK; //mask

  1775.   return MEMS_SUCCESS;
  1776. }
  1777. /*******************************************************************************
  1778. * Function Name  : LSM6DSM_ACC_GYRO_W_BDU
  1779. * Description    : Write BDU
  1780. * Input          : LSM6DSM_ACC_GYRO_BDU_t
  1781. * Output         : None
  1782. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1783. *******************************************************************************/
  1784. status_t  LSM6DSM_ACC_GYRO_W_BDU(void *handle, LSM6DSM_ACC_GYRO_BDU_t newValue)
  1785. {
  1786.   u8_t value;

  1787.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, &value) )
  1788.     return MEMS_ERROR;

  1789.   value &= ~LSM6DSM_ACC_GYRO_BDU_MASK;
  1790.   value |= newValue;
  1791.   
  1792.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, value) )
  1793.     return MEMS_ERROR;

  1794.   return MEMS_SUCCESS;
  1795. }

  1796. /*******************************************************************************
  1797. * Function Name  : LSM6DSM_ACC_GYRO_R_BDU
  1798. * Description    : Read BDU
  1799. * Input          : Pointer to LSM6DSM_ACC_GYRO_BDU_t
  1800. * Output         : Status of BDU see LSM6DSM_ACC_GYRO_BDU_t
  1801. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1802. *******************************************************************************/

  1803. status_t LSM6DSM_ACC_GYRO_R_BDU(void *handle, LSM6DSM_ACC_GYRO_BDU_t *value)
  1804. {
  1805. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, (u8_t *)value) )
  1806.     return MEMS_ERROR;

  1807.   *value &= LSM6DSM_ACC_GYRO_BDU_MASK; //mask

  1808.   return MEMS_SUCCESS;
  1809. }
  1810. /*******************************************************************************
  1811. * Function Name  : LSM6DSM_ACC_GYRO_W_BOOT
  1812. * Description    : Write BOOT
  1813. * Input          : LSM6DSM_ACC_GYRO_BOOT_t
  1814. * Output         : None
  1815. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1816. *******************************************************************************/
  1817. status_t  LSM6DSM_ACC_GYRO_W_BOOT(void *handle, LSM6DSM_ACC_GYRO_BOOT_t newValue)
  1818. {
  1819.   u8_t value;

  1820.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, &value) )
  1821.     return MEMS_ERROR;

  1822.   value &= ~LSM6DSM_ACC_GYRO_BOOT_MASK;
  1823.   value |= newValue;
  1824.   
  1825.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, value) )
  1826.     return MEMS_ERROR;

  1827.   return MEMS_SUCCESS;
  1828. }

  1829. /*******************************************************************************
  1830. * Function Name  : LSM6DSM_ACC_GYRO_R_BOOT
  1831. * Description    : Read BOOT
  1832. * Input          : Pointer to LSM6DSM_ACC_GYRO_BOOT_t
  1833. * Output         : Status of BOOT see LSM6DSM_ACC_GYRO_BOOT_t
  1834. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1835. *******************************************************************************/

  1836. status_t LSM6DSM_ACC_GYRO_R_BOOT(void *handle, LSM6DSM_ACC_GYRO_BOOT_t *value)
  1837. {
  1838. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL3_C, (u8_t *)value) )
  1839.     return MEMS_ERROR;

  1840.   *value &= LSM6DSM_ACC_GYRO_BOOT_MASK; //mask

  1841.   return MEMS_SUCCESS;
  1842. }

  1843. /*******************************************************************************
  1844. * Function Name  : LSM6DSM_ACC_GYRO_LPF1_SEL_G
  1845. * Description    : Write LPF1_SEL_G
  1846. * Input          : LSM6DSM_ACC_GYRO_LPF1_SEL_G_t
  1847. * Output         : None
  1848. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1849. *******************************************************************************/
  1850. status_t  LSM6DSM_ACC_GYRO_W_LPF1_SEL_G(void *handle, LSM6DSM_ACC_GYRO_LPF1_SEL_G_t newValue)
  1851. {
  1852.   u8_t value;

  1853.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL4_C, &value) )
  1854.     return MEMS_ERROR;

  1855.   value &= ~LSM6DSM_ACC_GYRO_LPF1_SEL_G_MASK;
  1856.   value |= newValue;
  1857.   
  1858.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL4_C, value) )
  1859.     return MEMS_ERROR;

  1860.   return MEMS_SUCCESS;
  1861. }

  1862. /*******************************************************************************
  1863. * Function Name  : LSM6DSM_ACC_GYRO_LPF1_SEL_G
  1864. * Description    : Read LPF1_SEL_G
  1865. * Input          : Pointer to LSM6DSM_ACC_GYRO_LPF1_SEL_G_t
  1866. * Output         : Status of LPF1_SEL_G see LSM6DSM_ACC_GYRO_LPF1_SEL_G_t
  1867. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1868. *******************************************************************************/

  1869. status_t LSM6DSM_ACC_GYRO_R_LPF1_SEL_G(void *handle, LSM6DSM_ACC_GYRO_LPF1_SEL_G_t *value)
  1870. {
  1871. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL4_C, (u8_t *)value) )
  1872.     return MEMS_ERROR;

  1873.   *value &= LSM6DSM_ACC_GYRO_LPF1_SEL_G_MASK; //mask

  1874.   return MEMS_SUCCESS;
  1875. }
  1876. /*******************************************************************************
  1877. * Function Name  : LSM6DSM_ACC_GYRO_W_I2C_DISABLE
  1878. * Description    : Write I2C_DISABLE
  1879. * Input          : LSM6DSM_ACC_GYRO_I2C_DISABLE_t
  1880. * Output         : None
  1881. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1882. *******************************************************************************/
  1883. status_t  LSM6DSM_ACC_GYRO_W_I2C_DISABLE(void *handle, LSM6DSM_ACC_GYRO_I2C_DISABLE_t newValue)
  1884. {
  1885.   u8_t value;

  1886.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL4_C, &value) )
  1887.     return MEMS_ERROR;

  1888.   value &= ~LSM6DSM_ACC_GYRO_I2C_DISABLE_MASK;
  1889.   value |= newValue;
  1890.   
  1891.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL4_C, value) )
  1892.     return MEMS_ERROR;

  1893.   return MEMS_SUCCESS;
  1894. }

  1895. /*******************************************************************************
  1896. * Function Name  : LSM6DSM_ACC_GYRO_R_I2C_DISABLE
  1897. * Description    : Read I2C_DISABLE
  1898. * Input          : Pointer to LSM6DSM_ACC_GYRO_I2C_DISABLE_t
  1899. * Output         : Status of I2C_DISABLE see LSM6DSM_ACC_GYRO_I2C_DISABLE_t
  1900. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1901. *******************************************************************************/

  1902. status_t LSM6DSM_ACC_GYRO_R_I2C_DISABLE(void *handle, LSM6DSM_ACC_GYRO_I2C_DISABLE_t *value)
  1903. {
  1904. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL4_C, (u8_t *)value) )
  1905.     return MEMS_ERROR;

  1906.   *value &= LSM6DSM_ACC_GYRO_I2C_DISABLE_MASK; //mask

  1907.   return MEMS_SUCCESS;
  1908. }
  1909. /*******************************************************************************
  1910. * Function Name  : LSM6DSM_ACC_GYRO_W_DRDY_MSK
  1911. * Description    : Write DRDY_MSK
  1912. * Input          : LSM6DSM_ACC_GYRO_DRDY_MSK_t
  1913. * Output         : None
  1914. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1915. *******************************************************************************/
  1916. status_t  LSM6DSM_ACC_GYRO_W_DRDY_MSK(void *handle, LSM6DSM_ACC_GYRO_DRDY_MSK_t newValue)
  1917. {
  1918.   u8_t value;

  1919.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL4_C, &value) )
  1920.     return MEMS_ERROR;

  1921.   value &= ~LSM6DSM_ACC_GYRO_DRDY_MSK_MASK;
  1922.   value |= newValue;
  1923.   
  1924.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL4_C, value) )
  1925.     return MEMS_ERROR;

  1926.   return MEMS_SUCCESS;
  1927. }

  1928. /*******************************************************************************
  1929. * Function Name  : LSM6DSM_ACC_GYRO_R_DRDY_MSK
  1930. * Description    : Read DRDY_MSK
  1931. * Input          : Pointer to LSM6DSM_ACC_GYRO_DRDY_MSK_t
  1932. * Output         : Status of DRDY_MSK see LSM6DSM_ACC_GYRO_DRDY_MSK_t
  1933. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1934. *******************************************************************************/

  1935. status_t LSM6DSM_ACC_GYRO_R_DRDY_MSK(void *handle, LSM6DSM_ACC_GYRO_DRDY_MSK_t *value)
  1936. {
  1937. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL4_C, (u8_t *)value) )
  1938.     return MEMS_ERROR;

  1939.   *value &= LSM6DSM_ACC_GYRO_DRDY_MSK_MASK; //mask

  1940.   return MEMS_SUCCESS;
  1941. }

  1942. /*******************************************************************************
  1943. * Function Name  : LSM6DSM_ACC_GYRO_W_INT2_ON_INT1
  1944. * Description    : Write INT2_ON_INT1
  1945. * Input          : LSM6DSM_ACC_GYRO_INT2_ON_INT1_t
  1946. * Output         : None
  1947. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1948. *******************************************************************************/
  1949. status_t  LSM6DSM_ACC_GYRO_W_INT2_ON_INT1(void *handle, LSM6DSM_ACC_GYRO_INT2_ON_INT1_t newValue)
  1950. {
  1951.   u8_t value;

  1952.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL4_C, &value) )
  1953.     return MEMS_ERROR;

  1954.   value &= ~LSM6DSM_ACC_GYRO_INT2_ON_INT1_MASK;
  1955.   value |= newValue;
  1956.   
  1957.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL4_C, value) )
  1958.     return MEMS_ERROR;

  1959.   return MEMS_SUCCESS;
  1960. }

  1961. /*******************************************************************************
  1962. * Function Name  : LSM6DSM_ACC_GYRO_R_INT2_ON_INT1
  1963. * Description    : Read INT2_ON_INT1
  1964. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_ON_INT1_t
  1965. * Output         : Status of INT2_ON_INT1 see LSM6DSM_ACC_GYRO_INT2_ON_INT1_t
  1966. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1967. *******************************************************************************/

  1968. status_t LSM6DSM_ACC_GYRO_R_INT2_ON_INT1(void *handle, LSM6DSM_ACC_GYRO_INT2_ON_INT1_t *value)
  1969. {
  1970. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL4_C, (u8_t *)value) )
  1971.     return MEMS_ERROR;

  1972.   *value &= LSM6DSM_ACC_GYRO_INT2_ON_INT1_MASK; //mask

  1973.   return MEMS_SUCCESS;
  1974. }
  1975. /*******************************************************************************
  1976. * Function Name  : LSM6DSM_ACC_GYRO_W_SleepMode_G
  1977. * Description    : Write SLEEP_G
  1978. * Input          : LSM6DSM_ACC_GYRO_SLEEP_G_t
  1979. * Output         : None
  1980. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  1981. *******************************************************************************/
  1982. status_t  LSM6DSM_ACC_GYRO_W_SleepMode_G(void *handle, LSM6DSM_ACC_GYRO_SLEEP_G_t newValue)
  1983. {
  1984.   u8_t value;

  1985.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL4_C, &value) )
  1986.     return MEMS_ERROR;

  1987.   value &= ~LSM6DSM_ACC_GYRO_SLEEP_G_MASK;
  1988.   value |= newValue;
  1989.   
  1990.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL4_C, value) )
  1991.     return MEMS_ERROR;

  1992.   return MEMS_SUCCESS;
  1993. }

  1994. /*******************************************************************************
  1995. * Function Name  : LSM6DSM_ACC_GYRO_R_SleepMode_G
  1996. * Description    : Read SLEEP_G
  1997. * Input          : Pointer to LSM6DSM_ACC_GYRO_SLEEP_G_t
  1998. * Output         : Status of SLEEP_G see LSM6DSM_ACC_GYRO_SLEEP_G_t
  1999. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2000. *******************************************************************************/

  2001. status_t LSM6DSM_ACC_GYRO_R_SleepMode_G(void *handle, LSM6DSM_ACC_GYRO_SLEEP_G_t *value)
  2002. {
  2003. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL4_C, (u8_t *)value) )
  2004.     return MEMS_ERROR;

  2005.   *value &= LSM6DSM_ACC_GYRO_SLEEP_G_MASK; //mask

  2006.   return MEMS_SUCCESS;
  2007. }

  2008. /*******************************************************************************
  2009. * Function Name  : LSM6DSM_ACC_GYRO_W_SelfTest_XL
  2010. * Description    : Write ST_XL
  2011. * Input          : LSM6DSM_ACC_GYRO_ST_XL_t
  2012. * Output         : None
  2013. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2014. *******************************************************************************/
  2015. status_t  LSM6DSM_ACC_GYRO_W_SelfTest_XL(void *handle, LSM6DSM_ACC_GYRO_ST_XL_t newValue)
  2016. {
  2017.   u8_t value;

  2018.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL5_C, &value) )
  2019.     return MEMS_ERROR;

  2020.   value &= ~LSM6DSM_ACC_GYRO_ST_XL_MASK;
  2021.   value |= newValue;
  2022.   
  2023.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL5_C, value) )
  2024.     return MEMS_ERROR;

  2025.   return MEMS_SUCCESS;
  2026. }

  2027. /*******************************************************************************
  2028. * Function Name  : LSM6DSM_ACC_GYRO_R_SelfTest_XL
  2029. * Description    : Read ST_XL
  2030. * Input          : Pointer to LSM6DSM_ACC_GYRO_ST_XL_t
  2031. * Output         : Status of ST_XL see LSM6DSM_ACC_GYRO_ST_XL_t
  2032. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2033. *******************************************************************************/

  2034. status_t LSM6DSM_ACC_GYRO_R_SelfTest_XL(void *handle, LSM6DSM_ACC_GYRO_ST_XL_t *value)
  2035. {
  2036. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL5_C, (u8_t *)value) )
  2037.     return MEMS_ERROR;

  2038.   *value &= LSM6DSM_ACC_GYRO_ST_XL_MASK; //mask

  2039.   return MEMS_SUCCESS;
  2040. }
  2041. /*******************************************************************************
  2042. * Function Name  : LSM6DSM_ACC_GYRO_W_SelfTest_G
  2043. * Description    : Write ST_G
  2044. * Input          : LSM6DSM_ACC_GYRO_ST_G_t
  2045. * Output         : None
  2046. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2047. *******************************************************************************/
  2048. status_t  LSM6DSM_ACC_GYRO_W_SelfTest_G(void *handle, LSM6DSM_ACC_GYRO_ST_G_t newValue)
  2049. {
  2050.   u8_t value;

  2051.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL5_C, &value) )
  2052.     return MEMS_ERROR;

  2053.   value &= ~LSM6DSM_ACC_GYRO_ST_G_MASK;
  2054.   value |= newValue;
  2055.   
  2056.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL5_C, value) )
  2057.     return MEMS_ERROR;

  2058.   return MEMS_SUCCESS;
  2059. }

  2060. /*******************************************************************************
  2061. * Function Name  : LSM6DSM_ACC_GYRO_R_SelfTest_G
  2062. * Description    : Read ST_G
  2063. * Input          : Pointer to LSM6DSM_ACC_GYRO_ST_G_t
  2064. * Output         : Status of ST_G see LSM6DSM_ACC_GYRO_ST_G_t
  2065. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2066. *******************************************************************************/

  2067. status_t LSM6DSM_ACC_GYRO_R_SelfTest_G(void *handle, LSM6DSM_ACC_GYRO_ST_G_t *value)
  2068. {
  2069. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL5_C, (u8_t *)value) )
  2070.     return MEMS_ERROR;

  2071.   *value &= LSM6DSM_ACC_GYRO_ST_G_MASK; //mask

  2072.   return MEMS_SUCCESS;
  2073. }

  2074. /*******************************************************************************
  2075. * Function Name  : LSM6DSM_ACC_GYRO_W_DEN_Polarity
  2076. * Description    : Write DEN_LH
  2077. * Input          : LSM6DSM_ACC_GYRO_DEN_LH_t
  2078. * Output         : None
  2079. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2080. *******************************************************************************/
  2081. status_t  LSM6DSM_ACC_GYRO_W_DEN_Polarity(void *handle, LSM6DSM_ACC_GYRO_DEN_LH_t newValue)
  2082. {
  2083.   u8_t value;

  2084.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL5_C, &value) )
  2085.     return MEMS_ERROR;

  2086.   value &= ~LSM6DSM_ACC_GYRO_DEN_LH_MASK;
  2087.   value |= newValue;
  2088.   
  2089.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL5_C, value) )
  2090.     return MEMS_ERROR;

  2091.   return MEMS_SUCCESS;
  2092. }

  2093. /*******************************************************************************
  2094. * Function Name  : LSM6DSM_ACC_GYRO_R_DEN_Polarity
  2095. * Description    : Read DEN_LH
  2096. * Input          : Pointer to LSM6DSM_ACC_GYRO_DEN_LH_t
  2097. * Output         : Status of DEN_LH see LSM6DSM_ACC_GYRO_DEN_LH_t
  2098. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2099. *******************************************************************************/

  2100. status_t LSM6DSM_ACC_GYRO_R_DEN_Polarity(void *handle, LSM6DSM_ACC_GYRO_DEN_LH_t *value)
  2101. {
  2102. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL5_C, (u8_t *)value) )
  2103.     return MEMS_ERROR;

  2104.   *value &= LSM6DSM_ACC_GYRO_DEN_LH_MASK; //mask

  2105.   return MEMS_SUCCESS;
  2106. }

  2107. /*******************************************************************************
  2108. * Function Name  : LSM6DSM_ACC_GYRO_W_CircularBurstMode
  2109. * Description    : Write ST_ROUNDING
  2110. * Input          : LSM6DSM_ACC_GYRO_ROUNDING_t
  2111. * Output         : None
  2112. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2113. *******************************************************************************/
  2114. status_t  LSM6DSM_ACC_GYRO_W_CircularBurstMode(void *handle, LSM6DSM_ACC_GYRO_ROUNDING_t newValue)
  2115. {
  2116.   u8_t value;

  2117.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL5_C, &value) )
  2118.     return MEMS_ERROR;

  2119.   value &= ~LSM6DSM_ACC_GYRO_LSM6DSM_ACC_GYRO_ROUNDING_t_MASK;
  2120.   value |= newValue;
  2121.   
  2122.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL5_C, value) )
  2123.     return MEMS_ERROR;

  2124.   return MEMS_SUCCESS;
  2125. }

  2126. /*******************************************************************************
  2127. * Function Name  : LSM6DSM_ACC_GYRO_R_CircularBurstMode
  2128. * Description    : Read ST_ROUNDING
  2129. * Input          : Pointer to LSM6DSM_ACC_GYRO_ROUNDING_t
  2130. * Output         : Status of ST_ROUNDING see LSM6DSM_ACC_GYRO_ROUNDING_t
  2131. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2132. *******************************************************************************/

  2133. status_t LSM6DSM_ACC_GYRO_R_CircularBurstMode(void *handle, LSM6DSM_ACC_GYRO_ROUNDING_t *value)
  2134. {
  2135. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL5_C, (u8_t *)value) )
  2136.     return MEMS_ERROR;

  2137.   *value &= LSM6DSM_ACC_GYRO_LSM6DSM_ACC_GYRO_ROUNDING_t_MASK; //mask

  2138.   return MEMS_SUCCESS;
  2139. }

  2140. /*******************************************************************************
  2141. * Function Name  : LSM6DSM_ACC_GYRO_W_LP_BW_G
  2142. * Description    : Write FTYPE
  2143. * Input          : LSM6DSM_ACC_GYRO_FTYPE_t
  2144. * Output         : None
  2145. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2146. *******************************************************************************/
  2147. status_t  LSM6DSM_ACC_GYRO_W_LP_BW_G(void *handle, LSM6DSM_ACC_GYRO_FTYPE_t newValue)
  2148. {
  2149.   u8_t value;

  2150.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, &value) )
  2151.     return MEMS_ERROR;

  2152.   value &= ~LSM6DSM_ACC_GYRO_FTYPE_MASK;
  2153.   value |= newValue;
  2154.   
  2155.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, value) )
  2156.     return MEMS_ERROR;

  2157.   return MEMS_SUCCESS;
  2158. }

  2159. /*******************************************************************************
  2160. * Function Name  : LSM6DSM_ACC_GYRO_R_LP_BW_G
  2161. * Description    : Read FTYPE
  2162. * Input          : Pointer to LSM6DSM_ACC_GYRO_FTYPE_t
  2163. * Output         : Status of FTYPE see LSM6DSM_ACC_GYRO_FTYPE_t
  2164. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2165. *******************************************************************************/

  2166. status_t LSM6DSM_ACC_GYRO_R_LP_BW_G(void *handle, LSM6DSM_ACC_GYRO_FTYPE_t *value)
  2167. {
  2168. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, (u8_t *)value) )
  2169.     return MEMS_ERROR;

  2170.   *value &= LSM6DSM_ACC_GYRO_FTYPE_MASK; //mask

  2171.   return MEMS_SUCCESS;
  2172. }

  2173. /*******************************************************************************
  2174. * Function Name  : LSM6DSM_ACC_GYRO_W_UserOffsetWeight
  2175. * Description    : Write USR_OFF_W
  2176. * Input          : LSM6DSM_ACC_GYRO_USR_OFF_W_t
  2177. * Output         : None
  2178. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2179. *******************************************************************************/
  2180. status_t  LSM6DSM_ACC_GYRO_W_UserOffsetWeight(void *handle, LSM6DSM_ACC_GYRO_USR_OFF_W_t newValue)
  2181. {
  2182.   u8_t value;

  2183.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, &value) )
  2184.     return MEMS_ERROR;

  2185.   value &= ~LSM6DSM_ACC_GYRO_USR_OFF_W_MASK;
  2186.   value |= newValue;
  2187.   
  2188.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, value) )
  2189.     return MEMS_ERROR;

  2190.   return MEMS_SUCCESS;
  2191. }

  2192. /*******************************************************************************
  2193. * Function Name  : LSM6DSM_ACC_GYRO_R_UserOffsetWeight
  2194. * Description    : Read USR_OFF_W
  2195. * Input          : Pointer to LSM6DSM_ACC_GYRO_USR_OFF_W_t
  2196. * Output         : Status of USR_OFF_W see LSM6DSM_ACC_GYRO_USR_OFF_W_t
  2197. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2198. *******************************************************************************/

  2199. status_t LSM6DSM_ACC_GYRO_R_UserOffsetWeight(void *handle, LSM6DSM_ACC_GYRO_USR_OFF_W_t *value)
  2200. {
  2201. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, (u8_t *)value) )
  2202.     return MEMS_ERROR;

  2203.   *value &= LSM6DSM_ACC_GYRO_USR_OFF_W_MASK; //mask

  2204.   return MEMS_SUCCESS;
  2205. }

  2206. /*******************************************************************************
  2207. * Function Name  : LSM6DSM_ACC_GYRO_W_LowPower_XL
  2208. * Description    : Write LP_XL
  2209. * Input          : LSM6DSM_ACC_GYRO_LP_XL_t
  2210. * Output         : None
  2211. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2212. *******************************************************************************/
  2213. status_t  LSM6DSM_ACC_GYRO_W_LowPower_XL(void *handle, LSM6DSM_ACC_GYRO_LP_XL_t newValue)
  2214. {
  2215.   u8_t value;

  2216.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, &value) )
  2217.     return MEMS_ERROR;

  2218.   value &= ~LSM6DSM_ACC_GYRO_LP_XL_MASK;
  2219.   value |= newValue;
  2220.   
  2221.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, value) )
  2222.     return MEMS_ERROR;

  2223.   return MEMS_SUCCESS;
  2224. }

  2225. /*******************************************************************************
  2226. * Function Name  : LSM6DSM_ACC_GYRO_R_LowPower_XL
  2227. * Description    : Read LP_XL
  2228. * Input          : Pointer to LSM6DSM_ACC_GYRO_LP_XL_t
  2229. * Output         : Status of LP_XL see LSM6DSM_ACC_GYRO_LP_XL_t
  2230. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2231. *******************************************************************************/

  2232. status_t LSM6DSM_ACC_GYRO_R_LowPower_XL(void *handle, LSM6DSM_ACC_GYRO_LP_XL_t *value)
  2233. {
  2234. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, (u8_t *)value) )
  2235.     return MEMS_ERROR;

  2236.   *value &= LSM6DSM_ACC_GYRO_LP_XL_MASK; //mask

  2237.   return MEMS_SUCCESS;
  2238. }
  2239. /*******************************************************************************
  2240. * Function Name  : LSM6DSM_ACC_GYRO_W_DEN_LVL2_EN
  2241. * Description    : Write DEN_LVL2_EN
  2242. * Input          : LSM6DSM_ACC_GYRO_DEN_LVL2_EN_t
  2243. * Output         : None
  2244. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2245. *******************************************************************************/
  2246. status_t  LSM6DSM_ACC_GYRO_W_DEN_LVL2_EN(void *handle, LSM6DSM_ACC_GYRO_DEN_LVL2_EN_t newValue)
  2247. {
  2248.   u8_t value;

  2249.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, &value) )
  2250.     return MEMS_ERROR;

  2251.   value &= ~LSM6DSM_ACC_GYRO_DEN_LVL2_EN_MASK;
  2252.   value |= newValue;
  2253.   
  2254.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, value) )
  2255.     return MEMS_ERROR;

  2256.   return MEMS_SUCCESS;
  2257. }

  2258. /*******************************************************************************
  2259. * Function Name  : LSM6DSM_ACC_GYRO_R_DEN_LVL2_EN
  2260. * Description    : Read DEN_LVL2_EN
  2261. * Input          : Pointer to LSM6DSM_ACC_GYRO_DEN_LVL2_EN_t
  2262. * Output         : Status of DEN_LVL2_EN see LSM6DSM_ACC_GYRO_DEN_LVL2_EN_t
  2263. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2264. *******************************************************************************/

  2265. status_t LSM6DSM_ACC_GYRO_R_DEN_LVL2_EN(void *handle, LSM6DSM_ACC_GYRO_DEN_LVL2_EN_t *value)
  2266. {
  2267. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, (u8_t *)value) )
  2268.     return MEMS_ERROR;

  2269.   *value &= LSM6DSM_ACC_GYRO_DEN_LVL2_EN_MASK; //mask

  2270.   return MEMS_SUCCESS;
  2271. }
  2272. /*******************************************************************************
  2273. * Function Name  : LSM6DSM_ACC_GYRO_W_DEN_LVL_EN
  2274. * Description    : Write DEN_LVL_EN
  2275. * Input          : LSM6DSM_ACC_GYRO_DEN_LVL_EN_t
  2276. * Output         : None
  2277. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2278. *******************************************************************************/
  2279. status_t  LSM6DSM_ACC_GYRO_W_DEN_LVL_EN(void *handle, LSM6DSM_ACC_GYRO_DEN_LVL_EN_t newValue)
  2280. {
  2281.   u8_t value;

  2282.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, &value) )
  2283.     return MEMS_ERROR;

  2284.   value &= ~LSM6DSM_ACC_GYRO_DEN_LVL_EN_MASK;
  2285.   value |= newValue;
  2286.   
  2287.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, value) )
  2288.     return MEMS_ERROR;

  2289.   return MEMS_SUCCESS;
  2290. }

  2291. /*******************************************************************************
  2292. * Function Name  : LSM6DSM_ACC_GYRO_R_DEN_LVL_EN
  2293. * Description    : Read DEN_LVL_EN
  2294. * Input          : Pointer to LSM6DSM_ACC_GYRO_DEN_LVL_EN_t
  2295. * Output         : Status of DEN_LVL_EN see LSM6DSM_ACC_GYRO_DEN_LVL_EN_t
  2296. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2297. *******************************************************************************/

  2298. status_t LSM6DSM_ACC_GYRO_R_DEN_LVL_EN(void *handle, LSM6DSM_ACC_GYRO_DEN_LVL_EN_t *value)
  2299. {
  2300. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, (u8_t *)value) )
  2301.     return MEMS_ERROR;

  2302.   *value &= LSM6DSM_ACC_GYRO_DEN_LVL_EN_MASK; //mask

  2303.   return MEMS_SUCCESS;
  2304. }
  2305. /*******************************************************************************
  2306. * Function Name  : LSM6DSM_ACC_GYRO_W_ExternalTrigger
  2307. * Description    : Write DEN_EDGE_EN
  2308. * Input          : LSM6DSM_ACC_GYRO_DEN_EDGE_EN_t
  2309. * Output         : None
  2310. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2311. *******************************************************************************/
  2312. status_t  LSM6DSM_ACC_GYRO_W_ExternalTrigger(void *handle, LSM6DSM_ACC_GYRO_DEN_EDGE_EN_t newValue)
  2313. {
  2314.   u8_t value;

  2315.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, &value) )
  2316.     return MEMS_ERROR;

  2317.   value &= ~LSM6DSM_ACC_GYRO_DEN_EDGE_EN_MASK;
  2318.   value |= newValue;
  2319.   
  2320.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, value) )
  2321.     return MEMS_ERROR;

  2322.   return MEMS_SUCCESS;
  2323. }

  2324. /*******************************************************************************
  2325. * Function Name  : LSM6DSM_ACC_GYRO_R_ExternalTrigger
  2326. * Description    : Read DEN_EDGE_EN
  2327. * Input          : Pointer to LSM6DSM_ACC_GYRO_DEN_EDGE_EN_t
  2328. * Output         : Status of DEN_EDGE_EN see LSM6DSM_ACC_GYRO_DEN_EDGE_EN_t
  2329. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2330. *******************************************************************************/

  2331. status_t LSM6DSM_ACC_GYRO_R_ExternalTrigger(void *handle, LSM6DSM_ACC_GYRO_DEN_EDGE_EN_t *value)
  2332. {
  2333. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL6_G, (u8_t *)value) )
  2334.     return MEMS_ERROR;

  2335.   *value &= LSM6DSM_ACC_GYRO_DEN_EDGE_EN_MASK; //mask

  2336.   return MEMS_SUCCESS;
  2337. }

  2338. /*******************************************************************************
  2339. * Function Name  : LSM6DSM_ACC_GYRO_W_HPM_G
  2340. * Description    : Write HPM_G
  2341. * Input          : LSM6DSM_ACC_GYRO_HPM_G_t
  2342. * Output         : None
  2343. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2344. *******************************************************************************/
  2345. status_t  LSM6DSM_ACC_GYRO_W_HPM_G(void *handle, LSM6DSM_ACC_GYRO_HPM_G_t newValue)
  2346. {
  2347.   u8_t value;

  2348.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, &value) )
  2349.     return MEMS_ERROR;

  2350.   value &= ~LSM6DSM_ACC_GYRO_HPM_G_MASK;
  2351.   value |= newValue;
  2352.   
  2353.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, value) )
  2354.     return MEMS_ERROR;

  2355.   return MEMS_SUCCESS;
  2356. }

  2357. /*******************************************************************************
  2358. * Function Name  : LSM6DSM_ACC_GYRO_R_HPM_G
  2359. * Description    : Read HPM_G
  2360. * Input          : Pointer to LSM6DSM_ACC_GYRO_HPM_G_t
  2361. * Output         : Status of HPM_G see LSM6DSM_ACC_GYRO_HPM_G_t
  2362. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2363. *******************************************************************************/

  2364. status_t LSM6DSM_ACC_GYRO_R_HPM_G(void *handle, LSM6DSM_ACC_GYRO_HPM_G_t *value)
  2365. {
  2366. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, (u8_t *)value) )
  2367.     return MEMS_ERROR;

  2368.   *value &= LSM6DSM_ACC_GYRO_HPM_G_MASK; //mask

  2369.   return MEMS_SUCCESS;
  2370. }

  2371. /*******************************************************************************
  2372. * Function Name  : LSM6DSM_ACC_GYRO_W_RoundingOnStatusRegisters
  2373. * Description    : Write HPM_G
  2374. * Input          : LSM6DSM_ACC_GYRO_RND_status_t
  2375. * Output         : None
  2376. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2377. *******************************************************************************/
  2378. status_t  LSM6DSM_ACC_GYRO_W_RoundingOnStatusRegisters(void *handle, LSM6DSM_ACC_GYRO_RND_STATUS_t newValue)
  2379. {
  2380.   u8_t value;

  2381.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, &value) )
  2382.     return MEMS_ERROR;

  2383.   value &= ~LSM6DSM_ACC_GYRO_RND_STATUS_MASK;
  2384.   value |= newValue;
  2385.   
  2386.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, value) )
  2387.     return MEMS_ERROR;

  2388.   return MEMS_SUCCESS;
  2389. }

  2390. /*******************************************************************************
  2391. * Function Name  : LSM6DSM_ACC_GYRO_R_RoundingOnStatusRegisters
  2392. * Description    : Read HPM_G
  2393. * Input          : Pointer to LSM6DSM_ACC_GYRO_RND_status_t
  2394. * Output         : Status of HPM_G see LSM6DSM_ACC_GYRO_RND_status_t
  2395. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2396. *******************************************************************************/

  2397. status_t LSM6DSM_ACC_GYRO_R_RoundingOnStatusRegisters(void *handle, LSM6DSM_ACC_GYRO_RND_STATUS_t *value)
  2398. {
  2399. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, (u8_t *)value) )
  2400.     return MEMS_ERROR;

  2401.   *value &= LSM6DSM_ACC_GYRO_RND_STATUS_MASK; //mask

  2402.   return MEMS_SUCCESS;
  2403. }

  2404. /*******************************************************************************
  2405. * Function Name  : LSM6DSM_ACC_GYRO_W_HPFilter_En
  2406. * Description    : Write HP_EN
  2407. * Input          : LSM6DSM_ACC_GYRO_HP_EN_t
  2408. * Output         : None
  2409. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2410. *******************************************************************************/
  2411. status_t  LSM6DSM_ACC_GYRO_W_HPFilter_En(void *handle, LSM6DSM_ACC_GYRO_HP_EN_t newValue)
  2412. {
  2413.   u8_t value;

  2414.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, &value) )
  2415.     return MEMS_ERROR;

  2416.   value &= ~LSM6DSM_ACC_GYRO_HP_EN_MASK;
  2417.   value |= newValue;
  2418.   
  2419.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, value) )
  2420.     return MEMS_ERROR;

  2421.   return MEMS_SUCCESS;
  2422. }

  2423. /*******************************************************************************
  2424. * Function Name  : LSM6DSM_ACC_GYRO_R_HPFilter_En
  2425. * Description    : Read HP_EN
  2426. * Input          : Pointer to LSM6DSM_ACC_GYRO_HP_EN_t
  2427. * Output         : Status of HP_EN see LSM6DSM_ACC_GYRO_HP_EN_t
  2428. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2429. *******************************************************************************/

  2430. status_t LSM6DSM_ACC_GYRO_R_HPFilter_En(void *handle, LSM6DSM_ACC_GYRO_HP_EN_t *value)
  2431. {
  2432. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, (u8_t *)value) )
  2433.     return MEMS_ERROR;

  2434.   *value &= LSM6DSM_ACC_GYRO_HP_EN_MASK; //mask

  2435.   return MEMS_SUCCESS;
  2436. }
  2437. /*******************************************************************************
  2438. * Function Name  : LSM6DSM_ACC_GYRO_W_LP_Mode
  2439. * Description    : Write LP_EN
  2440. * Input          : LSM6DSM_ACC_GYRO_LP_EN_t
  2441. * Output         : None
  2442. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2443. *******************************************************************************/
  2444. status_t  LSM6DSM_ACC_GYRO_W_LP_Mode(void *handle, LSM6DSM_ACC_GYRO_LP_EN_t newValue)
  2445. {
  2446.   u8_t value;

  2447.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, &value) )
  2448.     return MEMS_ERROR;

  2449.   value &= ~LSM6DSM_ACC_GYRO_LP_EN_MASK;
  2450.   value |= newValue;
  2451.   
  2452.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, value) )
  2453.     return MEMS_ERROR;

  2454.   return MEMS_SUCCESS;
  2455. }

  2456. /*******************************************************************************
  2457. * Function Name  : LSM6DSM_ACC_GYRO_R_LP_Mode
  2458. * Description    : Read LP_EN
  2459. * Input          : Pointer to LSM6DSM_ACC_GYRO_LP_EN_t
  2460. * Output         : Status of LP_EN see LSM6DSM_ACC_GYRO_LP_EN_t
  2461. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2462. *******************************************************************************/

  2463. status_t LSM6DSM_ACC_GYRO_R_LP_Mode(void *handle, LSM6DSM_ACC_GYRO_LP_EN_t *value)
  2464. {
  2465. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, (u8_t *)value) )
  2466.     return MEMS_ERROR;

  2467.   *value &= LSM6DSM_ACC_GYRO_LP_EN_MASK; //mask

  2468.   return MEMS_SUCCESS;
  2469. }

  2470. /*******************************************************************************
  2471. * Function Name  : LSM6DSM_ACC_GYRO_W_ROUNDING_STATUS
  2472. * Description    : Write ROUNDING_STATUS
  2473. * Input          : LSM6DSM_ACC_GYRO_ROUNDING_status_t
  2474. * Output         : None
  2475. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2476. *******************************************************************************/
  2477. status_t  LSM6DSM_ACC_GYRO_W_ROUNDING_STATUS(void *handle, LSM6DSM_ACC_GYRO_ROUNDING_STATUS_t newValue)
  2478. {
  2479.   u8_t value;

  2480.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, &value) )
  2481.     return MEMS_ERROR;

  2482.   value &= ~LSM6DSM_ACC_GYRO_ROUNDING_STATUS_MASK;
  2483.   value |= newValue;
  2484.   
  2485.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, value) )
  2486.     return MEMS_ERROR;

  2487.   return MEMS_SUCCESS;
  2488. }

  2489. /*******************************************************************************
  2490. * Function Name  : LSM6DSM_ACC_GYRO_R_ROUNDING_STATUS
  2491. * Description    : Read ROUNDING_STATUS
  2492. * Input          : Pointer to LSM6DSM_ACC_GYRO_ROUNDING_status_t
  2493. * Output         : Status of ROUNDING_STATUS see LSM6DSM_ACC_GYRO_ROUNDING_status_t
  2494. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2495. *******************************************************************************/

  2496. status_t LSM6DSM_ACC_GYRO_R_ROUNDING_STATUS(void *handle, LSM6DSM_ACC_GYRO_ROUNDING_STATUS_t *value)
  2497. {
  2498. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, (u8_t *)value) )
  2499.     return MEMS_ERROR;

  2500.   *value &= LSM6DSM_ACC_GYRO_ROUNDING_STATUS_MASK; //mask

  2501.   return MEMS_SUCCESS;
  2502. }

  2503. /*******************************************************************************
  2504. * Function Name  : LSM6DSM_ACC_GYRO_W_HP_G_RST
  2505. * Description    : Write HP_G_RST
  2506. * Input          : LSM6DSM_ACC_GYRO_HP_G_RST_t
  2507. * Output         : None
  2508. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2509. *******************************************************************************/
  2510. status_t  LSM6DSM_ACC_GYRO_W_HP_G_RST(void *handle, LSM6DSM_ACC_GYRO_HP_G_RST_t newValue)
  2511. {
  2512.   u8_t value;

  2513.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, &value) )
  2514.     return MEMS_ERROR;

  2515.   value &= ~LSM6DSM_ACC_GYRO_HP_G_RST_MASK;
  2516.   value |= newValue;
  2517.   
  2518.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, value) )
  2519.     return MEMS_ERROR;

  2520.   return MEMS_SUCCESS;
  2521. }

  2522. /*******************************************************************************
  2523. * Function Name  : LSM6DSM_ACC_GYRO_R_HP_G_RST
  2524. * Description    : Read HP_G_RST
  2525. * Input          : Pointer to LSM6DSM_ACC_GYRO_HP_G_RST_t
  2526. * Output         : Status of HP_G_RST see LSM6DSM_ACC_GYRO_HP_G_RST_t
  2527. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2528. *******************************************************************************/

  2529. status_t LSM6DSM_ACC_GYRO_R_HP_G_RST(void *handle, LSM6DSM_ACC_GYRO_HP_G_RST_t *value)
  2530. {
  2531. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL7_G, (u8_t *)value) )
  2532.     return MEMS_ERROR;

  2533.   *value &= LSM6DSM_ACC_GYRO_HP_G_RST_MASK; //mask

  2534.   return MEMS_SUCCESS;
  2535. }

  2536. /*******************************************************************************
  2537. * Function Name  : LSM6DSM_ACC_GYRO_W_InComposit
  2538. * Description    : Write INPUT_COMPOSITE
  2539. * Input          : LSM6DSM_ACC_GYRO_IN_COMP_t
  2540. * Output         : None
  2541. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2542. *******************************************************************************/
  2543. status_t  LSM6DSM_ACC_GYRO_W_InComposit(void *handle, LSM6DSM_ACC_GYRO_IN_COMP_t newValue)
  2544. {
  2545.   u8_t value;

  2546.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, &value) )
  2547.     return MEMS_ERROR;

  2548.   value &= ~LSM6DSM_ACC_GYRO_IN_COMP_MASK;
  2549.   value |= newValue;
  2550.   
  2551.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, value) )
  2552.     return MEMS_ERROR;

  2553.   return MEMS_SUCCESS;
  2554. }

  2555. /*******************************************************************************
  2556. * Function Name  : LSM6DSM_ACC_GYRO_R_InComposit
  2557. * Description    : Read INPUT_COMPOSITE
  2558. * Input          : Pointer to LSM6DSM_ACC_GYRO_IN_COMP_t
  2559. * Output         : Status of INPUT_COMPOSITE see LSM6DSM_ACC_GYRO_IN_COMP_t
  2560. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2561. *******************************************************************************/

  2562. status_t LSM6DSM_ACC_GYRO_R_InComposit(void *handle, LSM6DSM_ACC_GYRO_IN_COMP_t *value)
  2563. {
  2564. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, (u8_t *)value) )
  2565.     return MEMS_ERROR;

  2566.   *value &= LSM6DSM_ACC_GYRO_IN_COMP_MASK; //mask

  2567.   return MEMS_SUCCESS;
  2568. }

  2569. /*******************************************************************************
  2570. * Function Name  : LSM6DSM_ACC_GYRO_W_HPfilterReference
  2571. * Description    : Write HP_REF_MODE
  2572. * Input          : LSM6DSM_ACC_GYRO_HP_REF_MODE_t
  2573. * Output         : None
  2574. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2575. *******************************************************************************/
  2576. status_t  LSM6DSM_ACC_GYRO_W_HPfilterReference(void *handle, LSM6DSM_ACC_GYRO_HP_REF_MODE_t newValue)
  2577. {
  2578.   u8_t value;

  2579.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, &value) )
  2580.     return MEMS_ERROR;

  2581.   value &= ~LSM6DSM_ACC_GYRO_HP_REF_MODE_MASK;
  2582.   value |= newValue;
  2583.   
  2584.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, value) )
  2585.     return MEMS_ERROR;

  2586.   return MEMS_SUCCESS;
  2587. }

  2588. /*******************************************************************************
  2589. * Function Name  : LSM6DSM_ACC_GYRO_R_HPfilterReference
  2590. * Description    : Read HP_REF_MODE
  2591. * Input          : Pointer to LSM6DSM_ACC_GYRO_HP_REF_MODE_t
  2592. * Output         : Status of HP_REF_MODE see LSM6DSM_ACC_GYRO_HP_REF_MODE_t
  2593. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2594. *******************************************************************************/

  2595. status_t LSM6DSM_ACC_GYRO_R_HPfilterReference(void *handle, LSM6DSM_ACC_GYRO_HP_REF_MODE_t *value)
  2596. {
  2597. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, (u8_t *)value) )
  2598.     return MEMS_ERROR;

  2599.   *value &= LSM6DSM_ACC_GYRO_HP_REF_MODE_MASK; //mask

  2600.   return MEMS_SUCCESS;
  2601. }

  2602. /*******************************************************************************
  2603. * Function Name  : LSM6DSM_ACC_GYRO_W_HPCF_XL
  2604. * Description    : Write HPCF_XL
  2605. * Input          : LSM6DSM_ACC_GYRO_HPCF_XL_t
  2606. * Output         : None
  2607. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2608. *******************************************************************************/
  2609. status_t  LSM6DSM_ACC_GYRO_W_HPCF_XL(void *handle, LSM6DSM_ACC_GYRO_HPCF_XL_t newValue)
  2610. {
  2611.   u8_t value;

  2612.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, &value) )
  2613.     return MEMS_ERROR;

  2614.   value &= ~LSM6DSM_ACC_GYRO_HPCF_XL_MASK;
  2615.   value |= newValue;
  2616.   
  2617.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, value) )
  2618.     return MEMS_ERROR;

  2619.   return MEMS_SUCCESS;
  2620. }

  2621. /*******************************************************************************
  2622. * Function Name  : LSM6DSM_ACC_GYRO_R_HPCF_XL
  2623. * Description    : Read HPCF_XL
  2624. * Input          : Pointer to LSM6DSM_ACC_GYRO_HPCF_XL_t
  2625. * Output         : Status of HPCF_XL see LSM6DSM_ACC_GYRO_HPCF_XL_t
  2626. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2627. *******************************************************************************/

  2628. status_t LSM6DSM_ACC_GYRO_R_HPCF_XL(void *handle, LSM6DSM_ACC_GYRO_HPCF_XL_t *value)
  2629. {
  2630. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, (u8_t *)value) )
  2631.     return MEMS_ERROR;

  2632.   *value &= LSM6DSM_ACC_GYRO_HPCF_XL_MASK; //mask

  2633.   return MEMS_SUCCESS;
  2634. }

  2635. /*******************************************************************************
  2636. * Function Name  : LSM6DSM_ACC_GYRO_W_LowPassFiltSel_XL
  2637. * Description    : Write LPF2_XL_EN
  2638. * Input          : LSM6DSM_ACC_GYRO_LPF2_XL_t
  2639. * Output         : None
  2640. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2641. *******************************************************************************/
  2642. status_t  LSM6DSM_ACC_GYRO_W_LowPassFiltSel_XL(void *handle, LSM6DSM_ACC_GYRO_LPF2_XL_t newValue)
  2643. {
  2644.   u8_t value;

  2645.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, &value) )
  2646.     return MEMS_ERROR;

  2647.   value &= ~LSM6DSM_ACC_GYRO_LPF2_XL_MASK;
  2648.   value |= newValue;
  2649.   
  2650.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, value) )
  2651.     return MEMS_ERROR;

  2652.   return MEMS_SUCCESS;
  2653. }

  2654. /*******************************************************************************
  2655. * Function Name  : LSM6DSM_ACC_GYRO_R_LowPassFiltSel_XL
  2656. * Description    : Read LPF2_XL_EN
  2657. * Input          : Pointer to LSM6DSM_ACC_GYRO_LPF2_XL_t
  2658. * Output         : Status of LPF2_XL_EN see LSM6DSM_ACC_GYRO_LPF2_XL_t
  2659. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2660. *******************************************************************************/

  2661. status_t LSM6DSM_ACC_GYRO_R_LowPassFiltSel_XL(void *handle, LSM6DSM_ACC_GYRO_LPF2_XL_t *value)
  2662. {
  2663. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, (u8_t *)value) )
  2664.     return MEMS_ERROR;

  2665.   *value &= LSM6DSM_ACC_GYRO_LPF2_XL_MASK; //mask

  2666.   return MEMS_SUCCESS;
  2667. }

  2668. /*******************************************************************************
  2669. * Function Name  : LSM6DSM_ACC_GYRO_W_LOW_PASS_ON_6D
  2670. * Description    : Write LOW_PASS_ON_6D
  2671. * Input          : LSM6DSM_ACC_GYRO_LOW_PASS_ON_6D_t
  2672. * Output         : None
  2673. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2674. *******************************************************************************/
  2675. status_t  LSM6DSM_ACC_GYRO_W_LOW_PASS_ON_6D(void *handle, LSM6DSM_ACC_GYRO_LOW_PASS_ON_6D_t newValue)
  2676. {
  2677.   u8_t value;

  2678.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, &value) )
  2679.     return MEMS_ERROR;

  2680.   value &= ~LSM6DSM_ACC_GYRO_LOW_PASS_ON_6D_MASK;
  2681.   value |= newValue;
  2682.   
  2683.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, value) )
  2684.     return MEMS_ERROR;

  2685.   return MEMS_SUCCESS;
  2686. }

  2687. /*******************************************************************************
  2688. * Function Name  : LSM6DSM_ACC_GYRO_R_LOW_PASS_ON_6D
  2689. * Description    : Read LOW_PASS_ON_6D
  2690. * Input          : Pointer to LSM6DSM_ACC_GYRO_LOW_PASS_ON_6D_t
  2691. * Output         : Status of LOW_PASS_ON_6D see LSM6DSM_ACC_GYRO_LOW_PASS_ON_6D_t
  2692. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2693. *******************************************************************************/

  2694. status_t LSM6DSM_ACC_GYRO_R_LOW_PASS_ON_6D(void *handle, LSM6DSM_ACC_GYRO_LOW_PASS_ON_6D_t *value)
  2695. {
  2696. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, (u8_t *)value) )
  2697.     return MEMS_ERROR;

  2698.   *value &= LSM6DSM_ACC_GYRO_LOW_PASS_ON_6D_MASK; //mask

  2699.   return MEMS_SUCCESS;
  2700. }

  2701. /*******************************************************************************
  2702. * Function Name  : LSM6DSM_ACC_GYRO_W_HP_SLOPE_XL
  2703. * Description    : Write HP_SLOPE_XL_EN
  2704. * Input          : LSM6DSM_ACC_GYRO_HP_SLOPE_XL_t
  2705. * Output         : None
  2706. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2707. *******************************************************************************/
  2708. status_t  LSM6DSM_ACC_GYRO_W_HP_SLOPE_XL(void *handle, LSM6DSM_ACC_GYRO_HP_SLOPE_XL_t newValue)
  2709. {
  2710.   u8_t value;

  2711.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, &value) )
  2712.     return MEMS_ERROR;

  2713.   value &= ~LSM6DSM_ACC_GYRO_HP_SLOPE_XL_MASK;
  2714.   value |= newValue;
  2715.   
  2716.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, value) )
  2717.     return MEMS_ERROR;

  2718.   return MEMS_SUCCESS;
  2719. }

  2720. /*******************************************************************************
  2721. * Function Name  : LSM6DSM_ACC_GYRO_R_HP_SLOPE_XL
  2722. * Description    : Read HP_SLOPE_XL_EN
  2723. * Input          : Pointer to LSM6DSM_ACC_GYRO_HP_SLOPE_XL_t
  2724. * Output         : Status of HP_SLOPE_XL_EN see LSM6DSM_ACC_GYRO_HP_SLOPE_XL_t
  2725. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2726. *******************************************************************************/

  2727. status_t LSM6DSM_ACC_GYRO_R_HP_SLOPE_XL(void *handle, LSM6DSM_ACC_GYRO_HP_SLOPE_XL_t *value)
  2728. {
  2729. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL8_XL, (u8_t *)value) )
  2730.     return MEMS_ERROR;

  2731.   *value &= LSM6DSM_ACC_GYRO_HP_SLOPE_XL_MASK; //mask

  2732.   return MEMS_SUCCESS;
  2733. }


  2734. /*******************************************************************************
  2735. * Function Name  : LSM6DSM_ACC_GYRO_W_SOFT
  2736. * Description    : Write SOFT_EN
  2737. * Input          : LSM6DSM_ACC_GYRO_SOFT_t
  2738. * Output         : None
  2739. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2740. *******************************************************************************/
  2741. status_t  LSM6DSM_ACC_GYRO_W_SOFT(void *handle, LSM6DSM_ACC_GYRO_SOFT_t newValue)
  2742. {
  2743.   u8_t value;

  2744.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL9_XL, &value) )
  2745.     return MEMS_ERROR;

  2746.   value &= ~LSM6DSM_ACC_GYRO_SOFT_MASK;
  2747.   value |= newValue;
  2748.   
  2749.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL9_XL, value) )
  2750.     return MEMS_ERROR;

  2751.   return MEMS_SUCCESS;
  2752. }

  2753. /*******************************************************************************
  2754. * Function Name  : LSM6DSM_ACC_GYRO_R_SOFT
  2755. * Description    : Read SOFT_EN
  2756. * Input          : Pointer to LSM6DSM_ACC_GYRO_SOFT_t
  2757. * Output         : Status of SOFT_EN see LSM6DSM_ACC_GYRO_SOFT_t
  2758. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2759. *******************************************************************************/

  2760. status_t LSM6DSM_ACC_GYRO_R_SOFT(void *handle, LSM6DSM_ACC_GYRO_SOFT_t *value)
  2761. {
  2762. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL9_XL, (u8_t *)value) )
  2763.     return MEMS_ERROR;

  2764.   *value &= LSM6DSM_ACC_GYRO_SOFT_MASK; //mask

  2765.   return MEMS_SUCCESS;
  2766. }

  2767. /*******************************************************************************
  2768. * Function Name  : LSM6DSM_ACC_GYRO_W_SignifcantMotion
  2769. * Description    : Write SIGN_MOTION_EN
  2770. * Input          : LSM6DSM_ACC_GYRO_SIGN_MOTION_EN_t
  2771. * Output         : None
  2772. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2773. *******************************************************************************/
  2774. status_t  LSM6DSM_ACC_GYRO_W_SignifcantMotion(void *handle, LSM6DSM_ACC_GYRO_SIGN_MOTION_EN_t newValue)
  2775. {
  2776.   u8_t value;

  2777.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, &value) )
  2778.     return MEMS_ERROR;

  2779.   value &= ~LSM6DSM_ACC_GYRO_SIGN_MOTION_EN_MASK;
  2780.   value |= newValue;
  2781.   
  2782.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, value) )
  2783.     return MEMS_ERROR;

  2784.   return MEMS_SUCCESS;
  2785. }

  2786. /*******************************************************************************
  2787. * Function Name  : LSM6DSM_ACC_GYRO_R_SignifcantMotion
  2788. * Description    : Read SIGN_MOTION_EN
  2789. * Input          : Pointer to LSM6DSM_ACC_GYRO_SIGN_MOTION_EN_t
  2790. * Output         : Status of SIGN_MOTION_EN see LSM6DSM_ACC_GYRO_SIGN_MOTION_EN_t
  2791. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2792. *******************************************************************************/

  2793. status_t LSM6DSM_ACC_GYRO_R_SignifcantMotion(void *handle, LSM6DSM_ACC_GYRO_SIGN_MOTION_EN_t *value)
  2794. {
  2795. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, (u8_t *)value) )
  2796.     return MEMS_ERROR;

  2797.   *value &= LSM6DSM_ACC_GYRO_SIGN_MOTION_EN_MASK; //mask

  2798.   return MEMS_SUCCESS;
  2799. }
  2800. /*******************************************************************************
  2801. * Function Name  : LSM6DSM_ACC_GYRO_W_PedoStepReset
  2802. * Description    : Write PEDO_RST_STEP
  2803. * Input          : LSM6DSM_ACC_GYRO_PEDO_RST_STEP_t
  2804. * Output         : None
  2805. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2806. *******************************************************************************/
  2807. status_t  LSM6DSM_ACC_GYRO_W_PedoStepReset(void *handle, LSM6DSM_ACC_GYRO_PEDO_RST_STEP_t newValue)
  2808. {
  2809.   u8_t value;

  2810.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, &value) )
  2811.     return MEMS_ERROR;

  2812.   value &= ~LSM6DSM_ACC_GYRO_PEDO_RST_STEP_MASK;
  2813.   value |= newValue;
  2814.   
  2815.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, value) )
  2816.     return MEMS_ERROR;

  2817.   return MEMS_SUCCESS;
  2818. }

  2819. /*******************************************************************************
  2820. * Function Name  : LSM6DSM_ACC_GYRO_R_PedoStepReset
  2821. * Description    : Read PEDO_RST_STEP
  2822. * Input          : Pointer to LSM6DSM_ACC_GYRO_PEDO_RST_STEP_t
  2823. * Output         : Status of PEDO_RST_STEP see LSM6DSM_ACC_GYRO_PEDO_RST_STEP_t
  2824. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2825. *******************************************************************************/

  2826. status_t LSM6DSM_ACC_GYRO_R_PedoStepReset(void *handle, LSM6DSM_ACC_GYRO_PEDO_RST_STEP_t *value)
  2827. {
  2828. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, (u8_t *)value) )
  2829.     return MEMS_ERROR;

  2830.   *value &= LSM6DSM_ACC_GYRO_PEDO_RST_STEP_MASK; //mask

  2831.   return MEMS_SUCCESS;
  2832. }
  2833. /*******************************************************************************
  2834. * Function Name  : LSM6DSM_ACC_GYRO_W_TILT
  2835. * Description    : Write XEN_G
  2836. * Input          : LSM6DSM_ACC_GYRO_TILT_G_t
  2837. * Output         : None
  2838. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2839. *******************************************************************************/
  2840. status_t  LSM6DSM_ACC_GYRO_W_TILT(void *handle, LSM6DSM_ACC_GYRO_TILT_G_t newValue)
  2841. {
  2842.   u8_t value;

  2843.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, &value) )
  2844.     return MEMS_ERROR;

  2845.   value &= ~LSM6DSM_ACC_GYRO_TILT_MASK;
  2846.   value |= newValue;
  2847.   
  2848.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, value) )
  2849.     return MEMS_ERROR;

  2850.   return MEMS_SUCCESS;
  2851. }

  2852. /*******************************************************************************
  2853. * Function Name  : LSM6DSM_ACC_GYRO_R_TILT
  2854. * Description    : Read XEN_G
  2855. * Input          : Pointer to LSM6DSM_ACC_GYRO_TILT_G_t
  2856. * Output         : Status of XEN_G see LSM6DSM_ACC_GYRO_TILT_G_t
  2857. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2858. *******************************************************************************/

  2859. status_t LSM6DSM_ACC_GYRO_R_TILT(void *handle, LSM6DSM_ACC_GYRO_TILT_G_t *value)
  2860. {
  2861. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, (u8_t *)value) )
  2862.     return MEMS_ERROR;

  2863.   *value &= LSM6DSM_ACC_GYRO_TILT_MASK; //mask

  2864.   return MEMS_SUCCESS;
  2865. }
  2866. /*******************************************************************************
  2867. * Function Name  : LSM6DSM_ACC_GYRO_W_PEDO
  2868. * Description    : Write PEDO_EN
  2869. * Input          : LSM6DSM_ACC_GYRO_PEDO_t
  2870. * Output         : None
  2871. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2872. *******************************************************************************/
  2873. status_t  LSM6DSM_ACC_GYRO_W_PEDO(void *handle, LSM6DSM_ACC_GYRO_PEDO_t newValue)
  2874. {
  2875.   u8_t value;

  2876.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, &value) )
  2877.     return MEMS_ERROR;

  2878.   value &= ~LSM6DSM_ACC_GYRO_PEDO_MASK;
  2879.   value |= newValue;
  2880.   
  2881.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, value) )
  2882.     return MEMS_ERROR;

  2883.   return MEMS_SUCCESS;
  2884. }

  2885. /*******************************************************************************
  2886. * Function Name  : LSM6DSM_ACC_GYRO_R_PEDO
  2887. * Description    : Read PEDO_EN
  2888. * Input          : Pointer to LSM6DSM_ACC_GYRO_PEDO_t
  2889. * Output         : Status of PEDO_EN see LSM6DSM_ACC_GYRO_PEDO_t
  2890. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2891. *******************************************************************************/

  2892. status_t LSM6DSM_ACC_GYRO_R_PEDO(void *handle, LSM6DSM_ACC_GYRO_PEDO_t *value)
  2893. {
  2894. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, (u8_t *)value) )
  2895.     return MEMS_ERROR;

  2896.   *value &= LSM6DSM_ACC_GYRO_PEDO_MASK; //mask

  2897.   return MEMS_SUCCESS;
  2898. }

  2899. /*******************************************************************************
  2900. * Function Name  : LSM6DSM_ACC_GYRO_W_TIMER
  2901. * Description    : Write TIMER_EN
  2902. * Input          : LSM6DSM_ACC_GYRO_TIMER_t
  2903. * Output         : None
  2904. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2905. *******************************************************************************/
  2906. status_t  LSM6DSM_ACC_GYRO_W_TIMER(void *handle, LSM6DSM_ACC_GYRO_TIMER_t newValue)
  2907. {
  2908.   u8_t value;

  2909.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, &value) )
  2910.     return MEMS_ERROR;

  2911.   value &= ~LSM6DSM_ACC_GYRO_TIMER_MASK;
  2912.   value |= newValue;
  2913.   
  2914.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, value) )
  2915.     return MEMS_ERROR;

  2916.   return MEMS_SUCCESS;
  2917. }

  2918. /*******************************************************************************
  2919. * Function Name  : LSM6DSM_ACC_GYRO_R_TIMER
  2920. * Description    : Read TIMER_EN
  2921. * Input          : Pointer to LSM6DSM_ACC_GYRO_TIMER_t
  2922. * Output         : Status of TIMER_EN see LSM6DSM_ACC_GYRO_TIMER_t
  2923. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2924. *******************************************************************************/

  2925. status_t LSM6DSM_ACC_GYRO_R_TIMER(void *handle, LSM6DSM_ACC_GYRO_TIMER_t *value)
  2926. {
  2927. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, (u8_t *)value) )
  2928.     return MEMS_ERROR;

  2929.   *value &= LSM6DSM_ACC_GYRO_TIMER_MASK; //mask

  2930.   return MEMS_SUCCESS;
  2931. }
  2932. /*******************************************************************************
  2933. * Function Name  : LSM6DSM_ACC_GYRO_W_FUNC_EN
  2934. * Description    : Write FUNC_EN
  2935. * Input          : LSM6DSM_ACC_GYRO_FUNC_EN_t
  2936. * Output         : None
  2937. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2938. *******************************************************************************/
  2939. status_t  LSM6DSM_ACC_GYRO_W_FUNC_EN(void *handle, LSM6DSM_ACC_GYRO_FUNC_EN_t newValue)
  2940. {
  2941.   u8_t value;

  2942.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, &value) )
  2943.     return MEMS_ERROR;

  2944.   value &= ~LSM6DSM_ACC_GYRO_FUNC_EN_MASK;
  2945.   value |= newValue;
  2946.   
  2947.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, value) )
  2948.     return MEMS_ERROR;

  2949.   return MEMS_SUCCESS;
  2950. }

  2951. /*******************************************************************************
  2952. * Function Name  : LSM6DSM_ACC_GYRO_R_FUNC_EN
  2953. * Description    : Read FUNC_EN
  2954. * Input          : Pointer to LSM6DSM_ACC_GYRO_FUNC_EN_t
  2955. * Output         : Status of FUNC_EN see LSM6DSM_ACC_GYRO_FUNC_EN_t
  2956. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2957. *******************************************************************************/

  2958. status_t LSM6DSM_ACC_GYRO_R_FUNC_EN(void *handle, LSM6DSM_ACC_GYRO_FUNC_EN_t *value)
  2959. {
  2960. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CTRL10_C, (u8_t *)value) )
  2961.     return MEMS_ERROR;

  2962.   *value &= LSM6DSM_ACC_GYRO_FUNC_EN_MASK; //mask

  2963.   return MEMS_SUCCESS;
  2964. }
  2965. /*******************************************************************************
  2966. * Function Name  : LSM6DSM_ACC_GYRO_W_I2C_MASTER_Enable
  2967. * Description    : Write MASTER_ON
  2968. * Input          : LSM6DSM_ACC_GYRO_MASTER_ON_t
  2969. * Output         : None
  2970. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2971. *******************************************************************************/
  2972. status_t  LSM6DSM_ACC_GYRO_W_I2C_MASTER_Enable(void *handle, LSM6DSM_ACC_GYRO_MASTER_ON_t newValue)
  2973. {
  2974.   u8_t value;

  2975.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, &value) )
  2976.     return MEMS_ERROR;

  2977.   value &= ~LSM6DSM_ACC_GYRO_MASTER_ON_MASK;
  2978.   value |= newValue;
  2979.   
  2980.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, value) )
  2981.     return MEMS_ERROR;

  2982.   return MEMS_SUCCESS;
  2983. }

  2984. /*******************************************************************************
  2985. * Function Name  : LSM6DSM_ACC_GYRO_R_I2C_MASTER_Enable
  2986. * Description    : Read MASTER_ON
  2987. * Input          : Pointer to LSM6DSM_ACC_GYRO_MASTER_ON_t
  2988. * Output         : Status of MASTER_ON see LSM6DSM_ACC_GYRO_MASTER_ON_t
  2989. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  2990. *******************************************************************************/

  2991. status_t LSM6DSM_ACC_GYRO_R_I2C_MASTER_Enable(void *handle, LSM6DSM_ACC_GYRO_MASTER_ON_t *value)
  2992. {
  2993. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, (u8_t *)value) )
  2994.     return MEMS_ERROR;

  2995.   *value &= LSM6DSM_ACC_GYRO_MASTER_ON_MASK; //mask

  2996.   return MEMS_SUCCESS;
  2997. }

  2998. /*******************************************************************************
  2999. * Function Name  : LSM6DSM_ACC_GYRO_W_IronCorrection_EN
  3000. * Description    : Write IRON_EN
  3001. * Input          : LSM6DSM_ACC_GYRO_IRON_EN_t
  3002. * Output         : None
  3003. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3004. *******************************************************************************/
  3005. status_t  LSM6DSM_ACC_GYRO_W_IronCorrection_EN(void *handle, LSM6DSM_ACC_GYRO_IRON_EN_t newValue)
  3006. {
  3007.   u8_t value;

  3008.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, &value) )
  3009.     return MEMS_ERROR;

  3010.   value &= ~LSM6DSM_ACC_GYRO_IRON_EN_MASK;
  3011.   value |= newValue;
  3012.   
  3013.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, value) )
  3014.     return MEMS_ERROR;

  3015.   return MEMS_SUCCESS;
  3016. }

  3017. /*******************************************************************************
  3018. * Function Name  : LSM6DSM_ACC_GYRO_R_IronCorrection_EN
  3019. * Description    : Read IRON_EN
  3020. * Input          : Pointer to LSM6DSM_ACC_GYRO_IRON_EN_t
  3021. * Output         : Status of IRON_EN see LSM6DSM_ACC_GYRO_IRON_EN_t
  3022. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3023. *******************************************************************************/

  3024. status_t LSM6DSM_ACC_GYRO_R_IronCorrection_EN(void *handle, LSM6DSM_ACC_GYRO_IRON_EN_t *value)
  3025. {
  3026. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, (u8_t *)value) )
  3027.     return MEMS_ERROR;

  3028.   *value &= LSM6DSM_ACC_GYRO_IRON_EN_MASK; //mask

  3029.   return MEMS_SUCCESS;
  3030. }
  3031. /*******************************************************************************
  3032. * Function Name  : LSM6DSM_ACC_GYRO_W_PASS_THRU_MODE
  3033. * Description    : Write PASS_THRU_MODE
  3034. * Input          : LSM6DSM_ACC_GYRO_PASS_THRU_MODE_t
  3035. * Output         : None
  3036. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3037. *******************************************************************************/
  3038. status_t  LSM6DSM_ACC_GYRO_W_PASS_THRU_MODE(void *handle, LSM6DSM_ACC_GYRO_PASS_THRU_MODE_t newValue)
  3039. {
  3040.   u8_t value;

  3041.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, &value) )
  3042.     return MEMS_ERROR;

  3043.   value &= ~LSM6DSM_ACC_GYRO_PASS_THRU_MODE_MASK;
  3044.   value |= newValue;
  3045.   
  3046.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, value) )
  3047.     return MEMS_ERROR;

  3048.   return MEMS_SUCCESS;
  3049. }

  3050. /*******************************************************************************
  3051. * Function Name  : LSM6DSM_ACC_GYRO_R_PASS_THRU_MODE
  3052. * Description    : Read PASS_THRU_MODE
  3053. * Input          : Pointer to LSM6DSM_ACC_GYRO_PASS_THRU_MODE_t
  3054. * Output         : Status of PASS_THRU_MODE see LSM6DSM_ACC_GYRO_PASS_THRU_MODE_t
  3055. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3056. *******************************************************************************/

  3057. status_t LSM6DSM_ACC_GYRO_R_PASS_THRU_MODE(void *handle, LSM6DSM_ACC_GYRO_PASS_THRU_MODE_t *value)
  3058. {
  3059. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, (u8_t *)value) )
  3060.     return MEMS_ERROR;

  3061.   *value &= LSM6DSM_ACC_GYRO_PASS_THRU_MODE_MASK; //mask

  3062.   return MEMS_SUCCESS;
  3063. }
  3064. /*******************************************************************************
  3065. * Function Name  : LSM6DSM_ACC_GYRO_W_PULL_UP_EN
  3066. * Description    : Write PULL_UP_EN
  3067. * Input          : LSM6DSM_ACC_GYRO_PULL_UP_EN_t
  3068. * Output         : None
  3069. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3070. *******************************************************************************/
  3071. status_t  LSM6DSM_ACC_GYRO_W_PULL_UP_EN(void *handle, LSM6DSM_ACC_GYRO_PULL_UP_EN_t newValue)
  3072. {
  3073.   u8_t value;

  3074.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, &value) )
  3075.     return MEMS_ERROR;

  3076.   value &= ~LSM6DSM_ACC_GYRO_PULL_UP_EN_MASK;
  3077.   value |= newValue;
  3078.   
  3079.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, value) )
  3080.     return MEMS_ERROR;

  3081.   return MEMS_SUCCESS;
  3082. }

  3083. /*******************************************************************************
  3084. * Function Name  : LSM6DSM_ACC_GYRO_R_PULL_UP_EN
  3085. * Description    : Read PULL_UP_EN
  3086. * Input          : Pointer to LSM6DSM_ACC_GYRO_PULL_UP_EN_t
  3087. * Output         : Status of PULL_UP_EN see LSM6DSM_ACC_GYRO_PULL_UP_EN_t
  3088. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3089. *******************************************************************************/

  3090. status_t LSM6DSM_ACC_GYRO_R_PULL_UP_EN(void *handle, LSM6DSM_ACC_GYRO_PULL_UP_EN_t *value)
  3091. {
  3092. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, (u8_t *)value) )
  3093.     return MEMS_ERROR;

  3094.   *value &= LSM6DSM_ACC_GYRO_PULL_UP_EN_MASK; //mask

  3095.   return MEMS_SUCCESS;
  3096. }
  3097. /*******************************************************************************
  3098. * Function Name  : LSM6DSM_ACC_GYRO_W_SensorHUB_Trigger_Sel
  3099. * Description    : Write START_CONFIG
  3100. * Input          : LSM6DSM_ACC_GYRO_START_CONFIG_t
  3101. * Output         : None
  3102. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3103. *******************************************************************************/
  3104. status_t  LSM6DSM_ACC_GYRO_W_SensorHUB_Trigger_Sel(void *handle, LSM6DSM_ACC_GYRO_START_CONFIG_t newValue)
  3105. {
  3106.   u8_t value;

  3107.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, &value) )
  3108.     return MEMS_ERROR;

  3109.   value &= ~LSM6DSM_ACC_GYRO_START_CONFIG_MASK;
  3110.   value |= newValue;
  3111.   
  3112.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, value) )
  3113.     return MEMS_ERROR;

  3114.   return MEMS_SUCCESS;
  3115. }

  3116. /*******************************************************************************
  3117. * Function Name  : LSM6DSM_ACC_GYRO_R_SensorHUB_Trigger_Sel
  3118. * Description    : Read START_CONFIG
  3119. * Input          : Pointer to LSM6DSM_ACC_GYRO_START_CONFIG_t
  3120. * Output         : Status of START_CONFIG see LSM6DSM_ACC_GYRO_START_CONFIG_t
  3121. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3122. *******************************************************************************/

  3123. status_t LSM6DSM_ACC_GYRO_R_SensorHUB_Trigger_Sel(void *handle, LSM6DSM_ACC_GYRO_START_CONFIG_t *value)
  3124. {
  3125. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, (u8_t *)value) )
  3126.     return MEMS_ERROR;

  3127.   *value &= LSM6DSM_ACC_GYRO_START_CONFIG_MASK; //mask

  3128.   return MEMS_SUCCESS;
  3129. }
  3130. /*******************************************************************************
  3131. * Function Name  : LSM6DSM_ACC_GYRO_W_DATA_VAL_SEL_FIFO
  3132. * Description    : Write DATA_VAL_SEL_FIFO
  3133. * Input          : LSM6DSM_ACC_GYRO_DATA_VAL_SEL_FIFO_t
  3134. * Output         : None
  3135. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3136. *******************************************************************************/
  3137. status_t  LSM6DSM_ACC_GYRO_W_DATA_VAL_SEL_FIFO(void *handle, LSM6DSM_ACC_GYRO_DATA_VAL_SEL_FIFO_t newValue)
  3138. {
  3139.   u8_t value;

  3140.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, &value) )
  3141.     return MEMS_ERROR;

  3142.   value &= ~LSM6DSM_ACC_GYRO_DATA_VAL_SEL_FIFO_MASK;
  3143.   value |= newValue;
  3144.   
  3145.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, value) )
  3146.     return MEMS_ERROR;

  3147.   return MEMS_SUCCESS;
  3148. }

  3149. /*******************************************************************************
  3150. * Function Name  : LSM6DSM_ACC_GYRO_R_DATA_VAL_SEL_FIFO
  3151. * Description    : Read DATA_VAL_SEL_FIFO
  3152. * Input          : Pointer to LSM6DSM_ACC_GYRO_DATA_VAL_SEL_FIFO_t
  3153. * Output         : Status of DATA_VAL_SEL_FIFO see LSM6DSM_ACC_GYRO_DATA_VAL_SEL_FIFO_t
  3154. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3155. *******************************************************************************/

  3156. status_t LSM6DSM_ACC_GYRO_R_DATA_VAL_SEL_FIFO(void *handle, LSM6DSM_ACC_GYRO_DATA_VAL_SEL_FIFO_t *value)
  3157. {
  3158. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, (u8_t *)value) )
  3159.     return MEMS_ERROR;

  3160.   *value &= LSM6DSM_ACC_GYRO_DATA_VAL_SEL_FIFO_MASK; //mask

  3161.   return MEMS_SUCCESS;
  3162. }
  3163. /*******************************************************************************
  3164. * Function Name  : LSM6DSM_ACC_GYRO_W_DRDY_ON_INT1
  3165. * Description    : Write DRDY_ON_INT1
  3166. * Input          : LSM6DSM_ACC_GYRO_DRDY_ON_INT1_t
  3167. * Output         : None
  3168. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3169. *******************************************************************************/
  3170. status_t  LSM6DSM_ACC_GYRO_W_DRDY_ON_INT1(void *handle, LSM6DSM_ACC_GYRO_DRDY_ON_INT1_t newValue)
  3171. {
  3172.   u8_t value;

  3173.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, &value) )
  3174.     return MEMS_ERROR;

  3175.   value &= ~LSM6DSM_ACC_GYRO_DRDY_ON_INT1_MASK;
  3176.   value |= newValue;
  3177.   
  3178.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, value) )
  3179.     return MEMS_ERROR;

  3180.   return MEMS_SUCCESS;
  3181. }

  3182. /*******************************************************************************
  3183. * Function Name  : LSM6DSM_ACC_GYRO_R_DRDY_ON_INT1
  3184. * Description    : Read DRDY_ON_INT1
  3185. * Input          : Pointer to LSM6DSM_ACC_GYRO_DRDY_ON_INT1_t
  3186. * Output         : Status of DRDY_ON_INT1 see LSM6DSM_ACC_GYRO_DRDY_ON_INT1_t
  3187. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3188. *******************************************************************************/

  3189. status_t LSM6DSM_ACC_GYRO_R_DRDY_ON_INT1(void *handle, LSM6DSM_ACC_GYRO_DRDY_ON_INT1_t *value)
  3190. {
  3191. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MASTER_CONFIG, (u8_t *)value) )
  3192.     return MEMS_ERROR;

  3193.   *value &= LSM6DSM_ACC_GYRO_DRDY_ON_INT1_MASK; //mask

  3194.   return MEMS_SUCCESS;
  3195. }
  3196. /*******************************************************************************
  3197. * Function Name  : LSM6DSM_ACC_GYRO_R_Z_WU
  3198. * Description    : Read Z_WU
  3199. * Input          : Pointer to LSM6DSM_ACC_GYRO_Z_WU_t
  3200. * Output         : Status of Z_WU see LSM6DSM_ACC_GYRO_Z_WU_t
  3201. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3202. *******************************************************************************/

  3203. status_t LSM6DSM_ACC_GYRO_R_Z_WU(void *handle, LSM6DSM_ACC_GYRO_Z_WU_t *value)
  3204. {
  3205. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_SRC, (u8_t *)value) )
  3206.     return MEMS_ERROR;

  3207.   *value &= LSM6DSM_ACC_GYRO_Z_WU_MASK; //mask

  3208.   return MEMS_SUCCESS;
  3209. }
  3210. /*******************************************************************************
  3211. * Function Name  : LSM6DSM_ACC_GYRO_R_Y_WU
  3212. * Description    : Read Y_WU
  3213. * Input          : Pointer to LSM6DSM_ACC_GYRO_Y_WU_t
  3214. * Output         : Status of Y_WU see LSM6DSM_ACC_GYRO_Y_WU_t
  3215. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3216. *******************************************************************************/

  3217. status_t LSM6DSM_ACC_GYRO_R_Y_WU(void *handle, LSM6DSM_ACC_GYRO_Y_WU_t *value)
  3218. {
  3219. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_SRC, (u8_t *)value) )
  3220.     return MEMS_ERROR;

  3221.   *value &= LSM6DSM_ACC_GYRO_Y_WU_MASK; //mask

  3222.   return MEMS_SUCCESS;
  3223. }
  3224. /*******************************************************************************
  3225. * Function Name  : LSM6DSM_ACC_GYRO_R_X_WU
  3226. * Description    : Read X_WU
  3227. * Input          : Pointer to LSM6DSM_ACC_GYRO_X_WU_t
  3228. * Output         : Status of X_WU see LSM6DSM_ACC_GYRO_X_WU_t
  3229. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3230. *******************************************************************************/

  3231. status_t LSM6DSM_ACC_GYRO_R_X_WU(void *handle, LSM6DSM_ACC_GYRO_X_WU_t *value)
  3232. {
  3233. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_SRC, (u8_t *)value) )
  3234.     return MEMS_ERROR;

  3235.   *value &= LSM6DSM_ACC_GYRO_X_WU_MASK; //mask

  3236.   return MEMS_SUCCESS;
  3237. }
  3238. /*******************************************************************************
  3239. * Function Name  : LSM6DSM_ACC_GYRO_R_WU_EV_STATUS
  3240. * Description    : Read WU_EV_STATUS
  3241. * Input          : Pointer to LSM6DSM_ACC_GYRO_WU_EV_status_t
  3242. * Output         : Status of WU_EV_STATUS see LSM6DSM_ACC_GYRO_WU_EV_status_t
  3243. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3244. *******************************************************************************/

  3245. status_t LSM6DSM_ACC_GYRO_R_WU_EV_STATUS(void *handle, LSM6DSM_ACC_GYRO_WU_EV_STATUS_t *value)
  3246. {
  3247. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_SRC, (u8_t *)value) )
  3248.     return MEMS_ERROR;

  3249.   *value &= LSM6DSM_ACC_GYRO_WU_EV_STATUS_MASK; //mask

  3250.   return MEMS_SUCCESS;
  3251. }
  3252. /*******************************************************************************
  3253. * Function Name  : LSM6DSM_ACC_GYRO_R_SLEEP_EV_STATUS
  3254. * Description    : Read SLEEP_EV_STATUS
  3255. * Input          : Pointer to LSM6DSM_ACC_GYRO_SLEEP_EV_status_t
  3256. * Output         : Status of SLEEP_EV_STATUS see LSM6DSM_ACC_GYRO_SLEEP_EV_status_t
  3257. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3258. *******************************************************************************/

  3259. status_t LSM6DSM_ACC_GYRO_R_SLEEP_EV_STATUS(void *handle, LSM6DSM_ACC_GYRO_SLEEP_EV_STATUS_t *value)
  3260. {
  3261. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_SRC, (u8_t *)value) )
  3262.     return MEMS_ERROR;

  3263.   *value &= LSM6DSM_ACC_GYRO_SLEEP_EV_STATUS_MASK; //mask

  3264.   return MEMS_SUCCESS;
  3265. }
  3266. /*******************************************************************************
  3267. * Function Name  : LSM6DSM_ACC_GYRO_R_FF_EV_STATUS
  3268. * Description    : Read FF_EV_STATUS
  3269. * Input          : Pointer to LSM6DSM_ACC_GYRO_FF_EV_status_t
  3270. * Output         : Status of FF_EV_STATUS see LSM6DSM_ACC_GYRO_FF_EV_status_t
  3271. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3272. *******************************************************************************/

  3273. status_t LSM6DSM_ACC_GYRO_R_FF_EV_STATUS(void *handle, LSM6DSM_ACC_GYRO_FF_EV_STATUS_t *value)
  3274. {
  3275. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_SRC, (u8_t *)value) )
  3276.     return MEMS_ERROR;

  3277.   *value &= LSM6DSM_ACC_GYRO_FF_EV_STATUS_MASK; //mask

  3278.   return MEMS_SUCCESS;
  3279. }
  3280. /*******************************************************************************
  3281. * Function Name  : LSM6DSM_ACC_GYRO_R_Z_TAP
  3282. * Description    : Read Z_TAP
  3283. * Input          : Pointer to LSM6DSM_ACC_GYRO_Z_TAP_t
  3284. * Output         : Status of Z_TAP see LSM6DSM_ACC_GYRO_Z_TAP_t
  3285. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3286. *******************************************************************************/

  3287. status_t LSM6DSM_ACC_GYRO_R_Z_TAP(void *handle, LSM6DSM_ACC_GYRO_Z_TAP_t *value)
  3288. {
  3289. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_SRC, (u8_t *)value) )
  3290.     return MEMS_ERROR;

  3291.   *value &= LSM6DSM_ACC_GYRO_Z_TAP_MASK; //mask

  3292.   return MEMS_SUCCESS;
  3293. }
  3294. /*******************************************************************************
  3295. * Function Name  : LSM6DSM_ACC_GYRO_R_Y_TAP
  3296. * Description    : Read Y_TAP
  3297. * Input          : Pointer to LSM6DSM_ACC_GYRO_Y_TAP_t
  3298. * Output         : Status of Y_TAP see LSM6DSM_ACC_GYRO_Y_TAP_t
  3299. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3300. *******************************************************************************/

  3301. status_t LSM6DSM_ACC_GYRO_R_Y_TAP(void *handle, LSM6DSM_ACC_GYRO_Y_TAP_t *value)
  3302. {
  3303. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_SRC, (u8_t *)value) )
  3304.     return MEMS_ERROR;

  3305.   *value &= LSM6DSM_ACC_GYRO_Y_TAP_MASK; //mask

  3306.   return MEMS_SUCCESS;
  3307. }
  3308. /*******************************************************************************
  3309. * Function Name  : LSM6DSM_ACC_GYRO_R_X_TAP
  3310. * Description    : Read X_TAP
  3311. * Input          : Pointer to LSM6DSM_ACC_GYRO_X_TAP_t
  3312. * Output         : Status of X_TAP see LSM6DSM_ACC_GYRO_X_TAP_t
  3313. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3314. *******************************************************************************/

  3315. status_t LSM6DSM_ACC_GYRO_R_X_TAP(void *handle, LSM6DSM_ACC_GYRO_X_TAP_t *value)
  3316. {
  3317. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_SRC, (u8_t *)value) )
  3318.     return MEMS_ERROR;

  3319.   *value &= LSM6DSM_ACC_GYRO_X_TAP_MASK; //mask

  3320.   return MEMS_SUCCESS;
  3321. }
  3322. /*******************************************************************************
  3323. * Function Name  : LSM6DSM_ACC_GYRO_R_TAP_SIGN
  3324. * Description    : Read TAP_SIGN
  3325. * Input          : Pointer to LSM6DSM_ACC_GYRO_TAP_SIGN_t
  3326. * Output         : Status of TAP_SIGN see LSM6DSM_ACC_GYRO_TAP_SIGN_t
  3327. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3328. *******************************************************************************/

  3329. status_t LSM6DSM_ACC_GYRO_R_TAP_SIGN(void *handle, LSM6DSM_ACC_GYRO_TAP_SIGN_t *value)
  3330. {
  3331. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_SRC, (u8_t *)value) )
  3332.     return MEMS_ERROR;

  3333.   *value &= LSM6DSM_ACC_GYRO_TAP_SIGN_MASK; //mask

  3334.   return MEMS_SUCCESS;
  3335. }
  3336. /*******************************************************************************
  3337. * Function Name  : LSM6DSM_ACC_GYRO_R_DOUBLE_TAP_EV_STATUS
  3338. * Description    : Read DOUBLE_TAP_EV_STATUS
  3339. * Input          : Pointer to LSM6DSM_ACC_GYRO_DOUBLE_TAP_EV_status_t
  3340. * Output         : Status of DOUBLE_TAP_EV_STATUS see LSM6DSM_ACC_GYRO_DOUBLE_TAP_EV_status_t
  3341. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3342. *******************************************************************************/

  3343. status_t LSM6DSM_ACC_GYRO_R_DOUBLE_TAP_EV_STATUS(void *handle, LSM6DSM_ACC_GYRO_DOUBLE_TAP_EV_STATUS_t *value)
  3344. {
  3345. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_SRC, (u8_t *)value) )
  3346.     return MEMS_ERROR;

  3347.   *value &= LSM6DSM_ACC_GYRO_DOUBLE_TAP_EV_STATUS_MASK; //mask

  3348.   return MEMS_SUCCESS;
  3349. }
  3350. /*******************************************************************************
  3351. * Function Name  : LSM6DSM_ACC_GYRO_R_SINGLE_TAP_EV_STATUS
  3352. * Description    : Read SINGLE_TAP_EV_STATUS
  3353. * Input          : Pointer to LSM6DSM_ACC_GYRO_SINGLE_TAP_EV_status_t
  3354. * Output         : Status of SINGLE_TAP_EV_STATUS see LSM6DSM_ACC_GYRO_SINGLE_TAP_EV_status_t
  3355. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3356. *******************************************************************************/

  3357. status_t LSM6DSM_ACC_GYRO_R_SINGLE_TAP_EV_STATUS(void *handle, LSM6DSM_ACC_GYRO_SINGLE_TAP_EV_STATUS_t *value)
  3358. {
  3359. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_SRC, (u8_t *)value) )
  3360.     return MEMS_ERROR;

  3361.   *value &= LSM6DSM_ACC_GYRO_SINGLE_TAP_EV_STATUS_MASK; //mask

  3362.   return MEMS_SUCCESS;
  3363. }
  3364. /*******************************************************************************
  3365. * Function Name  : LSM6DSM_ACC_GYRO_R_TAP_EV_STATUS
  3366. * Description    : Read TAP_EV_STATUS
  3367. * Input          : Pointer to LSM6DSM_ACC_GYRO_TAP_EV_status_t
  3368. * Output         : Status of TAP_EV_STATUS see LSM6DSM_ACC_GYRO_TAP_EV_status_t
  3369. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3370. *******************************************************************************/

  3371. status_t LSM6DSM_ACC_GYRO_R_TAP_EV_STATUS(void *handle, LSM6DSM_ACC_GYRO_TAP_EV_STATUS_t *value)
  3372. {
  3373. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_SRC, (u8_t *)value) )
  3374.     return MEMS_ERROR;

  3375.   *value &= LSM6DSM_ACC_GYRO_TAP_EV_STATUS_MASK; //mask

  3376.   return MEMS_SUCCESS;
  3377. }
  3378. /*******************************************************************************
  3379. * Function Name  : LSM6DSM_ACC_GYRO_R_DSD_XL
  3380. * Description    : Read DSD_XL
  3381. * Input          : Pointer to LSM6DSM_ACC_GYRO_DSD_XL_t
  3382. * Output         : Status of DSD_XL see LSM6DSM_ACC_GYRO_DSD_XL_t
  3383. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3384. *******************************************************************************/

  3385. status_t LSM6DSM_ACC_GYRO_R_DSD_XL(void *handle, LSM6DSM_ACC_GYRO_DSD_XL_t *value)
  3386. {
  3387. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_D6D_SRC, (u8_t *)value) )
  3388.     return MEMS_ERROR;

  3389.   *value &= LSM6DSM_ACC_GYRO_DSD_XL_MASK; //mask

  3390.   return MEMS_SUCCESS;
  3391. }
  3392. /*******************************************************************************
  3393. * Function Name  : LSM6DSM_ACC_GYRO_R_DSD_XH
  3394. * Description    : Read DSD_XH
  3395. * Input          : Pointer to LSM6DSM_ACC_GYRO_DSD_XH_t
  3396. * Output         : Status of DSD_XH see LSM6DSM_ACC_GYRO_DSD_XH_t
  3397. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3398. *******************************************************************************/

  3399. status_t LSM6DSM_ACC_GYRO_R_DSD_XH(void *handle, LSM6DSM_ACC_GYRO_DSD_XH_t *value)
  3400. {
  3401. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_D6D_SRC, (u8_t *)value) )
  3402.     return MEMS_ERROR;

  3403.   *value &= LSM6DSM_ACC_GYRO_DSD_XH_MASK; //mask

  3404.   return MEMS_SUCCESS;
  3405. }
  3406. /*******************************************************************************
  3407. * Function Name  : LSM6DSM_ACC_GYRO_R_DSD_YL
  3408. * Description    : Read DSD_YL
  3409. * Input          : Pointer to LSM6DSM_ACC_GYRO_DSD_YL_t
  3410. * Output         : Status of DSD_YL see LSM6DSM_ACC_GYRO_DSD_YL_t
  3411. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3412. *******************************************************************************/

  3413. status_t LSM6DSM_ACC_GYRO_R_DSD_YL(void *handle, LSM6DSM_ACC_GYRO_DSD_YL_t *value)
  3414. {
  3415. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_D6D_SRC, (u8_t *)value) )
  3416.     return MEMS_ERROR;

  3417.   *value &= LSM6DSM_ACC_GYRO_DSD_YL_MASK; //mask

  3418.   return MEMS_SUCCESS;
  3419. }
  3420. /*******************************************************************************
  3421. * Function Name  : LSM6DSM_ACC_GYRO_R_DSD_YH
  3422. * Description    : Read DSD_YH
  3423. * Input          : Pointer to LSM6DSM_ACC_GYRO_DSD_YH_t
  3424. * Output         : Status of DSD_YH see LSM6DSM_ACC_GYRO_DSD_YH_t
  3425. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3426. *******************************************************************************/

  3427. status_t LSM6DSM_ACC_GYRO_R_DSD_YH(void *handle, LSM6DSM_ACC_GYRO_DSD_YH_t *value)
  3428. {
  3429. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_D6D_SRC, (u8_t *)value) )
  3430.     return MEMS_ERROR;

  3431.   *value &= LSM6DSM_ACC_GYRO_DSD_YH_MASK; //mask

  3432.   return MEMS_SUCCESS;
  3433. }
  3434. /*******************************************************************************
  3435. * Function Name  : LSM6DSM_ACC_GYRO_R_DSD_ZL
  3436. * Description    : Read DSD_ZL
  3437. * Input          : Pointer to LSM6DSM_ACC_GYRO_DSD_ZL_t
  3438. * Output         : Status of DSD_ZL see LSM6DSM_ACC_GYRO_DSD_ZL_t
  3439. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3440. *******************************************************************************/

  3441. status_t LSM6DSM_ACC_GYRO_R_DSD_ZL(void *handle, LSM6DSM_ACC_GYRO_DSD_ZL_t *value)
  3442. {
  3443. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_D6D_SRC, (u8_t *)value) )
  3444.     return MEMS_ERROR;

  3445.   *value &= LSM6DSM_ACC_GYRO_DSD_ZL_MASK; //mask

  3446.   return MEMS_SUCCESS;
  3447. }
  3448. /*******************************************************************************
  3449. * Function Name  : LSM6DSM_ACC_GYRO_R_DSD_ZH
  3450. * Description    : Read DSD_ZH
  3451. * Input          : Pointer to LSM6DSM_ACC_GYRO_DSD_ZH_t
  3452. * Output         : Status of DSD_ZH see LSM6DSM_ACC_GYRO_DSD_ZH_t
  3453. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3454. *******************************************************************************/

  3455. status_t LSM6DSM_ACC_GYRO_R_DSD_ZH(void *handle, LSM6DSM_ACC_GYRO_DSD_ZH_t *value)
  3456. {
  3457. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_D6D_SRC, (u8_t *)value) )
  3458.     return MEMS_ERROR;

  3459.   *value &= LSM6DSM_ACC_GYRO_DSD_ZH_MASK; //mask

  3460.   return MEMS_SUCCESS;
  3461. }
  3462. /*******************************************************************************
  3463. * Function Name  : LSM6DSM_ACC_GYRO_R_D6D_EV_STATUS
  3464. * Description    : Read D6D_EV_STATUS
  3465. * Input          : Pointer to LSM6DSM_ACC_GYRO_D6D_EV_status_t
  3466. * Output         : Status of D6D_EV_STATUS see LSM6DSM_ACC_GYRO_D6D_EV_status_t
  3467. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3468. *******************************************************************************/

  3469. status_t LSM6DSM_ACC_GYRO_R_D6D_EV_STATUS(void *handle, LSM6DSM_ACC_GYRO_D6D_EV_STATUS_t *value)
  3470. {
  3471. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_D6D_SRC, (u8_t *)value) )
  3472.     return MEMS_ERROR;

  3473.   *value &= LSM6DSM_ACC_GYRO_D6D_EV_STATUS_MASK; //mask

  3474.   return MEMS_SUCCESS;
  3475. }
  3476. /*******************************************************************************
  3477. * Function Name  : LSM6DSM_ACC_GYRO_R_XLDA
  3478. * Description    : Read XLDA
  3479. * Input          : Pointer to LSM6DSM_ACC_GYRO_XLDA_t
  3480. * Output         : Status of XLDA see LSM6DSM_ACC_GYRO_XLDA_t
  3481. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3482. *******************************************************************************/

  3483. status_t LSM6DSM_ACC_GYRO_R_XLDA(void *handle, LSM6DSM_ACC_GYRO_XLDA_t *value)
  3484. {
  3485. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_STATUS_REG, (u8_t *)value) )
  3486.     return MEMS_ERROR;

  3487.   *value &= LSM6DSM_ACC_GYRO_XLDA_MASK; //mask

  3488.   return MEMS_SUCCESS;
  3489. }
  3490. /*******************************************************************************
  3491. * Function Name  : LSM6DSM_ACC_GYRO_R_GDA
  3492. * Description    : Read GDA
  3493. * Input          : Pointer to LSM6DSM_ACC_GYRO_GDA_t
  3494. * Output         : Status of GDA see LSM6DSM_ACC_GYRO_GDA_t
  3495. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3496. *******************************************************************************/

  3497. status_t LSM6DSM_ACC_GYRO_R_GDA(void *handle, LSM6DSM_ACC_GYRO_GDA_t *value)
  3498. {
  3499. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_STATUS_REG, (u8_t *)value) )
  3500.     return MEMS_ERROR;

  3501.   *value &= LSM6DSM_ACC_GYRO_GDA_MASK; //mask

  3502.   return MEMS_SUCCESS;
  3503. }

  3504. /*******************************************************************************
  3505. * Function Name  : LSM6DSM_ACC_GYRO_R_TDA
  3506. * Description    : Read GDA
  3507. * Input          : Pointer to LSM6DSM_ACC_GYRO_TDA_t
  3508. * Output         : Status of GDA see LSM6DSM_ACC_GYRO_TDA_t
  3509. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3510. *******************************************************************************/

  3511. status_t LSM6DSM_ACC_GYRO_R_TDA(void *handle, LSM6DSM_ACC_GYRO_TDA_t *value)
  3512. {
  3513. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_STATUS_REG, (u8_t *)value) )
  3514.     return MEMS_ERROR;

  3515.   *value &= LSM6DSM_ACC_GYRO_TDA_MASK; //mask

  3516.   return MEMS_SUCCESS;
  3517. }

  3518. /*******************************************************************************
  3519. * Function Name  : LSM6DSM_ACC_GYRO_R_FIFONumOfEntries
  3520. * Description    : Read DIFF_FIFO
  3521. * Input          : Pointer to u16_t
  3522. * Output         : Status of DIFF_FIFO
  3523. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3524. *******************************************************************************/

  3525. status_t LSM6DSM_ACC_GYRO_R_FIFONumOfEntries(void *handle, u16_t *value)
  3526. {
  3527.   u8_t valueH, valueL;

  3528.   /* Low part from FIFO_STATUS1 */
  3529. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_STATUS1, (u8_t *)&valueL) )
  3530.     return MEMS_ERROR;

  3531.   valueL &= LSM6DSM_ACC_GYRO_DIFF_FIFO_STATUS1_MASK; //coerce
  3532.   valueL = valueL >> LSM6DSM_ACC_GYRO_DIFF_FIFO_STATUS1_POSITION; //mask

  3533.   /* High part from FIFO_STATUS2 */
  3534. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_STATUS2, (u8_t *)&valueH) )
  3535.     return MEMS_ERROR;

  3536.   valueH &= LSM6DSM_ACC_GYRO_DIFF_FIFO_STATUS2_MASK; //coerce
  3537.   valueH = valueH >> LSM6DSM_ACC_GYRO_DIFF_FIFO_STATUS2_POSITION; //mask

  3538.   *value = ((valueH << 8) & 0xFF00) | valueL;

  3539.   return MEMS_SUCCESS;
  3540. }

  3541. /*******************************************************************************
  3542. * Function Name  : LSM6DSM_ACC_GYRO_R_FIFOEmpty
  3543. * Description    : Read FIFO_EMPTY
  3544. * Input          : Pointer to LSM6DSM_ACC_GYRO_FIFO_EMPTY_t
  3545. * Output         : Status of FIFO_EMPTY see LSM6DSM_ACC_GYRO_FIFO_EMPTY_t
  3546. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3547. *******************************************************************************/

  3548. status_t LSM6DSM_ACC_GYRO_R_FIFOEmpty(void *handle, LSM6DSM_ACC_GYRO_FIFO_EMPTY_t *value)
  3549. {
  3550. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_STATUS2, (u8_t *)value) )
  3551.     return MEMS_ERROR;

  3552.   *value &= LSM6DSM_ACC_GYRO_FIFO_EMPTY_MASK; //mask

  3553.   return MEMS_SUCCESS;
  3554. }
  3555. /*******************************************************************************
  3556. * Function Name  : LSM6DSM_ACC_GYRO_R_FIFOFull
  3557. * Description    : Read FIFO_FULL
  3558. * Input          : Pointer to LSM6DSM_ACC_GYRO_FIFO_FULL_t
  3559. * Output         : Status of FIFO_FULL see LSM6DSM_ACC_GYRO_FIFO_FULL_t
  3560. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3561. *******************************************************************************/

  3562. status_t LSM6DSM_ACC_GYRO_R_FIFOFull(void *handle, LSM6DSM_ACC_GYRO_FIFO_FULL_t *value)
  3563. {
  3564. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_STATUS2, (u8_t *)value) )
  3565.     return MEMS_ERROR;

  3566.   *value &= LSM6DSM_ACC_GYRO_FIFO_FULL_MASK; //mask

  3567.   return MEMS_SUCCESS;
  3568. }
  3569. /*******************************************************************************
  3570. * Function Name  : LSM6DSM_ACC_GYRO_R_OVERRUN
  3571. * Description    : Read OVERRUN
  3572. * Input          : Pointer to LSM6DSM_ACC_GYRO_OVERRUN_t
  3573. * Output         : Status of OVERRUN see LSM6DSM_ACC_GYRO_OVERRUN_t
  3574. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3575. *******************************************************************************/

  3576. status_t LSM6DSM_ACC_GYRO_R_OVERRUN(void *handle, LSM6DSM_ACC_GYRO_OVERRUN_t *value)
  3577. {
  3578. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_STATUS2, (u8_t *)value) )
  3579.     return MEMS_ERROR;

  3580.   *value &= LSM6DSM_ACC_GYRO_OVERRUN_MASK; //mask

  3581.   return MEMS_SUCCESS;
  3582. }
  3583. /*******************************************************************************
  3584. * Function Name  : LSM6DSM_ACC_GYRO_R_WaterMark
  3585. * Description    : Read WTM
  3586. * Input          : Pointer to LSM6DSM_ACC_GYRO_WTM_t
  3587. * Output         : Status of WTM see LSM6DSM_ACC_GYRO_WTM_t
  3588. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3589. *******************************************************************************/

  3590. status_t LSM6DSM_ACC_GYRO_R_WaterMark(void *handle, LSM6DSM_ACC_GYRO_WTM_t *value)
  3591. {
  3592. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_STATUS2, (u8_t *)value) )
  3593.     return MEMS_ERROR;

  3594.   *value &= LSM6DSM_ACC_GYRO_WTM_MASK; //mask

  3595.   return MEMS_SUCCESS;
  3596. }
  3597. /*******************************************************************************
  3598. * Function Name  : LSM6DSM_ACC_GYRO_R_FIFOPattern
  3599. * Description    : Read FIFO_PATTERN
  3600. * Input          : Pointer to u16_t
  3601. * Output         : Status of FIFO_PATTERN
  3602. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3603. *******************************************************************************/

  3604. status_t LSM6DSM_ACC_GYRO_R_FIFOPattern(void *handle, u16_t *value)
  3605. {
  3606.   u8_t valueH, valueL;

  3607.   /* Low part from FIFO_STATUS3 */
  3608. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_STATUS3, (u8_t *)&valueL) )
  3609.     return MEMS_ERROR;

  3610.   valueL &= LSM6DSM_ACC_GYRO_FIFO_STATUS3_PATTERN_MASK; //coerce
  3611.   valueL = valueL >> LSM6DSM_ACC_GYRO_FIFO_STATUS3_PATTERN_POSITION; //mask

  3612.   /* High part from FIFO_STATUS4 */
  3613. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_STATUS4, (u8_t *)&valueH) )
  3614.     return MEMS_ERROR;

  3615.   valueH &= LSM6DSM_ACC_GYRO_FIFO_STATUS4_PATTERN_MASK; //coerce
  3616.   valueH = valueH >> LSM6DSM_ACC_GYRO_FIFO_STATUS4_PATTERN_POSITION; //mask

  3617.   *value = ((valueH << 8) & 0xFF00) | valueL;

  3618.   return MEMS_SUCCESS;
  3619. }

  3620. /*******************************************************************************
  3621. * Function Name  : LSM6DSM_ACC_GYRO_R_SENS_HUB_END
  3622. * Description    : Read SENS_HUB_END
  3623. * Input          : Pointer to LSM6DSM_ACC_GYRO_SENS_HUB_END_t
  3624. * Output         : Status of SENS_HUB_END see LSM6DSM_ACC_GYRO_SENS_HUB_END_t
  3625. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3626. *******************************************************************************/

  3627. status_t LSM6DSM_ACC_GYRO_R_SENS_HUB_END(void *handle, LSM6DSM_ACC_GYRO_SENS_HUB_END_t *value)
  3628. {
  3629. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FUNC_SRC, (u8_t *)value) )
  3630.     return MEMS_ERROR;

  3631.   *value &= LSM6DSM_ACC_GYRO_SENS_HUB_END_MASK; //mask

  3632.   return MEMS_SUCCESS;
  3633. }
  3634. /*******************************************************************************
  3635. * Function Name  : LSM6DSM_ACC_GYRO_R_SOFT_IRON_END
  3636. * Description    : Read SOFT_IRON_END
  3637. * Input          : Pointer to LSM6DSM_ACC_GYRO_SOFT_IRON_END_t
  3638. * Output         : Status of SOFT_IRON_END see LSM6DSM_ACC_GYRO_SOFT_IRON_END_t
  3639. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3640. *******************************************************************************/

  3641. status_t LSM6DSM_ACC_GYRO_R_SOFT_IRON_END(void *handle, LSM6DSM_ACC_GYRO_SOFT_IRON_END_t *value)
  3642. {
  3643. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FUNC_SRC, (u8_t *)value) )
  3644.     return MEMS_ERROR;

  3645.   *value &= LSM6DSM_ACC_GYRO_SOFT_IRON_END_MASK; //mask

  3646.   return MEMS_SUCCESS;
  3647. }

  3648. /*******************************************************************************
  3649. * Function Name  : LSM6DSM_ACC_GYRO_R_HardIron
  3650. * Description    : Read HI_FAIL
  3651. * Input          : Pointer to LSM6DSM_ACC_GYRO_SOFT_HARD_IRON_STAT_t
  3652. * Output         : Status of HI_FAIL see LSM6DSM_ACC_GYRO_SOFT_HARD_IRON_STAT_t
  3653. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3654. *******************************************************************************/

  3655. status_t LSM6DSM_ACC_GYRO_R_HardIron(void *handle, LSM6DSM_ACC_GYRO_SOFT_HARD_IRON_STAT_t *value)
  3656. {
  3657. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FUNC_SRC, (u8_t *)value) )
  3658.     return MEMS_ERROR;

  3659.   *value &= LSM6DSM_ACC_GYRO_HARD_IRON_STAT_MASK; //mask

  3660.   return MEMS_SUCCESS;
  3661. }

  3662. /*******************************************************************************
  3663. * Function Name  : LSM6DSM_ACC_GYRO_R_STEP_OVERFLOW
  3664. * Description    : Read STEP_OVERFLOW
  3665. * Input          : Pointer to LSM6DSM_ACC_GYRO_STEP_OVERFLOW_t
  3666. * Output         : Status of STEP_OVERFLOW see LSM6DSM_ACC_GYRO_STEP_OVERFLOW_t
  3667. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3668. *******************************************************************************/

  3669. status_t LSM6DSM_ACC_GYRO_R_STEP_OVERFLOW(void *handle, LSM6DSM_ACC_GYRO_STEP_OVERFLOW_t *value)
  3670. {
  3671. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FUNC_SRC, (u8_t *)value) )
  3672.     return MEMS_ERROR;

  3673.   *value &= LSM6DSM_ACC_GYRO_STEP_OVERFLOW_MASK; //mask

  3674.   return MEMS_SUCCESS;
  3675. }

  3676. /*******************************************************************************
  3677. * Function Name  : LSM6DSM_ACC_GYRO_R_STEP_COUNT_DELTA
  3678. * Description    : Read STEP_COUNT_DELTA_IA
  3679. * Input          : Pointer to LSM6DSM_ACC_GYRO_STEP_COUNT_DELTA_t
  3680. * Output         : Status of STEP_COUNT_DELTA_IA see LSM6DSM_ACC_GYRO_STEP_COUNT_DELTA_t
  3681. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3682. *******************************************************************************/

  3683. status_t LSM6DSM_ACC_GYRO_R_STEP_COUNT_DELTA(void *handle, LSM6DSM_ACC_GYRO_STEP_COUNT_DELTA_t *value)
  3684. {
  3685. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FUNC_SRC, (u8_t *)value) )
  3686.     return MEMS_ERROR;

  3687.   *value &= LSM6DSM_ACC_GYRO_STEP_COUNT_DELTA_MASK; //mask

  3688.   return MEMS_SUCCESS;
  3689. }

  3690. /*******************************************************************************
  3691. * Function Name  : LSM6DSM_ACC_GYRO_R_PEDO_EV_STATUS
  3692. * Description    : Read PEDO_EV_STATUS
  3693. * Input          : Pointer to LSM6DSM_ACC_GYRO_PEDO_EV_status_t
  3694. * Output         : Status of PEDO_EV_STATUS see LSM6DSM_ACC_GYRO_PEDO_EV_status_t
  3695. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3696. *******************************************************************************/

  3697. status_t LSM6DSM_ACC_GYRO_R_PEDO_EV_STATUS(void *handle, LSM6DSM_ACC_GYRO_PEDO_EV_STATUS_t *value)
  3698. {
  3699. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FUNC_SRC, (u8_t *)value) )
  3700.     return MEMS_ERROR;

  3701.   *value &= LSM6DSM_ACC_GYRO_PEDO_EV_STATUS_MASK; //mask

  3702.   return MEMS_SUCCESS;
  3703. }
  3704. /*******************************************************************************
  3705. * Function Name  : LSM6DSM_ACC_GYRO_R_TILT_EV_STATUS
  3706. * Description    : Read TILT_EV_STATUS
  3707. * Input          : Pointer to LSM6DSM_ACC_GYRO_TILT_EV_status_t
  3708. * Output         : Status of TILT_EV_STATUS see LSM6DSM_ACC_GYRO_TILT_EV_status_t
  3709. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3710. *******************************************************************************/

  3711. status_t LSM6DSM_ACC_GYRO_R_TILT_EV_STATUS(void *handle, LSM6DSM_ACC_GYRO_TILT_EV_STATUS_t *value)
  3712. {
  3713. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FUNC_SRC, (u8_t *)value) )
  3714.     return MEMS_ERROR;

  3715.   *value &= LSM6DSM_ACC_GYRO_TILT_EV_STATUS_MASK; //mask

  3716.   return MEMS_SUCCESS;
  3717. }
  3718. /*******************************************************************************
  3719. * Function Name  : LSM6DSM_ACC_GYRO_R_SIGN_MOT_EV_STATUS
  3720. * Description    : Read SIGN_MOT_EV_STATUS
  3721. * Input          : Pointer to LSM6DSM_ACC_GYRO_SIGN_MOT_EV_status_t
  3722. * Output         : Status of SIGN_MOT_EV_STATUS see LSM6DSM_ACC_GYRO_SIGN_MOT_EV_status_t
  3723. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3724. *******************************************************************************/

  3725. status_t LSM6DSM_ACC_GYRO_R_SIGN_MOT_EV_STATUS(void *handle, LSM6DSM_ACC_GYRO_SIGN_MOT_EV_STATUS_t *value)
  3726. {
  3727. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FUNC_SRC, (u8_t *)value) )
  3728.     return MEMS_ERROR;

  3729.   *value &= LSM6DSM_ACC_GYRO_SIGN_MOT_EV_STATUS_MASK; //mask

  3730.   return MEMS_SUCCESS;
  3731. }
  3732. /*******************************************************************************
  3733. * Function Name  : LSM6DSM_ACC_GYRO_W_LIR
  3734. * Description    : Write LIR
  3735. * Input          : LSM6DSM_ACC_GYRO_LIR_t
  3736. * Output         : None
  3737. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3738. *******************************************************************************/
  3739. status_t  LSM6DSM_ACC_GYRO_W_LIR(void *handle, LSM6DSM_ACC_GYRO_LIR_t newValue)
  3740. {
  3741.   u8_t value;

  3742.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, &value) )
  3743.     return MEMS_ERROR;

  3744.   value &= ~LSM6DSM_ACC_GYRO_LIR_MASK;
  3745.   value |= newValue;
  3746.   
  3747.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, value) )
  3748.     return MEMS_ERROR;

  3749.   return MEMS_SUCCESS;
  3750. }

  3751. /*******************************************************************************
  3752. * Function Name  : LSM6DSM_ACC_GYRO_R_LIR
  3753. * Description    : Read LIR
  3754. * Input          : Pointer to LSM6DSM_ACC_GYRO_LIR_t
  3755. * Output         : Status of LIR see LSM6DSM_ACC_GYRO_LIR_t
  3756. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3757. *******************************************************************************/

  3758. status_t LSM6DSM_ACC_GYRO_R_LIR(void *handle, LSM6DSM_ACC_GYRO_LIR_t *value)
  3759. {
  3760. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, (u8_t *)value) )
  3761.     return MEMS_ERROR;

  3762.   *value &= LSM6DSM_ACC_GYRO_LIR_MASK; //mask

  3763.   return MEMS_SUCCESS;
  3764. }
  3765. /*******************************************************************************
  3766. * Function Name  : LSM6DSM_ACC_GYRO_W_TAP_Z_EN
  3767. * Description    : Write TAP_Z_EN
  3768. * Input          : LSM6DSM_ACC_GYRO_TAP_Z_EN_t
  3769. * Output         : None
  3770. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3771. *******************************************************************************/
  3772. status_t  LSM6DSM_ACC_GYRO_W_TAP_Z_EN(void *handle, LSM6DSM_ACC_GYRO_TAP_Z_EN_t newValue)
  3773. {
  3774.   u8_t value;

  3775.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, &value) )
  3776.     return MEMS_ERROR;

  3777.   value &= ~LSM6DSM_ACC_GYRO_TAP_Z_EN_MASK;
  3778.   value |= newValue;
  3779.   
  3780.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, value) )
  3781.     return MEMS_ERROR;

  3782.   return MEMS_SUCCESS;
  3783. }

  3784. /*******************************************************************************
  3785. * Function Name  : LSM6DSM_ACC_GYRO_R_TAP_Z_EN
  3786. * Description    : Read TAP_Z_EN
  3787. * Input          : Pointer to LSM6DSM_ACC_GYRO_TAP_Z_EN_t
  3788. * Output         : Status of TAP_Z_EN see LSM6DSM_ACC_GYRO_TAP_Z_EN_t
  3789. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3790. *******************************************************************************/

  3791. status_t LSM6DSM_ACC_GYRO_R_TAP_Z_EN(void *handle, LSM6DSM_ACC_GYRO_TAP_Z_EN_t *value)
  3792. {
  3793. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, (u8_t *)value) )
  3794.     return MEMS_ERROR;

  3795.   *value &= LSM6DSM_ACC_GYRO_TAP_Z_EN_MASK; //mask

  3796.   return MEMS_SUCCESS;
  3797. }
  3798. /*******************************************************************************
  3799. * Function Name  : LSM6DSM_ACC_GYRO_W_TAP_Y_EN
  3800. * Description    : Write TAP_Y_EN
  3801. * Input          : LSM6DSM_ACC_GYRO_TAP_Y_EN_t
  3802. * Output         : None
  3803. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3804. *******************************************************************************/
  3805. status_t  LSM6DSM_ACC_GYRO_W_TAP_Y_EN(void *handle, LSM6DSM_ACC_GYRO_TAP_Y_EN_t newValue)
  3806. {
  3807.   u8_t value;

  3808.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, &value) )
  3809.     return MEMS_ERROR;

  3810.   value &= ~LSM6DSM_ACC_GYRO_TAP_Y_EN_MASK;
  3811.   value |= newValue;
  3812.   
  3813.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, value) )
  3814.     return MEMS_ERROR;

  3815.   return MEMS_SUCCESS;
  3816. }

  3817. /*******************************************************************************
  3818. * Function Name  : LSM6DSM_ACC_GYRO_R_TAP_Y_EN
  3819. * Description    : Read TAP_Y_EN
  3820. * Input          : Pointer to LSM6DSM_ACC_GYRO_TAP_Y_EN_t
  3821. * Output         : Status of TAP_Y_EN see LSM6DSM_ACC_GYRO_TAP_Y_EN_t
  3822. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3823. *******************************************************************************/

  3824. status_t LSM6DSM_ACC_GYRO_R_TAP_Y_EN(void *handle, LSM6DSM_ACC_GYRO_TAP_Y_EN_t *value)
  3825. {
  3826. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, (u8_t *)value) )
  3827.     return MEMS_ERROR;

  3828.   *value &= LSM6DSM_ACC_GYRO_TAP_Y_EN_MASK; //mask

  3829.   return MEMS_SUCCESS;
  3830. }
  3831. /*******************************************************************************
  3832. * Function Name  : LSM6DSM_ACC_GYRO_W_TAP_X_EN
  3833. * Description    : Write TAP_X_EN
  3834. * Input          : LSM6DSM_ACC_GYRO_TAP_X_EN_t
  3835. * Output         : None
  3836. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3837. *******************************************************************************/
  3838. status_t  LSM6DSM_ACC_GYRO_W_TAP_X_EN(void *handle, LSM6DSM_ACC_GYRO_TAP_X_EN_t newValue)
  3839. {
  3840.   u8_t value;

  3841.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, &value) )
  3842.     return MEMS_ERROR;

  3843.   value &= ~LSM6DSM_ACC_GYRO_TAP_X_EN_MASK;
  3844.   value |= newValue;
  3845.   
  3846.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, value) )
  3847.     return MEMS_ERROR;

  3848.   return MEMS_SUCCESS;
  3849. }

  3850. /*******************************************************************************
  3851. * Function Name  : LSM6DSM_ACC_GYRO_R_TAP_X_EN
  3852. * Description    : Read TAP_X_EN
  3853. * Input          : Pointer to LSM6DSM_ACC_GYRO_TAP_X_EN_t
  3854. * Output         : Status of TAP_X_EN see LSM6DSM_ACC_GYRO_TAP_X_EN_t
  3855. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3856. *******************************************************************************/

  3857. status_t LSM6DSM_ACC_GYRO_R_TAP_X_EN(void *handle, LSM6DSM_ACC_GYRO_TAP_X_EN_t *value)
  3858. {
  3859. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, (u8_t *)value) )
  3860.     return MEMS_ERROR;

  3861.   *value &= LSM6DSM_ACC_GYRO_TAP_X_EN_MASK; //mask

  3862.   return MEMS_SUCCESS;
  3863. }


  3864. /*******************************************************************************
  3865. * Function Name  : LSM6DSM_ACC_GYRO_W_SLOPE_FDS
  3866. * Description    : Write SLOPE_FDS
  3867. * Input          : LSM6DSM_ACC_GYRO_SLOPE_FDS_t
  3868. * Output         : None
  3869. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3870. *******************************************************************************/
  3871. status_t  LSM6DSM_ACC_GYRO_W_SLOPE_FDS(void *handle, LSM6DSM_ACC_GYRO_SLOPE_FDS_t newValue)
  3872. {
  3873.   u8_t value;

  3874.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, &value) )
  3875.     return MEMS_ERROR;

  3876.   value &= ~LSM6DSM_ACC_GYRO_SLOPE_FDS_MASK;
  3877.   value |= newValue;
  3878.   
  3879.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, value) )
  3880.     return MEMS_ERROR;

  3881.   return MEMS_SUCCESS;
  3882. }

  3883. /*******************************************************************************
  3884. * Function Name  : LSM6DSM_ACC_GYRO_R_SLOPE_FDS
  3885. * Description    : Read SLOPE_FDS
  3886. * Input          : Pointer to LSM6DSM_ACC_GYRO_SLOPE_FDS_t
  3887. * Output         : Status of SLOPE_FDS see LSM6DSM_ACC_GYRO_SLOPE_FDS_t
  3888. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3889. *******************************************************************************/

  3890. status_t LSM6DSM_ACC_GYRO_R_SLOPE_FDS(void *handle, LSM6DSM_ACC_GYRO_SLOPE_FDS_t *value)
  3891. {
  3892. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, (u8_t *)value) )
  3893.     return MEMS_ERROR;

  3894.   *value &= LSM6DSM_ACC_GYRO_SLOPE_FDS_MASK; //mask

  3895.   return MEMS_SUCCESS;
  3896. }

  3897. /*******************************************************************************
  3898. * Function Name  : LSM6DSM_ACC_GYRO_W_BASIC_INT
  3899. * Description    : Write INTERRUPTS_ENABLE
  3900. * Input          : LSM6DSM_ACC_GYRO_INT_EN_t
  3901. * Output         : None
  3902. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3903. *******************************************************************************/
  3904. status_t  LSM6DSM_ACC_GYRO_W_BASIC_INT(void *handle, LSM6DSM_ACC_GYRO_INT_EN_t newValue)
  3905. {
  3906.   u8_t value;

  3907.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, &value) )
  3908.     return MEMS_ERROR;

  3909.   value &= ~LSM6DSM_ACC_GYRO_INT_EN_MASK;
  3910.   value |= newValue;
  3911.   
  3912.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, value) )
  3913.     return MEMS_ERROR;

  3914.   return MEMS_SUCCESS;
  3915. }

  3916. /*******************************************************************************
  3917. * Function Name  : LSM6DSM_ACC_GYRO_R_BASIC_INT
  3918. * Description    : Read INTERRUPTS_ENABLE
  3919. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT_EN_t
  3920. * Output         : Status of INTERRUPTS_ENABLE see LSM6DSM_ACC_GYRO_INT_EN_t
  3921. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3922. *******************************************************************************/

  3923. status_t LSM6DSM_ACC_GYRO_R_BASIC_INT(void *handle, LSM6DSM_ACC_GYRO_INT_EN_t *value)
  3924. {
  3925. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_CFG1, (u8_t *)value) )
  3926.     return MEMS_ERROR;

  3927.   *value &= LSM6DSM_ACC_GYRO_INT_EN_MASK; //mask

  3928.   return MEMS_SUCCESS;
  3929. }

  3930. /*******************************************************************************
  3931. * Function Name  : LSM6DSM_ACC_GYRO_W_TAP_THS
  3932. * Description    : Write TAP_THS
  3933. * Input          : u8_t
  3934. * Output         : None
  3935. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3936. *******************************************************************************/
  3937. status_t  LSM6DSM_ACC_GYRO_W_TAP_THS(void *handle, u8_t newValue)
  3938. {
  3939.   u8_t value;

  3940.   newValue = newValue << LSM6DSM_ACC_GYRO_TAP_THS_POSITION; //mask       
  3941.   newValue &= LSM6DSM_ACC_GYRO_TAP_THS_MASK; //coerce
  3942.   
  3943.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_THS_6D, &value) )
  3944.     return MEMS_ERROR;

  3945.   value &= ~LSM6DSM_ACC_GYRO_TAP_THS_MASK;
  3946.   value |= newValue;
  3947.   
  3948.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_TAP_THS_6D, value) )
  3949.     return MEMS_ERROR;

  3950.   return MEMS_SUCCESS;
  3951. }

  3952. /*******************************************************************************
  3953. * Function Name  : LSM6DSM_ACC_GYRO_R_TAP_THS
  3954. * Description    : Read TAP_THS
  3955. * Input          : Pointer to u8_t
  3956. * Output         : Status of TAP_THS
  3957. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3958. *******************************************************************************/

  3959. status_t LSM6DSM_ACC_GYRO_R_TAP_THS(void *handle, u8_t *value)
  3960. {
  3961. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_THS_6D, (u8_t *)value) )
  3962.     return MEMS_ERROR;

  3963.   *value &= LSM6DSM_ACC_GYRO_TAP_THS_MASK; //coerce       
  3964.   *value = *value >> LSM6DSM_ACC_GYRO_TAP_THS_POSITION; //mask       

  3965.   return MEMS_SUCCESS;
  3966. }
  3967. /*******************************************************************************
  3968. * Function Name  : LSM6DSM_ACC_GYRO_W_SIXD_THS
  3969. * Description    : Write SIXD_THS
  3970. * Input          : LSM6DSM_ACC_GYRO_SIXD_THS_t
  3971. * Output         : None
  3972. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3973. *******************************************************************************/
  3974. status_t  LSM6DSM_ACC_GYRO_W_SIXD_THS(void *handle, LSM6DSM_ACC_GYRO_SIXD_THS_t newValue)
  3975. {
  3976.   u8_t value;

  3977.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_THS_6D, &value) )
  3978.     return MEMS_ERROR;

  3979.   value &= ~LSM6DSM_ACC_GYRO_SIXD_THS_MASK;
  3980.   value |= newValue;
  3981.   
  3982.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_TAP_THS_6D, value) )
  3983.     return MEMS_ERROR;

  3984.   return MEMS_SUCCESS;
  3985. }

  3986. /*******************************************************************************
  3987. * Function Name  : LSM6DSM_ACC_GYRO_R_SIXD_THS
  3988. * Description    : Read SIXD_THS
  3989. * Input          : Pointer to LSM6DSM_ACC_GYRO_SIXD_THS_t
  3990. * Output         : Status of SIXD_THS see LSM6DSM_ACC_GYRO_SIXD_THS_t
  3991. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  3992. *******************************************************************************/

  3993. status_t LSM6DSM_ACC_GYRO_R_SIXD_THS(void *handle, LSM6DSM_ACC_GYRO_SIXD_THS_t *value)
  3994. {
  3995. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_THS_6D, (u8_t *)value) )
  3996.     return MEMS_ERROR;

  3997.   *value &= LSM6DSM_ACC_GYRO_SIXD_THS_MASK; //mask

  3998.   return MEMS_SUCCESS;
  3999. }

  4000. /*******************************************************************************
  4001. * Function Name  : LSM6DSM_ACC_GYRO_W_D4D
  4002. * Description    : Write D4D_EN
  4003. * Input          : LSM6DSM_ACC_GYRO_D4D_t
  4004. * Output         : None
  4005. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4006. *******************************************************************************/
  4007. status_t  LSM6DSM_ACC_GYRO_W_D4D(void *handle, LSM6DSM_ACC_GYRO_D4D_t newValue)
  4008. {
  4009.   u8_t value;

  4010.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_THS_6D, &value) )
  4011.     return MEMS_ERROR;

  4012.   value &= ~LSM6DSM_ACC_GYRO_D4D_MASK;
  4013.   value |= newValue;
  4014.   
  4015.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_TAP_THS_6D, value) )
  4016.     return MEMS_ERROR;

  4017.   return MEMS_SUCCESS;
  4018. }

  4019. /*******************************************************************************
  4020. * Function Name  : LSM6DSM_ACC_GYRO_R_D4D
  4021. * Description    : Read D4D_EN
  4022. * Input          : Pointer to LSM6DSM_ACC_GYRO_D4D_t
  4023. * Output         : Status of D4D_EN see LSM6DSM_ACC_GYRO_D4D_t
  4024. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4025. *******************************************************************************/

  4026. status_t LSM6DSM_ACC_GYRO_R_D4D(void *handle, LSM6DSM_ACC_GYRO_D4D_t *value)
  4027. {
  4028. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TAP_THS_6D, (u8_t *)value) )
  4029.     return MEMS_ERROR;

  4030.   *value &= LSM6DSM_ACC_GYRO_D4D_MASK; //mask

  4031.   return MEMS_SUCCESS;
  4032. }

  4033. /*******************************************************************************
  4034. * Function Name  : LSM6DSM_ACC_GYRO_W_SHOCK_Duration
  4035. * Description    : Write SHOCK
  4036. * Input          : u8_t
  4037. * Output         : None
  4038. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4039. *******************************************************************************/
  4040. status_t  LSM6DSM_ACC_GYRO_W_SHOCK_Duration(void *handle, u8_t newValue)
  4041. {
  4042.   u8_t value;

  4043.   newValue = newValue << LSM6DSM_ACC_GYRO_SHOCK_POSITION; //mask       
  4044.   newValue &= LSM6DSM_ACC_GYRO_SHOCK_MASK; //coerce
  4045.   
  4046.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT_DUR2, &value) )
  4047.     return MEMS_ERROR;

  4048.   value &= ~LSM6DSM_ACC_GYRO_SHOCK_MASK;
  4049.   value |= newValue;
  4050.   
  4051.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT_DUR2, value) )
  4052.     return MEMS_ERROR;

  4053.   return MEMS_SUCCESS;
  4054. }

  4055. /*******************************************************************************
  4056. * Function Name  : LSM6DSM_ACC_GYRO_R_SHOCK_Duration
  4057. * Description    : Read SHOCK
  4058. * Input          : Pointer to u8_t
  4059. * Output         : Status of SHOCK
  4060. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4061. *******************************************************************************/

  4062. status_t LSM6DSM_ACC_GYRO_R_SHOCK_Duration(void *handle, u8_t *value)
  4063. {
  4064. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT_DUR2, (u8_t *)value) )
  4065.     return MEMS_ERROR;

  4066.   *value &= LSM6DSM_ACC_GYRO_SHOCK_MASK; //coerce       
  4067.   *value = *value >> LSM6DSM_ACC_GYRO_SHOCK_POSITION; //mask       

  4068.   return MEMS_SUCCESS;
  4069. }
  4070. /*******************************************************************************
  4071. * Function Name  : LSM6DSM_ACC_GYRO_W_QUIET_Duration
  4072. * Description    : Write QUIET
  4073. * Input          : u8_t
  4074. * Output         : None
  4075. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4076. *******************************************************************************/
  4077. status_t  LSM6DSM_ACC_GYRO_W_QUIET_Duration(void *handle, u8_t newValue)
  4078. {
  4079.   u8_t value;

  4080.   newValue = newValue << LSM6DSM_ACC_GYRO_QUIET_POSITION; //mask       
  4081.   newValue &= LSM6DSM_ACC_GYRO_QUIET_MASK; //coerce
  4082.   
  4083.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT_DUR2, &value) )
  4084.     return MEMS_ERROR;

  4085.   value &= ~LSM6DSM_ACC_GYRO_QUIET_MASK;
  4086.   value |= newValue;
  4087.   
  4088.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT_DUR2, value) )
  4089.     return MEMS_ERROR;

  4090.   return MEMS_SUCCESS;
  4091. }

  4092. /*******************************************************************************
  4093. * Function Name  : LSM6DSM_ACC_GYRO_R_QUIET_Duration
  4094. * Description    : Read QUIET
  4095. * Input          : Pointer to u8_t
  4096. * Output         : Status of QUIET
  4097. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4098. *******************************************************************************/

  4099. status_t LSM6DSM_ACC_GYRO_R_QUIET_Duration(void *handle, u8_t *value)
  4100. {
  4101. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT_DUR2, (u8_t *)value) )
  4102.     return MEMS_ERROR;

  4103.   *value &= LSM6DSM_ACC_GYRO_QUIET_MASK; //coerce       
  4104.   *value = *value >> LSM6DSM_ACC_GYRO_QUIET_POSITION; //mask       

  4105.   return MEMS_SUCCESS;
  4106. }
  4107. /*******************************************************************************
  4108. * Function Name  : LSM6DSM_ACC_GYRO_W_DUR
  4109. * Description    : Write DUR
  4110. * Input          : u8_t
  4111. * Output         : None
  4112. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4113. *******************************************************************************/
  4114. status_t  LSM6DSM_ACC_GYRO_W_DUR(void *handle, u8_t newValue)
  4115. {
  4116.   u8_t value;

  4117.   newValue = newValue << LSM6DSM_ACC_GYRO_DUR_POSITION; //mask       
  4118.   newValue &= LSM6DSM_ACC_GYRO_DUR_MASK; //coerce
  4119.   
  4120.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT_DUR2, &value) )
  4121.     return MEMS_ERROR;

  4122.   value &= ~LSM6DSM_ACC_GYRO_DUR_MASK;
  4123.   value |= newValue;
  4124.   
  4125.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_INT_DUR2, value) )
  4126.     return MEMS_ERROR;

  4127.   return MEMS_SUCCESS;
  4128. }

  4129. /*******************************************************************************
  4130. * Function Name  : LSM6DSM_ACC_GYRO_R_DUR
  4131. * Description    : Read DUR
  4132. * Input          : Pointer to u8_t
  4133. * Output         : Status of DUR
  4134. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4135. *******************************************************************************/

  4136. status_t LSM6DSM_ACC_GYRO_R_DUR(void *handle, u8_t *value)
  4137. {
  4138. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_INT_DUR2, (u8_t *)value) )
  4139.     return MEMS_ERROR;

  4140.   *value &= LSM6DSM_ACC_GYRO_DUR_MASK; //coerce       
  4141.   *value = *value >> LSM6DSM_ACC_GYRO_DUR_POSITION; //mask       

  4142.   return MEMS_SUCCESS;
  4143. }
  4144. /*******************************************************************************
  4145. * Function Name  : LSM6DSM_ACC_GYRO_W_WK_THS
  4146. * Description    : Write WK_THS
  4147. * Input          : u8_t
  4148. * Output         : None
  4149. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4150. *******************************************************************************/
  4151. status_t  LSM6DSM_ACC_GYRO_W_WK_THS(void *handle, u8_t newValue)
  4152. {
  4153.   u8_t value;

  4154.   newValue = newValue << LSM6DSM_ACC_GYRO_WK_THS_POSITION; //mask       
  4155.   newValue &= LSM6DSM_ACC_GYRO_WK_THS_MASK; //coerce
  4156.   
  4157.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_THS, &value) )
  4158.     return MEMS_ERROR;

  4159.   value &= ~LSM6DSM_ACC_GYRO_WK_THS_MASK;
  4160.   value |= newValue;
  4161.   
  4162.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_THS, value) )
  4163.     return MEMS_ERROR;

  4164.   return MEMS_SUCCESS;
  4165. }

  4166. /*******************************************************************************
  4167. * Function Name  : LSM6DSM_ACC_GYRO_R_WK_THS
  4168. * Description    : Read WK_THS
  4169. * Input          : Pointer to u8_t
  4170. * Output         : Status of WK_THS
  4171. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4172. *******************************************************************************/

  4173. status_t LSM6DSM_ACC_GYRO_R_WK_THS(void *handle, u8_t *value)
  4174. {
  4175. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_THS, (u8_t *)value) )
  4176.     return MEMS_ERROR;

  4177.   *value &= LSM6DSM_ACC_GYRO_WK_THS_MASK; //coerce       
  4178.   *value = *value >> LSM6DSM_ACC_GYRO_WK_THS_POSITION; //mask       

  4179.   return MEMS_SUCCESS;
  4180. }

  4181. /*******************************************************************************
  4182. * Function Name  : LSM6DSM_ACC_GYRO_W_SINGLE_DOUBLE_TAP_EV
  4183. * Description    : Write SINGLE_DOUBLE_TAP
  4184. * Input          : LSM6DSM_ACC_GYRO_SINGLE_DOUBLE_TAP_t
  4185. * Output         : None
  4186. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4187. *******************************************************************************/
  4188. status_t  LSM6DSM_ACC_GYRO_W_SINGLE_DOUBLE_TAP_EV(void *handle, LSM6DSM_ACC_GYRO_SINGLE_DOUBLE_TAP_t newValue)
  4189. {
  4190.   u8_t value;

  4191.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_THS, &value) )
  4192.     return MEMS_ERROR;

  4193.   value &= ~LSM6DSM_ACC_GYRO_SINGLE_DOUBLE_TAP_MASK;
  4194.   value |= newValue;
  4195.   
  4196.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_THS, value) )
  4197.     return MEMS_ERROR;

  4198.   return MEMS_SUCCESS;
  4199. }

  4200. /*******************************************************************************
  4201. * Function Name  : LSM6DSM_ACC_GYRO_R_SINGLE_DOUBLE_TAP_EV
  4202. * Description    : Read SINGLE_DOUBLE_TAP
  4203. * Input          : Pointer to LSM6DSM_ACC_GYRO_SINGLE_DOUBLE_TAP_t
  4204. * Output         : Status of SINGLE_DOUBLE_TAP see LSM6DSM_ACC_GYRO_SINGLE_DOUBLE_TAP_t
  4205. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4206. *******************************************************************************/

  4207. status_t LSM6DSM_ACC_GYRO_R_SINGLE_DOUBLE_TAP_EV(void *handle, LSM6DSM_ACC_GYRO_SINGLE_DOUBLE_TAP_t *value)
  4208. {
  4209. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_THS, (u8_t *)value) )
  4210.     return MEMS_ERROR;

  4211.   *value &= LSM6DSM_ACC_GYRO_SINGLE_DOUBLE_TAP_MASK; //mask

  4212.   return MEMS_SUCCESS;
  4213. }
  4214. /*******************************************************************************
  4215. * Function Name  : LSM6DSM_ACC_GYRO_W_SLEEP_DUR
  4216. * Description    : Write SLEEP_DUR
  4217. * Input          : u8_t
  4218. * Output         : None
  4219. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4220. *******************************************************************************/
  4221. status_t  LSM6DSM_ACC_GYRO_W_SLEEP_DUR(void *handle, u8_t newValue)
  4222. {
  4223.   u8_t value;

  4224.   newValue = newValue << LSM6DSM_ACC_GYRO_SLEEP_DUR_POSITION; //mask       
  4225.   newValue &= LSM6DSM_ACC_GYRO_SLEEP_DUR_MASK; //coerce
  4226.   
  4227.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_DUR, &value) )
  4228.     return MEMS_ERROR;

  4229.   value &= ~LSM6DSM_ACC_GYRO_SLEEP_DUR_MASK;
  4230.   value |= newValue;
  4231.   
  4232.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_DUR, value) )
  4233.     return MEMS_ERROR;

  4234.   return MEMS_SUCCESS;
  4235. }

  4236. /*******************************************************************************
  4237. * Function Name  : LSM6DSM_ACC_GYRO_R_SLEEP_DUR
  4238. * Description    : Read SLEEP_DUR
  4239. * Input          : Pointer to u8_t
  4240. * Output         : Status of SLEEP_DUR
  4241. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4242. *******************************************************************************/

  4243. status_t LSM6DSM_ACC_GYRO_R_SLEEP_DUR(void *handle, u8_t *value)
  4244. {
  4245. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_DUR, (u8_t *)value) )
  4246.     return MEMS_ERROR;

  4247.   *value &= LSM6DSM_ACC_GYRO_SLEEP_DUR_MASK; //coerce       
  4248.   *value = *value >> LSM6DSM_ACC_GYRO_SLEEP_DUR_POSITION; //mask       

  4249.   return MEMS_SUCCESS;
  4250. }
  4251. /*******************************************************************************
  4252. * Function Name  : LSM6DSM_ACC_GYRO_W_TIMER_HR
  4253. * Description    : Write TIMER_HR
  4254. * Input          : LSM6DSM_ACC_GYRO_TIMER_HR_t
  4255. * Output         : None
  4256. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4257. *******************************************************************************/
  4258. status_t  LSM6DSM_ACC_GYRO_W_TIMER_HR(void *handle, LSM6DSM_ACC_GYRO_TIMER_HR_t newValue)
  4259. {
  4260.   u8_t value;

  4261.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_DUR, &value) )
  4262.     return MEMS_ERROR;

  4263.   value &= ~LSM6DSM_ACC_GYRO_TIMER_HR_MASK;
  4264.   value |= newValue;
  4265.   
  4266.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_DUR, value) )
  4267.     return MEMS_ERROR;

  4268.   return MEMS_SUCCESS;
  4269. }

  4270. /*******************************************************************************
  4271. * Function Name  : LSM6DSM_ACC_GYRO_R_TIMER_HR
  4272. * Description    : Read TIMER_HR
  4273. * Input          : Pointer to LSM6DSM_ACC_GYRO_TIMER_HR_t
  4274. * Output         : Status of TIMER_HR see LSM6DSM_ACC_GYRO_TIMER_HR_t
  4275. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4276. *******************************************************************************/

  4277. status_t LSM6DSM_ACC_GYRO_R_TIMER_HR(void *handle, LSM6DSM_ACC_GYRO_TIMER_HR_t *value)
  4278. {
  4279. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_DUR, (u8_t *)value) )
  4280.     return MEMS_ERROR;

  4281.   *value &= LSM6DSM_ACC_GYRO_TIMER_HR_MASK; //mask

  4282.   return MEMS_SUCCESS;
  4283. }
  4284. /*******************************************************************************
  4285. * Function Name  : LSM6DSM_ACC_GYRO_W_WAKE_DUR
  4286. * Description    : Write WAKE_DUR
  4287. * Input          : u8_t
  4288. * Output         : None
  4289. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4290. *******************************************************************************/
  4291. status_t  LSM6DSM_ACC_GYRO_W_WAKE_DUR(void *handle, u8_t newValue)
  4292. {
  4293.   u8_t value;

  4294.   newValue = newValue << LSM6DSM_ACC_GYRO_WAKE_DUR_POSITION; //mask       
  4295.   newValue &= LSM6DSM_ACC_GYRO_WAKE_DUR_MASK; //coerce
  4296.   
  4297.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_DUR, &value) )
  4298.     return MEMS_ERROR;

  4299.   value &= ~LSM6DSM_ACC_GYRO_WAKE_DUR_MASK;
  4300.   value |= newValue;
  4301.   
  4302.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_DUR, value) )
  4303.     return MEMS_ERROR;

  4304.   return MEMS_SUCCESS;
  4305. }

  4306. /*******************************************************************************
  4307. * Function Name  : LSM6DSM_ACC_GYRO_R_WAKE_DUR
  4308. * Description    : Read WAKE_DUR
  4309. * Input          : Pointer to u8_t
  4310. * Output         : Status of WAKE_DUR
  4311. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4312. *******************************************************************************/

  4313. status_t LSM6DSM_ACC_GYRO_R_WAKE_DUR(void *handle, u8_t *value)
  4314. {
  4315. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_DUR, (u8_t *)value) )
  4316.     return MEMS_ERROR;

  4317.   *value &= LSM6DSM_ACC_GYRO_WAKE_DUR_MASK; //coerce       
  4318.   *value = *value >> LSM6DSM_ACC_GYRO_WAKE_DUR_POSITION; //mask       

  4319.   return MEMS_SUCCESS;
  4320. }

  4321. /*******************************************************************************
  4322. * Function Name  : LSM6DSM_ACC_GYRO_W_FF_THS
  4323. * Description    : Write FF_THS
  4324. * Input          : LSM6DSM_ACC_GYRO_FF_THS_t
  4325. * Output         : None
  4326. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4327. *******************************************************************************/
  4328. status_t  LSM6DSM_ACC_GYRO_W_FF_THS(void *handle, LSM6DSM_ACC_GYRO_FF_THS_t newValue)
  4329. {
  4330.   u8_t value;

  4331.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FREE_FALL, &value) )
  4332.     return MEMS_ERROR;

  4333.   value &= ~LSM6DSM_ACC_GYRO_FF_THS_MASK;
  4334.   value |= newValue;
  4335.   
  4336.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FREE_FALL, value) )
  4337.     return MEMS_ERROR;

  4338.   return MEMS_SUCCESS;
  4339. }

  4340. /*******************************************************************************
  4341. * Function Name  : LSM6DSM_ACC_GYRO_R_FF_THS
  4342. * Description    : Read FF_THS
  4343. * Input          : Pointer to LSM6DSM_ACC_GYRO_FF_THS_t
  4344. * Output         : Status of FF_THS see LSM6DSM_ACC_GYRO_FF_THS_t
  4345. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4346. *******************************************************************************/

  4347. status_t LSM6DSM_ACC_GYRO_R_FF_THS(void *handle, LSM6DSM_ACC_GYRO_FF_THS_t *value)
  4348. {
  4349. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FREE_FALL, (u8_t *)value) )
  4350.     return MEMS_ERROR;

  4351.   *value &= LSM6DSM_ACC_GYRO_FF_THS_MASK; //mask

  4352.   return MEMS_SUCCESS;
  4353. }

  4354. /*******************************************************************************
  4355. * Function Name  : LSM6DSM_ACC_GYRO_W_FF_Duration
  4356. * Description    : Write FF_DUR
  4357. * Input          : u8_t
  4358. * Output         : None
  4359. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4360. *******************************************************************************/
  4361. status_t  LSM6DSM_ACC_GYRO_W_FF_Duration(void *handle, u8_t newValue)
  4362. {
  4363.   u8_t valueH, valueL;
  4364.   u8_t value;

  4365.   valueL = newValue & 0x1F;
  4366.   valueH = (newValue >> 5) & 0x1;

  4367.   /* Low part in FREE_FALL reg */
  4368.   valueL = valueL << LSM6DSM_ACC_GYRO_FF_FREE_FALL_DUR_POSITION; //mask       
  4369.   valueL &= LSM6DSM_ACC_GYRO_FF_FREE_FALL_DUR_MASK; //coerce
  4370.   
  4371.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FREE_FALL, &value) )
  4372.     return MEMS_ERROR;

  4373.   value &= ~LSM6DSM_ACC_GYRO_FF_FREE_FALL_DUR_MASK;
  4374.   value |= valueL;
  4375.   
  4376.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_FREE_FALL, value) )
  4377.     return MEMS_ERROR;

  4378.   /* High part in WAKE_UP_DUR reg */
  4379.   valueH = valueH << LSM6DSM_ACC_GYRO_FF_WAKE_UP_DUR_POSITION; //mask       
  4380.   valueH &= LSM6DSM_ACC_GYRO_FF_WAKE_UP_DUR_MASK; //coerce
  4381.   
  4382.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_DUR, &value) )
  4383.     return MEMS_ERROR;

  4384.   value &= ~LSM6DSM_ACC_GYRO_FF_WAKE_UP_DUR_MASK;
  4385.   value |= valueH;
  4386.   
  4387.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_DUR, value) )
  4388.     return MEMS_ERROR;

  4389.   return MEMS_SUCCESS;
  4390. }

  4391. /*******************************************************************************
  4392. * Function Name  : LSM6DSM_ACC_GYRO_R_FF_Duration
  4393. * Description    : Read FF_DUR
  4394. * Input          : Pointer to u8_t
  4395. * Output         : Status of FF_DUR
  4396. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4397. *******************************************************************************/

  4398. status_t LSM6DSM_ACC_GYRO_R_FF_Duration(void *handle, u8_t *value)
  4399. {
  4400.   u8_t valueH, valueL;

  4401.   /* Low part from FREE_FALL reg */
  4402. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FREE_FALL, (u8_t *)&valueL) )
  4403.     return MEMS_ERROR;

  4404.   valueL &= LSM6DSM_ACC_GYRO_FF_FREE_FALL_DUR_MASK; //coerce
  4405.   valueL = valueL >> LSM6DSM_ACC_GYRO_FF_FREE_FALL_DUR_POSITION; //mask

  4406.   /* High part from WAKE_UP_DUR reg */
  4407. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_WAKE_UP_DUR, (u8_t *)&valueH) )
  4408.     return MEMS_ERROR;

  4409.   valueH &= LSM6DSM_ACC_GYRO_FF_WAKE_UP_DUR_MASK; //coerce
  4410.   valueH = valueH >> LSM6DSM_ACC_GYRO_FF_WAKE_UP_DUR_POSITION; //mask

  4411.   *value = ((valueH << 5) & 0x20) | valueL;

  4412.   return MEMS_SUCCESS;
  4413. }
  4414. /*******************************************************************************
  4415. * Function Name  : LSM6DSM_ACC_GYRO_W_TimerEvRouteInt1
  4416. * Description    : Write INT1_TIMER
  4417. * Input          : LSM6DSM_ACC_GYRO_INT1_TIMER_t
  4418. * Output         : None
  4419. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4420. *******************************************************************************/
  4421. status_t  LSM6DSM_ACC_GYRO_W_TimerEvRouteInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_TIMER_t newValue)
  4422. {
  4423.   u8_t value;

  4424.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, &value) )
  4425.     return MEMS_ERROR;

  4426.   value &= ~LSM6DSM_ACC_GYRO_INT1_TIMER_MASK;
  4427.   value |= newValue;
  4428.   
  4429.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, value) )
  4430.     return MEMS_ERROR;

  4431.   return MEMS_SUCCESS;
  4432. }

  4433. /*******************************************************************************
  4434. * Function Name  : LSM6DSM_ACC_GYRO_R_TimerEvRouteInt1
  4435. * Description    : Read INT1_TIMER
  4436. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_TIMER_t
  4437. * Output         : Status of INT1_TIMER see LSM6DSM_ACC_GYRO_INT1_TIMER_t
  4438. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4439. *******************************************************************************/

  4440. status_t LSM6DSM_ACC_GYRO_R_TimerEvRouteInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_TIMER_t *value)
  4441. {
  4442. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, (u8_t *)value) )
  4443.     return MEMS_ERROR;

  4444.   *value &= LSM6DSM_ACC_GYRO_INT1_TIMER_MASK; //mask

  4445.   return MEMS_SUCCESS;
  4446. }
  4447. /*******************************************************************************
  4448. * Function Name  : LSM6DSM_ACC_GYRO_W_TiltEvOnInt1
  4449. * Description    : Write INT1_TILT
  4450. * Input          : LSM6DSM_ACC_GYRO_INT1_TILT_t
  4451. * Output         : None
  4452. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4453. *******************************************************************************/
  4454. status_t  LSM6DSM_ACC_GYRO_W_TiltEvOnInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_TILT_t newValue)
  4455. {
  4456.   u8_t value;

  4457.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, &value) )
  4458.     return MEMS_ERROR;

  4459.   value &= ~LSM6DSM_ACC_GYRO_INT1_TILT_MASK;
  4460.   value |= newValue;
  4461.   
  4462.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, value) )
  4463.     return MEMS_ERROR;

  4464.   return MEMS_SUCCESS;
  4465. }

  4466. /*******************************************************************************
  4467. * Function Name  : LSM6DSM_ACC_GYRO_R_TiltEvOnInt1
  4468. * Description    : Read INT1_TILT
  4469. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_TILT_t
  4470. * Output         : Status of INT1_TILT see LSM6DSM_ACC_GYRO_INT1_TILT_t
  4471. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4472. *******************************************************************************/

  4473. status_t LSM6DSM_ACC_GYRO_R_TiltEvOnInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_TILT_t *value)
  4474. {
  4475. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, (u8_t *)value) )
  4476.     return MEMS_ERROR;

  4477.   *value &= LSM6DSM_ACC_GYRO_INT1_TILT_MASK; //mask

  4478.   return MEMS_SUCCESS;
  4479. }
  4480. /*******************************************************************************
  4481. * Function Name  : LSM6DSM_ACC_GYRO_W_6DEvOnInt1
  4482. * Description    : Write INT1_6D
  4483. * Input          : LSM6DSM_ACC_GYRO_INT1_6D_t
  4484. * Output         : None
  4485. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4486. *******************************************************************************/
  4487. status_t  LSM6DSM_ACC_GYRO_W_6DEvOnInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_6D_t newValue)
  4488. {
  4489.   u8_t value;

  4490.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, &value) )
  4491.     return MEMS_ERROR;

  4492.   value &= ~LSM6DSM_ACC_GYRO_INT1_6D_MASK;
  4493.   value |= newValue;
  4494.   
  4495.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, value) )
  4496.     return MEMS_ERROR;

  4497.   return MEMS_SUCCESS;
  4498. }

  4499. /*******************************************************************************
  4500. * Function Name  : LSM6DSM_ACC_GYRO_R_6DEvOnInt1
  4501. * Description    : Read INT1_6D
  4502. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_6D_t
  4503. * Output         : Status of INT1_6D see LSM6DSM_ACC_GYRO_INT1_6D_t
  4504. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4505. *******************************************************************************/

  4506. status_t LSM6DSM_ACC_GYRO_R_6DEvOnInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_6D_t *value)
  4507. {
  4508. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, (u8_t *)value) )
  4509.     return MEMS_ERROR;

  4510.   *value &= LSM6DSM_ACC_GYRO_INT1_6D_MASK; //mask

  4511.   return MEMS_SUCCESS;
  4512. }
  4513. /*******************************************************************************
  4514. * Function Name  : LSM6DSM_ACC_GYRO_W_TapEvOnInt1
  4515. * Description    : Write INT1_TAP
  4516. * Input          : LSM6DSM_ACC_GYRO_INT1_TAP_t
  4517. * Output         : None
  4518. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4519. *******************************************************************************/
  4520. status_t  LSM6DSM_ACC_GYRO_W_TapEvOnInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_TAP_t newValue)
  4521. {
  4522.   u8_t value;

  4523.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, &value) )
  4524.     return MEMS_ERROR;

  4525.   value &= ~LSM6DSM_ACC_GYRO_INT1_TAP_MASK;
  4526.   value |= newValue;
  4527.   
  4528.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, value) )
  4529.     return MEMS_ERROR;

  4530.   return MEMS_SUCCESS;
  4531. }

  4532. /*******************************************************************************
  4533. * Function Name  : LSM6DSM_ACC_GYRO_R_TapEvOnInt1
  4534. * Description    : Read INT1_TAP
  4535. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_TAP_t
  4536. * Output         : Status of INT1_TAP see LSM6DSM_ACC_GYRO_INT1_TAP_t
  4537. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4538. *******************************************************************************/

  4539. status_t LSM6DSM_ACC_GYRO_R_TapEvOnInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_TAP_t *value)
  4540. {
  4541. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, (u8_t *)value) )
  4542.     return MEMS_ERROR;

  4543.   *value &= LSM6DSM_ACC_GYRO_INT1_TAP_MASK; //mask

  4544.   return MEMS_SUCCESS;
  4545. }
  4546. /*******************************************************************************
  4547. * Function Name  : LSM6DSM_ACC_GYRO_W_FFEvOnInt1
  4548. * Description    : Write INT1_FF
  4549. * Input          : LSM6DSM_ACC_GYRO_INT1_FF_t
  4550. * Output         : None
  4551. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4552. *******************************************************************************/
  4553. status_t  LSM6DSM_ACC_GYRO_W_FFEvOnInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_FF_t newValue)
  4554. {
  4555.   u8_t value;

  4556.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, &value) )
  4557.     return MEMS_ERROR;

  4558.   value &= ~LSM6DSM_ACC_GYRO_INT1_FF_MASK;
  4559.   value |= newValue;
  4560.   
  4561.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, value) )
  4562.     return MEMS_ERROR;

  4563.   return MEMS_SUCCESS;
  4564. }

  4565. /*******************************************************************************
  4566. * Function Name  : LSM6DSM_ACC_GYRO_R_FFEvOnInt1
  4567. * Description    : Read INT1_FF
  4568. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_FF_t
  4569. * Output         : Status of INT1_FF see LSM6DSM_ACC_GYRO_INT1_FF_t
  4570. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4571. *******************************************************************************/

  4572. status_t LSM6DSM_ACC_GYRO_R_FFEvOnInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_FF_t *value)
  4573. {
  4574. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, (u8_t *)value) )
  4575.     return MEMS_ERROR;

  4576.   *value &= LSM6DSM_ACC_GYRO_INT1_FF_MASK; //mask

  4577.   return MEMS_SUCCESS;
  4578. }
  4579. /*******************************************************************************
  4580. * Function Name  : LSM6DSM_ACC_GYRO_W_WUEvOnInt1
  4581. * Description    : Write INT1_WU
  4582. * Input          : LSM6DSM_ACC_GYRO_INT1_WU_t
  4583. * Output         : None
  4584. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4585. *******************************************************************************/
  4586. status_t  LSM6DSM_ACC_GYRO_W_WUEvOnInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_WU_t newValue)
  4587. {
  4588.   u8_t value;

  4589.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, &value) )
  4590.     return MEMS_ERROR;

  4591.   value &= ~LSM6DSM_ACC_GYRO_INT1_WU_MASK;
  4592.   value |= newValue;
  4593.   
  4594.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, value) )
  4595.     return MEMS_ERROR;

  4596.   return MEMS_SUCCESS;
  4597. }

  4598. /*******************************************************************************
  4599. * Function Name  : LSM6DSM_ACC_GYRO_R_WUEvOnInt1
  4600. * Description    : Read INT1_WU
  4601. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_WU_t
  4602. * Output         : Status of INT1_WU see LSM6DSM_ACC_GYRO_INT1_WU_t
  4603. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4604. *******************************************************************************/

  4605. status_t LSM6DSM_ACC_GYRO_R_WUEvOnInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_WU_t *value)
  4606. {
  4607. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, (u8_t *)value) )
  4608.     return MEMS_ERROR;

  4609.   *value &= LSM6DSM_ACC_GYRO_INT1_WU_MASK; //mask

  4610.   return MEMS_SUCCESS;
  4611. }
  4612. /*******************************************************************************
  4613. * Function Name  : LSM6DSM_ACC_GYRO_W_SingleTapOnInt1
  4614. * Description    : Write INT1_SINGLE_TAP
  4615. * Input          : LSM6DSM_ACC_GYRO_INT1_SINGLE_TAP_t
  4616. * Output         : None
  4617. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4618. *******************************************************************************/
  4619. status_t  LSM6DSM_ACC_GYRO_W_SingleTapOnInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_SINGLE_TAP_t newValue)
  4620. {
  4621.   u8_t value;

  4622.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, &value) )
  4623.     return MEMS_ERROR;

  4624.   value &= ~LSM6DSM_ACC_GYRO_INT1_SINGLE_TAP_MASK;
  4625.   value |= newValue;
  4626.   
  4627.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, value) )
  4628.     return MEMS_ERROR;

  4629.   return MEMS_SUCCESS;
  4630. }

  4631. /*******************************************************************************
  4632. * Function Name  : LSM6DSM_ACC_GYRO_R_SingleTapOnInt1
  4633. * Description    : Read INT1_SINGLE_TAP
  4634. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_SINGLE_TAP_t
  4635. * Output         : Status of INT1_SINGLE_TAP see LSM6DSM_ACC_GYRO_INT1_SINGLE_TAP_t
  4636. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4637. *******************************************************************************/

  4638. status_t LSM6DSM_ACC_GYRO_R_SingleTapOnInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_SINGLE_TAP_t *value)
  4639. {
  4640. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, (u8_t *)value) )
  4641.     return MEMS_ERROR;

  4642.   *value &= LSM6DSM_ACC_GYRO_INT1_SINGLE_TAP_MASK; //mask

  4643.   return MEMS_SUCCESS;
  4644. }
  4645. /*******************************************************************************
  4646. * Function Name  : LSM6DSM_ACC_GYRO_W_SleepEvOnInt1
  4647. * Description    : Write INT1_SLEEP
  4648. * Input          : LSM6DSM_ACC_GYRO_INT1_SLEEP_t
  4649. * Output         : None
  4650. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4651. *******************************************************************************/
  4652. status_t  LSM6DSM_ACC_GYRO_W_SleepEvOnInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_SLEEP_t newValue)
  4653. {
  4654.   u8_t value;

  4655.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, &value) )
  4656.     return MEMS_ERROR;

  4657.   value &= ~LSM6DSM_ACC_GYRO_INT1_SLEEP_MASK;
  4658.   value |= newValue;
  4659.   
  4660.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, value) )
  4661.     return MEMS_ERROR;

  4662.   return MEMS_SUCCESS;
  4663. }

  4664. /*******************************************************************************
  4665. * Function Name  : LSM6DSM_ACC_GYRO_R_SleepEvOnInt1
  4666. * Description    : Read INT1_SLEEP
  4667. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT1_SLEEP_t
  4668. * Output         : Status of INT1_SLEEP see LSM6DSM_ACC_GYRO_INT1_SLEEP_t
  4669. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4670. *******************************************************************************/

  4671. status_t LSM6DSM_ACC_GYRO_R_SleepEvOnInt1(void *handle, LSM6DSM_ACC_GYRO_INT1_SLEEP_t *value)
  4672. {
  4673. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD1_CFG, (u8_t *)value) )
  4674.     return MEMS_ERROR;

  4675.   *value &= LSM6DSM_ACC_GYRO_INT1_SLEEP_MASK; //mask

  4676.   return MEMS_SUCCESS;
  4677. }
  4678. /*******************************************************************************
  4679. * Function Name  : LSM6DSM_ACC_GYRO_W_MagCorrection_Int2
  4680. * Description    : Write INT2_IRON
  4681. * Input          : LSM6DSM_ACC_GYRO_INT2_IRON_t
  4682. * Output         : None
  4683. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4684. *******************************************************************************/
  4685. status_t  LSM6DSM_ACC_GYRO_W_MagCorrection_Int2(void *handle, LSM6DSM_ACC_GYRO_INT2_IRON_t newValue)
  4686. {
  4687.   u8_t value;

  4688.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, &value) )
  4689.     return MEMS_ERROR;

  4690.   value &= ~LSM6DSM_ACC_GYRO_INT2_IRON_MASK;
  4691.   value |= newValue;
  4692.   
  4693.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, value) )
  4694.     return MEMS_ERROR;

  4695.   return MEMS_SUCCESS;
  4696. }

  4697. /*******************************************************************************
  4698. * Function Name  : LSM6DSM_ACC_GYRO_R_MagCorrection_Int2
  4699. * Description    : Read INT2_IRON
  4700. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_IRON_t
  4701. * Output         : Status of INT2_IRON see LSM6DSM_ACC_GYRO_INT2_IRON_t
  4702. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4703. *******************************************************************************/

  4704. status_t LSM6DSM_ACC_GYRO_R_MagCorrection_Int2(void *handle, LSM6DSM_ACC_GYRO_INT2_IRON_t *value)
  4705. {
  4706. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, (u8_t *)value) )
  4707.     return MEMS_ERROR;

  4708.   *value &= LSM6DSM_ACC_GYRO_INT2_IRON_MASK; //mask

  4709.   return MEMS_SUCCESS;
  4710. }
  4711. /*******************************************************************************
  4712. * Function Name  : LSM6DSM_ACC_GYRO_W_TiltEvOnInt2
  4713. * Description    : Write INT2_TILT
  4714. * Input          : LSM6DSM_ACC_GYRO_INT2_TILT_t
  4715. * Output         : None
  4716. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4717. *******************************************************************************/
  4718. status_t  LSM6DSM_ACC_GYRO_W_TiltEvOnInt2(void *handle, LSM6DSM_ACC_GYRO_INT2_TILT_t newValue)
  4719. {
  4720.   u8_t value;

  4721.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, &value) )
  4722.     return MEMS_ERROR;

  4723.   value &= ~LSM6DSM_ACC_GYRO_INT2_TILT_MASK;
  4724.   value |= newValue;
  4725.   
  4726.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, value) )
  4727.     return MEMS_ERROR;

  4728.   return MEMS_SUCCESS;
  4729. }

  4730. /*******************************************************************************
  4731. * Function Name  : LSM6DSM_ACC_GYRO_R_TiltEvOnInt2
  4732. * Description    : Read INT2_TILT
  4733. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_TILT_t
  4734. * Output         : Status of INT2_TILT see LSM6DSM_ACC_GYRO_INT2_TILT_t
  4735. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4736. *******************************************************************************/

  4737. status_t LSM6DSM_ACC_GYRO_R_TiltEvOnInt2(void *handle, LSM6DSM_ACC_GYRO_INT2_TILT_t *value)
  4738. {
  4739. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, (u8_t *)value) )
  4740.     return MEMS_ERROR;

  4741.   *value &= LSM6DSM_ACC_GYRO_INT2_TILT_MASK; //mask

  4742.   return MEMS_SUCCESS;
  4743. }
  4744. /*******************************************************************************
  4745. * Function Name  : LSM6DSM_ACC_GYRO_W_6DEvOnInt2
  4746. * Description    : Write INT2_6D
  4747. * Input          : LSM6DSM_ACC_GYRO_INT2_6D_t
  4748. * Output         : None
  4749. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4750. *******************************************************************************/
  4751. status_t  LSM6DSM_ACC_GYRO_W_6DEvOnInt2(void *handle, LSM6DSM_ACC_GYRO_INT2_6D_t newValue)
  4752. {
  4753.   u8_t value;

  4754.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, &value) )
  4755.     return MEMS_ERROR;

  4756.   value &= ~LSM6DSM_ACC_GYRO_INT2_6D_MASK;
  4757.   value |= newValue;
  4758.   
  4759.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, value) )
  4760.     return MEMS_ERROR;

  4761.   return MEMS_SUCCESS;
  4762. }

  4763. /*******************************************************************************
  4764. * Function Name  : LSM6DSM_ACC_GYRO_R_6DEvOnInt2
  4765. * Description    : Read INT2_6D
  4766. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_6D_t
  4767. * Output         : Status of INT2_6D see LSM6DSM_ACC_GYRO_INT2_6D_t
  4768. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4769. *******************************************************************************/

  4770. status_t LSM6DSM_ACC_GYRO_R_6DEvOnInt2(void *handle, LSM6DSM_ACC_GYRO_INT2_6D_t *value)
  4771. {
  4772. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, (u8_t *)value) )
  4773.     return MEMS_ERROR;

  4774.   *value &= LSM6DSM_ACC_GYRO_INT2_6D_MASK; //mask

  4775.   return MEMS_SUCCESS;
  4776. }
  4777. /*******************************************************************************
  4778. * Function Name  : LSM6DSM_ACC_GYRO_W_TapEvOnInt2
  4779. * Description    : Write INT2_TAP
  4780. * Input          : LSM6DSM_ACC_GYRO_INT2_TAP_t
  4781. * Output         : None
  4782. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4783. *******************************************************************************/
  4784. status_t  LSM6DSM_ACC_GYRO_W_TapEvOnInt2(void *handle, LSM6DSM_ACC_GYRO_INT2_TAP_t newValue)
  4785. {
  4786.   u8_t value;

  4787.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, &value) )
  4788.     return MEMS_ERROR;

  4789.   value &= ~LSM6DSM_ACC_GYRO_INT2_TAP_MASK;
  4790.   value |= newValue;
  4791.   
  4792.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, value) )
  4793.     return MEMS_ERROR;

  4794.   return MEMS_SUCCESS;
  4795. }

  4796. /*******************************************************************************
  4797. * Function Name  : LSM6DSM_ACC_GYRO_R_TapEvOnInt2
  4798. * Description    : Read INT2_TAP
  4799. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_TAP_t
  4800. * Output         : Status of INT2_TAP see LSM6DSM_ACC_GYRO_INT2_TAP_t
  4801. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4802. *******************************************************************************/

  4803. status_t LSM6DSM_ACC_GYRO_R_TapEvOnInt2(void *handle, LSM6DSM_ACC_GYRO_INT2_TAP_t *value)
  4804. {
  4805. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, (u8_t *)value) )
  4806.     return MEMS_ERROR;

  4807.   *value &= LSM6DSM_ACC_GYRO_INT2_TAP_MASK; //mask

  4808.   return MEMS_SUCCESS;
  4809. }
  4810. /*******************************************************************************
  4811. * Function Name  : LSM6DSM_ACC_GYRO_W_FFEvOnInt2
  4812. * Description    : Write INT2_FF
  4813. * Input          : LSM6DSM_ACC_GYRO_INT2_FF_t
  4814. * Output         : None
  4815. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4816. *******************************************************************************/
  4817. status_t  LSM6DSM_ACC_GYRO_W_FFEvOnInt2(void *handle, LSM6DSM_ACC_GYRO_INT2_FF_t newValue)
  4818. {
  4819.   u8_t value;

  4820.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, &value) )
  4821.     return MEMS_ERROR;

  4822.   value &= ~LSM6DSM_ACC_GYRO_INT2_FF_MASK;
  4823.   value |= newValue;
  4824.   
  4825.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, value) )
  4826.     return MEMS_ERROR;

  4827.   return MEMS_SUCCESS;
  4828. }

  4829. /*******************************************************************************
  4830. * Function Name  : LSM6DSM_ACC_GYRO_R_FFEvOnInt2
  4831. * Description    : Read INT2_FF
  4832. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_FF_t
  4833. * Output         : Status of INT2_FF see LSM6DSM_ACC_GYRO_INT2_FF_t
  4834. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4835. *******************************************************************************/

  4836. status_t LSM6DSM_ACC_GYRO_R_FFEvOnInt2(void *handle, LSM6DSM_ACC_GYRO_INT2_FF_t *value)
  4837. {
  4838. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, (u8_t *)value) )
  4839.     return MEMS_ERROR;

  4840.   *value &= LSM6DSM_ACC_GYRO_INT2_FF_MASK; //mask

  4841.   return MEMS_SUCCESS;
  4842. }
  4843. /*******************************************************************************
  4844. * Function Name  : LSM6DSM_ACC_GYRO_W_WUEvOnInt2
  4845. * Description    : Write INT2_WU
  4846. * Input          : LSM6DSM_ACC_GYRO_INT2_WU_t
  4847. * Output         : None
  4848. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4849. *******************************************************************************/
  4850. status_t  LSM6DSM_ACC_GYRO_W_WUEvOnInt2(void *handle, LSM6DSM_ACC_GYRO_INT2_WU_t newValue)
  4851. {
  4852.   u8_t value;

  4853.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, &value) )
  4854.     return MEMS_ERROR;

  4855.   value &= ~LSM6DSM_ACC_GYRO_INT2_WU_MASK;
  4856.   value |= newValue;
  4857.   
  4858.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, value) )
  4859.     return MEMS_ERROR;

  4860.   return MEMS_SUCCESS;
  4861. }

  4862. /*******************************************************************************
  4863. * Function Name  : LSM6DSM_ACC_GYRO_R_WUEvOnInt2
  4864. * Description    : Read INT2_WU
  4865. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_WU_t
  4866. * Output         : Status of INT2_WU see LSM6DSM_ACC_GYRO_INT2_WU_t
  4867. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4868. *******************************************************************************/

  4869. status_t LSM6DSM_ACC_GYRO_R_WUEvOnInt2(void *handle, LSM6DSM_ACC_GYRO_INT2_WU_t *value)
  4870. {
  4871. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, (u8_t *)value) )
  4872.     return MEMS_ERROR;

  4873.   *value &= LSM6DSM_ACC_GYRO_INT2_WU_MASK; //mask

  4874.   return MEMS_SUCCESS;
  4875. }
  4876. /*******************************************************************************
  4877. * Function Name  : LSM6DSM_ACC_GYRO_W_SingleTapOnInt2
  4878. * Description    : Write INT2_SINGLE_TAP
  4879. * Input          : LSM6DSM_ACC_GYRO_INT2_SINGLE_TAP_t
  4880. * Output         : None
  4881. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4882. *******************************************************************************/
  4883. status_t  LSM6DSM_ACC_GYRO_W_SingleTapOnInt2(void *handle, LSM6DSM_ACC_GYRO_INT2_SINGLE_TAP_t newValue)
  4884. {
  4885.   u8_t value;

  4886.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, &value) )
  4887.     return MEMS_ERROR;

  4888.   value &= ~LSM6DSM_ACC_GYRO_INT2_SINGLE_TAP_MASK;
  4889.   value |= newValue;
  4890.   
  4891.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, value) )
  4892.     return MEMS_ERROR;

  4893.   return MEMS_SUCCESS;
  4894. }

  4895. /*******************************************************************************
  4896. * Function Name  : LSM6DSM_ACC_GYRO_R_SingleTapOnInt2
  4897. * Description    : Read INT2_SINGLE_TAP
  4898. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_SINGLE_TAP_t
  4899. * Output         : Status of INT2_SINGLE_TAP see LSM6DSM_ACC_GYRO_INT2_SINGLE_TAP_t
  4900. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4901. *******************************************************************************/

  4902. status_t LSM6DSM_ACC_GYRO_R_SingleTapOnInt2(void *handle, LSM6DSM_ACC_GYRO_INT2_SINGLE_TAP_t *value)
  4903. {
  4904. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, (u8_t *)value) )
  4905.     return MEMS_ERROR;

  4906.   *value &= LSM6DSM_ACC_GYRO_INT2_SINGLE_TAP_MASK; //mask

  4907.   return MEMS_SUCCESS;
  4908. }
  4909. /*******************************************************************************
  4910. * Function Name  : LSM6DSM_ACC_GYRO_W_SleepEvOnInt2
  4911. * Description    : Write INT2_SLEEP
  4912. * Input          : LSM6DSM_ACC_GYRO_INT2_SLEEP_t
  4913. * Output         : None
  4914. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4915. *******************************************************************************/
  4916. status_t  LSM6DSM_ACC_GYRO_W_SleepEvOnInt2(void *handle, LSM6DSM_ACC_GYRO_INT2_SLEEP_t newValue)
  4917. {
  4918.   u8_t value;

  4919.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, &value) )
  4920.     return MEMS_ERROR;

  4921.   value &= ~LSM6DSM_ACC_GYRO_INT2_SLEEP_MASK;
  4922.   value |= newValue;
  4923.   
  4924.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, value) )
  4925.     return MEMS_ERROR;

  4926.   return MEMS_SUCCESS;
  4927. }

  4928. /*******************************************************************************
  4929. * Function Name  : LSM6DSM_ACC_GYRO_R_SleepEvOnInt2
  4930. * Description    : Read INT2_SLEEP
  4931. * Input          : Pointer to LSM6DSM_ACC_GYRO_INT2_SLEEP_t
  4932. * Output         : Status of INT2_SLEEP see LSM6DSM_ACC_GYRO_INT2_SLEEP_t
  4933. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4934. *******************************************************************************/

  4935. status_t LSM6DSM_ACC_GYRO_R_SleepEvOnInt2(void *handle, LSM6DSM_ACC_GYRO_INT2_SLEEP_t *value)
  4936. {
  4937. if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_MD2_CFG, (u8_t *)value) )
  4938.     return MEMS_ERROR;

  4939.   *value &= LSM6DSM_ACC_GYRO_INT2_SLEEP_MASK; //mask

  4940.   return MEMS_SUCCESS;
  4941. }

  4942. /*******************************************************************************
  4943. * Function Name  : status_t LSM6DSM_ACC_GYRO_GetRawGyroData(u8_t *buff)
  4944. * Description    : Read GetGyroData output register
  4945. * Input          : pointer to [u8_t]
  4946. * Output         : GetGyroData buffer u8_t
  4947. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  4948. *******************************************************************************/
  4949. status_t LSM6DSM_ACC_GYRO_GetRawGyroData(void *handle, u8_t *buff)
  4950. {
  4951.   u8_t i, j, k;
  4952.   u8_t numberOfByteForDimension;
  4953.   
  4954.   numberOfByteForDimension=6/3;

  4955.   k=0;
  4956.   for (i=0; i<3;i++ )
  4957.   {
  4958.         for (j=0; j<numberOfByteForDimension;j++ )
  4959.         {       
  4960.                 if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_OUTX_L_G+k, &buff[k]))
  4961.                   return MEMS_ERROR;
  4962.                 k++;       
  4963.         }
  4964.   }

  4965.   return MEMS_SUCCESS;
  4966. }

  4967. /*
  4968. * Following is the table of sensitivity values for each case.
  4969. * Values are espressed in udps/digit.
  4970. */
  4971. static const long long LSM6DSM_GYRO_Sensitivity_List[5] = {
  4972.       4375,        /* FS [url=home.php?mod=space&uid=42867]@125[/url] */
  4973.       8750,        /* FS [url=home.php?mod=space&uid=454190]@245[/url] */
  4974.       17500,        /* FS @500 */
  4975.       35000,        /* FS [url=home.php?mod=space&uid=27776]@1000[/url] */
  4976.       70000,        /* FS [url=home.php?mod=space&uid=3290]@2000[/url] */
  4977. };

  4978. /*
  4979. * Returned values are espressed in mdps.
  4980. */
  4981. status_t LSM6DSM_ACC_Get_AngularRate(void *handle, int *buff, u8_t from_fifo)
  4982. {
  4983.   LSM6DSM_ACC_GYRO_FS_125_t fs_125;
  4984.   LSM6DSM_ACC_GYRO_FS_G_t fs;
  4985.   long long sensitivity=0;
  4986.   Type3Axis16bit_U raw_data_tmp;

  4987.   /* Read out current odr, fs, hf setting */
  4988.   if(!LSM6DSM_ACC_GYRO_R_FS_125(handle, &fs_125)) {
  4989.     return MEMS_ERROR;
  4990.   }

  4991.   if (fs_125 == LSM6DSM_ACC_GYRO_FS_125_ENABLED) {
  4992.     sensitivity = LSM6DSM_GYRO_Sensitivity_List[0];
  4993.   } else {
  4994.     if(!LSM6DSM_ACC_GYRO_R_FS_G(handle, &fs)) {
  4995.       return MEMS_ERROR;
  4996.     }

  4997.     /* Determine the sensitivity according to fs */
  4998.     switch(fs) {
  4999.     case LSM6DSM_ACC_GYRO_FS_G_245dps:
  5000.       sensitivity = LSM6DSM_GYRO_Sensitivity_List[1];
  5001.       break;

  5002.     case LSM6DSM_ACC_GYRO_FS_G_500dps:
  5003.       sensitivity = LSM6DSM_GYRO_Sensitivity_List[2];
  5004.       break;

  5005.     case LSM6DSM_ACC_GYRO_FS_G_1000dps:
  5006.       sensitivity = LSM6DSM_GYRO_Sensitivity_List[3];
  5007.       break;

  5008.     case LSM6DSM_ACC_GYRO_FS_G_2000dps:
  5009.       sensitivity = LSM6DSM_GYRO_Sensitivity_List[4];
  5010.       break;
  5011.     }
  5012.   }

  5013.   /* Read out raw accelerometer samples */
  5014.   if (from_fifo) {
  5015.     u8_t i;

  5016.     /* read all 3 axis from FIFO */
  5017.     for(i = 0; i < 3; i++) {
  5018.       if(!LSM6DSM_ACC_GYRO_Get_GetFIFOData(handle, raw_data_tmp.u8bit + 2*i)) {
  5019.         return MEMS_ERROR;
  5020.       }
  5021.     }
  5022.   } else {
  5023.     if(!LSM6DSM_ACC_GYRO_GetRawGyroData(handle, raw_data_tmp.u8bit)) {
  5024.       return MEMS_ERROR;
  5025.     }
  5026.   }

  5027.   /* Apply proper shift and sensitivity */
  5028.   buff[0] = (raw_data_tmp.i16bit[0] * sensitivity + 500)/1000;
  5029.   buff[1] = (raw_data_tmp.i16bit[1] * sensitivity + 500)/1000;
  5030.   buff[2] = (raw_data_tmp.i16bit[2] * sensitivity + 500)/1000;

  5031.   return MEMS_SUCCESS;
  5032. }

  5033. /*******************************************************************************
  5034. * Function Name  : status_t LSM6DSM_ACC_GYRO_GetRawAccData(u8_t *buff)
  5035. * Description    : Read GetAccData output register
  5036. * Input          : pointer to [u8_t]
  5037. * Output         : GetAccData buffer u8_t
  5038. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  5039. *******************************************************************************/
  5040. status_t LSM6DSM_ACC_GYRO_GetRawAccData(void *handle, u8_t *buff)
  5041. {
  5042.   u8_t i, j, k;
  5043.   u8_t numberOfByteForDimension;
  5044.   
  5045.   numberOfByteForDimension=6/3;

  5046.   k=0;
  5047.   for (i=0; i<3;i++ ) {
  5048.         for (j=0; j<numberOfByteForDimension;j++ ) {       
  5049.                 if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_OUTX_L_XL+k, &buff[k]))
  5050.                   return MEMS_ERROR;
  5051.                 k++;       
  5052.         }
  5053.   }

  5054.   return MEMS_SUCCESS;
  5055. }

  5056. /*
  5057. * Following is the table of sensitivity values for each case.
  5058. * Values are espressed in ug/digit.
  5059. */
  5060. static const long long LSM6DSM_ACC_Sensitivity_List[4] = {
  5061.       61,        /* FS @2g */
  5062.       122,        /* FS @4g */
  5063.       244,        /* FS @8g */
  5064.       488,        /* FS @16g */
  5065. };

  5066. /*
  5067. * Returned values are espressed in mg.
  5068. */
  5069. status_t LSM6DSM_ACC_Get_Acceleration(void *handle, int *buff, u8_t from_fifo)
  5070. {
  5071.   LSM6DSM_ACC_GYRO_FS_XL_t fs;
  5072.   long long sensitivity=0;
  5073.   Type3Axis16bit_U raw_data_tmp;

  5074.   /* Read out current odr, fs, hf setting */
  5075.   if(!LSM6DSM_ACC_GYRO_R_FS_XL(handle, &fs)) {
  5076.     return MEMS_ERROR;
  5077.   }

  5078.   /* Determine the sensitivity according to fs */
  5079.   switch(fs) {
  5080.   case LSM6DSM_ACC_GYRO_FS_XL_2g:
  5081.     sensitivity = LSM6DSM_ACC_Sensitivity_List[0];
  5082.     break;

  5083.   case LSM6DSM_ACC_GYRO_FS_XL_4g:
  5084.     sensitivity = LSM6DSM_ACC_Sensitivity_List[1];
  5085.     break;

  5086.   case LSM6DSM_ACC_GYRO_FS_XL_8g:
  5087.     sensitivity = LSM6DSM_ACC_Sensitivity_List[2];
  5088.     break;

  5089.   case LSM6DSM_ACC_GYRO_FS_XL_16g:
  5090.     sensitivity = LSM6DSM_ACC_Sensitivity_List[3];
  5091.     break;
  5092.   }

  5093.   /* Read out raw accelerometer samples */
  5094.   if (from_fifo) {
  5095.     u8_t i;

  5096.     /* read all 3 axis from FIFO */
  5097.     for(i = 0; i < 3; i++) {
  5098.       if(!LSM6DSM_ACC_GYRO_Get_GetFIFOData(handle, raw_data_tmp.u8bit + 2*i)) {
  5099.         return MEMS_ERROR;
  5100.       }
  5101.     }
  5102.   } else {
  5103.     if(!LSM6DSM_ACC_GYRO_GetRawAccData(handle, raw_data_tmp.u8bit)) {
  5104.       return MEMS_ERROR;
  5105.     }
  5106.   }

  5107.   /* Apply proper shift and sensitivity */
  5108.   buff[0] = (raw_data_tmp.i16bit[0] * sensitivity + 500)/1000;
  5109.   buff[1] = (raw_data_tmp.i16bit[1] * sensitivity + 500)/1000;
  5110.   buff[2] = (raw_data_tmp.i16bit[2] * sensitivity + 500)/1000;

  5111.   return MEMS_SUCCESS;
  5112. }

  5113. /*******************************************************************************
  5114. * Function Name  : status_t LSM6DSM_ACC_GYRO_Get_GetFIFOData(u8_t *buff)
  5115. * Description    : Read GetFIFOData output register
  5116. * Input          : pointer to [u8_t]
  5117. * Output         : GetFIFOData buffer u8_t
  5118. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  5119. *******************************************************************************/
  5120. status_t LSM6DSM_ACC_GYRO_Get_GetFIFOData(void *handle, u8_t *buff)
  5121. {
  5122.   u8_t i, j, k;
  5123.   u8_t numberOfByteForDimension;
  5124.   
  5125.   numberOfByteForDimension=2/1;

  5126.   k=0;
  5127.   for (i=0; i<1;i++ )
  5128.   {
  5129.         for (j=0; j<numberOfByteForDimension;j++ )
  5130.         {       
  5131.                 if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_FIFO_DATA_OUT_L+k, &buff[k]))
  5132.                   return MEMS_ERROR;
  5133.                 k++;       
  5134.         }
  5135.   }

  5136.   return MEMS_SUCCESS;
  5137. }

  5138. /*******************************************************************************
  5139. * Function Name  : status_t LSM6DSM_ACC_GYRO_Get_GetTimestamp(u8_t *buff)
  5140. * Description    : Read GetTimestamp output register
  5141. * Input          : pointer to [u8_t]
  5142. * Output         : GetTimestamp buffer u8_t
  5143. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  5144. *******************************************************************************/
  5145. status_t LSM6DSM_ACC_GYRO_Get_GetTimestamp(void *handle, u8_t *buff)
  5146. {
  5147.   u8_t i, j, k;
  5148.   u8_t numberOfByteForDimension;
  5149.   
  5150.   numberOfByteForDimension=3/1;

  5151.   k=0;
  5152.   for (i=0; i<1;i++ )
  5153.   {
  5154.         for (j=0; j<numberOfByteForDimension;j++ )
  5155.         {       
  5156.                 if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_TIMESTAMP0_REG+k, &buff[k]))
  5157.                   return MEMS_ERROR;
  5158.                 k++;       
  5159.         }
  5160.   }

  5161.   return MEMS_SUCCESS;
  5162. }

  5163. /*******************************************************************************
  5164. * Function Name  : status_t LSM6DSM_ACC_GYRO_Get_GetStepCounter(u8_t *buff)
  5165. * Description    : Read GetStepCounter output register
  5166. * Input          : pointer to [u8_t]
  5167. * Output         : GetStepCounter buffer u8_t
  5168. * Return         : Status [MEMS_ERROR, MEMS_SUCCESS]
  5169. *******************************************************************************/
  5170. status_t LSM6DSM_ACC_GYRO_Get_GetStepCounter(void *handle, u8_t *buff)
  5171. {
  5172.   u8_t i, j, k;
  5173.   u8_t numberOfByteForDimension;
  5174.   
  5175.   numberOfByteForDimension=2/1;

  5176.   k=0;
  5177.   for (i=0; i<1;i++ )
  5178.   {
  5179.         for (j=0; j<numberOfByteForDimension;j++ )
  5180.         {       
  5181.                 if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_STEP_COUNTER_L+k, &buff[k]))
  5182.                   return MEMS_ERROR;
  5183.                 k++;       
  5184.         }
  5185.   }

  5186.   return MEMS_SUCCESS;
  5187. }

  5188. /************** Program Pedometer Threshold  *******************/
  5189. status_t  LSM6DSM_ACC_GYRO_W_PedoThreshold(void *handle, u8_t newValue)
  5190. {
  5191.   u8_t value;

  5192.   /* Open Embedded Function Register page*/
  5193.   if( !LSM6DSM_ACC_GYRO_W_EmbeddedAccess(handle, LSM6DSM_ACC_GYRO_EMBEDDED_ACCESS_ENABLED))
  5194.     return MEMS_ERROR;

  5195.   /* read current value */
  5196.   if( !LSM6DSM_ACC_GYRO_ReadReg(handle, LSM6DSM_ACC_GYRO_CONFIG_PEDO_THS_MIN, &value))
  5197.     return MEMS_ERROR;

  5198.   value &= ~0x1F;
  5199.   value |= (newValue & 0x1F);
  5200.   
  5201.   /* write new value */
  5202.   if( !LSM6DSM_ACC_GYRO_WriteReg(handle, LSM6DSM_ACC_GYRO_CONFIG_PEDO_THS_MIN, value))
  5203.     return MEMS_ERROR;

  5204.   /* Close Embedded Function Register page*/
  5205.   if( !LSM6DSM_ACC_GYRO_W_EmbeddedAccess(handle, LSM6DSM_ACC_GYRO_EMBEDDED_ACCESS_DISABLED))
  5206.     return MEMS_ERROR;

  5207.   return MEMS_SUCCESS;
  5208. }


  5209. /************** Use Sensor Hub  *******************/

  5210. /*
  5211. * Program the nine Soft Iron Matrix coefficients.
  5212. * The SI_Matrix buffer must provide coefficients
  5213. * in xx, xy, xz, yx, yy, yz, zx, zy, zz order.
  5214. */
  5215. status_t LSM6DSM_ACC_GYRO_SH_init_SI_Matrix(void *handle, u8_t *SI_matrix)
  5216. {
  5217.   /* Open Embedded Function Register page*/
  5218.   if( !LSM6DSM_ACC_GYRO_W_EmbeddedAccess(handle, LSM6DSM_ACC_GYRO_EMBEDDED_ACCESS_ENABLED))
  5219.     return MEMS_ERROR;

  5220.   /* Write the Soft Iron Matrix coefficients */
  5221.   if( !LSM6DSM_ACC_GYRO_WriteMem(handle, LSM6DSM_ACC_GYRO_MAG_SI_XX, SI_matrix, 9))
  5222.     return MEMS_ERROR;

  5223.   /* Close Embedded Function Register page*/
  5224.   if( !LSM6DSM_ACC_GYRO_W_EmbeddedAccess(handle, LSM6DSM_ACC_GYRO_EMBEDDED_ACCESS_DISABLED))
  5225.     return MEMS_ERROR;

  5226.   return MEMS_SUCCESS;
  5227. }

  5228. /* Read a remote device through I2C Sensor Hub Slave 0 */
  5229. status_t LSM6DSM_ACC_GYRO_SH0_Program(void *handle, u8_t SlvAddr, u8_t Reg, u8_t len)
  5230. {
  5231.   /* Open Embedded Function Register page*/
  5232.   if( !LSM6DSM_ACC_GYRO_W_EmbeddedAccess(handle, LSM6DSM_ACC_GYRO_EMBEDDED_ACCESS_ENABLED))
  5233.     return MEMS_ERROR;

  5234.   /* Write remote device I2C slave address */
  5235.   SlvAddr |= 0x1; /* Raise the read op bit */
  5236.   if( !LSM6DSM_ACC_GYRO_WriteMem(handle, LSM6DSM_ACC_GYRO_SLV0_ADD, &SlvAddr, 1))
  5237.     return MEMS_ERROR;

  5238.   /* Write remote device I2C subaddress */
  5239.   if( !LSM6DSM_ACC_GYRO_WriteMem(handle, LSM6DSM_ACC_GYRO_SLV0_SUBADD, &Reg, 1))
  5240.     return MEMS_ERROR;

  5241.   /* Write number of bytes to read */
  5242.   if( !LSM6DSM_ACC_GYRO_WriteMem(handle, LSM6DSM_ACC_GYRO_SLAVE0_CONFIG, &len, 1))
  5243.     return MEMS_ERROR;

  5244.   /* Close Embedded Function Register page*/
  5245.   if( !LSM6DSM_ACC_GYRO_W_EmbeddedAccess(handle, LSM6DSM_ACC_GYRO_EMBEDDED_ACCESS_DISABLED))
  5246.     return MEMS_ERROR;

  5247.   /* Enable FUNC */
  5248.   if( !LSM6DSM_ACC_GYRO_W_FUNC_EN(handle, LSM6DSM_ACC_GYRO_FUNC_EN_ENABLED))
  5249.     return MEMS_ERROR;

  5250.   /* Enable PULL_UP_EN and MASTER_EN */
  5251.   if( !LSM6DSM_ACC_GYRO_W_PULL_UP_EN(handle, LSM6DSM_ACC_GYRO_PULL_UP_EN_ENABLED))
  5252.     return MEMS_ERROR;
  5253.   if( !LSM6DSM_ACC_GYRO_W_I2C_MASTER_Enable(handle, LSM6DSM_ACC_GYRO_MASTER_ON_ENABLED))
  5254.     return MEMS_ERROR;

  5255.   return MEMS_SUCCESS;
  5256. }

  5257. /* Read a remote device through I2C Sensor Hub Slave 0 */
  5258. status_t LSM6DSM_ACC_GYRO_SH0_ReadMem(void *handle, u8_t SlvAddr, u8_t Reg, u8_t *Bufp, u8_t len, u8_t stop)
  5259. {
  5260.   LSM6DSM_ACC_GYRO_SENS_HUB_END_t op_cmpl = LSM6DSM_ACC_GYRO_SENS_HUB_END_STILL_ONGOING;

  5261.   if( !LSM6DSM_ACC_GYRO_SH0_Program(handle, SlvAddr, Reg, len))
  5262.     return MEMS_ERROR;

  5263.   /* Wait until operation is not completed */
  5264.   do {
  5265.     if( !LSM6DSM_ACC_GYRO_R_SENS_HUB_END(handle, &op_cmpl))
  5266.       return MEMS_ERROR;
  5267.   } while(op_cmpl != LSM6DSM_ACC_GYRO_SENS_HUB_END_OP_COMPLETED);

  5268.   /* Read the result */
  5269.   if( !LSM6DSM_ACC_GYRO_ReadMem(handle, LSM6DSM_ACC_GYRO_SENSORHUB1_REG, Bufp, len))
  5270.     return MEMS_ERROR;

  5271.   if (stop) {
  5272.     /* Stop everything */
  5273.     if( !LSM6DSM_ACC_GYRO_W_FUNC_EN(handle, LSM6DSM_ACC_GYRO_FUNC_EN_DISABLED))
  5274.       return MEMS_ERROR;
  5275.     if( !LSM6DSM_ACC_GYRO_W_I2C_MASTER_Enable(handle, LSM6DSM_ACC_GYRO_MASTER_ON_DISABLED))
  5276.       return MEMS_ERROR;
  5277.   }

  5278.   return MEMS_SUCCESS;
  5279. }

  5280. /* Write a remote device through I2C Sensor Hub Slave 0 */
  5281. status_t LSM6DSM_ACC_GYRO_SH0_WriteByte(void *handle, u8_t SlvAddr, u8_t Reg, u8_t Bufp)
  5282. {
  5283.   /* Open Embedded Function Register page*/
  5284.   if( !LSM6DSM_ACC_GYRO_W_EmbeddedAccess(handle, LSM6DSM_ACC_GYRO_EMBEDDED_ACCESS_ENABLED))
  5285.     return MEMS_ERROR;

  5286.   /* Write remote device I2C slave address */
  5287.   if( !LSM6DSM_ACC_GYRO_WriteMem(handle, LSM6DSM_ACC_GYRO_SLV0_ADD, &SlvAddr, 1))
  5288.     return MEMS_ERROR;

  5289.   /* Write remote device I2C subaddress */
  5290.   if( !LSM6DSM_ACC_GYRO_WriteMem(handle, LSM6DSM_ACC_GYRO_SLV0_SUBADD, &Reg, 1))
  5291.     return MEMS_ERROR;

  5292.   /* Write the data */
  5293.   if( !LSM6DSM_ACC_GYRO_WriteMem(handle, LSM6DSM_ACC_GYRO_DATAWRITE_SRC_MODE_SUB_SLV0, &Bufp, 1))
  5294.     return MEMS_ERROR;

  5295.   /* Close Embedded Function Register page*/
  5296.   if( !LSM6DSM_ACC_GYRO_W_EmbeddedAccess(handle, LSM6DSM_ACC_GYRO_EMBEDDED_ACCESS_DISABLED))
  5297.     return MEMS_ERROR;

  5298.   /* Enable FUNC */
  5299.   if( !LSM6DSM_ACC_GYRO_W_FUNC_EN(handle, LSM6DSM_ACC_GYRO_FUNC_EN_ENABLED))
  5300.     return MEMS_ERROR;

  5301.   /* Enable PULL_UP_EN and MASTER_EN */
  5302.   if( !LSM6DSM_ACC_GYRO_W_PULL_UP_EN(handle, LSM6DSM_ACC_GYRO_PULL_UP_EN_ENABLED))
  5303.     return MEMS_ERROR;
  5304.   if( !LSM6DSM_ACC_GYRO_W_I2C_MASTER_Enable(handle, LSM6DSM_ACC_GYRO_MASTER_ON_ENABLED))
  5305.     return MEMS_ERROR;

  5306.   /* Add 20ms of delay, because for now there's no write complete indication */
  5307.   //Delay(20);

  5308.   /* Stop everything */
  5309.   if( !LSM6DSM_ACC_GYRO_W_FUNC_EN(handle, LSM6DSM_ACC_GYRO_FUNC_EN_DISABLED))
  5310.     return MEMS_ERROR;
  5311.   if( !LSM6DSM_ACC_GYRO_W_I2C_MASTER_Enable(handle, LSM6DSM_ACC_GYRO_MASTER_ON_DISABLED))
  5312.     return MEMS_ERROR;

  5313.   return MEMS_SUCCESS;
  5314. }

虾扯蛋,蛋扯虾,虾扯蛋扯虾
点赞  2017-12-21 18:14
引用: littleshrimp 发表于 2017-12-21 18:14
试试官方的驱动库


[code]
/******************** (C) COPYRIGHT 2015 STMicroelectr ...

好的 多谢版主
点赞  2017-12-21 18:17
问题解决了,参考如图这两种配置就可以解决问题。解答留给遇到同样问题的童鞋们,不要感谢我,感谢版主!
  • lsm6dsm.bmp
点赞  2017-12-22 14:17
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复