1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 22:35:23 +03:00

Static i2c Clockspeed set to 1200khz (Stability test needed)

Luxfloat can now run with acc stable
This commit is contained in:
borisbstyle 2015-09-23 01:25:45 +02:00
parent f79e7dd6d6
commit 9ed1c46065
6 changed files with 6 additions and 24 deletions

View file

@ -128,7 +128,7 @@ static uint32_t activeFeaturesLatch = 0;
static uint8_t currentControlRateProfileIndex = 0; static uint8_t currentControlRateProfileIndex = 0;
controlRateConfig_t *currentControlRateProfile; controlRateConfig_t *currentControlRateProfile;
static const uint8_t EEPROM_CONF_VERSION = 109; static const uint8_t EEPROM_CONF_VERSION = 108;
static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims) static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims)
{ {
@ -453,7 +453,6 @@ static void resetConf(void)
resetSerialConfig(&masterConfig.serialConfig); resetSerialConfig(&masterConfig.serialConfig);
masterConfig.emf_avoidance = 0; masterConfig.emf_avoidance = 0;
masterConfig.i2c_overclock = 0;
resetPidProfile(&currentProfile->pidProfile); resetPidProfile(&currentProfile->pidProfile);

View file

@ -26,7 +26,6 @@ typedef struct master_t {
uint8_t mixerMode; uint8_t mixerMode;
uint32_t enabledFeatures; uint32_t enabledFeatures;
uint8_t emf_avoidance; // change pll settings to avoid noise in the uhf band uint8_t emf_avoidance; // change pll settings to avoid noise in the uhf band
uint8_t i2c_overclock; // i2c clockspeed, 0 = 400kHz default (conform specs), 1 = 800kHz, 2 = 1200kHz
motorMixer_t customMotorMixer[MAX_SUPPORTED_MOTORS]; motorMixer_t customMotorMixer[MAX_SUPPORTED_MOTORS];
#ifdef USE_SERVOS #ifdef USE_SERVOS

View file

@ -23,7 +23,6 @@ typedef enum I2CDevice {
I2CDEV_MAX = I2CDEV_2, I2CDEV_MAX = I2CDEV_2,
} I2CDevice; } I2CDevice;
void i2cSetClockSelect(uint8_t clockSelect);
void i2cInit(I2CDevice index); void i2cInit(I2CDevice index);
bool i2cWriteBuffer(uint8_t addr_, uint8_t reg_, uint8_t len_, uint8_t *data); bool i2cWriteBuffer(uint8_t addr_, uint8_t reg_, uint8_t len_, uint8_t *data);
bool i2cWrite(uint8_t addr_, uint8_t reg, uint8_t data); bool i2cWrite(uint8_t addr_, uint8_t reg, uint8_t data);

View file

@ -31,6 +31,8 @@
#ifndef SOFT_I2C #ifndef SOFT_I2C
#define CLOCKSPEED 1200000 // i2c clockspeed 400kHz default (conform specs), 800kHz and 1200kHz (Betaflight default)
// I2C2 // I2C2
// SCL PB10 // SCL PB10
// SDA PB11 // SDA PB11
@ -61,7 +63,6 @@ static const i2cDevice_t i2cHardwareMap[] = {
static I2C_TypeDef *I2Cx = NULL; static I2C_TypeDef *I2Cx = NULL;
// Copy of device index for reinit, etc purposes // Copy of device index for reinit, etc purposes
static I2CDevice I2Cx_index; static I2CDevice I2Cx_index;
static uint8_t i2cClockSelect = 0;
void I2C1_ER_IRQHandler(void) void I2C1_ER_IRQHandler(void)
{ {
@ -313,11 +314,6 @@ void i2c_ev_handler(void)
} }
} }
void i2cSetClockSelect(uint8_t clockSelect)
{
i2cClockSelect = clockSelect;
}
void i2cInit(I2CDevice index) void i2cInit(I2CDevice index)
{ {
NVIC_InitTypeDef nvic; NVIC_InitTypeDef nvic;
@ -346,24 +342,15 @@ void i2cInit(I2CDevice index)
i2c.I2C_Mode = I2C_Mode_I2C; i2c.I2C_Mode = I2C_Mode_I2C;
i2c.I2C_DutyCycle = I2C_DutyCycle_2; i2c.I2C_DutyCycle = I2C_DutyCycle_2;
i2c.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; i2c.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
// Overclocking i2c, test results // Overclocking i2c, test results
// Default speed, conform specs is 400000 (400 kHz) // Default speed, conform specs is 400000 (400 kHz)
// 2.0* : 800kHz - worked without errors // 2.0* : 800kHz - worked without errors
// 3.0* : 1200kHz - worked without errors // 3.0* : 1200kHz - worked without errors
// 3.5* : 1400kHz - failed, hangup, bootpin recovery needed // 3.5* : 1400kHz - failed, hangup, bootpin recovery needed
// 4.0* : 1600kHz - failed, hangup, bootpin recovery needed // 4.0* : 1600kHz - failed, hangup, bootpin recovery needed
switch (i2cClockSelect) { i2c.I2C_ClockSpeed = CLOCKSPEED;
default:
case 0:
i2c.I2C_ClockSpeed = 400000;
break;
case 1:
i2c.I2C_ClockSpeed = 800000;
break;
case 2:
i2c.I2C_ClockSpeed = 1200000;
break;
}
I2C_Cmd(I2Cx, ENABLE); I2C_Cmd(I2Cx, ENABLE);
I2C_Init(I2Cx, &i2c); I2C_Init(I2Cx, &i2c);

View file

@ -325,7 +325,6 @@ typedef struct {
const clivalue_t valueTable[] = { const clivalue_t valueTable[] = {
{ "emf_avoidance", VAR_UINT8 | MASTER_VALUE, &masterConfig.emf_avoidance, 0, 1 }, { "emf_avoidance", VAR_UINT8 | MASTER_VALUE, &masterConfig.emf_avoidance, 0, 1 },
{ "i2c_overclock", VAR_UINT8 | MASTER_VALUE, &masterConfig.i2c_overclock, 0, 2 },
{ "mid_rc", VAR_UINT16 | MASTER_VALUE, &masterConfig.rxConfig.midrc, 1200, 1700 }, { "mid_rc", VAR_UINT16 | MASTER_VALUE, &masterConfig.rxConfig.midrc, 1200, 1700 },
{ "min_check", VAR_UINT16 | MASTER_VALUE, &masterConfig.rxConfig.mincheck, PWM_RANGE_ZERO, PWM_RANGE_MAX }, { "min_check", VAR_UINT16 | MASTER_VALUE, &masterConfig.rxConfig.mincheck, PWM_RANGE_ZERO, PWM_RANGE_MAX },

View file

@ -168,7 +168,6 @@ void init(void)
// Configure the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers // Configure the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers
// Configure the Flash Latency cycles and enable prefetch buffer // Configure the Flash Latency cycles and enable prefetch buffer
SetSysClock(masterConfig.emf_avoidance); SetSysClock(masterConfig.emf_avoidance);
i2cSetClockSelect(masterConfig.i2c_overclock);
#endif #endif
#ifdef USE_HARDWARE_REVISION_DETECTION #ifdef USE_HARDWARE_REVISION_DETECTION