Example #1
0
OSStatus lps25hb_sensor_init(void)
{
  PRESSURE_InitTypeDef lps25hb;
  lps25hb.OutputDataRate = LPS25HB_ODR_ONE_SHOT;
  lps25hb.PressureResolution = LPS25HB_P_RES_AVG_32;
  lps25hb.TemperatureResolution = LPS25HB_T_RES_AVG_32;
  lps25hb.DiffEnable = LPS25HB_DIFF_ENABLE;
  lps25hb.BlockDataUpdate = LPS25HB_BDU_READ;
  lps25hb.SPIMode = LPS25HB_SPI_SIM_4W;
     
  if(LPS25HB_Init(&lps25hb) != PRESSURE_OK){
    return -1;
  }
  return 0;
}
Example #2
0
/**
 * @brief Initialize the LPS25HB pressure sensor
 * @param handle the device handle
 * @retval COMPONENT_OK in case of success
 * @retval COMPONENT_ERROR in case of failure
 */
static DrvStatusTypeDef LPS25HB_P_Init( DrvContextTypeDef *handle )
{

  /* Check if the LPS25H/B temperature sensor is already initialized. */
  /* If yes, skip the initialize function, if not call initialize function */
  if((((LPS25HB_P_Data_t *)(((PRESSURE_Data_t *)(handle->pData))->pComponentData))->comboData->isTempInitialized == 0))
  {
    if(LPS25HB_Init(handle) == COMPONENT_ERROR)
    {
      return COMPONENT_ERROR;
    }
  }
  
  ((LPS25HB_P_Data_t *)(((PRESSURE_Data_t *)(handle->pData))->pComponentData))->comboData->isPressInitialized = 1;
  
  handle->isInitialized = 1;
  
  return COMPONENT_OK;
}