mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-24 00:35:34 +03:00
I2C Overclock Feature
This speeds up IMU speed significantly. F1 Targets like NAZE Looptime of ~900 is possible F3 Targets like SPRACINGF3 looptime of 370 is posible
This commit is contained in:
parent
83109dbf17
commit
9da66d5005
8 changed files with 35 additions and 4 deletions
|
@ -105,6 +105,7 @@ Re-apply any new defaults as desired.
|
||||||
|---------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|--------|---------------|--------------|----------|
|
|---------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|--------|---------------|--------------|----------|
|
||||||
| `looptime` | This is the main loop time (in us). Changing this affects PID effect with some PID controllers (see PID section for details). Default of 3500us/285Hz should work for everyone. Setting it to zero does not limit loop time, so it will go as fast as possible. | 0 | 9000 | 3500 | Master | UINT16 |
|
| `looptime` | This is the main loop time (in us). Changing this affects PID effect with some PID controllers (see PID section for details). Default of 3500us/285Hz should work for everyone. Setting it to zero does not limit loop time, so it will go as fast as possible. | 0 | 9000 | 3500 | Master | UINT16 |
|
||||||
| `emf_avoidance` | Default value is 0 for 72MHz processor speed. Setting this to 1 increases the processor speed, to move the 6th harmonic away from 432MHz. | 0 | 1 | 0 | Master | UINT8 |
|
| `emf_avoidance` | Default value is 0 for 72MHz processor speed. Setting this to 1 increases the processor speed, to move the 6th harmonic away from 432MHz. | 0 | 1 | 0 | Master | UINT8 |
|
||||||
|
| `i2c_overclock` | Default value is 0 for disabled. Enabling this feature speeds up IMU speed significantly and faster looptimes are possible. | 0 | 1 | 0 | Master | UINT8 |
|
||||||
| `mid_rc` | This is an important number to set in order to avoid trimming receiver/transmitter. Most standard receivers will have this at 1500, however Futaba transmitters will need this set to 1520. A way to find out if this needs to be changed, is to clear all trim/subtrim on transmitter, and connect to GUI. Note the value most channels idle at - this should be the number to choose. Once midrc is set, use subtrim on transmitter to make sure all channels (except throttle of course) are centered at midrc value. | 1200 | 1700 | 1500 | Master | UINT16 |
|
| `mid_rc` | This is an important number to set in order to avoid trimming receiver/transmitter. Most standard receivers will have this at 1500, however Futaba transmitters will need this set to 1520. A way to find out if this needs to be changed, is to clear all trim/subtrim on transmitter, and connect to GUI. Note the value most channels idle at - this should be the number to choose. Once midrc is set, use subtrim on transmitter to make sure all channels (except throttle of course) are centered at midrc value. | 1200 | 1700 | 1500 | Master | UINT16 |
|
||||||
| `min_check` | These are min/max values (in us) which, when a channel is smaller (min) or larger (max) than the value will activate various RC commands, such as arming, or stick configuration. Normally, every RC channel should be set so that min = 1000us, max = 2000us. On most transmitters this usually means 125% endpoints. Default check values are 100us above/below this value. | 0 | 2000 | 1100 | Master | UINT16 |
|
| `min_check` | These are min/max values (in us) which, when a channel is smaller (min) or larger (max) than the value will activate various RC commands, such as arming, or stick configuration. Normally, every RC channel should be set so that min = 1000us, max = 2000us. On most transmitters this usually means 125% endpoints. Default check values are 100us above/below this value. | 0 | 2000 | 1100 | Master | UINT16 |
|
||||||
| `max_check` | These are min/max values (in us) which, when a channel is smaller (min) or larger (max) than the value will activate various RC commands, such as arming, or stick configuration. Normally, every RC channel should be set so that min = 1000us, max = 2000us. On most transmitters this usually means 125% endpoints. Default check values are 100us above/below this value. | 0 | 2000 | 1900 | Master | UINT16 |
|
| `max_check` | These are min/max values (in us) which, when a channel is smaller (min) or larger (max) than the value will activate various RC commands, such as arming, or stick configuration. Normally, every RC channel should be set so that min = 1000us, max = 2000us. On most transmitters this usually means 125% endpoints. Default check values are 100us above/below this value. | 0 | 2000 | 1900 | Master | UINT16 |
|
||||||
|
|
|
@ -132,7 +132,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 = 106;
|
static const uint8_t EEPROM_CONF_VERSION = 107;
|
||||||
|
|
||||||
static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims)
|
static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims)
|
||||||
{
|
{
|
||||||
|
@ -476,6 +476,7 @@ static void resetConf(void)
|
||||||
|
|
||||||
masterConfig.looptime = 3500;
|
masterConfig.looptime = 3500;
|
||||||
masterConfig.emf_avoidance = 0;
|
masterConfig.emf_avoidance = 0;
|
||||||
|
masterConfig.i2c_overclock = 0;
|
||||||
|
|
||||||
resetPidProfile(¤tProfile->pidProfile);
|
resetPidProfile(¤tProfile->pidProfile);
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ typedef struct master_t {
|
||||||
uint32_t enabledFeatures;
|
uint32_t enabledFeatures;
|
||||||
uint16_t looptime; // imu loop time in us
|
uint16_t looptime; // imu loop time in us
|
||||||
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; // Overclock i2c Bus for faster IMU readings
|
||||||
|
|
||||||
motorMixer_t customMotorMixer[MAX_SUPPORTED_MOTORS];
|
motorMixer_t customMotorMixer[MAX_SUPPORTED_MOTORS];
|
||||||
#ifdef USE_SERVOS
|
#ifdef USE_SERVOS
|
||||||
|
|
|
@ -28,3 +28,4 @@ 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);
|
||||||
bool i2cRead(uint8_t addr_, uint8_t reg, uint8_t len, uint8_t* buf);
|
bool i2cRead(uint8_t addr_, uint8_t reg, uint8_t len, uint8_t* buf);
|
||||||
uint16_t i2cGetErrorCounter(void);
|
uint16_t i2cGetErrorCounter(void);
|
||||||
|
void i2cSetOverclock(uint8_t OverClock);
|
||||||
|
|
|
@ -61,6 +61,11 @@ 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 bool i2cOverClock;
|
||||||
|
|
||||||
|
void i2cSetOverclock(uint8_t OverClock) {
|
||||||
|
i2cOverClock = (OverClock) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
void I2C1_ER_IRQHandler(void)
|
void I2C1_ER_IRQHandler(void)
|
||||||
{
|
{
|
||||||
|
@ -340,7 +345,13 @@ 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;
|
||||||
i2c.I2C_ClockSpeed = 400000;
|
|
||||||
|
if (i2cOverClock) {
|
||||||
|
i2c.I2C_ClockSpeed = 800000; // 800khz Maximum speed tested on various boards without issues
|
||||||
|
} else {
|
||||||
|
i2c.I2C_ClockSpeed = 400000; // 400khz Operation according specs
|
||||||
|
}
|
||||||
|
|
||||||
I2C_Cmd(I2Cx, ENABLE);
|
I2C_Cmd(I2Cx, ENABLE);
|
||||||
I2C_Init(I2Cx, &i2c);
|
I2C_Init(I2Cx, &i2c);
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,12 @@ static I2C_TypeDef *I2Cx = NULL;
|
||||||
// I2C TimeoutUserCallback
|
// I2C TimeoutUserCallback
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static bool i2cOverClock;
|
||||||
|
|
||||||
|
void i2cSetOverclock(uint8_t OverClock) {
|
||||||
|
i2cOverClock = (OverClock) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t i2cTimeoutUserCallback(I2C_TypeDef *I2Cx)
|
uint32_t i2cTimeoutUserCallback(I2C_TypeDef *I2Cx)
|
||||||
{
|
{
|
||||||
if (I2Cx == I2C1) {
|
if (I2Cx == I2C1) {
|
||||||
|
@ -118,7 +124,11 @@ void i2cInitPort(I2C_TypeDef *I2Cx)
|
||||||
I2C_InitStructure.I2C_OwnAddress1 = 0x00;
|
I2C_InitStructure.I2C_OwnAddress1 = 0x00;
|
||||||
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
|
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
|
||||||
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
|
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
|
||||||
I2C_InitStructure.I2C_Timing = 0x00E0257A; // 400 Khz, 72Mhz Clock, Analog Filter Delay ON, Rise 100, Fall 10.
|
if (i2cOverClock) {
|
||||||
|
I2C_InitStructure.I2C_Timing = 0x00500E30; // 1000 Khz, 72Mhz Clock, Analog Filter Delay ON, Setup 40, Hold 4.
|
||||||
|
} else {
|
||||||
|
I2C_InitStructure.I2C_Timing = 0x00E0257A; // 400 Khz, 72Mhz Clock, Analog Filter Delay ON, Rise 100, Fall 10
|
||||||
|
}
|
||||||
//I2C_InitStructure.I2C_Timing = 0x8000050B;
|
//I2C_InitStructure.I2C_Timing = 0x8000050B;
|
||||||
|
|
||||||
I2C_Init(I2C1, &I2C_InitStructure);
|
I2C_Init(I2C1, &I2C_InitStructure);
|
||||||
|
@ -165,7 +175,11 @@ void i2cInitPort(I2C_TypeDef *I2Cx)
|
||||||
// ^ when using this setting and after a few seconds of a scope probe being attached to the I2C bus it was observed that the bus enters
|
// ^ when using this setting and after a few seconds of a scope probe being attached to the I2C bus it was observed that the bus enters
|
||||||
// a busy state and does not recover.
|
// a busy state and does not recover.
|
||||||
|
|
||||||
I2C_InitStructure.I2C_Timing = 0x00E0257A; // 400 Khz, 72Mhz Clock, Analog Filter Delay ON, Rise 100, Fall 10.
|
if (i2cOverClock) {
|
||||||
|
I2C_InitStructure.I2C_Timing = 0x00500E30; // 1000 Khz, 72Mhz Clock, Analog Filter Delay ON, Setup 40, Hold 4.
|
||||||
|
} else {
|
||||||
|
I2C_InitStructure.I2C_Timing = 0x00E0257A; // 400 Khz, 72Mhz Clock, Analog Filter Delay ON, Rise 100, Fall 10
|
||||||
|
}
|
||||||
|
|
||||||
//I2C_InitStructure.I2C_Timing = 0x8000050B;
|
//I2C_InitStructure.I2C_Timing = 0x8000050B;
|
||||||
|
|
||||||
|
|
|
@ -325,6 +325,7 @@ typedef struct {
|
||||||
const clivalue_t valueTable[] = {
|
const clivalue_t valueTable[] = {
|
||||||
{ "looptime", VAR_UINT16 | MASTER_VALUE, &masterConfig.looptime, 0, 9000 },
|
{ "looptime", VAR_UINT16 | MASTER_VALUE, &masterConfig.looptime, 0, 9000 },
|
||||||
{ "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, 1 },
|
||||||
|
|
||||||
{ "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 },
|
||||||
|
|
|
@ -169,6 +169,7 @@ void init(void)
|
||||||
// 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);
|
||||||
#endif
|
#endif
|
||||||
|
i2cSetOverclock(masterConfig.i2c_overclock);
|
||||||
|
|
||||||
#ifdef USE_HARDWARE_REVISION_DETECTION
|
#ifdef USE_HARDWARE_REVISION_DETECTION
|
||||||
detectHardwareRevision();
|
detectHardwareRevision();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue