1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 21:35:44 +03:00

Merge pull request #9406 from jflyper/bfdev-g4-persistent

[G4] Persistent object support
This commit is contained in:
Michael Keller 2020-01-25 20:04:36 +13:00 committed by GitHub
commit ff04f0d37e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -51,18 +51,33 @@ void persistentObjectWrite(persistentObjectId_e id, uint32_t value)
void persistentObjectRTCEnable(void)
{
#if !defined(STM32G4)
// G4 library V1.0.0 __HAL_RTC_WRITEPROTECTION_ENABLE/DISABLE macro does not use handle parameter
RTC_HandleTypeDef rtcHandle = { .Instance = RTC };
#endif
#if !defined(STM32H7)
__HAL_RCC_PWR_CLK_ENABLE(); // Enable Access to PWR
#endif
HAL_PWR_EnableBkUpAccess(); // Disable backup domain protection
#if defined(STM32G4)
/* Enable RTC APB clock */
__HAL_RCC_RTCAPB_CLK_ENABLE();
/* Peripheral clock enable */
__HAL_RCC_RTC_ENABLE();
#else // !STM32G4, F7 and H7 case
#if defined(__HAL_RCC_RTC_CLK_ENABLE)
// For those MCUs with RTCAPBEN bit in RCC clock enable register, turn it on.
__HAL_RCC_RTC_CLK_ENABLE(); // Enable RTC module
#endif
#endif // STM32G4
// We don't need a clock source for RTC itself. Skip it.
__HAL_RTC_WRITEPROTECTION_ENABLE(&rtcHandle); // Reset sequence

View file

@ -66,7 +66,7 @@ bool isMPUSoftReset(void);
void cycleCounterInit(void);
uint32_t clockCyclesToMicros(uint32_t clockCycles);
uint32_t getCycleCounter(void);
#if defined(STM32H7)
#if defined(STM32H7) || defined(STM32G4)
void systemCheckResetReason(void);
#endif