Hi Anthony!
Thanks for answer!
I use my own driver for MPL3115A2. The driver source code in attachment.
And so I use it:
//
// ...
//
mpl3115a2_init( &mpl3115a2 );
mpl3115a2_set_pwrmode( &mpl3115a2, MPL3115A2_PWRMODE_STANDBY );
mpl3115a2_set_ready_mode(
&mpl3115a2,
MPL3115A2_READY_MODE_POLLING );
mpl3115a2_set_mode(
&mpl3115a2,
MPL3115A2_MODE_ALTIMETER,
MPL3115A2_OSR_128 );
mpl3115a2_set_pt(
&mpl3115a2,
MPL3115A2_PT_DREM |
MPL3115A2_PT_PDEFE |
MPL3115A2_PT_TDEFE );
mpl3115a2_set_pwrmode( &mpl3115a2, MPL3115A2_PWRMODE_ACTIVE );
//
// ...
//
while ( 1 ) {
//
// ...
//
dev_res = mpl3115a2_update( &mpl3115a2 );
dev_res = mpl3115a2_get_h( &mpl3115a2, &data->alt, NULL );
dev_res = mpl3115a2_get_t( &mpl3115a2, &data->temp, &data->temp_l );
dev_res = mpl3115a2_get_p( &mpl3115a2, &data->ph, &data->pl );
//
// ...
//
// (In timer-counter value of 'mode_change' increment)
if ( mode_change >= 50 ) {
if ( mpl3115a2.mode == MPL3115A2_MODE_ALTIMETER ) {
mpl3115a2_set_pwrmode( &mpl3115a2, MPL3115A2_PWRMODE_STANDBY );
mpl3115a2_set_mode( &mpl3115a2, MPL3115A2_MODE_BAROMETER, MPL3115A2_OSR_128 );
mpl3115a2_set_pwrmode( &mpl3115a2, MPL3115A2_PWRMODE_ACTIVE );
}
else {
mpl3115a2_set_pwrmode( &mpl3115a2, MPL3115A2_PWRMODE_STANDBY );
mpl3115a2_set_mode( &mpl3115a2, MPL3115A2_MODE_ALTIMETER, MPL3115A2_OSR_128 );
mpl3115a2_set_pwrmode( &mpl3115a2, MPL3115A2_PWRMODE_ACTIVE );
}
mode_change = 0;
}
//
// ...
//
// And sleep at 1 - 2 sec...
//
//...
//Restore after fail
#if MPL3115A2_DEBUG
if ( mpl3115a2_get_fail_count( &mpl3115a2 ) > 11 ) {
mpl3115a2_reset( &mpl3115a2 );
mpl3115a2_set_pt(
&mpl3115a2,
MPL3115A2_PT_DREM |
MPL3115A2_PT_PDEFE |
MPL3115A2_PT_TDEFE );
mpl3115a2_set_pwrmode( &mpl3115a2, MPL3115A2_PWRMODE_ACTIVE );
mpl3115a2_fail_count_clear( &mpl3115a2 );
}
#endif
}