mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Added detection of soft reset and swich of bind mode
after first hard reset (power on) if hardware bind plug is not configured. Now completly tested.
This commit is contained in:
parent
c09877e5b9
commit
1be3e8e550
4 changed files with 35 additions and 2 deletions
|
@ -22,11 +22,19 @@
|
|||
#include "platform.h"
|
||||
|
||||
#include "gpio.h"
|
||||
#include "system.h"
|
||||
|
||||
#define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
|
||||
#define BKP_SOFTRESET (0x50F7B007)
|
||||
|
||||
void systemReset(void)
|
||||
{
|
||||
// write magic value that we're doing a soft reset
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
|
||||
PWR->CR |= PWR_CR_DBP;
|
||||
*((uint16_t *)BKP_BASE + 0x04) = BKP_SOFTRESET & 0xffff;
|
||||
*((uint16_t *)BKP_BASE + 0x08) = (BKP_SOFTRESET & 0xffff0000) >> 16;
|
||||
|
||||
// Generate system reset
|
||||
SCB->AIRCR = AIRCR_VECTKEY_MASK | (uint32_t)0x04;
|
||||
}
|
||||
|
@ -52,3 +60,11 @@ void enableGPIOPowerUsageAndNoiseReductions(void)
|
|||
gpioInit(GPIOB, &gpio);
|
||||
gpioInit(GPIOC, &gpio);
|
||||
}
|
||||
|
||||
bool isMPUSoftReset(void)
|
||||
{
|
||||
if ((*((uint16_t *)BKP_BASE + 0x04) | *((uint16_t *)BKP_BASE + 0x08) << 16) == BKP_SOFTRESET)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue