61 static DrvContextTypeDef PRESSURE_SensorHandle[ PRESSURE_SENSORS_MAX_NUM ];
62 static PRESSURE_Data_t PRESSURE_Data[ PRESSURE_SENSORS_MAX_NUM ];
63 static LPS22HB_P_Data_t LPS22HB_P_0_Data;
73 static DrvStatusTypeDef BSP_LPS22HB_PRESSURE_Init(
void **handle );
84 extern DrvStatusTypeDef Sensor_IO_Init(
void );
107 case PRESSURE_SENSORS_AUTO:
110 if( BSP_LPS22HB_PRESSURE_Init(handle) == COMPONENT_ERROR )
112 return COMPONENT_ERROR;
118 if( BSP_LPS22HB_PRESSURE_Init(handle) == COMPONENT_ERROR )
120 return COMPONENT_ERROR;
129 static DrvStatusTypeDef BSP_LPS22HB_PRESSURE_Init(
void **handle )
131 PRESSURE_Drv_t *driver = NULL;
134 if(PRESSURE_SensorHandle[ LPS22HB_P_0 ].isInitialized == 1)
137 return COMPONENT_ERROR;
142 return COMPONENT_ERROR;
146 PRESSURE_SensorHandle[ LPS22HB_P_0 ].who_am_i = LPS22HB_WHO_AM_I_VAL;
147 PRESSURE_SensorHandle[ LPS22HB_P_0 ].ifType = 1;
148 PRESSURE_SensorHandle[ LPS22HB_P_0 ].address = LPS22HB_ADDRESS_HIGH;
149 PRESSURE_SensorHandle[ LPS22HB_P_0 ].spiDevice = LPS22HB;
150 PRESSURE_SensorHandle[ LPS22HB_P_0 ].instance = LPS22HB_P_0;
151 PRESSURE_SensorHandle[ LPS22HB_P_0 ].isInitialized = 0;
152 PRESSURE_SensorHandle[ LPS22HB_P_0 ].isEnabled = 0;
153 PRESSURE_SensorHandle[ LPS22HB_P_0 ].isCombo = 1;
154 PRESSURE_SensorHandle[ LPS22HB_P_0 ].pData = (
void * )&PRESSURE_Data[ LPS22HB_P_0 ];
155 PRESSURE_SensorHandle[ LPS22HB_P_0 ].pVTable = (
void * )&LPS22HB_P_Drv;
156 PRESSURE_SensorHandle[ LPS22HB_P_0 ].pExtVTable = 0;
158 LPS22HB_P_0_Data.comboData = &LPS22HB_Combo_Data[0];
159 PRESSURE_Data[ LPS22HB_P_0 ].pComponentData = (
void * )&LPS22HB_P_0_Data;
160 PRESSURE_Data[ LPS22HB_P_0 ].pExtData = 0;
162 *handle = (
void *)&PRESSURE_SensorHandle[ LPS22HB_P_0 ];
164 Sensor_IO_SPI_CS_Init(*handle);
166 if(LPS22HB_Combo_Data[0].isTempInitialized == 0)
171 return COMPONENT_ERROR;
174 if(LPS22HB_SwResetAndMemoryBoot(*handle))
176 return COMPONENT_ERROR;
185 return COMPONENT_ERROR;
189 driver = ( PRESSURE_Drv_t * )((DrvContextTypeDef *)(*handle))->pVTable;
191 if ( driver->Init == NULL )
193 memset((*handle), 0,
sizeof(DrvContextTypeDef));
195 return COMPONENT_ERROR;
198 if ( driver->Init( (DrvContextTypeDef *)(*handle) ) == COMPONENT_ERROR )
200 memset((*handle), 0,
sizeof(DrvContextTypeDef));
202 return COMPONENT_ERROR;
206 if ( LPS22HB_Set_I2C( *handle, LPS22HB_DISABLE ) == LPS22HB_ERROR )
208 return COMPONENT_ERROR;
223 DrvContextTypeDef *ctx = (DrvContextTypeDef *)(*handle);
224 PRESSURE_Drv_t *driver = NULL;
228 return COMPONENT_ERROR;
231 driver = ( PRESSURE_Drv_t * )ctx->pVTable;
233 if ( driver->DeInit == NULL )
235 return COMPONENT_ERROR;
238 if ( driver->DeInit( ctx ) == COMPONENT_ERROR )
240 return COMPONENT_ERROR;
243 memset(ctx, 0,
sizeof(DrvContextTypeDef));
261 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
262 PRESSURE_Drv_t *driver = NULL;
266 return COMPONENT_ERROR;
269 driver = ( PRESSURE_Drv_t * )ctx->pVTable;
271 if ( driver->Sensor_Enable == NULL )
273 return COMPONENT_ERROR;
276 if ( driver->Sensor_Enable( ctx ) == COMPONENT_ERROR )
278 return COMPONENT_ERROR;
295 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
296 PRESSURE_Drv_t *driver = NULL;
300 return COMPONENT_ERROR;
303 driver = ( PRESSURE_Drv_t * )ctx->pVTable;
305 if ( driver->Sensor_Disable == NULL )
307 return COMPONENT_ERROR;
310 if ( driver->Sensor_Disable( ctx ) == COMPONENT_ERROR )
312 return COMPONENT_ERROR;
328 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
332 return COMPONENT_ERROR;
335 if ( status == NULL )
337 return COMPONENT_ERROR;
340 *status = ctx->isInitialized;
355 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
359 return COMPONENT_ERROR;
362 if ( status == NULL )
364 return COMPONENT_ERROR;
367 *status = ctx->isEnabled;
382 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
386 return COMPONENT_ERROR;
389 if ( status == NULL )
391 return COMPONENT_ERROR;
394 *status = ctx->isCombo;
409 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
413 return COMPONENT_ERROR;
416 if ( instance == NULL )
418 return COMPONENT_ERROR;
421 *instance = ctx->instance;
438 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
439 PRESSURE_Drv_t *driver = NULL;
443 return COMPONENT_ERROR;
446 driver = ( PRESSURE_Drv_t * )ctx->pVTable;
448 if ( who_am_i == NULL )
450 return COMPONENT_ERROR;
452 if ( driver->Get_WhoAmI == NULL )
454 return COMPONENT_ERROR;
456 if ( driver->Get_WhoAmI( ctx, who_am_i ) == COMPONENT_ERROR )
458 return COMPONENT_ERROR;
475 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
476 PRESSURE_Drv_t *driver = NULL;
480 return COMPONENT_ERROR;
483 driver = ( PRESSURE_Drv_t * )ctx->pVTable;
485 if ( driver->Check_WhoAmI == NULL )
487 return COMPONENT_ERROR;
489 if ( driver->Check_WhoAmI( ctx ) == COMPONENT_ERROR )
491 return COMPONENT_ERROR;
509 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
510 PRESSURE_Drv_t *driver = NULL;
514 return COMPONENT_ERROR;
517 driver = ( PRESSURE_Drv_t * )ctx->pVTable;
519 if ( pressure == NULL )
521 return COMPONENT_ERROR;
523 if ( driver->Get_Press == NULL )
525 return COMPONENT_ERROR;
527 if ( driver->Get_Press( ctx, pressure ) == COMPONENT_ERROR )
529 return COMPONENT_ERROR;
547 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
548 PRESSURE_Drv_t *driver = NULL;
552 return COMPONENT_ERROR;
555 driver = ( PRESSURE_Drv_t * )ctx->pVTable;
559 return COMPONENT_ERROR;
561 if ( driver->Get_ODR == NULL )
563 return COMPONENT_ERROR;
565 if ( driver->Get_ODR( ctx, odr ) == COMPONENT_ERROR )
567 return COMPONENT_ERROR;
585 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
586 PRESSURE_Drv_t *driver = NULL;
590 return COMPONENT_ERROR;
593 driver = ( PRESSURE_Drv_t * )ctx->pVTable;
595 if ( driver->Set_ODR == NULL )
597 return COMPONENT_ERROR;
599 if ( driver->Set_ODR( ctx, odr ) == COMPONENT_ERROR )
601 return COMPONENT_ERROR;
619 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
620 PRESSURE_Drv_t *driver = NULL;
624 return COMPONENT_ERROR;
627 driver = ( PRESSURE_Drv_t * )ctx->pVTable;
629 if ( driver->Set_ODR_Value == NULL )
631 return COMPONENT_ERROR;
633 if ( driver->Set_ODR_Value( ctx, odr ) == COMPONENT_ERROR )
635 return COMPONENT_ERROR;
653 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
654 PRESSURE_Drv_t *driver = NULL;
658 return COMPONENT_ERROR;
661 driver = ( PRESSURE_Drv_t * )ctx->pVTable;
665 return COMPONENT_ERROR;
668 if ( driver->Read_Reg == NULL )
670 return COMPONENT_ERROR;
673 if ( driver->Read_Reg( ctx, reg, data ) == COMPONENT_ERROR )
675 return COMPONENT_ERROR;
694 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
695 PRESSURE_Drv_t *driver = NULL;
699 return COMPONENT_ERROR;
702 driver = ( PRESSURE_Drv_t * )ctx->pVTable;
704 if ( driver->Write_Reg == NULL )
706 return COMPONENT_ERROR;
709 if ( driver->Write_Reg( ctx, reg, data ) == COMPONENT_ERROR )
711 return COMPONENT_ERROR;
729 DrvContextTypeDef *ctx = (DrvContextTypeDef *)handle;
730 PRESSURE_Drv_t *driver = NULL;
734 return COMPONENT_ERROR;
737 driver = ( PRESSURE_Drv_t * )ctx->pVTable;
739 if ( driver->Get_DRDY_Status == NULL )
741 return COMPONENT_ERROR;
744 if ( driver->Get_DRDY_Status( ctx, status ) == COMPONENT_ERROR )
746 return COMPONENT_ERROR;
DrvStatusTypeDef BSP_PRESSURE_Read_Reg(void *handle, uint8_t reg, uint8_t *data)
Read the data from register.
DrvStatusTypeDef BSP_PRESSURE_Init(PRESSURE_ID_t id, void **handle)
Initialize a pressure sensor.
DrvStatusTypeDef BSP_PRESSURE_Write_Reg(void *handle, uint8_t reg, uint8_t data)
Write the data to register.
DrvStatusTypeDef BSP_PRESSURE_Sensor_Enable(void *handle)
Enable pressure sensor.
DrvStatusTypeDef BSP_PRESSURE_Get_ODR(void *handle, float *odr)
Get the pressure sensor output data rate.
DrvStatusTypeDef BSP_PRESSURE_Set_ODR(void *handle, SensorOdr_t odr)
Set the pressure sensor output data rate.
DrvStatusTypeDef BSP_PRESSURE_Get_WhoAmI(void *handle, uint8_t *who_am_i)
Get the WHO_AM_I ID of the pressure sensor.
uint8_t Sensor_IO_Write(void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite)
Writes a buffer to the sensor.
DrvStatusTypeDef BSP_PRESSURE_Set_ODR_Value(void *handle, float odr)
Set the pressure sensor output data rate.
DrvStatusTypeDef Sensor_IO_SPI_Init(void)
Configures sensor SPI interface.
DrvStatusTypeDef BSP_PRESSURE_DeInit(void **handle)
Deinitialize a pressure sensor.
This file contains definitions for SensorTile_pressure.c driver.
DrvStatusTypeDef BSP_PRESSURE_IsCombo(void *handle, uint8_t *status)
Check if the pressure sensor is combo.
DrvStatusTypeDef BSP_PRESSURE_Get_DRDY_Status(void *handle, uint8_t *status)
Get pressure data ready status.
DrvStatusTypeDef BSP_PRESSURE_IsInitialized(void *handle, uint8_t *status)
Check if the pressure sensor is initialized.
DrvStatusTypeDef BSP_PRESSURE_Get_Press(void *handle, float *pressure)
Get the pressure value.
DrvStatusTypeDef BSP_PRESSURE_Sensor_Disable(void *handle)
Disable pressure sensor.
DrvStatusTypeDef BSP_PRESSURE_IsEnabled(void *handle, uint8_t *status)
Check if the pressure sensor is enabled.
DrvStatusTypeDef BSP_PRESSURE_Get_Instance(void *handle, uint8_t *instance)
Get the pressure sensor instance.
DrvStatusTypeDef BSP_PRESSURE_Check_WhoAmI(void *handle)
Check the WHO_AM_I ID of the pressure sensor.