mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
OP-1273 Uncrustify
This commit is contained in:
parent
8e26338f24
commit
c5dc556a43
@ -157,7 +157,7 @@ static void airspeedTask(__attribute__((unused)) void *parameters)
|
||||
|
||||
// if sensor type changed and the last sensor was
|
||||
// either Eagletree or PixHawk, reset I2C alarms
|
||||
if(airspeedSettings.AirspeedSensorType != lastAirspeedSensorType){
|
||||
if (airspeedSettings.AirspeedSensorType != lastAirspeedSensorType) {
|
||||
switch (lastAirspeedSensorType) {
|
||||
// Eagletree or PixHawk => Reset I2C alams
|
||||
case AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_EAGLETREEAIRSPEEDV3:
|
||||
|
@ -53,7 +53,7 @@
|
||||
#define CASFACTOR 760.8802669f // sqrt(5) * speed of sound at standard
|
||||
#define TASFACTOR 0.05891022589f // 1/sqrt(T0)
|
||||
|
||||
#define max(x,y) ((x)>=(y) ? (x) : (y))
|
||||
#define max(x, y) ((x) >= (y) ? (x) : (y))
|
||||
|
||||
// Private types
|
||||
|
||||
@ -70,7 +70,7 @@ void baro_airspeedGetMS4525DO(AirspeedSensorData *airspeedSensor, AirspeedSettin
|
||||
// request measurement first
|
||||
int8_t retVal = PIOS_MS4525DO_Request();
|
||||
|
||||
if( retVal !=0 ){
|
||||
if (retVal != 0) {
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_I2C, SYSTEMALARMS_ALARM_ERROR);
|
||||
return;
|
||||
}
|
||||
@ -78,22 +78,22 @@ void baro_airspeedGetMS4525DO(AirspeedSensorData *airspeedSensor, AirspeedSettin
|
||||
// Datasheet of MS4525DO: conversion needs 0.5 ms + 20% more when status bit used
|
||||
// delay by one Tick or at least 2 ms
|
||||
const portTickType xDelay = max(2 / portTICK_RATE_MS, 1);
|
||||
vTaskDelay( xDelay );
|
||||
vTaskDelay(xDelay);
|
||||
|
||||
// read the sensor
|
||||
retVal = baro_airspeedReadMS4525DO(airspeedSensor,airspeedSettings);
|
||||
retVal = baro_airspeedReadMS4525DO(airspeedSensor, airspeedSettings);
|
||||
|
||||
switch( retVal ){
|
||||
case 0 : AlarmsClear(SYSTEMALARMS_ALARM_I2C);
|
||||
switch (retVal) {
|
||||
case 0: AlarmsClear(SYSTEMALARMS_ALARM_I2C);
|
||||
break;
|
||||
case -4 :
|
||||
case -5 : AlarmsSet(SYSTEMALARMS_ALARM_I2C, SYSTEMALARMS_ALARM_WARNING);
|
||||
case -4:
|
||||
case -5: AlarmsSet(SYSTEMALARMS_ALARM_I2C, SYSTEMALARMS_ALARM_WARNING);
|
||||
break;
|
||||
case -1 :
|
||||
case -2 :
|
||||
case -3 :
|
||||
case -6 :
|
||||
default : AlarmsSet(SYSTEMALARMS_ALARM_I2C, SYSTEMALARMS_ALARM_ERROR);
|
||||
case -1:
|
||||
case -2:
|
||||
case -3:
|
||||
case -6:
|
||||
default: AlarmsSet(SYSTEMALARMS_ALARM_I2C, SYSTEMALARMS_ALARM_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,9 +103,9 @@ static int8_t baro_airspeedReadMS4525DO(AirspeedSensorData *airspeedSensor, Airs
|
||||
{
|
||||
// Check to see if airspeed sensor is returning airspeedSensor
|
||||
uint16_t values[2];
|
||||
int8_t retVal=PIOS_MS4525DO_Read(values);
|
||||
int8_t retVal = PIOS_MS4525DO_Read(values);
|
||||
|
||||
if( retVal == 0 ){
|
||||
if (retVal == 0) {
|
||||
airspeedSensor->SensorValue = values[0];
|
||||
airspeedSensor->SensorValueTemperature = values[1];
|
||||
} else {
|
||||
@ -117,21 +117,21 @@ static int8_t baro_airspeedReadMS4525DO(AirspeedSensorData *airspeedSensor, Airs
|
||||
}
|
||||
|
||||
// only calibrate if no stored calibration is available
|
||||
if ( !airspeedSettings->ZeroPoint ) {
|
||||
if (!airspeedSettings->ZeroPoint) {
|
||||
// Calibrate sensor by averaging zero point value
|
||||
if (calibrationCount <= CALIBRATION_IDLE_MS / airspeedSettings->SamplePeriod) {
|
||||
calibrationCount++;
|
||||
filter_reg = (airspeedSensor->SensorValue << FILTER_SHIFT );
|
||||
filter_reg = (airspeedSensor->SensorValue << FILTER_SHIFT);
|
||||
|
||||
return retVal;
|
||||
} else if (calibrationCount <= (CALIBRATION_IDLE_MS + CALIBRATION_COUNT_MS) / airspeedSettings->SamplePeriod) {
|
||||
calibrationCount++;
|
||||
// update filter register
|
||||
filter_reg = filter_reg - ( filter_reg >> FILTER_SHIFT ) + airspeedSensor->SensorValue;
|
||||
filter_reg = filter_reg - (filter_reg >> FILTER_SHIFT) + airspeedSensor->SensorValue;
|
||||
|
||||
if (calibrationCount > (CALIBRATION_IDLE_MS + CALIBRATION_COUNT_MS) / airspeedSettings->SamplePeriod) {
|
||||
// Scale output for unity gain.
|
||||
airspeedSettings->ZeroPoint = (uint16_t)( filter_reg >> FILTER_SHIFT );
|
||||
airspeedSettings->ZeroPoint = (uint16_t)(filter_reg >> FILTER_SHIFT);
|
||||
|
||||
AirspeedSettingsZeroPointSet(&airspeedSettings->ZeroPoint);
|
||||
calibrationCount = 0;
|
||||
@ -150,16 +150,16 @@ static int8_t baro_airspeedReadMS4525DO(AirspeedSensorData *airspeedSensor, Airs
|
||||
Inversion: T = (200*out - 102350)/2047 in C
|
||||
T = (200*out - 102350)/2047 + 273.15 in K
|
||||
*/
|
||||
const float dP = ( 10*(int32_t)(airspeedSensor->SensorValue-airspeedSettings->ZeroPoint) ) * 0.1052120688f;
|
||||
const float T = (float)( 200*(int32_t)airspeedSensor->SensorValueTemperature - 102350) / 2047 + 273.15f;
|
||||
const float dP = (10 * (int32_t)(airspeedSensor->SensorValue - airspeedSettings->ZeroPoint)) * 0.1052120688f;
|
||||
const float T = (float)(200 * (int32_t)airspeedSensor->SensorValueTemperature - 102350) / 2047 + 273.15f;
|
||||
|
||||
airspeedSensor->DifferentialPressure = dP;
|
||||
airspeedSensor->Temperature = T;
|
||||
// CAS = Csound * sqrt( 5 *( (dP/P0 +1)^(2/7) - 1) )
|
||||
// TAS = Csound * sqrt( 5 T/T0 *( (dP/P0 +1)^(2/7) - 1) )
|
||||
// where Csound = 340.276 m/s at standard condition T0=288.15 K and P0 = 101315 Pa
|
||||
airspeedSensor->CalibratedAirspeed = airspeedSettings->Scale * CASFACTOR * sqrtf( powf( fabsf(dP) / P0 + 1.0f , CCEXPONENT ) - 1.0f );
|
||||
airspeedSensor->TrueAirspeed = airspeedSensor->CalibratedAirspeed * TASFACTOR * sqrtf( T );
|
||||
airspeedSensor->CalibratedAirspeed = airspeedSettings->Scale * CASFACTOR * sqrtf(powf(fabsf(dP) / P0 + 1.0f, CCEXPONENT) - 1.0f);
|
||||
airspeedSensor->TrueAirspeed = airspeedSensor->CalibratedAirspeed * TASFACTOR * sqrtf(T);
|
||||
airspeedSensor->SensorConnected = AIRSPEEDSENSOR_SENSORCONNECTED_TRUE;
|
||||
|
||||
return retVal;
|
||||
|
@ -650,7 +650,7 @@ static int32_t updateAttitudeComplementary(bool first_run)
|
||||
if (airspeedSensor.SensorConnected == AIRSPEEDSENSOR_SENSORCONNECTED_TRUE) {
|
||||
// we have airspeed available
|
||||
airspeed.CalibratedAirspeed = airspeedSensor.CalibratedAirspeed;
|
||||
airspeed.TrueAirspeed = (airspeedSensor.TrueAirspeed < 0.f) ? airspeed.CalibratedAirspeed * IAS2TAS(homeLocation.Altitude - positionState.Down) : airspeedSensor.TrueAirspeed;
|
||||
airspeed.TrueAirspeed = (airspeedSensor.TrueAirspeed < 0.f) ? airspeed.CalibratedAirspeed *IAS2TAS(homeLocation.Altitude - positionState.Down) : airspeedSensor.TrueAirspeed;
|
||||
AirspeedStateSet(&airspeed);
|
||||
}
|
||||
}
|
||||
@ -1078,7 +1078,7 @@ static int32_t updateAttitudeINSGPS(bool first_run, bool outdoor_mode)
|
||||
AirspeedStateGet(&airspeed);
|
||||
|
||||
airspeed.CalibratedAirspeed = airspeedData.CalibratedAirspeed;
|
||||
airspeed.TrueAirspeed = (airspeedSensor.TrueAirspeed < 0.f) ? airspeed.CalibratedAirspeed * IAS2TAS(homeLocation.Altitude - positionState.Down) : airspeedSensor.TrueAirspeed;
|
||||
airspeed.TrueAirspeed = (airspeedSensor.TrueAirspeed < 0.f) ? airspeed.CalibratedAirspeed *IAS2TAS(homeLocation.Altitude - positionState.Down) : airspeedSensor.TrueAirspeed;
|
||||
|
||||
AirspeedStateSet(&airspeed);
|
||||
|
||||
|
@ -78,7 +78,7 @@ static int32_t filter(stateFilter *self, stateEstimation *state)
|
||||
this->altitude = state->baro[0];
|
||||
}
|
||||
// calculate true airspeed estimation
|
||||
if (IS_SET(state->updated, SENSORUPDATES_airspeed) && (state->airspeed[1]<0.f) ) {
|
||||
if (IS_SET(state->updated, SENSORUPDATES_airspeed) && (state->airspeed[1] < 0.f)) {
|
||||
state->airspeed[1] = state->airspeed[0] * IAS2TAS(this->altitude);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,6 @@ static int8_t PIOS_MS4525DO_WriteI2C(uint8_t *buffer, uint8_t len);
|
||||
static bool pios_ms4525do_requested = false;
|
||||
|
||||
|
||||
|
||||
static int8_t PIOS_MS4525DO_ReadI2C(uint8_t *buffer, uint8_t len)
|
||||
{
|
||||
const struct pios_i2c_txn txn_list[] = {
|
||||
@ -73,15 +72,15 @@ static int8_t PIOS_MS4525DO_WriteI2C(uint8_t *buffer, uint8_t len)
|
||||
}
|
||||
|
||||
|
||||
|
||||
int8_t PIOS_MS4525DO_Request(void)
|
||||
{
|
||||
// MS4525DO expects a zero length write.
|
||||
// Sending one byte is a workaround that works for the moment
|
||||
uint8_t data=0;
|
||||
int8_t retVal=PIOS_MS4525DO_WriteI2C(&data,sizeof(data));
|
||||
uint8_t data = 0;
|
||||
int8_t retVal = PIOS_MS4525DO_WriteI2C(&data, sizeof(data));
|
||||
|
||||
/* requested only when transfer worked */
|
||||
pios_ms4525do_requested = ( retVal == 0 );
|
||||
pios_ms4525do_requested = (retVal == 0);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
@ -98,7 +97,7 @@ int8_t PIOS_MS4525DO_Read(uint16_t *values)
|
||||
}
|
||||
|
||||
uint8_t data[4];
|
||||
int8_t retVal=PIOS_MS4525DO_ReadI2C(data, sizeof(data));
|
||||
int8_t retVal = PIOS_MS4525DO_ReadI2C(data, sizeof(data));
|
||||
|
||||
uint8_t status = data[0] & 0xC0;
|
||||
if (status == 0x80) {
|
||||
@ -119,7 +118,7 @@ int8_t PIOS_MS4525DO_Read(uint16_t *values)
|
||||
values[1] = (values[1] >> 5);
|
||||
|
||||
/* not requested anymore, only when transfer worked */
|
||||
pios_ms4525do_requested = !( retVal == 0 );
|
||||
pios_ms4525do_requested = !(retVal == 0);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user