62 static DrvContextTypeDef GYRO_SensorHandle[ GYRO_SENSORS_MAX_NUM ];
63 static GYRO_Data_t GYRO_Data[ GYRO_SENSORS_MAX_NUM ];
64 static LSM6DSM_G_Data_t LSM6DSM_G_0_Data;
72 static DrvStatusTypeDef BSP_LSM6DSM_GYRO_Init(
void **handle );
95 case GYRO_SENSORS_AUTO:
98 if( BSP_LSM6DSM_GYRO_Init(handle) == COMPONENT_ERROR )
100 return COMPONENT_ERROR;
106 if( BSP_LSM6DSM_GYRO_Init(handle) == COMPONENT_ERROR )
108 return COMPONENT_ERROR;
119 static DrvStatusTypeDef BSP_LSM6DSM_GYRO_Init(
void **handle )
121 GYRO_Drv_t *driver = NULL;
124 if(GYRO_SensorHandle[ LSM6DSM_G_0 ].isInitialized == 1)
127 return COMPONENT_ERROR;
132 return COMPONENT_ERROR;
137 GYRO_SensorHandle[ LSM6DSM_G_0 ].who_am_i = LSM6DSM_ACC_GYRO_WHO_AM_I;
138 GYRO_SensorHandle[ LSM6DSM_G_0 ].ifType = 1;
139 GYRO_SensorHandle[ LSM6DSM_G_0 ].address = LSM6DSM_ACC_GYRO_I2C_ADDRESS_HIGH;
140 GYRO_SensorHandle[ LSM6DSM_G_0 ].spiDevice = LSM6DSM;
141 GYRO_SensorHandle[ LSM6DSM_G_0 ].instance = LSM6DSM_G_0;
142 GYRO_SensorHandle[ LSM6DSM_G_0 ].isInitialized = 0;
143 GYRO_SensorHandle[ LSM6DSM_G_0 ].isEnabled = 0;
144 GYRO_SensorHandle[ LSM6DSM_G_0 ].isCombo = 1;
145 GYRO_SensorHandle[ LSM6DSM_G_0 ].pData = (
void * )&GYRO_Data[ LSM6DSM_G_0 ];
146 GYRO_SensorHandle[ LSM6DSM_G_0 ].pVTable = (
void * )&LSM6DSM_G_Drv;
147 GYRO_SensorHandle[ LSM6DSM_G_0 ].pExtVTable = 0;
149 LSM6DSM_G_0_Data.comboData = &LSM6DSM_Combo_Data[0];
150 GYRO_Data[ LSM6DSM_G_0 ].pComponentData = (
void * )&LSM6DSM_G_0_Data;
151 GYRO_Data[ LSM6DSM_G_0 ].pExtData = 0;
153 *handle = (
void *)&GYRO_SensorHandle[ LSM6DSM_G_0 ];
155 Sensor_IO_SPI_CS_Init(*handle);
157 if(LSM6DSM_Combo_Data[0].isAccInitialized == 0)
162 return COMPONENT_ERROR;
166 driver = ( GYRO_Drv_t * )((DrvContextTypeDef *)(*handle))->pVTable;
168 if ( driver->Init == NULL )
170 memset((*handle), 0,
sizeof(DrvContextTypeDef));
172 return COMPONENT_ERROR;
175 if ( driver->Init( (DrvContextTypeDef *)(*handle) ) == COMPONENT_ERROR )
177 memset((*handle), 0,
sizeof(DrvContextTypeDef));
179 return COMPONENT_ERROR;
183 if ( LSM6DSM_ACC_GYRO_W_I2C_DISABLE( *handle, LSM6DSM_ACC_GYRO_I2C_DISABLE_SPI_ONLY ) == MEMS_ERROR )
185 return COMPONENT_ERROR;
201 DrvContextTypeDef *ctx = (DrvContextTypeDef *)(*handle);
202 GYRO_Drv_t *driver = NULL;
206 return COMPONENT_ERROR;
209 driver = ( GYRO_Drv_t * )ctx->pVTable;
211 if ( driver->DeInit == NULL )
213 return COMPONENT_ERROR;
216 if ( driver->DeInit( ctx ) == COMPONENT_ERROR )
218 return COMPONENT_ERROR;
221 memset(ctx, 0,
sizeof(DrvContextTypeDef));
239 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
240 GYRO_Drv_t *driver = NULL;
244 return COMPONENT_ERROR;
247 driver = ( GYRO_Drv_t * )ctx->pVTable;
249 if ( driver->Sensor_Enable == NULL )
251 return COMPONENT_ERROR;
254 if ( driver->Sensor_Enable( ctx ) == COMPONENT_ERROR )
256 return COMPONENT_ERROR;
273 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
274 GYRO_Drv_t *driver = NULL;
278 return COMPONENT_ERROR;
281 driver = ( GYRO_Drv_t * )ctx->pVTable;
283 if ( driver->Sensor_Disable == NULL )
285 return COMPONENT_ERROR;
288 if ( driver->Sensor_Disable( ctx ) == COMPONENT_ERROR )
290 return COMPONENT_ERROR;
306 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
310 return COMPONENT_ERROR;
313 if ( status == NULL )
315 return COMPONENT_ERROR;
318 *status = ctx->isInitialized;
333 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
337 return COMPONENT_ERROR;
340 if ( status == NULL )
342 return COMPONENT_ERROR;
345 *status = ctx->isEnabled;
360 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
364 return COMPONENT_ERROR;
367 if ( status == NULL )
369 return COMPONENT_ERROR;
372 *status = ctx->isCombo;
387 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
391 return COMPONENT_ERROR;
394 if ( instance == NULL )
396 return COMPONENT_ERROR;
399 *instance = ctx->instance;
416 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
417 GYRO_Drv_t *driver = NULL;
421 return COMPONENT_ERROR;
424 driver = ( GYRO_Drv_t * )ctx->pVTable;
426 if ( who_am_i == NULL )
428 return COMPONENT_ERROR;
430 if ( driver->Get_WhoAmI == NULL )
432 return COMPONENT_ERROR;
434 if ( driver->Get_WhoAmI( ctx, who_am_i ) == COMPONENT_ERROR )
436 return COMPONENT_ERROR;
453 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
454 GYRO_Drv_t *driver = NULL;
458 return COMPONENT_ERROR;
461 driver = ( GYRO_Drv_t * )ctx->pVTable;
463 if ( driver->Check_WhoAmI == NULL )
465 return COMPONENT_ERROR;
467 if ( driver->Check_WhoAmI( ctx ) == COMPONENT_ERROR )
469 return COMPONENT_ERROR;
487 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
488 GYRO_Drv_t *driver = NULL;
492 return COMPONENT_ERROR;
495 driver = ( GYRO_Drv_t * )ctx->pVTable;
497 if ( angular_velocity == NULL )
499 return COMPONENT_ERROR;
501 if ( driver->Get_Axes == NULL )
503 return COMPONENT_ERROR;
505 if ( driver->Get_Axes( ctx, angular_velocity ) == COMPONENT_ERROR )
507 return COMPONENT_ERROR;
525 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
526 GYRO_Drv_t *driver = NULL;
530 return COMPONENT_ERROR;
533 driver = ( GYRO_Drv_t * )ctx->pVTable;
537 return COMPONENT_ERROR;
540 if ( driver->Get_AxesRaw == NULL )
542 return COMPONENT_ERROR;
545 if ( driver->Get_AxesRaw( ctx, value ) == COMPONENT_ERROR )
547 return COMPONENT_ERROR;
564 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
565 GYRO_Drv_t *driver = NULL;
569 return COMPONENT_ERROR;
572 driver = ( GYRO_Drv_t * )ctx->pVTable;
574 if ( sensitivity == NULL )
576 return COMPONENT_ERROR;
578 if ( driver->Get_Sensitivity == NULL )
580 return COMPONENT_ERROR;
582 if ( driver->Get_Sensitivity( ctx, sensitivity ) == COMPONENT_ERROR )
584 return COMPONENT_ERROR;
602 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
603 GYRO_Drv_t *driver = NULL;
607 return COMPONENT_ERROR;
610 driver = ( GYRO_Drv_t * )ctx->pVTable;
614 return COMPONENT_ERROR;
616 if ( driver->Get_ODR == NULL )
618 return COMPONENT_ERROR;
620 if ( driver->Get_ODR( ctx, odr ) == COMPONENT_ERROR )
622 return COMPONENT_ERROR;
640 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
641 GYRO_Drv_t *driver = NULL;
645 return COMPONENT_ERROR;
648 driver = ( GYRO_Drv_t * )ctx->pVTable;
650 if ( driver->Set_ODR == NULL )
652 return COMPONENT_ERROR;
654 if ( driver->Set_ODR( ctx, odr ) == COMPONENT_ERROR )
656 return COMPONENT_ERROR;
674 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
675 GYRO_Drv_t *driver = NULL;
679 return COMPONENT_ERROR;
682 driver = ( GYRO_Drv_t * )ctx->pVTable;
684 if ( driver->Set_ODR_Value == NULL )
686 return COMPONENT_ERROR;
688 if ( driver->Set_ODR_Value( ctx, odr ) == COMPONENT_ERROR )
690 return COMPONENT_ERROR;
708 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
709 GYRO_Drv_t *driver = NULL;
713 return COMPONENT_ERROR;
716 driver = ( GYRO_Drv_t * )ctx->pVTable;
718 if ( fullScale == NULL )
720 return COMPONENT_ERROR;
722 if ( driver->Get_FS == NULL )
724 return COMPONENT_ERROR;
726 if ( driver->Get_FS( ctx, fullScale ) == COMPONENT_ERROR )
728 return COMPONENT_ERROR;
746 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
747 GYRO_Drv_t *driver = NULL;
751 return COMPONENT_ERROR;
754 driver = ( GYRO_Drv_t * )ctx->pVTable;
756 if ( driver->Set_FS == NULL )
758 return COMPONENT_ERROR;
760 if ( driver->Set_FS( ctx, fullScale ) == COMPONENT_ERROR )
762 return COMPONENT_ERROR;
780 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
781 GYRO_Drv_t *driver = NULL;
785 return COMPONENT_ERROR;
788 driver = ( GYRO_Drv_t * )ctx->pVTable;
790 if ( driver->Set_FS_Value == NULL )
792 return COMPONENT_ERROR;
794 if ( driver->Set_FS_Value( ctx, fullScale ) == COMPONENT_ERROR )
796 return COMPONENT_ERROR;
814 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
815 GYRO_Drv_t *driver = NULL;
819 return COMPONENT_ERROR;
822 driver = ( GYRO_Drv_t * )ctx->pVTable;
824 if ( xyz_enabled == NULL )
826 return COMPONENT_ERROR;
828 if ( driver->Get_Axes_Status == NULL )
830 return COMPONENT_ERROR;
832 if ( driver->Get_Axes_Status( ctx, xyz_enabled ) == COMPONENT_ERROR )
834 return COMPONENT_ERROR;
852 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
853 GYRO_Drv_t *driver = NULL;
857 return COMPONENT_ERROR;
860 driver = ( GYRO_Drv_t * )ctx->pVTable;
864 return COMPONENT_ERROR;
867 if ( driver->Read_Reg == NULL )
869 return COMPONENT_ERROR;
872 if ( driver->Read_Reg( ctx, reg, data ) == COMPONENT_ERROR )
874 return COMPONENT_ERROR;
892 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
893 GYRO_Drv_t *driver = NULL;
897 return COMPONENT_ERROR;
900 driver = ( GYRO_Drv_t * )ctx->pVTable;
902 if ( driver->Write_Reg == NULL )
904 return COMPONENT_ERROR;
907 if ( driver->Write_Reg( ctx, reg, data ) == COMPONENT_ERROR )
909 return COMPONENT_ERROR;
926 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
927 GYRO_Drv_t *driver = NULL;
931 return COMPONENT_ERROR;
934 driver = ( GYRO_Drv_t * )ctx->pVTable;
936 if ( driver->Get_DRDY_Status == NULL )
938 return COMPONENT_ERROR;
941 if ( driver->Get_DRDY_Status( ctx, status ) == COMPONENT_ERROR )
943 return COMPONENT_ERROR;
960 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
961 GYRO_Drv_t *driver = NULL;
965 return COMPONENT_ERROR;
968 driver = ( GYRO_Drv_t * )ctx->pVTable;
970 if ( enable_xyz == NULL )
972 return COMPONENT_ERROR;
974 if ( driver->Set_Axes_Status == NULL )
976 return COMPONENT_ERROR;
978 if ( driver->Set_Axes_Status( ctx, enable_xyz ) == COMPONENT_ERROR )
980 return COMPONENT_ERROR;
DrvStatusTypeDef BSP_GYRO_Get_Axes_Status(void *handle, uint8_t *xyz_enabled)
Get the gyroscope sensor axes status.
DrvStatusTypeDef BSP_GYRO_Get_WhoAmI(void *handle, uint8_t *who_am_i)
Get the WHO_AM_I ID of the gyroscope sensor.
DrvStatusTypeDef BSP_GYRO_Sensor_Disable(void *handle)
Disable gyroscope sensor.
DrvStatusTypeDef BSP_GYRO_IsEnabled(void *handle, uint8_t *status)
Check if the gyroscope sensor is enabled.
DrvStatusTypeDef BSP_GYRO_Set_FS_Value(void *handle, float fullScale)
Set the gyroscope sensor full scale.
DrvStatusTypeDef BSP_GYRO_Write_Reg(void *handle, uint8_t reg, uint8_t data)
Write the data to register.
DrvStatusTypeDef BSP_GYRO_Init(GYRO_ID_t id, void **handle)
Initialize a gyroscope sensor.
DrvStatusTypeDef BSP_GYRO_Set_FS(void *handle, SensorFs_t fullScale)
Set the gyroscope sensor full scale.
uint8_t Sensor_IO_Write(void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite)
Writes a buffer to the sensor.
DrvStatusTypeDef BSP_GYRO_Read_Reg(void *handle, uint8_t reg, uint8_t *data)
Read the data from register.
DrvStatusTypeDef Sensor_IO_SPI_Init(void)
Configures sensor SPI interface.
This file contains definitions for SensorTile_gyro.c driver.
DrvStatusTypeDef BSP_GYRO_Get_Sensitivity(void *handle, float *sensitivity)
Get the gyroscope sensor sensitivity.
DrvStatusTypeDef BSP_GYRO_IsCombo(void *handle, uint8_t *status)
Check if the gyroscope sensor is combo.
DrvStatusTypeDef BSP_GYRO_Check_WhoAmI(void *handle)
Check the WHO_AM_I ID of the gyroscope sensor.
DrvStatusTypeDef BSP_GYRO_Set_ODR(void *handle, SensorOdr_t odr)
Set the gyroscope sensor output data rate.
DrvStatusTypeDef BSP_GYRO_DeInit(void **handle)
Deinitialize a gyroscope sensor.
DrvStatusTypeDef BSP_GYRO_Get_Axes(void *handle, SensorAxes_t *angular_velocity)
Get the gyroscope sensor axes.
DrvStatusTypeDef BSP_GYRO_Get_ODR(void *handle, float *odr)
Get the gyroscope sensor output data rate.
DrvStatusTypeDef BSP_GYRO_Get_Instance(void *handle, uint8_t *instance)
Get the gyroscope sensor instance.
DrvStatusTypeDef BSP_GYRO_Sensor_Enable(void *handle)
Enable gyroscope sensor.
DrvStatusTypeDef BSP_GYRO_Get_DRDY_Status(void *handle, uint8_t *status)
Get gyroscope data ready status.
DrvStatusTypeDef BSP_GYRO_Get_FS(void *handle, float *fullScale)
Get the gyroscope sensor full scale.
DrvStatusTypeDef BSP_GYRO_Set_Axes_Status(void *handle, uint8_t *enable_xyz)
Set the enabled/disabled status of the gyroscope sensor axes.
DrvStatusTypeDef BSP_GYRO_Get_AxesRaw(void *handle, SensorAxesRaw_t *value)
Get the gyroscope sensor raw axes.
DrvStatusTypeDef BSP_GYRO_Set_ODR_Value(void *handle, float odr)
Set the gyroscope sensor output data rate.
DrvStatusTypeDef BSP_GYRO_IsInitialized(void *handle, uint8_t *status)
Check if the gyroscope sensor is initialized.