Whitespace/compiler warnings cleanups by Dominic Clifton;

Slight tweak of new althold defaults
NOT-flight-tested .hex committing so people can commence with althold testing.

git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@391 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
timecop@gmail.com 2013-08-31 01:40:13 +00:00
parent 77a241bd5f
commit 509e349e69
11 changed files with 3312 additions and 3231 deletions

File diff suppressed because it is too large Load Diff

View File

@ -192,6 +192,7 @@ typedef struct baro_t
// OLIMEXINO
#include "drv_adc.h"
#include "drv_i2c.h"
#include "drv_spi.h"
#include "drv_adxl345.h"
#include "drv_mpu3050.h"
#include "drv_mpu6050.h"

View File

@ -33,7 +33,7 @@ static float _atof(const char *p);
static char *ftoa(float x, char *floatString);
// sync this with MultiType enum from mw.h
const char * const mixerNames[] = {
static const char * const mixerNames[] = {
"TRI", "QUADP", "QUADX", "BI",
"GIMBAL", "Y6", "HEX6",
"FLYING_WING", "Y4", "HEX6X", "OCTOX8", "OCTOFLATP", "OCTOFLATX",
@ -41,7 +41,7 @@ const char * const mixerNames[] = {
};
// sync this with AvailableFeatures enum from board.h
const char * const featureNames[] = {
static const char * const featureNames[] = {
"PPM", "VBAT", "INFLIGHT_ACC_CAL", "SPEKTRUM", "MOTOR_STOP",
"SERVO_TILT", "GYRO_SMOOTHING", "LED_RING", "GPS",
"FAILSAFE", "SONAR", "TELEMETRY", "POWERMETER", "VARIO", "3D",
@ -49,17 +49,17 @@ const char * const featureNames[] = {
};
// sync this with AvailableSensors enum from board.h
const char * const sensorNames[] = {
static const char * const sensorNames[] = {
"ACC", "BARO", "MAG", "SONAR", "GPS", NULL
};
const char * const accNames[] = {
static const char * const accNames[] = {
"", "ADXL345", "MPU6050", "MMA845x", NULL
};
typedef struct {
char *name;
char *param;
const char *name;
const char *param;
void (*func)(char *cmdline);
} clicmd_t;
@ -80,7 +80,7 @@ const clicmd_t cmdTable[] = {
{ "status", "show system status", cliStatus },
{ "version", "", cliVersion },
};
#define CMD_COUNT (sizeof(cmdTable) / sizeof(cmdTable[0]))
#define CMD_COUNT (sizeof(cmdTable) / sizeof(clicmd_t))
typedef enum {
VAR_UINT8,
@ -140,6 +140,7 @@ const clivalue_t valueTable[] = {
{ "deadband", VAR_UINT8, &cfg.deadband, 0, 32 },
{ "yawdeadband", VAR_UINT8, &cfg.yawdeadband, 0, 100 },
{ "alt_hold_throttle_neutral", VAR_UINT8, &cfg.alt_hold_throttle_neutral, 1, 250 },
{ "alt_hold_fast_change", VAR_UINT8, &cfg.alt_hold_fast_change, 0, 1 },
{ "throttle_angle_correction", VAR_UINT8, &cfg.throttle_angle_correction, 0, 100 },
{ "rc_rate", VAR_UINT8, &cfg.rcRate8, 0, 250 },
{ "rc_expo", VAR_UINT8, &cfg.rcExpo8, 0, 100 },
@ -216,7 +217,7 @@ const clivalue_t valueTable[] = {
{ "d_level", VAR_UINT8, &cfg.D8[PIDLEVEL], 0, 200 },
};
#define VALUE_COUNT (sizeof(valueTable) / sizeof(valueTable[0]))
#define VALUE_COUNT (sizeof(valueTable) / sizeof(clivalue_t))
static void cliSetVar(const clivalue_t *var, const int32_t value);
static void cliPrintVar(const clivalue_t *var, uint32_t full);
@ -536,7 +537,6 @@ static void cliDefaults(char *cmdline)
static void cliDump(char *cmdline)
{
int i;
char buf[16];
float thr, roll, pitch, yaw;
@ -692,7 +692,7 @@ static void cliMap(char *cmdline)
if (len == 8) {
// uppercase it
for (i = 0; i < 8; i++)
cmdline[i] = toupper(cmdline[i]);
cmdline[i] = toupper((unsigned char)cmdline[i]);
for (i = 0; i < 8; i++) {
if (strchr(rcChannelLetters, cmdline[i]) && !strchr(cmdline + i + 1, cmdline[i]))
continue;
@ -862,7 +862,7 @@ static void cliSet(char *cmdline)
cliPrintVar(val, len); // when len is 1 (when * is passed as argument), it will print min/max values as well, for gui
cliPrint("\r\n");
}
} else if ((eqptr = strstr(cmdline, "="))) {
} else if ((eqptr = strstr(cmdline, "=")) != NULL) {
// has equal, set var
eqptr++;
len--;

View File

@ -255,7 +255,7 @@ static void resetConf(void)
cfg.baro_tab_size = 21;
cfg.baro_noise_lpf = 0.6f;
cfg.baro_cf_vel = 0.995f;
cfg.baro_cf_alt = 0.900f;
cfg.baro_cf_alt = 0.950f;
cfg.acc_unarmedcal = 1;
// Radio

View File

@ -110,7 +110,9 @@ bool bmp085Detect(baro_t *baro)
gpio.pin = Pin_14;
gpio.mode = Mode_IN_FLOATING;
gpioInit(GPIOC, &gpio);
#ifdef BARO
BARO_ON;
#endif
// EXTI interrupt for barometer EOC
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource14);
@ -148,7 +150,9 @@ bool bmp085Detect(baro_t *baro)
baro->calculate = bmp085_calculate;
return true;
}
#ifdef BARO
BARO_OFF;
#endif
return false;
}
@ -214,16 +218,11 @@ static void bmp085_start_ut(void)
static void bmp085_get_ut(void)
{
uint8_t data[2];
uint16_t timeout = 10000;
// wait in case of cockup
if (!convDone)
convOverrun++;
#if 0
while (!convDone && timeout-- > 0) {
__NOP();
}
#endif
i2cRead(BMP085_I2C_ADDR, BMP085_ADC_OUT_MSB_REG, 2, data);
bmp085_ut = (data[0] << 8) | data[1];
}
@ -244,16 +243,11 @@ static void bmp085_start_up(void)
static void bmp085_get_up(void)
{
uint8_t data[3];
uint16_t timeout = 10000;
// wait in case of cockup
if (!convDone)
convOverrun++;
#if 0
while (!convDone && timeout-- > 0) {
__NOP();
}
#endif
i2cRead(BMP085_I2C_ADDR, BMP085_ADC_OUT_MSB_REG, 3, data);
bmp085_up = (((uint32_t) data[0] << 16) | ((uint32_t) data[1] << 8) | (uint32_t) data[2]) >> (8 - bmp085.oversampling_setting);
}

View File

@ -47,17 +47,17 @@ static volatile uint8_t* read_p;
static void i2c_er_handler(void)
{
volatile uint32_t SR1Register, SR2Register;
/* Read the I2C1 status register */
volatile uint32_t SR1Register;
// Read the I2C1 status register
SR1Register = I2Cx->SR1;
if (SR1Register & 0x0F00) { //an error
error = true;
// I2C1error.error = ((SR1Register & 0x0F00) >> 8); //save error
// I2C1error.job = job; //the task
}
/* If AF, BERR or ARLO, abandon the current job and commence new if there are jobs */
// If AF, BERR or ARLO, abandon the current job and commence new if there are jobs
if (SR1Register & 0x0700) {
SR2Register = I2Cx->SR2; //read second status register to clear ADDR if it is set (note that BTF will not be set after a NACK)
(void)I2Cx->SR2; // read second status register to clear ADDR if it is set (note that BTF will not be set after a NACK)
I2C_ITConfig(I2Cx, I2C_IT_BUF, DISABLE); // disable the RXNE/TXE interrupt - prevent the ISR tailchaining onto the ER (hopefully)
if (!(SR1Register & 0x0200) && !(I2Cx->CR1 & 0x0200)) { // if we dont have an ARLO error, ensure sending of a stop
if (I2Cx->CR1 & 0x0100) { // We are currently trying to send a start, this is very bad as start,stop will hang the peripheral
@ -168,17 +168,16 @@ void i2c_ev_handler(void)
}
} else if (SReg_1 & 0x0002) { //we just sent the address - EV6 in ref manual
// Read SR1,2 to clear ADDR
volatile uint8_t a;
__DMB(); // memory fence to control hardware
if (bytes == 1 && reading && subaddress_sent) { // we are receiving 1 byte - EV6_3
I2C_AcknowledgeConfig(I2Cx, DISABLE); // turn off ACK
__DMB();
a = I2Cx->SR2; //clear ADDR after ACK is turned off
(void)I2Cx->SR2; // clear ADDR after ACK is turned off
I2C_GenerateSTOP(I2Cx, ENABLE); // program the stop
final_stop = 1;
I2C_ITConfig(I2Cx, I2C_IT_BUF, ENABLE); // allow us to have an EV7
} else { // EV6 and EV6_1
a = I2Cx->SR2; //clear the ADDR here
(void)I2Cx->SR2; // clear the ADDR here
__DMB();
if (bytes == 2 && reading && subaddress_sent) { //rx 2 bytes - EV6_1
I2C_AcknowledgeConfig(I2Cx, DISABLE); //turn off ACK

View File

@ -713,7 +713,7 @@ uint32_t GPS_coord_to_degrees(char* s)
int i;
// scan for decimal point or end of field
for (p = s; isdigit(*p); p++)
for (p = s; isdigit((unsigned char)*p); p++)
;
q = s;
@ -736,7 +736,7 @@ uint32_t GPS_coord_to_degrees(char* s)
q = p + 1;
for (i = 0; i < 4; i++) {
frac_min *= 10;
if (isdigit(*q))
if (isdigit((unsigned char)*q))
frac_min += *q++ - '0';
}
}
@ -1002,8 +1002,6 @@ static bool _new_position;
// do we have new speed information?
static bool _new_speed;
static uint8_t _disable_counter;
// Receive buffer
static union {
ubx_nav_posllh posllh;

View File

@ -372,7 +372,6 @@ int getEstimatedAltitude(void)
int32_t baroVel;
int32_t vel_tmp;
int32_t BaroAlt_tmp;
float vel_calc;
static float vel = 0.0f;
static float accAlt = 0.0f;
static int32_t lastBaroAlt;
@ -396,8 +395,7 @@ int getEstimatedAltitude(void)
BaroAlt = BaroAlt * cfg.baro_noise_lpf + BaroAlt_tmp * (1.0f - cfg.baro_noise_lpf); // additional LPF to reduce baro noise
// Integrator - velocity, cm/sec
vel_calc = (float) accSum[2] * accVelScale * (float) accTimeSum / (float) accSumCount;
vel += vel_calc;
vel += (float)accSum[2] * accVelScale * (float)accTimeSum / (float)accSumCount;
// Integrator - Altitude in cm
accAlt += vel * ((float) accTimeSum * 0.0000005f); // integrate velocity to get distance (x= a/2 * t^2)

View File

@ -6,7 +6,6 @@ int16_t motor[MAX_MOTORS];
int16_t servo[8] = { 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500 };
static motorMixer_t currentMixer[MAX_MOTORS];
static servoParam_t currentServo[MAX_SERVOS];
static const motorMixer_t mixerTri[] = {
{ 1.0f, 0.0f, 1.333333f, 0.0f }, // REAR

View File

@ -285,7 +285,7 @@ static void pidMultiWii(void)
{
int axis, prop;
int32_t error, errorAngle;
int32_t PTerm, ITerm, PTermACC, ITermACC = 0, PTermGYRO = 0, ITermGYRO = 0, DTerm;
int32_t PTerm, ITerm, PTermACC = 0, ITermACC = 0, PTermGYRO = 0, ITermGYRO = 0, DTerm;
static int16_t lastGyro[3] = { 0, 0, 0 };
static int32_t delta1[3], delta2[3];
int32_t deltaSum;
@ -429,7 +429,9 @@ void loop(void)
uint8_t stTmp = 0;
int i;
static uint32_t rcTime = 0;
#ifdef BARO
static int16_t initialThrottleHold;
#endif
static uint32_t loopTime;
uint16_t auxState = 0;
static uint8_t GPSNavReset = 1;