1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 04:45:24 +03:00

Switch to cleaner way of detecting a soft-reset on STM32F103 based targets using RCC->CSR register.

This commit is contained in:
Konstantin Sharlaimov 2015-03-13 23:42:12 +10:00 committed by Dominic Clifton
parent 11493cd01a
commit bd6297f0cc
4 changed files with 9 additions and 9 deletions

View file

@ -25,16 +25,9 @@
#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;
}
@ -63,7 +56,7 @@ void enableGPIOPowerUsageAndNoiseReductions(void)
bool isMPUSoftReset(void)
{
if ((*((uint16_t *)BKP_BASE + 0x04) | *((uint16_t *)BKP_BASE + 0x08) << 16) == BKP_SOFTRESET)
if (cachedRccCsrValue & RCC_CSR_SFTRSTF)
return true;
else
return false;