Merge pull request #658 from blckmn/usb_vcp_fix
Fixed build issue for F1, and added dfu CLI command (for restart in D…
This commit is contained in:
commit
6df812fabd
|
@ -40,14 +40,12 @@ typedef uint8_t ioConfig_t; // packed IO configuration
|
||||||
#define IO_CONFIG(mode, speed) ((mode) | (speed))
|
#define IO_CONFIG(mode, speed) ((mode) | (speed))
|
||||||
|
|
||||||
#define IOCFG_OUT_PP IO_CONFIG(GPIO_Mode_Out_PP, GPIO_Speed_2MHz)
|
#define IOCFG_OUT_PP IO_CONFIG(GPIO_Mode_Out_PP, GPIO_Speed_2MHz)
|
||||||
#define IOCFG_OUT_PP_25 IO_CONFIG(GPIO_Mode_Out_PP, GPIO_Speed_25MHz)
|
|
||||||
#define IOCFG_OUT_OD IO_CONFIG(GPIO_Mode_Out_OD, GPIO_Speed_2MHz)
|
#define IOCFG_OUT_OD IO_CONFIG(GPIO_Mode_Out_OD, GPIO_Speed_2MHz)
|
||||||
#define IOCFG_AF_PP IO_CONFIG(GPIO_Mode_AF_PP, GPIO_Speed_2MHz)
|
#define IOCFG_AF_PP IO_CONFIG(GPIO_Mode_AF_PP, GPIO_Speed_2MHz)
|
||||||
#define IOCFG_AF_OD IO_CONFIG(GPIO_Mode_AF_OD, GPIO_Speed_2MHz)
|
#define IOCFG_AF_OD IO_CONFIG(GPIO_Mode_AF_OD, GPIO_Speed_2MHz)
|
||||||
#define IOCFG_IPD IO_CONFIG(GPIO_Mode_IPD, GPIO_Speed_2MHz)
|
#define IOCFG_IPD IO_CONFIG(GPIO_Mode_IPD, GPIO_Speed_2MHz)
|
||||||
#define IOCFG_IPU IO_CONFIG(GPIO_Mode_IPU, GPIO_Speed_2MHz)
|
#define IOCFG_IPU IO_CONFIG(GPIO_Mode_IPU, GPIO_Speed_2MHz)
|
||||||
#define IOCFG_IN_FLOATING IO_CONFIG(GPIO_Mode_IN_FLOATING, GPIO_Speed_2MHz)
|
#define IOCFG_IN_FLOATING IO_CONFIG(GPIO_Mode_IN_FLOATING, GPIO_Speed_2MHz)
|
||||||
#define IOCFG_IPU_25 IO_CONFIG(GPIO_Mode_IPU, GPIO_Speed_25MHz)
|
|
||||||
|
|
||||||
#elif defined(STM32F3) || defined(STM32F4)
|
#elif defined(STM32F3) || defined(STM32F4)
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ void systemReset(void);
|
||||||
void systemResetToBootloader(void);
|
void systemResetToBootloader(void);
|
||||||
bool isMPUSoftReset(void);
|
bool isMPUSoftReset(void);
|
||||||
void cycleCounterInit(void);
|
void cycleCounterInit(void);
|
||||||
|
void checkForBootLoaderRequest(void);
|
||||||
|
|
||||||
void enableGPIOPowerUsageAndNoiseReductions(void);
|
void enableGPIOPowerUsageAndNoiseReductions(void);
|
||||||
// current crystal frequency - 8 or 12MHz
|
// current crystal frequency - 8 or 12MHz
|
||||||
|
|
|
@ -37,7 +37,8 @@ void systemReset(void)
|
||||||
SCB->AIRCR = AIRCR_VECTKEY_MASK | (uint32_t)0x04;
|
SCB->AIRCR = AIRCR_VECTKEY_MASK | (uint32_t)0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemResetToBootloader(void) {
|
void systemResetToBootloader(void)
|
||||||
|
{
|
||||||
// 1FFFF000 -> 20000200 -> SP
|
// 1FFFF000 -> 20000200 -> SP
|
||||||
// 1FFFF004 -> 1FFFF021 -> PC
|
// 1FFFF004 -> 1FFFF021 -> PC
|
||||||
|
|
||||||
|
@ -68,6 +69,8 @@ bool isMPUSoftReset(void)
|
||||||
|
|
||||||
void systemInit(void)
|
void systemInit(void)
|
||||||
{
|
{
|
||||||
|
checkForBootLoaderRequest();
|
||||||
|
|
||||||
SetSysClock(false);
|
SetSysClock(false);
|
||||||
|
|
||||||
#ifdef CC3D
|
#ifdef CC3D
|
||||||
|
@ -110,3 +113,6 @@ void systemInit(void)
|
||||||
SysTick_Config(SystemCoreClock / 1000);
|
SysTick_Config(SystemCoreClock / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkForBootLoaderRequest(void)
|
||||||
|
{
|
||||||
|
}
|
|
@ -35,7 +35,8 @@ void systemReset(void)
|
||||||
SCB->AIRCR = AIRCR_VECTKEY_MASK | (uint32_t)0x04;
|
SCB->AIRCR = AIRCR_VECTKEY_MASK | (uint32_t)0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemResetToBootloader(void) {
|
void systemResetToBootloader(void)
|
||||||
|
{
|
||||||
// 1FFFF000 -> 20000200 -> SP
|
// 1FFFF000 -> 20000200 -> SP
|
||||||
// 1FFFF004 -> 1FFFF021 -> PC
|
// 1FFFF004 -> 1FFFF021 -> PC
|
||||||
|
|
||||||
|
@ -82,6 +83,8 @@ bool isMPUSoftReset(void)
|
||||||
|
|
||||||
void systemInit(void)
|
void systemInit(void)
|
||||||
{
|
{
|
||||||
|
checkForBootLoaderRequest();
|
||||||
|
|
||||||
// Enable FPU
|
// Enable FPU
|
||||||
SCB->CPACR = (0x3 << (10 * 2)) | (0x3 << (11 * 2));
|
SCB->CPACR = (0x3 << (10 * 2)) | (0x3 << (11 * 2));
|
||||||
SetSysClock();
|
SetSysClock();
|
||||||
|
@ -102,3 +105,7 @@ void systemInit(void)
|
||||||
// SysTick
|
// SysTick
|
||||||
SysTick_Config(SystemCoreClock / 1000);
|
SysTick_Config(SystemCoreClock / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkForBootLoaderRequest(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -169,6 +169,8 @@ bool isMPUSoftReset(void)
|
||||||
|
|
||||||
void systemInit(void)
|
void systemInit(void)
|
||||||
{
|
{
|
||||||
|
checkForBootLoaderRequest();
|
||||||
|
|
||||||
SetSysClock();
|
SetSysClock();
|
||||||
|
|
||||||
// Configure NVIC preempt/priority groups
|
// Configure NVIC preempt/priority groups
|
||||||
|
@ -194,3 +196,18 @@ void systemInit(void)
|
||||||
SysTick_Config(SystemCoreClock / 1000);
|
SysTick_Config(SystemCoreClock / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void(*bootJump)(void);
|
||||||
|
void checkForBootLoaderRequest(void)
|
||||||
|
{
|
||||||
|
if (*((uint32_t *)0x2001FFFC) == 0xDEADBEEF) {
|
||||||
|
|
||||||
|
*((uint32_t *)0x2001FFFC) = 0x0;
|
||||||
|
|
||||||
|
__enable_irq();
|
||||||
|
__set_MSP(0x20001000);
|
||||||
|
|
||||||
|
bootJump = (void(*)(void))(*((uint32_t *) 0x1fff0004));
|
||||||
|
bootJump();
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
}
|
|
@ -120,12 +120,12 @@ void setEscLo(uint8_t selEsc)
|
||||||
|
|
||||||
void setEscInput(uint8_t selEsc)
|
void setEscInput(uint8_t selEsc)
|
||||||
{
|
{
|
||||||
IOConfigGPIO(escHardware[selEsc].io, IOCFG_IPU_25);
|
IOConfigGPIO(escHardware[selEsc].io, IOCFG_IPU);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEscOutput(uint8_t selEsc)
|
void setEscOutput(uint8_t selEsc)
|
||||||
{
|
{
|
||||||
IOConfigGPIO(escHardware[selEsc].io, IOCFG_OUT_PP_25);
|
IOConfigGPIO(escHardware[selEsc].io, IOCFG_OUT_PP);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize 4way ESC interface
|
// Initialize 4way ESC interface
|
||||||
|
|
|
@ -112,6 +112,7 @@ static void cliRxFail(char *cmdline);
|
||||||
static void cliAdjustmentRange(char *cmdline);
|
static void cliAdjustmentRange(char *cmdline);
|
||||||
static void cliMotorMix(char *cmdline);
|
static void cliMotorMix(char *cmdline);
|
||||||
static void cliDefaults(char *cmdline);
|
static void cliDefaults(char *cmdline);
|
||||||
|
void cliDfu(char *cmdLine);
|
||||||
static void cliDump(char *cmdLine);
|
static void cliDump(char *cmdLine);
|
||||||
void cliDumpProfile(uint8_t profileIndex);
|
void cliDumpProfile(uint8_t profileIndex);
|
||||||
void cliDumpRateProfile(uint8_t rateProfileIndex) ;
|
void cliDumpRateProfile(uint8_t rateProfileIndex) ;
|
||||||
|
@ -122,6 +123,7 @@ static void cliPlaySound(char *cmdline);
|
||||||
static void cliProfile(char *cmdline);
|
static void cliProfile(char *cmdline);
|
||||||
static void cliRateProfile(char *cmdline);
|
static void cliRateProfile(char *cmdline);
|
||||||
static void cliReboot(void);
|
static void cliReboot(void);
|
||||||
|
static void cliRebootEx(bool bootLoader);
|
||||||
static void cliSave(char *cmdline);
|
static void cliSave(char *cmdline);
|
||||||
static void cliSerial(char *cmdline);
|
static void cliSerial(char *cmdline);
|
||||||
#ifndef SKIP_SERIAL_PASSTHROUGH
|
#ifndef SKIP_SERIAL_PASSTHROUGH
|
||||||
|
@ -263,8 +265,8 @@ const clicmd_t cmdTable[] = {
|
||||||
CLI_COMMAND_DEF("color", "configure colors", NULL, cliColor),
|
CLI_COMMAND_DEF("color", "configure colors", NULL, cliColor),
|
||||||
#endif
|
#endif
|
||||||
CLI_COMMAND_DEF("defaults", "reset to defaults and reboot", NULL, cliDefaults),
|
CLI_COMMAND_DEF("defaults", "reset to defaults and reboot", NULL, cliDefaults),
|
||||||
CLI_COMMAND_DEF("dump", "dump configuration",
|
CLI_COMMAND_DEF("dfu", "DFU mode on reboot", NULL, cliDfu),
|
||||||
"[master|profile]", cliDump),
|
CLI_COMMAND_DEF("dump", "dump configuration", "[master|profile]", cliDump),
|
||||||
CLI_COMMAND_DEF("exit", NULL, NULL, cliExit),
|
CLI_COMMAND_DEF("exit", NULL, NULL, cliExit),
|
||||||
CLI_COMMAND_DEF("feature", "configure features",
|
CLI_COMMAND_DEF("feature", "configure features",
|
||||||
"list\r\n"
|
"list\r\n"
|
||||||
|
@ -2564,10 +2566,19 @@ static void cliRateProfile(char *cmdline) {
|
||||||
|
|
||||||
static void cliReboot(void)
|
static void cliReboot(void)
|
||||||
{
|
{
|
||||||
cliPrint("\r\nRebooting");
|
cliRebootEx(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cliRebootEx(bool bootLoader)
|
||||||
|
{
|
||||||
|
cliPrint("\r\nRebooting");
|
||||||
bufWriterFlush(cliWriter);
|
bufWriterFlush(cliWriter);
|
||||||
waitForSerialPortToFinishTransmitting(cliPort);
|
waitForSerialPortToFinishTransmitting(cliPort);
|
||||||
stopMotors();
|
stopMotors();
|
||||||
|
if (bootLoader) {
|
||||||
|
systemResetToBootloader();
|
||||||
|
return;
|
||||||
|
}
|
||||||
systemReset();
|
systemReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3107,6 +3118,13 @@ static void cliResource(char *cmdline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cliDfu(char *cmdLine)
|
||||||
|
{
|
||||||
|
UNUSED(cmdLine);
|
||||||
|
cliPrint("\r\nRestarting in DFU mode");
|
||||||
|
cliRebootEx(true);
|
||||||
|
}
|
||||||
|
|
||||||
void cliInit(serialConfig_t *serialConfig)
|
void cliInit(serialConfig_t *serialConfig)
|
||||||
{
|
{
|
||||||
UNUSED(serialConfig);
|
UNUSED(serialConfig);
|
||||||
|
|
Loading…
Reference in New Issue