Skip to content

Commit

Permalink
Merge pull request #18 from patricklaf/main
Browse files Browse the repository at this point in the history
Add support for FIFO compression
  • Loading branch information
cparata authored Jun 29, 2022
2 parents 3ef77e4 + c2c0339 commit c075b24
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 0 deletions.
91 changes: 91 additions & 0 deletions src/LSM6DSOXSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3252,6 +3252,97 @@ LSM6DSOXStatusTypeDef LSM6DSOXSensor::Set_FIFO_Timestamp_Decimation(uint8_t Deci
return ret;
}

/**
* @brief Set the LSM6DSOX FIFO compression initialization status
* @param Status FIFO compression initialization status
* @retval 0 in case of success, an error code otherwise
*/
LSM6DSOXStatusTypeDef LSM6DSOXSensor::Set_FIFO_Compression_Algo_Init(uint8_t Status)
{
if (lsm6dsox_compression_algo_init_set(&reg_ctx, Status) != LSM6DSOX_OK)
{
return LSM6DSOX_ERROR;
}

return LSM6DSOX_OK;
}

/**
* @brief Set the LSM6DSOX FIFO compression enable status
* @param Status FIFO compression enable status
* @retval 0 in case of success, an error code otherwise
*/
LSM6DSOXStatusTypeDef LSM6DSOXSensor::Set_FIFO_Compression_Algo_Enable(uint8_t Status)
{
lsm6dsox_emb_sens_t val;
if (lsm6dsox_embedded_sens_get(&reg_ctx, &val) != LSM6DSOX_OK)
{
return LSM6DSOX_ERROR;
}

val.fifo_compr = Status;

if (lsm6dsox_embedded_sens_set(&reg_ctx, &val) != LSM6DSOX_OK)
{
return LSM6DSOX_ERROR;
}

return LSM6DSOX_OK;
}

/**
* @brief Set the LSM6DSOX FIFO compression configuration and enable status
* @param Compression FIFO compression and enable status
* @retval 0 in case of success, an error code otherwise
*/
LSM6DSOXStatusTypeDef LSM6DSOXSensor::Set_FIFO_Compression_Algo_Set(uint8_t Compression)
{
LSM6DSOXStatusTypeDef ret = LSM6DSOX_OK;

/* Verify that the passed parameter contains one of the valid values. */
switch ((lsm6dsox_uncoptr_rate_t)Compression)
{
case LSM6DSOX_CMP_DISABLE:
case LSM6DSOX_CMP_ALWAYS:
case LSM6DSOX_CMP_8_TO_1:
case LSM6DSOX_CMP_16_TO_1:
case LSM6DSOX_CMP_32_TO_1:
break;

default:
ret = LSM6DSOX_ERROR;
break;
}


if (ret == LSM6DSOX_ERROR)
{
return ret;
}

if (lsm6dsox_compression_algo_set(&reg_ctx, (lsm6dsox_uncoptr_rate_t)Compression) != LSM6DSOX_OK)
{
return LSM6DSOX_ERROR;
}

return ret;
}

/**
* @brief Set the LSM6DSOX FIFO compression real time enable status
* @param Status FIFO compression real time enable status
* @retval 0 in case of success, an error code otherwise
*/
LSM6DSOXStatusTypeDef LSM6DSOXSensor::Set_FIFO_Compression_Algo_Real_Time_Set(uint8_t Status)
{
if (lsm6dsox_compression_algo_real_time_set(&reg_ctx, Status) != LSM6DSOX_OK)
{
return LSM6DSOX_ERROR;
}

return LSM6DSOX_OK;
}

int32_t LSM6DSOX_io_write(void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite)
{
return ((LSM6DSOXSensor *)handle)->IO_Write(pBuffer, WriteAddr, nBytesToWrite);
Expand Down
8 changes: 8 additions & 0 deletions src/LSM6DSOXSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ class LSM6DSOXSensor

LSM6DSOXStatusTypeDef Set_FIFO_Timestamp_Decimation(uint8_t Decimation);

LSM6DSOXStatusTypeDef Set_FIFO_Compression_Algo_Init(uint8_t Status);

LSM6DSOXStatusTypeDef Set_FIFO_Compression_Algo_Enable(uint8_t Status);

LSM6DSOXStatusTypeDef Set_FIFO_Compression_Algo_Set(uint8_t Compression);

LSM6DSOXStatusTypeDef Set_FIFO_Compression_Algo_Real_Time_Set(uint8_t Status);

/**
* @brief Utility function to read data.
* @param pBuffer: pointer to data to be read.
Expand Down

0 comments on commit c075b24

Please sign in to comment.