[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paparazzi-commits] [6266] remove baro ets event makro and move transact
From: |
Felix Ruess |
Subject: |
[paparazzi-commits] [6266] remove baro ets event makro and move transaction status check into event function |
Date: |
Tue, 26 Oct 2010 11:21:20 +0000 |
Revision: 6266
http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=6266
Author: flixr
Date: 2010-10-26 11:21:20 +0000 (Tue, 26 Oct 2010)
Log Message:
-----------
remove baro ets event makro and move transaction status check into event
function
Modified Paths:
--------------
paparazzi3/trunk/conf/modules/baro_ets.xml
paparazzi3/trunk/sw/airborne/modules/sensors/baro_ets.c
paparazzi3/trunk/sw/airborne/modules/sensors/baro_ets.h
Modified: paparazzi3/trunk/conf/modules/baro_ets.xml
===================================================================
--- paparazzi3/trunk/conf/modules/baro_ets.xml 2010-10-26 11:21:13 UTC (rev
6265)
+++ paparazzi3/trunk/conf/modules/baro_ets.xml 2010-10-26 11:21:20 UTC (rev
6266)
@@ -11,11 +11,10 @@
</header>
<init fun="baro_ets_init()"/>
<periodic fun="baro_ets_read_periodic()" freq="10."/>
- <event fun="BaroEtsEvent()"/>
+ <event fun="baro_ets_event()"/>
<makefile>
- <file name="baro_ets.c"/>
+ <file name="baro_ets.c"/>
</makefile>
</module>
-
Modified: paparazzi3/trunk/sw/airborne/modules/sensors/baro_ets.c
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/sensors/baro_ets.c 2010-10-26
11:21:13 UTC (rev 6265)
+++ paparazzi3/trunk/sw/airborne/modules/sensors/baro_ets.c 2010-10-26
11:21:20 UTC (rev 6266)
@@ -81,62 +81,65 @@
baro_ets_cnt = BARO_ETS_OFFSET_NBSAMPLES_INIT +
BARO_ETS_OFFSET_NBSAMPLES_AVRG;
baro_ets_r = BARO_ETS_R;
baro_ets_sigma2 = BARO_ETS_SIGMA2;
+
+ baro_ets_i2c_trans.status = I2CTransDone;
}
void baro_ets_read_periodic( void ) {
// Initiate next read
#ifndef SITL
- I2CReceive(i2c0, baro_ets_i2c_trans, BARO_ETS_ADDR, 2);
+ if (baro_ets_i2c_trans.status == I2CTransDone)
+ I2CReceive(i2c0, baro_ets_i2c_trans, BARO_ETS_ADDR, 2);
#else // SITL
baro_ets_adc = 0;
baro_ets_altitude = gps_alt / 100.0;
baro_ets_valid = TRUE;
EstimatorSetAlt(baro_ets_altitude);
#endif
-}
-
-void baro_ets_read_event( void ) {
- // 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]);
- // Check if this is valid altimeter
- if (baro_ets_adc == 0)
- baro_ets_valid = FALSE;
- else
- baro_ets_valid = TRUE;
+}
- // Continue only if a new altimeter value was received
- if (baro_ets_valid) {
- // Calculate offset average if not done already
- if (!baro_ets_offset_init) {
- --baro_ets_cnt;
- // Check if averaging completed
- if (baro_ets_cnt == 0) {
- // Calculate average
- baro_ets_offset = (uint16_t)(baro_ets_offset_tmp /
BARO_ETS_OFFSET_NBSAMPLES_AVRG);
- // Limit offset
- if (baro_ets_offset < BARO_ETS_OFFSET_MIN)
- baro_ets_offset = BARO_ETS_OFFSET_MIN;
- if (baro_ets_offset > BARO_ETS_OFFSET_MAX)
- baro_ets_offset = BARO_ETS_OFFSET_MAX;
- baro_ets_offset_init = TRUE;
+void baro_ets_event( void ) {
+ if (baro_ets_i2c_trans.status == I2CTransSuccess) {
+ // 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]);
+ // Check if this is valid altimeter
+ if (baro_ets_adc == 0)
+ baro_ets_valid = FALSE;
+ else
+ baro_ets_valid = TRUE;
+
+ // Continue only if a new altimeter value was received
+ if (baro_ets_valid) {
+ // Calculate offset average if not done already
+ if (!baro_ets_offset_init) {
+ --baro_ets_cnt;
+ // Check if averaging completed
+ if (baro_ets_cnt == 0) {
+ // Calculate average
+ baro_ets_offset = (uint16_t)(baro_ets_offset_tmp /
BARO_ETS_OFFSET_NBSAMPLES_AVRG);
+ // Limit offset
+ if (baro_ets_offset < BARO_ETS_OFFSET_MIN)
+ baro_ets_offset = BARO_ETS_OFFSET_MIN;
+ if (baro_ets_offset > BARO_ETS_OFFSET_MAX)
+ baro_ets_offset = BARO_ETS_OFFSET_MAX;
+ baro_ets_offset_init = TRUE;
+ }
+ // Check if averaging needs to continue
+ else if (baro_ets_cnt <= BARO_ETS_OFFSET_NBSAMPLES_AVRG)
+ baro_ets_offset_tmp += baro_ets_adc;
}
- // Check if averaging needs to continue
- else if (baro_ets_cnt <= BARO_ETS_OFFSET_NBSAMPLES_AVRG)
- baro_ets_offset_tmp += baro_ets_adc;
- }
- // Convert raw to m/s
- if (baro_ets_offset_init)
- baro_ets_altitude = BARO_ETS_SCALE *
(float)(baro_ets_offset-baro_ets_adc);
- else
+ // Convert raw to m/s
+ if (baro_ets_offset_init)
+ baro_ets_altitude = BARO_ETS_SCALE *
(float)(baro_ets_offset-baro_ets_adc);
+ else
+ baro_ets_altitude = 0.0;
+ // New value available
+ EstimatorSetAlt(baro_ets_altitude);
+ } else {
baro_ets_altitude = 0.0;
- // New value available
- EstimatorSetAlt(baro_ets_altitude);
- } else {
- baro_ets_altitude = 0.0;
+ }
+
+ // Transaction has been read
+ baro_ets_i2c_trans.status = I2CTransDone;
}
-
- // Transaction has been read
- baro_ets_i2c_trans.status = I2CTransDone;
-
}
-
Modified: paparazzi3/trunk/sw/airborne/modules/sensors/baro_ets.h
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/sensors/baro_ets.h 2010-10-26
11:21:13 UTC (rev 6265)
+++ paparazzi3/trunk/sw/airborne/modules/sensors/baro_ets.h 2010-10-26
11:21:20 UTC (rev 6266)
@@ -56,8 +56,6 @@
extern void baro_ets_init( 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paparazzi-commits] [6266] remove baro ets event makro and move transaction status check into event function,
Felix Ruess <=