Use cached value instead of RCC->CSR

This commit is contained in:
jflyper 2017-06-20 09:45:46 +09:00
parent 7b762e640c
commit d51d66f8f1
4 changed files with 6 additions and 6 deletions

View File

@ -83,7 +83,7 @@ void systemInit(void)
// Turn on clocks for stuff we use // Turn on clocks for stuff we use
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
// cache RCC->CSR value to use it in isMPUSoftreset() and others // cache RCC->CSR value to use it in isMPUSoftReset() and others
cachedRccCsrValue = RCC->CSR; cachedRccCsrValue = RCC->CSR;
RCC_ClearFlag(); RCC_ClearFlag();

View File

@ -90,7 +90,7 @@ void systemInit(void)
// Configure NVIC preempt/priority groups // Configure NVIC preempt/priority groups
NVIC_PriorityGroupConfig(NVIC_PRIORITY_GROUPING); NVIC_PriorityGroupConfig(NVIC_PRIORITY_GROUPING);
// cache RCC->CSR value to use it in isMPUSoftreset() and others // cache RCC->CSR value to use it in isMPUSoftReset() and others
cachedRccCsrValue = RCC->CSR; cachedRccCsrValue = RCC->CSR;
RCC_ClearFlag(); RCC_ClearFlag();

View File

@ -152,7 +152,7 @@ void enableGPIOPowerUsageAndNoiseReductions(void)
bool isMPUSoftReset(void) bool isMPUSoftReset(void)
{ {
if (RCC->CSR & RCC_CSR_SFTRSTF) if (cachedRccCsrValue & RCC_CSR_SFTRSTF)
return true; return true;
else else
return false; return false;
@ -167,7 +167,7 @@ void systemInit(void)
// Configure NVIC preempt/priority groups // Configure NVIC preempt/priority groups
NVIC_PriorityGroupConfig(NVIC_PRIORITY_GROUPING); NVIC_PriorityGroupConfig(NVIC_PRIORITY_GROUPING);
// cache RCC->CSR value to use it in isMPUSoftreset() and others // cache RCC->CSR value to use it in isMPUSoftReset() and others
cachedRccCsrValue = RCC->CSR; cachedRccCsrValue = RCC->CSR;
/* Accounts for OP Bootloader, set the Vector Table base address as specified in .ld file */ /* Accounts for OP Bootloader, set the Vector Table base address as specified in .ld file */

View File

@ -149,7 +149,7 @@ void enableGPIOPowerUsageAndNoiseReductions(void)
bool isMPUSoftReset(void) bool isMPUSoftReset(void)
{ {
if (RCC->CSR & RCC_CSR_SFTRSTF) if (cachedRccCsrValue & RCC_CSR_SFTRSTF)
return true; return true;
else else
return false; return false;
@ -164,7 +164,7 @@ void systemInit(void)
// Configure NVIC preempt/priority groups // Configure NVIC preempt/priority groups
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITY_GROUPING); HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITY_GROUPING);
// cache RCC->CSR value to use it in isMPUSoftreset() and others // cache RCC->CSR value to use it in isMPUSoftReset() and others
cachedRccCsrValue = RCC->CSR; cachedRccCsrValue = RCC->CSR;
/* Accounts for OP Bootloader, set the Vector Table base address as specified in .ld file */ /* Accounts for OP Bootloader, set the Vector Table base address as specified in .ld file */