Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/main/drivers/bus_i2c_hal.c b/src/main/drivers/bus_i2c_hal.c
- index e3bc13da9..97e6ba9ec 100644
- --- a/src/main/drivers/bus_i2c_hal.c
- +++ b/src/main/drivers/bus_i2c_hal.c
- @@ -32,7 +32,7 @@
- #include "drivers/bus_i2c.h"
- #include "drivers/bus_i2c_impl.h"
- -#define CLOCKSPEED 800000 // i2c clockspeed 400kHz default (conform specs), 800kHz and 1200kHz (Betaflight default)
- +#define CLOCKSPEED 400000 // i2c clockspeed 400kHz default (conform specs), 800kHz and 1200kHz (Betaflight default)
- // Number of bits in I2C protocol phase
- #define LEN_ADDR 7
- @@ -261,9 +261,9 @@ void i2cInit(I2CDevice device)
- if (pDev->overClock) {
- // 800khz Maximum speed tested on various boards without issues
- - pHandle->Init.Timing = 0x00500D1D;
- + pHandle->Init.Timing = 0x00401B1B;
- } else {
- - pHandle->Init.Timing = 0x00500C6F;
- + pHandle->Init.Timing = 0x00A01B5B;
- }
- pHandle->Init.OwnAddress1 = 0x0;
- diff --git a/src/main/drivers/bus_i2c_impl.h b/src/main/drivers/bus_i2c_impl.h
- index 42cb32751..372b28a14 100644
- --- a/src/main/drivers/bus_i2c_impl.h
- +++ b/src/main/drivers/bus_i2c_impl.h
- @@ -24,7 +24,7 @@
- #define I2C_SHORT_TIMEOUT ((uint32_t)0x1000)
- #define I2C_LONG_TIMEOUT ((uint32_t)(10 * I2C_SHORT_TIMEOUT))
- -#define I2C_DEFAULT_TIMEOUT I2C_SHORT_TIMEOUT
- +#define I2C_DEFAULT_TIMEOUT I2C_LONG_TIMEOUT
- #define I2C_PIN_SEL_MAX 4
- diff --git a/src/main/drivers/compass/compass_hmc5883l.c b/src/main/drivers/compass/compass_hmc5883l.c
- index 1a074a658..91461ea05 100644
- --- a/src/main/drivers/compass/compass_hmc5883l.c
- +++ b/src/main/drivers/compass/compass_hmc5883l.c
- @@ -198,11 +201,6 @@ static void hmc5883SpiInit(busDevice_t *busdev)
- }
- #endif
- -static int16_t parseMag(uint8_t *raw, int16_t gain) {
- - int ret = (int16_t)(raw[0] << 8 | raw[1]) * gain / 256;
- - return constrain(ret, INT16_MIN, INT16_MAX);
- -}
- -
- static bool hmc5883lRead(magDev_t *mag, int16_t *magData)
- {
- uint8_t buf[6];
- @@ -214,94 +211,27 @@ static bool hmc5883lRead(magDev_t *mag, int16_t *magData)
- if (!ack) {
- return false;
- }
- - // During calibration, magGain is 1.0, so the read returns normal non-calibrated values.
- - // After calibration is done, magGain is set to calculated gain values.
- - magData[X] = parseMag(buf + 0, mag->magGain[X]);
- - magData[Z] = parseMag(buf + 2, mag->magGain[Z]);
- - magData[Y] = parseMag(buf + 4, mag->magGain[Y]);
- + magData[X] = (int16_t)(buf[0] << 8 | buf[1]);
- + magData[Z] = (int16_t)(buf[2] << 8 | buf[3]);
- + magData[Y] = (int16_t)(buf[4] << 8 | buf[5]);
- return true;
- }
- static bool hmc5883lInit(magDev_t *mag)
- {
- - enum {
- - polPos,
- - polNeg
- - };
- busDevice_t *busdev = &mag->busdev;
- - int16_t magADC[3];
- - int i;
- - int32_t xyz_total[3] = { 0, 0, 0 }; // 32 bit totals so they won't overflow.
- - bool bret = true; // Error indicator
- -
- - mag->magGain[X] = 256;
- - mag->magGain[Y] = 256;
- - mag->magGain[Z] = 256;
- -
- - delay(50);
- -
- - busWriteRegister(busdev, HMC58X3_REG_CONFA, HMC_CONFA_DOR_15HZ | HMC_CONFA_POS_BIAS); // Reg A DOR = 0x010 + MS1, MS0 set to pos bias
- -
- - // Note that the very first measurement after a gain change maintains the same gain as the previous setting.
- - // The new gain setting is effective from the second measurement and on.
- -
- - busWriteRegister(busdev, HMC58X3_REG_CONFB, HMC_CONFB_GAIN_2_5GA); // Set the Gain to 2.5Ga (7:5->011)
- -
- - delay(100);
- -
- - hmc5883lRead(mag, magADC);
- -
- - for (int polarity = polPos; polarity <= polNeg; polarity++) {
- - switch(polarity) {
- - case polPos:
- - busWriteRegister(busdev, HMC58X3_REG_CONFA, HMC_CONFA_DOR_15HZ | HMC_CONFA_POS_BIAS); // Reg A DOR = 0x010 + MS1, MS0 set to pos bias
- - break;
- - case polNeg:
- - busWriteRegister(busdev, HMC58X3_REG_CONFA, HMC_CONFA_DOR_15HZ | HMC_CONFA_NEG_BIAS); // Reg A DOR = 0x010 + MS1, MS0 set to negative bias.
- - break;
- - }
- - for (i = 0; i < 10; i++) { // Collect 10 samples
- - busWriteRegister(busdev, HMC58X3_REG_MODE, HMC_MODE_SINGLE);
- - delay(20);
- - hmc5883lRead(mag, magADC); // Get the raw values in case the scales have already been changed.
- -
- - // Since the measurements are noisy, they should be averaged rather than taking the max.
- -
- - xyz_total[X] += ((polarity == polPos) ? 1 : -1) * magADC[X];
- - xyz_total[Y] += ((polarity == polPos) ? 1 : -1) * magADC[Y];
- - xyz_total[Z] += ((polarity == polPos) ? 1 : -1) * magADC[Z];
- -
- - // Detect saturation.
- - if (-4096 >= MIN(magADC[X], MIN(magADC[Y], magADC[Z]))) {
- - bret = false;
- - break; // Breaks out of the for loop. No sense in continuing if we saturated.
- - }
- - LED1_TOGGLE;
- - }
- - }
- -
- - mag->magGain[X] = (int)(660.0f * HMC58X3_X_SELF_TEST_GAUSS * 2.0f * 10.0f * 256.0f) / xyz_total[X];
- - mag->magGain[Y] = (int)(660.0f * HMC58X3_Y_SELF_TEST_GAUSS * 2.0f * 10.0f * 256.0f) / xyz_total[Y];
- - mag->magGain[Z] = (int)(660.0f * HMC58X3_Z_SELF_TEST_GAUSS * 2.0f * 10.0f * 256.0f) / xyz_total[Z];
- // leave test mode
- -
- busWriteRegister(busdev, HMC58X3_REG_CONFA, HMC_CONFA_8_SAMLES | HMC_CONFA_DOR_15HZ | HMC_CONFA_NORMAL); // Configuration Register A -- 0 11 100 00 num samples: 8 ; output rate: 15Hz ; normal measurement mode
- busWriteRegister(busdev, HMC58X3_REG_CONFB, HMC_CONFB_GAIN_1_3GA); // Configuration Register B -- 001 00000 configuration gain 1.3Ga
- busWriteRegister(busdev, HMC58X3_REG_MODE, HMC_MODE_CONTINOUS); // Mode register -- 000000 00 continuous Conversion Mode
- delay(100);
- - if (!bret) { // Something went wrong so get a best guess
- - mag->magGain[X] = 256;
- - mag->magGain[Y] = 256;
- - mag->magGain[Z] = 256;
- - }
- -
- hmc5883lConfigureDataReadyInterruptHandling(mag);
- return true;
- }
- diff --git a/src/main/target/OMNIBUSF7/target.c b/src/main/target/OMNIBUSF7/target.c
- index e559da763..2e3941d90 100644
- --- a/src/main/target/OMNIBUSF7/target.c
- +++ b/src/main/target/OMNIBUSF7/target.c
- @@ -43,7 +43,6 @@ const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
- DEF_TIM(TIM8, CH2, PC7, TIM_USE_NONE, 0, 0 ), // UART6_RX
- DEF_TIM(TIM2, CH4, PA3, TIM_USE_PPM, 0, 0 ), // UART2_RX, joined with PE13
- - // For ESC serial
- - DEF_TIM(TIM9, CH1, PA2, TIM_USE_NONE, 0, 0 ), // UART2_TX (unwired)
- -
- + // SmartPort on Softserial
- + DEF_TIM(TIM9, CH2, PE6, TIM_USE_NONE, 0, 0 ), // MOSI -> Softserial
- };
- diff --git a/src/main/target/common_fc_pre.h b/src/main/target/common_fc_pre.h
- index 7ca03d37a..428ab5735 100644
- --- a/src/main/target/common_fc_pre.h
- +++ b/src/main/target/common_fc_pre.h
- @@ -28,8 +28,8 @@
- //#define SCHEDULER_DEBUG // define this to use scheduler debug[] values. Undefined by default for performance reasons
- #define DEBUG_MODE DEBUG_NONE // change this to change initial debug mode
- -#define I2C1_OVERCLOCK true
- -#define I2C2_OVERCLOCK true
- +#define I2C1_OVERCLOCK false
- +#define I2C2_OVERCLOCK false
- #ifdef STM32F1
- #define MINIMAL_CLI
- @@ -47,7 +47,7 @@
- #ifdef STM32F4
- #define USE_DSHOT
- #define USE_ESC_SENSOR
- -#define I2C3_OVERCLOCK true
- +#define I2C3_OVERCLOCK false
- #define USE_GYRO_DATA_ANALYSE
- #define USE_ADC
- #define USE_ADC_INTERNAL
- @@ -64,8 +64,8 @@
- #ifdef STM32F7
- #define USE_DSHOT
- #define USE_ESC_SENSOR
- -#define I2C3_OVERCLOCK true
- -#define I2C4_OVERCLOCK true
- +#define I2C3_OVERCLOCK false
- +#define I2C4_OVERCLOCK false
- #define USE_GYRO_DATA_ANALYSE
- #endif
Add Comment
Please, Sign In to add comment