mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 21:35:44 +03:00
i2c no-ack fix (never actually worked properly, fixed now)
bumped config version, or else r198 crashed on update from recent version airplane mode config passed to drv_pwm git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@199 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
parent
e6cb4a0b1c
commit
10570a6579
5 changed files with 2495 additions and 2490 deletions
4936
obj/baseflight.hex
4936
obj/baseflight.hex
File diff suppressed because it is too large
Load diff
|
@ -13,7 +13,7 @@ config_t cfg;
|
|||
const char rcChannelLetters[] = "AERT1234";
|
||||
|
||||
static uint32_t enabledSensors = 0;
|
||||
uint8_t checkNewConf = 25;
|
||||
uint8_t checkNewConf = 26;
|
||||
|
||||
void parseRcChannels(const char *input)
|
||||
{
|
||||
|
|
|
@ -52,6 +52,7 @@ static void i2c_er_handler(void)
|
|||
/* 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
|
||||
}
|
||||
|
@ -89,6 +90,7 @@ bool i2cWriteBuffer(uint8_t addr_, uint8_t reg_, uint8_t len_, uint8_t *data)
|
|||
read_p = my_data;
|
||||
bytes = len_;
|
||||
busy = 1;
|
||||
error = false;
|
||||
|
||||
// too long
|
||||
if (len_ > 16)
|
||||
|
@ -113,7 +115,7 @@ bool i2cWriteBuffer(uint8_t addr_, uint8_t reg_, uint8_t len_, uint8_t *data)
|
|||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !error;
|
||||
}
|
||||
|
||||
bool i2cWrite(uint8_t addr_, uint8_t reg_, uint8_t data)
|
||||
|
@ -133,6 +135,7 @@ bool i2cRead(uint8_t addr_, uint8_t reg_, uint8_t len, uint8_t* buf)
|
|||
write_p = buf;
|
||||
bytes = len;
|
||||
busy = 1;
|
||||
error = false;
|
||||
|
||||
if (!(I2Cx->CR2 & I2C_IT_EVT)) { //if we are restarting the driver
|
||||
if (!(I2Cx->CR1 & 0x0100)) { // ensure sending a start
|
||||
|
@ -150,7 +153,7 @@ bool i2cRead(uint8_t addr_, uint8_t reg_, uint8_t len, uint8_t* buf)
|
|||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !error;
|
||||
}
|
||||
|
||||
void i2c_ev_handler(void)
|
||||
|
|
|
@ -23,7 +23,6 @@ int main(void)
|
|||
GPIOA->BRR = 0x8000; // set low 15
|
||||
GPIOC->CRH = 0x44434444; // PIN 12 Output 50MHz
|
||||
GPIOC->BRR = 0x1000; // set low 12
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
@ -52,7 +51,9 @@ int main(void)
|
|||
#endif
|
||||
|
||||
mixerInit(); // this will set useServo var depending on mixer type
|
||||
// pwmInit returns true if throttle calibration is requested. if so, do it here. throttleCalibration() does NOT return - for safety.
|
||||
// when using airplane/wing mixer, servo/motor outputs are remapped
|
||||
if (cfg.mixerConfiguration == MULTITYPE_AIRPLANE || cfg.mixerConfiguration == MULTITYPE_FLYING_WING)
|
||||
pwm_params.airplane = true;
|
||||
pwm_params.usePPM = feature(FEATURE_PPM);
|
||||
pwm_params.enableInput = !feature(FEATURE_SPEKTRUM); // disable inputs if using spektrum
|
||||
pwm_params.useServos = useServo;
|
||||
|
@ -92,8 +93,7 @@ int main(void)
|
|||
} else {
|
||||
// spektrum and GPS are mutually exclusive
|
||||
// Optional GPS - available only when using PPM, otherwise required pins won't be usable
|
||||
if (feature(FEATURE_PPM))
|
||||
{
|
||||
if (feature(FEATURE_PPM)) {
|
||||
if (feature(FEATURE_GPS))
|
||||
gpsInit(cfg.gps_baudrate);
|
||||
#ifdef SONAR
|
||||
|
|
18
src/mw.c
18
src/mw.c
|
@ -532,11 +532,11 @@ void loop(void)
|
|||
cycleTime = (int32_t)(currentTime - previousTime);
|
||||
previousTime = currentTime;
|
||||
|
||||
#ifdef MPU6050_DMP
|
||||
#ifdef MPU6050_DMP
|
||||
mpu6050DmpLoop();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MAG
|
||||
#ifdef MAG
|
||||
if (sensors(SENSOR_MAG)) {
|
||||
if (abs(rcCommand[YAW]) < 70 && f.MAG_MODE) {
|
||||
int16_t dif = heading - magHold;
|
||||
|
@ -549,9 +549,9 @@ void loop(void)
|
|||
} else
|
||||
magHold = heading;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef BARO
|
||||
#ifdef BARO
|
||||
if (sensors(SENSOR_BARO)) {
|
||||
if (f.BARO_MODE) {
|
||||
if (abs(rcCommand[THROTTLE] - initialThrottleHold) > 20) {
|
||||
|
@ -560,7 +560,7 @@ void loop(void)
|
|||
rcCommand[THROTTLE] = initialThrottleHold + BaroPID;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (sensors(SENSOR_GPS)) {
|
||||
// Check that we really need to navigate ?
|
||||
|
@ -586,11 +586,11 @@ void loop(void)
|
|||
if (f.ACC_MODE && axis < 2) { // LEVEL MODE
|
||||
// 50 degrees max inclination
|
||||
errorAngle = constrain(2 * rcCommand[axis] - GPS_angle[axis], -500, +500) - angle[axis] + cfg.angleTrim[axis];
|
||||
#ifdef LEVEL_PDF
|
||||
#ifdef LEVEL_PDF
|
||||
PTerm = -(int32_t) angle[axis] * cfg.P8[PIDLEVEL] / 100;
|
||||
#else
|
||||
#else
|
||||
PTerm = (int32_t) errorAngle *cfg.P8[PIDLEVEL] / 100; //32 bits is needed for calculation: errorAngle*P8[PIDLEVEL] could exceed 32768 16 bits is ok for result
|
||||
#endif
|
||||
#endif
|
||||
PTerm = constrain(PTerm, -cfg.D8[PIDLEVEL] * 5, +cfg.D8[PIDLEVEL] * 5);
|
||||
|
||||
errorAngleI[axis] = constrain(errorAngleI[axis] + errorAngle, -10000, +10000); // WindUp // 16 bits is ok here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue