Add comments to Stop & Stby modes (#3798)

This commit is contained in:
NMSTEC 2022-01-17 10:11:24 -08:00 committed by GitHub
parent 54b70fbc3c
commit c8fdd25d5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 9 deletions

View File

@ -217,15 +217,15 @@ void setBoardDefaultConfiguration() {
void boardPrepareForStop() { void boardPrepareForStop() {
#ifdef STM32F7XX #ifdef STM32F7XX
// enable EXTI on PD0 - CAN RX pin // enable EXTI on PD0 - CAN RX pin
palSetPadMode(GPIOD, 0, PAL_MODE_INPUT); palSetPadMode(GPIOD, 0, PAL_MODE_INPUT); //Select Pin 0 on D Port - PD0, CAN RX as input
palEnableLineEvent(PAL_LINE(GPIOD, 0), PAL_EVENT_MODE_RISING_EDGE); palEnableLineEvent(PAL_LINE(GPIOD, 0), PAL_EVENT_MODE_RISING_EDGE); // Set PD0 to interrupt on rising edge
#endif #endif
#ifdef STM32F4XX #ifdef STM32F4XX
// enable EXTI on PA0 - The only WKUP pin F4 has. // enable EXTI on PA0 - The only WKUP pin F4 has.
PWR->CR |= PWR_CR_CWUF; //Clear Wakeup Pin flag for PA0 PWR->CR |= PWR_CR_CWUF; //Clear Wakeup Pin flag for PA0
palSetPadMode(GPIOA, 0, PAL_MODE_INPUT); palSetPadMode(GPIOA, 0, PAL_MODE_INPUT); //Select Pin 0 on D Port - PA0, Wkup
palEnableLineEvent(PAL_LINE(GPIOA, 0), PAL_EVENT_MODE_RISING_EDGE); palEnableLineEvent(PAL_LINE(GPIOA, 0), PAL_EVENT_MODE_RISING_EDGE); // Set PA0 to interrupt on rising edge
#endif #endif
} }

View File

@ -30,7 +30,11 @@ uintptr_t getFlashAddrFirstCopy() {
uintptr_t getFlashAddrSecondCopy() { uintptr_t getFlashAddrSecondCopy() {
return 0x080C0000; return 0x080C0000;
} }
/*
STOP mode for F7 is needed for wakeup from multiple EXTI pins. For example PD0, which is CAN rx.
However, for F40X & F42X this may be useless. STOP in itself eats more current than standby.
With F4 only having PA0 available for wakeup, this negates its need.
*/
void stm32_stop() { void stm32_stop() {
SysTick->CTRL = 0; SysTick->CTRL = 0;
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
@ -45,7 +49,7 @@ void stm32_stop() {
boardPrepareForStop(); boardPrepareForStop();
PWR->CR &= ~PWR_CR_PDDS; // cleared PDDS means stop mode (not standby) PWR->CR &= ~PWR_CR_PDDS; // cleared PDDS means stop mode (not standby)
PWR->CR |= PWR_CR_FPDS; // turn off flash in stop mode PWR->CR |= PWR_CR_FPDS; // turn off flash in stop mode
#ifdef STM32F429xx #ifdef STM32F429xx //F40X Does not have these regulators available.
PWR->CR |= PWR_CR_UDEN; // regulator underdrive in stop mode * PWR->CR |= PWR_CR_UDEN; // regulator underdrive in stop mode *
PWR->CR |= PWR_CR_LPUDS; // low power regulator in under drive mode PWR->CR |= PWR_CR_LPUDS; // low power regulator in under drive mode
#endif #endif
@ -59,7 +63,10 @@ void stm32_stop() {
// Lastly, reboot // Lastly, reboot
NVIC_SystemReset(); NVIC_SystemReset();
} }
/*
Standby for both F4 & F7 works perfectly, with very little curent consumption. Downside is that theres a limited amount of pins that can wakeup F7, and only PA0 for F4XX.
Cannot be used for CAN wakeup without hardware modificatinos.
*/
void stm32_standby() { void stm32_standby() {
SysTick->CTRL = 0; SysTick->CTRL = 0;
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;

View File

@ -174,7 +174,11 @@ void sys_dual_bank(void) {
*/ */
} }
/*
STOP mode for F7 is needed for wakeup from multiple EXTI pins. For example PD0, which is CAN rx.
However, for F40X & F42X this may be useless. STOP in itself eats more current than standby.
With F4 only having PA0 available for wakeup, this negates its need.
*/
void stm32_stop() { void stm32_stop() {
SysTick->CTRL = 0; SysTick->CTRL = 0;
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
@ -202,7 +206,10 @@ void stm32_stop() {
// Lastly, reboot // Lastly, reboot
NVIC_SystemReset(); NVIC_SystemReset();
} }
/*
Standby for both F4 & F7 works perfectly, with very little curent consumption. Downside is that theres a limited amount of pins that can wakeup F7, and only PA0 for F4XX.
Cannot be used for CAN wakeup without hardware modificatinos.
*/
void stm32_standby() { void stm32_standby() {
SysTick->CTRL = 0; SysTick->CTRL = 0;
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;