/*******************************************************************************
  Function:  ACCEL_RESULT ACCELInitialize(ACCEL_INIT *initialization)
  *****************************************************************************/
ACCEL_RESULT ACCELInitialize(ACCEL_INIT *initialization, uint8_t accl_range)
{
    PLIB_I2C_BaudRateSet(ACCEL_BMA250_I2C_MODULE, initialization->sourceClock, initialization->dataRate);
    PLIB_I2C_Enable(ACCEL_BMA250_I2C_MODULE);

#ifndef ACCEL_USE_EXTERNAL_INTERUPT_HANDLER
#ifndef ACCEL_USE_POLLING
    SYS_INT_VectorPrioritySet(ACCEL_BMA250_I2C_VECTOR,INT_PRIORITY_LEVEL_2);
#endif
#endif

    if(ReadChipID() == ACCEL_INVALID)
        return ACCEL_INVALID;

    SetRangeAndBandwidth(accl_range);

    ReadChipVersion();

    SetThershold();

    SetFIFO();

    accelXYZData.acc_x_lsb.new_data_x = 0;
    accelXYZData.acc_y_lsb.new_data_y = 0;
    accelXYZData.acc_z_lsb.new_data_z = 0;

    return ACCEL_VALID;
}
Exemple #2
0
bool BME280::Initialize()
{
   bool success(true);

   success &= ReadChipID();

   if(success)
   {
      success &= ReadTrim();
      WriteSettings();
   }

   m_initialized = success;

   return m_initialized;
}