mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 05:45:31 +03:00
Merge pull request #580 from blckmn/development
Fix for needing to slow down serial in the CLI for F4 targets.
This commit is contained in:
commit
b9dca13c31
11 changed files with 197 additions and 178 deletions
|
@ -1046,7 +1046,8 @@ void changeProfile(uint8_t profileIndex)
|
||||||
beeperConfirmationBeeps(profileIndex + 1);
|
beeperConfirmationBeeps(profileIndex + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeControlRateProfile(uint8_t profileIndex) {
|
void changeControlRateProfile(uint8_t profileIndex)
|
||||||
|
{
|
||||||
if (profileIndex > MAX_RATEPROFILES) {
|
if (profileIndex > MAX_RATEPROFILES) {
|
||||||
profileIndex = MAX_RATEPROFILES - 1;
|
profileIndex = MAX_RATEPROFILES - 1;
|
||||||
}
|
}
|
||||||
|
@ -1054,17 +1055,6 @@ void changeControlRateProfile(uint8_t profileIndex) {
|
||||||
activateControlRateConfig();
|
activateControlRateConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleOneshotFeatureChangeOnRestart(void)
|
|
||||||
{
|
|
||||||
// Shutdown PWM on all motors prior to soft restart
|
|
||||||
StopPwmAllMotors();
|
|
||||||
delay(50);
|
|
||||||
// Apply additional delay when OneShot125 feature changed from on to off state
|
|
||||||
if (feature(FEATURE_ONESHOT125) && !featureConfigured(FEATURE_ONESHOT125)) {
|
|
||||||
delay(ONESHOT_FEATURE_CHANGED_DELAY_ON_BOOT_MS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void latchActiveFeatures()
|
void latchActiveFeatures()
|
||||||
{
|
{
|
||||||
activeFeaturesLatch = masterConfig.enabledFeatures;
|
activeFeaturesLatch = masterConfig.enabledFeatures;
|
||||||
|
|
|
@ -50,7 +50,6 @@ typedef enum {
|
||||||
FEATURE_VTX = 1 << 25,
|
FEATURE_VTX = 1 << 25,
|
||||||
} features_e;
|
} features_e;
|
||||||
|
|
||||||
void handleOneshotFeatureChangeOnRestart(void);
|
|
||||||
void latchActiveFeatures(void);
|
void latchActiveFeatures(void);
|
||||||
bool featureConfigured(uint32_t mask);
|
bool featureConfigured(uint32_t mask);
|
||||||
bool feature(uint32_t mask);
|
bool feature(uint32_t mask);
|
||||||
|
|
|
@ -82,10 +82,10 @@ static void i2cUnstick(IO_t scl, IO_t sda);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static i2cDevice_t i2cHardwareMap[] = {
|
static i2cDevice_t i2cHardwareMap[] = {
|
||||||
{ .dev = I2C1, .scl = IO_TAG(I2C1_SCL), .sda = IO_TAG(I2C1_SDA), .rcc = RCC_APB1(I2C1), .overClock = false, .ev_irq = I2C1_EV_IRQn, .er_irq = I2C1_ER_IRQn },
|
{ .dev = I2C1, .scl = IO_TAG(I2C1_SCL), .sda = IO_TAG(I2C1_SDA), .rcc = RCC_APB1(I2C1), .overClock = I2C1_OVERCLOCK, .ev_irq = I2C1_EV_IRQn, .er_irq = I2C1_ER_IRQn },
|
||||||
{ .dev = I2C2, .scl = IO_TAG(I2C2_SCL), .sda = IO_TAG(I2C2_SDA), .rcc = RCC_APB1(I2C2), .overClock = false, .ev_irq = I2C2_EV_IRQn, .er_irq = I2C2_ER_IRQn },
|
{ .dev = I2C2, .scl = IO_TAG(I2C2_SCL), .sda = IO_TAG(I2C2_SDA), .rcc = RCC_APB1(I2C2), .overClock = I2C2_OVERCLOCK, .ev_irq = I2C2_EV_IRQn, .er_irq = I2C2_ER_IRQn },
|
||||||
#ifdef STM32F4
|
#ifdef STM32F4
|
||||||
{ .dev = I2C3, .scl = IO_TAG(I2C3_SCL), .sda = IO_TAG(I2C3_SDA), .rcc = RCC_APB1(I2C3), .overClock = false, .ev_irq = I2C3_EV_IRQn, .er_irq = I2C3_ER_IRQn }
|
{ .dev = I2C3, .scl = IO_TAG(I2C3_SCL), .sda = IO_TAG(I2C3_SDA), .rcc = RCC_APB1(I2C3), .overClock = I2C2_OVERCLOCK, .ev_irq = I2C3_EV_IRQn, .er_irq = I2C3_ER_IRQn }
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ void i2cInit(I2CDevice device)
|
||||||
i2cUnstick(scl, sda);
|
i2cUnstick(scl, sda);
|
||||||
|
|
||||||
// Init pins
|
// Init pins
|
||||||
#if defined(STM32F40_41xxx) || defined(STM32F411xE)
|
#ifdef STM32F4
|
||||||
IOConfigGPIOAF(scl, IOCFG_I2C, GPIO_AF_I2C);
|
IOConfigGPIOAF(scl, IOCFG_I2C, GPIO_AF_I2C);
|
||||||
IOConfigGPIOAF(sda, IOCFG_I2C, GPIO_AF_I2C);
|
IOConfigGPIOAF(sda, IOCFG_I2C, GPIO_AF_I2C);
|
||||||
#else
|
#else
|
||||||
|
@ -416,8 +416,7 @@ void i2cInit(I2CDevice device)
|
||||||
|
|
||||||
if (i2c->overClock) {
|
if (i2c->overClock) {
|
||||||
i2cInit.I2C_ClockSpeed = 800000; // 800khz Maximum speed tested on various boards without issues
|
i2cInit.I2C_ClockSpeed = 800000; // 800khz Maximum speed tested on various boards without issues
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
i2cInit.I2C_ClockSpeed = 400000; // 400khz Operation according specs
|
i2cInit.I2C_ClockSpeed = 400000; // 400khz Operation according specs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,8 @@ static volatile uint16_t i2cErrorCount = 0;
|
||||||
//static volatile uint16_t i2c2ErrorCount = 0;
|
//static volatile uint16_t i2c2ErrorCount = 0;
|
||||||
|
|
||||||
static i2cDevice_t i2cHardwareMap[] = {
|
static i2cDevice_t i2cHardwareMap[] = {
|
||||||
{ .dev = I2C1, .scl = IO_TAG(I2C1_SCL), .sda = IO_TAG(I2C1_SDA), .rcc = RCC_APB1(I2C1), .overClock = false },
|
{ .dev = I2C1, .scl = IO_TAG(I2C1_SCL), .sda = IO_TAG(I2C1_SDA), .rcc = RCC_APB1(I2C1), .overClock = I2C1_OVERCLOCK },
|
||||||
{ .dev = I2C2, .scl = IO_TAG(I2C2_SCL), .sda = IO_TAG(I2C2_SDA), .rcc = RCC_APB1(I2C2), .overClock = false }
|
{ .dev = I2C2, .scl = IO_TAG(I2C2_SCL), .sda = IO_TAG(I2C2_SDA), .rcc = RCC_APB1(I2C2), .overClock = I2C2_OVERCLOCK }
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -93,13 +93,12 @@ void i2cInit(I2CDevice device)
|
||||||
.I2C_OwnAddress1 = 0x00,
|
.I2C_OwnAddress1 = 0x00,
|
||||||
.I2C_Ack = I2C_Ack_Enable,
|
.I2C_Ack = I2C_Ack_Enable,
|
||||||
.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit,
|
.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit,
|
||||||
.I2C_Timing = 0x00E0257A, // 400 Khz, 72Mhz Clock, Analog Filter Delay ON, Rise 100, Fall 10.
|
.I2C_Timing = i2c->overClock ?
|
||||||
|
0x00500E30 : // 1000 Khz, 72Mhz Clock, Analog Filter Delay ON, Setup 40, Hold 4.
|
||||||
|
0x00E0257A, // 400 Khz, 72Mhz Clock, Analog Filter Delay ON, Rise 100, Fall 10.
|
||||||
//.I2C_Timing = 0x8000050B;
|
//.I2C_Timing = 0x8000050B;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (i2c->overClock) {
|
|
||||||
i2cInit.I2C_Timing = 0x00500E30; // 1000 Khz, 72Mhz Clock, Analog Filter Delay ON, Setup 40, Hold 4.
|
|
||||||
}
|
|
||||||
I2C_Init(I2Cx, &i2cInit);
|
I2C_Init(I2Cx, &i2cInit);
|
||||||
|
|
||||||
I2C_Cmd(I2Cx, ENABLE);
|
I2C_Cmd(I2Cx, ENABLE);
|
||||||
|
|
|
@ -117,6 +117,7 @@ static bool usbVcpFlush(vcpPort_t *port)
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!usbIsConnected() || !usbIsConfigured()) {
|
if (!usbIsConnected() || !usbIsConfigured()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1903,9 +1903,10 @@ static void dumpValues(uint16_t valueSection)
|
||||||
cliPrintVar(value, 0);
|
cliPrintVar(value, 0);
|
||||||
cliPrint("\r\n");
|
cliPrint("\r\n");
|
||||||
|
|
||||||
#ifdef STM32F4
|
#ifdef USE_SLOW_SERIAL_CLI
|
||||||
delay(2);
|
delay(2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1979,6 +1980,9 @@ static void cliDump(char *cmdline)
|
||||||
if (yaw < 0)
|
if (yaw < 0)
|
||||||
cliWrite(' ');
|
cliWrite(' ');
|
||||||
cliPrintf("%s\r\n", ftoa(yaw, buf));
|
cliPrintf("%s\r\n", ftoa(yaw, buf));
|
||||||
|
#ifdef USE_SLOW_SERIAL_CLI
|
||||||
|
delay(2);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_SERVOS
|
#ifdef USE_SERVOS
|
||||||
|
@ -2000,6 +2004,10 @@ static void cliDump(char *cmdline)
|
||||||
masterConfig.customServoMixer[i].max,
|
masterConfig.customServoMixer[i].max,
|
||||||
masterConfig.customServoMixer[i].box
|
masterConfig.customServoMixer[i].box
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#ifdef USE_SLOW_SERIAL_CLI
|
||||||
|
delay(2);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2012,12 +2020,18 @@ static void cliDump(char *cmdline)
|
||||||
if (featureNames[i] == NULL)
|
if (featureNames[i] == NULL)
|
||||||
break;
|
break;
|
||||||
cliPrintf("feature -%s\r\n", featureNames[i]);
|
cliPrintf("feature -%s\r\n", featureNames[i]);
|
||||||
|
#ifdef USE_SLOW_SERIAL_CLI
|
||||||
|
delay(2);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
for (i = 0; ; i++) { // reenable what we want.
|
for (i = 0; ; i++) { // reenable what we want.
|
||||||
if (featureNames[i] == NULL)
|
if (featureNames[i] == NULL)
|
||||||
break;
|
break;
|
||||||
if (mask & (1 << i))
|
if (mask & (1 << i))
|
||||||
cliPrintf("feature %s\r\n", featureNames[i]);
|
cliPrintf("feature %s\r\n", featureNames[i]);
|
||||||
|
#ifdef USE_SLOW_SERIAL_CLI
|
||||||
|
delay(2);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2077,6 +2091,9 @@ static void cliDump(char *cmdline)
|
||||||
for (channel = 0; channel < INPUT_SOURCE_COUNT; channel++) {
|
for (channel = 0; channel < INPUT_SOURCE_COUNT; channel++) {
|
||||||
if (servoDirection(i, channel) < 0) {
|
if (servoDirection(i, channel) < 0) {
|
||||||
cliPrintf("smix reverse %d %d r\r\n", i , channel);
|
cliPrintf("smix reverse %d %d r\r\n", i , channel);
|
||||||
|
#ifdef USE_SLOW_SERIAL_CLI
|
||||||
|
delay(2);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2109,6 +2126,9 @@ static void cliDump(char *cmdline)
|
||||||
|
|
||||||
changeControlRateProfile(currentRateIndex);
|
changeControlRateProfile(currentRateIndex);
|
||||||
cliRateProfile("");
|
cliRateProfile("");
|
||||||
|
#ifdef USE_SLOW_SERIAL_CLI
|
||||||
|
delay(2);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPrint("\r\n# restore original profile selection\r\n");
|
cliPrint("\r\n# restore original profile selection\r\n");
|
||||||
|
@ -2133,7 +2153,8 @@ static void cliDump(char *cmdline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cliDumpProfile(uint8_t profileIndex) {
|
void cliDumpProfile(uint8_t profileIndex)
|
||||||
|
{
|
||||||
if (profileIndex >= MAX_PROFILE_COUNT) // Faulty values
|
if (profileIndex >= MAX_PROFILE_COUNT) // Faulty values
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2148,7 +2169,8 @@ void cliDumpProfile(uint8_t profileIndex) {
|
||||||
cliRateProfile("");
|
cliRateProfile("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void cliDumpRateProfile(uint8_t rateProfileIndex) {
|
void cliDumpRateProfile(uint8_t rateProfileIndex)
|
||||||
|
{
|
||||||
if (rateProfileIndex >= MAX_RATEPROFILES) // Faulty values
|
if (rateProfileIndex >= MAX_RATEPROFILES) // Faulty values
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2541,12 +2563,12 @@ static void cliRateProfile(char *cmdline) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cliReboot(void) {
|
static void cliReboot(void)
|
||||||
|
{
|
||||||
cliPrint("\r\nRebooting");
|
cliPrint("\r\nRebooting");
|
||||||
bufWriterFlush(cliWriter);
|
bufWriterFlush(cliWriter);
|
||||||
waitForSerialPortToFinishTransmitting(cliPort);
|
waitForSerialPortToFinishTransmitting(cliPort);
|
||||||
stopMotors();
|
stopMotors();
|
||||||
handleOneshotFeatureChangeOnRestart();
|
|
||||||
systemReset();
|
systemReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2718,7 +2740,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
|
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");
|
cliPrint("\r\n");
|
||||||
|
|
||||||
#ifdef STM32F4
|
#ifdef USE_SLOW_SERIAL_CLI
|
||||||
delay(2);
|
delay(2);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -1969,7 +1969,6 @@ void mspProcess(void)
|
||||||
if (isRebootScheduled) {
|
if (isRebootScheduled) {
|
||||||
waitForSerialPortToFinishTransmitting(candidatePort->port);
|
waitForSerialPortToFinishTransmitting(candidatePort->port);
|
||||||
stopMotors();
|
stopMotors();
|
||||||
handleOneshotFeatureChangeOnRestart();
|
|
||||||
// On real flight controllers, systemReset() will do a soft reset of the device,
|
// On real flight controllers, systemReset() will do a soft reset of the device,
|
||||||
// reloading the program. But to support offline testing this flag needs to be
|
// reloading the program. But to support offline testing this flag needs to be
|
||||||
// cleared so that the software doesn't continuously attempt to reboot itself.
|
// cleared so that the software doesn't continuously attempt to reboot itself.
|
||||||
|
|
|
@ -1545,7 +1545,6 @@ void taskBstMasterProcess(void)
|
||||||
bstMasterWriteLoop();
|
bstMasterWriteLoop();
|
||||||
if (isRebootScheduled) {
|
if (isRebootScheduled) {
|
||||||
stopMotors();
|
stopMotors();
|
||||||
handleOneshotFeatureChangeOnRestart();
|
|
||||||
systemReset();
|
systemReset();
|
||||||
}
|
}
|
||||||
resetBstChecker();
|
resetBstChecker();
|
||||||
|
@ -1555,12 +1554,14 @@ void taskBstMasterProcess(void)
|
||||||
static uint8_t masterWriteBufferPointer;
|
static uint8_t masterWriteBufferPointer;
|
||||||
static uint8_t masterWriteData[DATA_BUFFER_SIZE];
|
static uint8_t masterWriteData[DATA_BUFFER_SIZE];
|
||||||
|
|
||||||
static void bstMasterStartBuffer(uint8_t address) {
|
static void bstMasterStartBuffer(uint8_t address)
|
||||||
|
{
|
||||||
masterWriteData[0] = address;
|
masterWriteData[0] = address;
|
||||||
masterWriteBufferPointer = 2;
|
masterWriteBufferPointer = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bstMasterWrite8(uint8_t data) {
|
static void bstMasterWrite8(uint8_t data)
|
||||||
|
{
|
||||||
masterWriteData[masterWriteBufferPointer++] = data;
|
masterWriteData[masterWriteBufferPointer++] = data;
|
||||||
masterWriteData[1] = masterWriteBufferPointer;
|
masterWriteData[1] = masterWriteBufferPointer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@
|
||||||
|
|
||||||
// Performance logging for SD card operations:
|
// Performance logging for SD card operations:
|
||||||
// #define AFATFS_USE_INTROSPECTIVE_LOGGING
|
// #define AFATFS_USE_INTROSPECTIVE_LOGGING
|
||||||
#define DEFAULT_FEATURES (FEATURE_BLACKBOX | FEATURE_RX_SERIAL | FEATURE_OSD | FEATURE_VTX)
|
|
||||||
#define USE_ADC
|
#define USE_ADC
|
||||||
#define BOARD_HAS_VOLTAGE_DIVIDER
|
#define BOARD_HAS_VOLTAGE_DIVIDER
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@
|
||||||
|
|
||||||
#define USE_SERVOS
|
#define USE_SERVOS
|
||||||
#define DEFAULT_RX_FEATURE FEATURE_RX_PPM
|
#define DEFAULT_RX_FEATURE FEATURE_RX_PPM
|
||||||
#define DEFAULT_FEATURES FEATURE_BLACKBOX
|
#define DEFAULT_FEATURES (FEATURE_BLACKBOX | FEATURE_RX_SERIAL | FEATURE_OSD | FEATURE_VTX)
|
||||||
|
|
||||||
#define USE_SERIAL_4WAY_BLHELI_INTERFACE
|
#define USE_SERIAL_4WAY_BLHELI_INTERFACE
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,23 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#define I2C1_OVERCLOCK true
|
||||||
|
#define I2C2_OVERCLOCK true
|
||||||
|
|
||||||
|
|
||||||
|
/* STM32F4 specific settings that apply to all F4 targets */
|
||||||
#ifdef STM32F4
|
#ifdef STM32F4
|
||||||
|
|
||||||
#define TASK_GYROPID_DESIRED_PERIOD 125
|
#define TASK_GYROPID_DESIRED_PERIOD 125
|
||||||
#define SCHEDULER_DELAY_LIMIT 10
|
#define SCHEDULER_DELAY_LIMIT 10
|
||||||
#else
|
#define USE_SLOW_SERIAL_CLI
|
||||||
|
#define I2C3_OVERCLOCK true
|
||||||
|
|
||||||
|
#else /* when not an F4 */
|
||||||
|
|
||||||
#define TASK_GYROPID_DESIRED_PERIOD 1000
|
#define TASK_GYROPID_DESIRED_PERIOD 1000
|
||||||
#define SCHEDULER_DELAY_LIMIT 100
|
#define SCHEDULER_DELAY_LIMIT 100
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SERIAL_RX
|
#define SERIAL_RX
|
||||||
|
|
|
@ -153,13 +153,12 @@ static uint16_t VCP_Ctrl(uint32_t Cmd, uint8_t* Buf, uint32_t Len)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
uint32_t CDC_Send_DATA(uint8_t *ptrBuffer, uint8_t sendLength)
|
uint32_t CDC_Send_DATA(uint8_t *ptrBuffer, uint8_t sendLength)
|
||||||
{
|
{
|
||||||
if(USB_Tx_State!=1)
|
if (USB_Tx_State)
|
||||||
{
|
return 0;
|
||||||
|
|
||||||
VCP_DataTx(ptrBuffer, sendLength);
|
VCP_DataTx(ptrBuffer, sendLength);
|
||||||
return sendLength;
|
return sendLength;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief VCP_DataTx
|
* @brief VCP_DataTx
|
||||||
|
@ -171,7 +170,6 @@ uint32_t CDC_Send_DATA(uint8_t *ptrBuffer, uint8_t sendLength)
|
||||||
*/
|
*/
|
||||||
static uint16_t VCP_DataTx(uint8_t* Buf, uint32_t Len)
|
static uint16_t VCP_DataTx(uint8_t* Buf, uint32_t Len)
|
||||||
{
|
{
|
||||||
|
|
||||||
uint16_t ptr = APP_Rx_ptr_in;
|
uint16_t ptr = APP_Rx_ptr_in;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue