mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-29 19:17:28 +08:00
remove baro ets event makro and move transaction status check into event function
This commit is contained in:
@@ -11,11 +11,10 @@
|
|||||||
</header>
|
</header>
|
||||||
<init fun="baro_ets_init()"/>
|
<init fun="baro_ets_init()"/>
|
||||||
<periodic fun="baro_ets_read_periodic()" freq="10."/>
|
<periodic fun="baro_ets_read_periodic()" freq="10."/>
|
||||||
<event fun="BaroEtsEvent()"/>
|
<event fun="baro_ets_event()"/>
|
||||||
|
|
||||||
<makefile>
|
<makefile>
|
||||||
<file name="baro_ets.c"/>
|
<file name="baro_ets.c"/>
|
||||||
</makefile>
|
</makefile>
|
||||||
|
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
|
|||||||
@@ -81,11 +81,14 @@ void baro_ets_init( void ) {
|
|||||||
baro_ets_cnt = BARO_ETS_OFFSET_NBSAMPLES_INIT + BARO_ETS_OFFSET_NBSAMPLES_AVRG;
|
baro_ets_cnt = BARO_ETS_OFFSET_NBSAMPLES_INIT + BARO_ETS_OFFSET_NBSAMPLES_AVRG;
|
||||||
baro_ets_r = BARO_ETS_R;
|
baro_ets_r = BARO_ETS_R;
|
||||||
baro_ets_sigma2 = BARO_ETS_SIGMA2;
|
baro_ets_sigma2 = BARO_ETS_SIGMA2;
|
||||||
|
|
||||||
|
baro_ets_i2c_trans.status = I2CTransDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
void baro_ets_read_periodic( void ) {
|
void baro_ets_read_periodic( void ) {
|
||||||
// Initiate next read
|
// Initiate next read
|
||||||
#ifndef SITL
|
#ifndef SITL
|
||||||
|
if (baro_ets_i2c_trans.status == I2CTransDone)
|
||||||
I2CReceive(i2c0, baro_ets_i2c_trans, BARO_ETS_ADDR, 2);
|
I2CReceive(i2c0, baro_ets_i2c_trans, BARO_ETS_ADDR, 2);
|
||||||
#else // SITL
|
#else // SITL
|
||||||
baro_ets_adc = 0;
|
baro_ets_adc = 0;
|
||||||
@@ -95,7 +98,8 @@ void baro_ets_read_periodic( void ) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void baro_ets_read_event( void ) {
|
void baro_ets_event( void ) {
|
||||||
|
if (baro_ets_i2c_trans.status == I2CTransSuccess) {
|
||||||
// Get raw altimeter from buffer
|
// Get raw altimeter from buffer
|
||||||
baro_ets_adc = ((uint16_t)(baro_ets_i2c_trans.buf[1]) << 8) | (uint16_t)(baro_ets_i2c_trans.buf[0]);
|
baro_ets_adc = ((uint16_t)(baro_ets_i2c_trans.buf[1]) << 8) | (uint16_t)(baro_ets_i2c_trans.buf[0]);
|
||||||
// Check if this is valid altimeter
|
// Check if this is valid altimeter
|
||||||
@@ -137,6 +141,5 @@ void baro_ets_read_event( void ) {
|
|||||||
|
|
||||||
// Transaction has been read
|
// Transaction has been read
|
||||||
baro_ets_i2c_trans.status = I2CTransDone;
|
baro_ets_i2c_trans.status = I2CTransDone;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ extern struct i2c_transaction baro_ets_i2c_trans;
|
|||||||
|
|
||||||
extern void baro_ets_init( void );
|
extern void baro_ets_init( void );
|
||||||
extern void baro_ets_read_periodic( void );
|
extern void baro_ets_read_periodic( void );
|
||||||
extern void baro_ets_read_event( void );
|
extern void baro_ets_event( void );
|
||||||
|
|
||||||
#define BaroEtsEvent() { if (baro_ets_i2c_trans.status == I2CTransSuccess) baro_ets_read_event(); }
|
|
||||||
|
|
||||||
#endif // BARO_ETS_H
|
#endif // BARO_ETS_H
|
||||||
|
|||||||
Reference in New Issue
Block a user