static DrvStatusTypeDef
LSM6DSM_G_Init( DrvContextTypeDef *handle
)
{
GYRO_Data_t *pData = ( GYRO_Data_t
* )handle->pData;
LSM6DSM_G_Data_t *pComponentData
= ( LSM6DSM_G_Data_t
* )pData->pComponentData;
LSM6DSM_Combo_Data_t *comboData = pComponentData->comboData;
if ( LSM6DSM_Check_WhoAmI( handle
) == COMPONENT_ERROR
)
{
return COMPONENT_ERROR;
}
/* Enable register address automatically incremented during a
multiple byte
access with a serial interface. */
if ( LSM6DSM_ACC_GYRO_W_IF_Addr_Incr( (void *)handle, LSM6DSM_ACC_GYRO_IF_INC_ENABLED
) == MEMS_ERROR )
{
return COMPONENT_ERROR;
}
/* Enable BDU */
if ( LSM6DSM_ACC_GYRO_W_BDU( (void *)handle, LSM6DSM_ACC_GYRO_BDU_BLOCK_UPDATE
) == MEMS_ERROR )
{
return COMPONENT_ERROR;
}
/* FIFO mode selection */
if ( LSM6DSM_ACC_GYRO_W_FIFO_MODE( (void *)handle, LSM6DSM_ACC_GYRO_FIFO_MODE_BYPASS
) == MEMS_ERROR )
{
return COMPONENT_ERROR;
}
/* Select default output data rate. */
pComponentData->Previous_ODR = 104.0f;
/* Output data rate selection - power down */
if ( LSM6DSM_ACC_GYRO_W_ODR_G( (void *)handle, LSM6DSM_ACC_GYRO_ODR_G_POWER_DOWN
) == MEMS_ERROR )
{
return COMPONENT_ERROR;
}
/* Full scale selection. */
if ( LSM6DSM_G_Set_FS( handle, FS_HIGH
) == COMPONENT_ERROR
)
{
return COMPONENT_ERROR;
}
comboData->isGyroInitialized = 1;
handle->isInitialized = 1;
return COMPONENT_OK;
}
|