Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c24a312

Browse filesBrowse files
authored
Merge pull request #17 from patricklaf/main
Add support for FIFO timestamp
2 parents 9026fe2 + b757e91 commit c24a312
Copy full SHA for c24a312

File tree

Expand file treeCollapse file tree

2 files changed

+88
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+88
-0
lines changed

‎src/LSM6DSOXSensor.cpp

Copy file name to clipboardExpand all lines: src/LSM6DSOXSensor.cpp
+82Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,6 +3018,22 @@ LSM6DSOXStatusTypeDef LSM6DSOXSensor::Get_FIFO_Data(uint8_t *Data)
30183018
return LSM6DSOX_OK;
30193019
}
30203020

3021+
/**
3022+
* @brief Get the LSM6DSOX FIFO sample
3023+
* @param Sample FIFO sample array [multiple of 7]
3024+
* @param Count Count of samples to get.
3025+
* @retval 0 in case of success, an error code otherwise
3026+
*/
3027+
LSM6DSOXStatusTypeDef LSM6DSOXSensor::Get_FIFO_Sample(uint8_t *Sample, uint16_t Count)
3028+
{
3029+
if (lsm6dsox_read_reg(&reg_ctx, LSM6DSOX_FIFO_DATA_OUT_TAG, Sample, Count * 7) != LSM6DSOX_OK)
3030+
{
3031+
return LSM6DSOX_ERROR;
3032+
}
3033+
3034+
return LSM6DSOX_OK;
3035+
}
3036+
30213037
/**
30223038
* @brief Get the LSM6DSOX FIFO accelero single sample (16-bit data per 3 axes) and calculate acceleration [mg]
30233039
* @param Acceleration FIFO accelero axes [mg]
@@ -3170,6 +3186,72 @@ LSM6DSOXStatusTypeDef LSM6DSOXSensor::Get_MLC_Output(uint8_t *Output)
31703186
return LSM6DSOX_OK;
31713187
}
31723188

3189+
/**
3190+
* @brief Get the LSM6DSOX timestamp enable status
3191+
* @param Status Timestamp enable status
3192+
* @retval 0 in case of success, an error code otherwise
3193+
*/
3194+
LSM6DSOXStatusTypeDef LSM6DSOXSensor::Get_Timestamp_Status(uint8_t *Status)
3195+
{
3196+
if (lsm6dsox_timestamp_get(&reg_ctx, Status) != LSM6DSOX_OK)
3197+
{
3198+
return LSM6DSOX_ERROR;
3199+
}
3200+
3201+
return LSM6DSOX_OK;
3202+
}
3203+
3204+
/**
3205+
* @brief Set the LSM6DSOX timestamp enable status
3206+
* @param Status Timestamp enable status
3207+
* @retval 0 in case of success, an error code otherwise
3208+
*/
3209+
LSM6DSOXStatusTypeDef LSM6DSOXSensor::Set_Timestamp_Status(uint8_t Status)
3210+
{
3211+
if (lsm6dsox_timestamp_set(&reg_ctx, Status) != LSM6DSOX_OK)
3212+
{
3213+
return LSM6DSOX_ERROR;
3214+
}
3215+
3216+
return LSM6DSOX_OK;
3217+
}
3218+
3219+
/**
3220+
* @brief Set the LSM6DSOX FIFO timestamp decimation
3221+
* @param Decimation FIFO timestamp decimation
3222+
* @retval 0 in case of success, an error code otherwise
3223+
*/
3224+
LSM6DSOXStatusTypeDef LSM6DSOXSensor::Set_FIFO_Timestamp_Decimation(uint8_t Decimation)
3225+
{
3226+
LSM6DSOXStatusTypeDef ret = LSM6DSOX_OK;
3227+
3228+
/* Verify that the passed parameter contains one of the valid values. */
3229+
switch ((lsm6dsox_odr_ts_batch_t)Decimation)
3230+
{
3231+
case LSM6DSOX_NO_DECIMATION:
3232+
case LSM6DSOX_DEC_1:
3233+
case LSM6DSOX_DEC_8:
3234+
case LSM6DSOX_DEC_32:
3235+
break;
3236+
3237+
default:
3238+
ret = LSM6DSOX_ERROR;
3239+
break;
3240+
}
3241+
3242+
if (ret == LSM6DSOX_ERROR)
3243+
{
3244+
return ret;
3245+
}
3246+
3247+
if (lsm6dsox_fifo_timestamp_decimation_set(&reg_ctx, (lsm6dsox_odr_ts_batch_t)Decimation) != LSM6DSOX_OK)
3248+
{
3249+
return LSM6DSOX_ERROR;
3250+
}
3251+
3252+
return ret;
3253+
}
3254+
31733255
int32_t LSM6DSOX_io_write(void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite)
31743256
{
31753257
return ((LSM6DSOXSensor *)handle)->IO_Write(pBuffer, WriteAddr, nBytesToWrite);

‎src/LSM6DSOXSensor.h

Copy file name to clipboardExpand all lines: src/LSM6DSOXSensor.h
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ class LSM6DSOXSensor
213213
LSM6DSOXStatusTypeDef Set_FIFO_Mode(uint8_t Mode);
214214
LSM6DSOXStatusTypeDef Get_FIFO_Tag(uint8_t *Tag);
215215
LSM6DSOXStatusTypeDef Get_FIFO_Data(uint8_t *Data);
216+
LSM6DSOXStatusTypeDef Get_FIFO_Sample(uint8_t *Sample, uint16_t Count = 1);
216217
LSM6DSOXStatusTypeDef Get_FIFO_X_Axes(int32_t *Acceleration);
217218
LSM6DSOXStatusTypeDef Set_FIFO_X_BDR(float Bdr);
218219
LSM6DSOXStatusTypeDef Get_FIFO_G_Axes(int32_t *AngularVelocity);
@@ -221,6 +222,11 @@ class LSM6DSOXSensor
221222
LSM6DSOXStatusTypeDef Get_MLC_Status(LSM6DSOX_MLC_Status_t *Status);
222223
LSM6DSOXStatusTypeDef Get_MLC_Output(uint8_t *Output);
223224

225+
LSM6DSOXStatusTypeDef Get_Timestamp_Status(uint8_t *Status);
226+
LSM6DSOXStatusTypeDef Set_Timestamp_Status(uint8_t Status);
227+
228+
LSM6DSOXStatusTypeDef Set_FIFO_Timestamp_Decimation(uint8_t Decimation);
229+
224230
/**
225231
* @brief Utility function to read data.
226232
* @param pBuffer: pointer to data to be read.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.