1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-03 11:24:10 +01:00

OP-1273 Uncrustify

This commit is contained in:
Andres 2014-03-27 16:19:22 +01:00
parent 8e26338f24
commit c5dc556a43
9 changed files with 91 additions and 92 deletions

View File

@ -157,7 +157,7 @@ static void airspeedTask(__attribute__((unused)) void *parameters)
// if sensor type changed and the last sensor was // if sensor type changed and the last sensor was
// either Eagletree or PixHawk, reset I2C alarms // either Eagletree or PixHawk, reset I2C alarms
if(airspeedSettings.AirspeedSensorType != lastAirspeedSensorType){ if (airspeedSettings.AirspeedSensorType != lastAirspeedSensorType) {
switch (lastAirspeedSensorType) { switch (lastAirspeedSensorType) {
// Eagletree or PixHawk => Reset I2C alams // Eagletree or PixHawk => Reset I2C alams
case AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_EAGLETREEAIRSPEEDV3: case AIRSPEEDSETTINGS_AIRSPEEDSENSORTYPE_EAGLETREEAIRSPEEDV3:

View File

@ -53,7 +53,7 @@
#define CASFACTOR 760.8802669f // sqrt(5) * speed of sound at standard #define CASFACTOR 760.8802669f // sqrt(5) * speed of sound at standard
#define TASFACTOR 0.05891022589f // 1/sqrt(T0) #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 // Private types
@ -70,7 +70,7 @@ void baro_airspeedGetMS4525DO(AirspeedSensorData *airspeedSensor, AirspeedSettin
// request measurement first // request measurement first
int8_t retVal = PIOS_MS4525DO_Request(); int8_t retVal = PIOS_MS4525DO_Request();
if( retVal !=0 ){ if (retVal != 0) {
AlarmsSet(SYSTEMALARMS_ALARM_I2C, SYSTEMALARMS_ALARM_ERROR); AlarmsSet(SYSTEMALARMS_ALARM_I2C, SYSTEMALARMS_ALARM_ERROR);
return; 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 // Datasheet of MS4525DO: conversion needs 0.5 ms + 20% more when status bit used
// delay by one Tick or at least 2 ms // delay by one Tick or at least 2 ms
const portTickType xDelay = max(2 / portTICK_RATE_MS, 1); const portTickType xDelay = max(2 / portTICK_RATE_MS, 1);
vTaskDelay( xDelay ); vTaskDelay(xDelay);
// read the sensor // read the sensor
retVal = baro_airspeedReadMS4525DO(airspeedSensor,airspeedSettings); retVal = baro_airspeedReadMS4525DO(airspeedSensor, airspeedSettings);
switch( retVal ){ switch (retVal) {
case 0 : AlarmsClear(SYSTEMALARMS_ALARM_I2C); case 0: AlarmsClear(SYSTEMALARMS_ALARM_I2C);
break; break;
case -4 : case -4:
case -5 : AlarmsSet(SYSTEMALARMS_ALARM_I2C, SYSTEMALARMS_ALARM_WARNING); case -5: AlarmsSet(SYSTEMALARMS_ALARM_I2C, SYSTEMALARMS_ALARM_WARNING);
break; break;
case -1 : case -1:
case -2 : case -2:
case -3 : case -3:
case -6 : case -6:
default : AlarmsSet(SYSTEMALARMS_ALARM_I2C, SYSTEMALARMS_ALARM_ERROR); 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 // Check to see if airspeed sensor is returning airspeedSensor
uint16_t values[2]; 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->SensorValue = values[0];
airspeedSensor->SensorValueTemperature = values[1]; airspeedSensor->SensorValueTemperature = values[1];
} else { } else {
@ -117,21 +117,21 @@ static int8_t baro_airspeedReadMS4525DO(AirspeedSensorData *airspeedSensor, Airs
} }
// only calibrate if no stored calibration is available // only calibrate if no stored calibration is available
if ( !airspeedSettings->ZeroPoint ) { if (!airspeedSettings->ZeroPoint) {
// Calibrate sensor by averaging zero point value // Calibrate sensor by averaging zero point value
if (calibrationCount <= CALIBRATION_IDLE_MS / airspeedSettings->SamplePeriod) { if (calibrationCount <= CALIBRATION_IDLE_MS / airspeedSettings->SamplePeriod) {
calibrationCount++; calibrationCount++;
filter_reg = (airspeedSensor->SensorValue << FILTER_SHIFT ); filter_reg = (airspeedSensor->SensorValue << FILTER_SHIFT);
return retVal; return retVal;
} else if (calibrationCount <= (CALIBRATION_IDLE_MS + CALIBRATION_COUNT_MS) / airspeedSettings->SamplePeriod) { } else if (calibrationCount <= (CALIBRATION_IDLE_MS + CALIBRATION_COUNT_MS) / airspeedSettings->SamplePeriod) {
calibrationCount++; calibrationCount++;
// update filter register // 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) { if (calibrationCount > (CALIBRATION_IDLE_MS + CALIBRATION_COUNT_MS) / airspeedSettings->SamplePeriod) {
// Scale output for unity gain. // Scale output for unity gain.
airspeedSettings->ZeroPoint = (uint16_t)( filter_reg >> FILTER_SHIFT ); airspeedSettings->ZeroPoint = (uint16_t)(filter_reg >> FILTER_SHIFT);
AirspeedSettingsZeroPointSet(&airspeedSettings->ZeroPoint); AirspeedSettingsZeroPointSet(&airspeedSettings->ZeroPoint);
calibrationCount = 0; calibrationCount = 0;
@ -150,16 +150,16 @@ static int8_t baro_airspeedReadMS4525DO(AirspeedSensorData *airspeedSensor, Airs
Inversion: T = (200*out - 102350)/2047 in C Inversion: T = (200*out - 102350)/2047 in C
T = (200*out - 102350)/2047 + 273.15 in K T = (200*out - 102350)/2047 + 273.15 in K
*/ */
const float dP = ( 10*(int32_t)(airspeedSensor->SensorValue-airspeedSettings->ZeroPoint) ) * 0.1052120688f; 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 T = (float)(200 * (int32_t)airspeedSensor->SensorValueTemperature - 102350) / 2047 + 273.15f;
airspeedSensor->DifferentialPressure = dP; airspeedSensor->DifferentialPressure = dP;
airspeedSensor->Temperature = T; airspeedSensor->Temperature = T;
// CAS = Csound * sqrt( 5 *( (dP/P0 +1)^(2/7) - 1) ) // CAS = Csound * sqrt( 5 *( (dP/P0 +1)^(2/7) - 1) )
// TAS = Csound * sqrt( 5 T/T0 *( (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 // 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->CalibratedAirspeed = airspeedSettings->Scale * CASFACTOR * sqrtf(powf(fabsf(dP) / P0 + 1.0f, CCEXPONENT) - 1.0f);
airspeedSensor->TrueAirspeed = airspeedSensor->CalibratedAirspeed * TASFACTOR * sqrtf( T ); airspeedSensor->TrueAirspeed = airspeedSensor->CalibratedAirspeed * TASFACTOR * sqrtf(T);
airspeedSensor->SensorConnected = AIRSPEEDSENSOR_SENSORCONNECTED_TRUE; airspeedSensor->SensorConnected = AIRSPEEDSENSOR_SENSORCONNECTED_TRUE;
return retVal; return retVal;

View File

@ -650,7 +650,7 @@ static int32_t updateAttitudeComplementary(bool first_run)
if (airspeedSensor.SensorConnected == AIRSPEEDSENSOR_SENSORCONNECTED_TRUE) { if (airspeedSensor.SensorConnected == AIRSPEEDSENSOR_SENSORCONNECTED_TRUE) {
// we have airspeed available // we have airspeed available
airspeed.CalibratedAirspeed = airspeedSensor.CalibratedAirspeed; 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); AirspeedStateSet(&airspeed);
} }
} }
@ -1078,7 +1078,7 @@ static int32_t updateAttitudeINSGPS(bool first_run, bool outdoor_mode)
AirspeedStateGet(&airspeed); AirspeedStateGet(&airspeed);
airspeed.CalibratedAirspeed = airspeedData.CalibratedAirspeed; 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); AirspeedStateSet(&airspeed);

View File

@ -78,7 +78,7 @@ static int32_t filter(stateFilter *self, stateEstimation *state)
this->altitude = state->baro[0]; this->altitude = state->baro[0];
} }
// calculate true airspeed estimation // 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); state->airspeed[1] = state->airspeed[0] * IAS2TAS(this->altitude);
} }

View File

@ -40,7 +40,6 @@ static int8_t PIOS_MS4525DO_WriteI2C(uint8_t *buffer, uint8_t len);
static bool pios_ms4525do_requested = false; static bool pios_ms4525do_requested = false;
static int8_t PIOS_MS4525DO_ReadI2C(uint8_t *buffer, uint8_t len) static int8_t PIOS_MS4525DO_ReadI2C(uint8_t *buffer, uint8_t len)
{ {
const struct pios_i2c_txn txn_list[] = { 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) int8_t PIOS_MS4525DO_Request(void)
{ {
// MS4525DO expects a zero length write. // MS4525DO expects a zero length write.
// Sending one byte is a workaround that works for the moment // Sending one byte is a workaround that works for the moment
uint8_t data=0; uint8_t data = 0;
int8_t retVal=PIOS_MS4525DO_WriteI2C(&data,sizeof(data)); int8_t retVal = PIOS_MS4525DO_WriteI2C(&data, sizeof(data));
/* requested only when transfer worked */ /* requested only when transfer worked */
pios_ms4525do_requested = ( retVal == 0 ); pios_ms4525do_requested = (retVal == 0);
return retVal; return retVal;
} }
@ -98,7 +97,7 @@ int8_t PIOS_MS4525DO_Read(uint16_t *values)
} }
uint8_t data[4]; 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; uint8_t status = data[0] & 0xC0;
if (status == 0x80) { if (status == 0x80) {
@ -119,7 +118,7 @@ int8_t PIOS_MS4525DO_Read(uint16_t *values)
values[1] = (values[1] >> 5); values[1] = (values[1] >> 5);
/* not requested anymore, only when transfer worked */ /* not requested anymore, only when transfer worked */
pios_ms4525do_requested = !( retVal == 0 ); pios_ms4525do_requested = !(retVal == 0);
return retVal; return retVal;
} }