Skip to content

Commit

Permalink
stm32/sdram: Add function to enable SDRAM power-down mode.
Browse files Browse the repository at this point in the history
Add power-down mode for maximum power saving while in standby mode, to be
used by a board if needed.  Also fix a typo in a comment.
  • Loading branch information
iabdalkader authored and dpgeorge committed Apr 11, 2022
1 parent cb0372b commit 2a19c3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ports/stm32/sdram.c
Expand Up @@ -259,7 +259,7 @@ static void sdram_init_seq(SDRAM_HandleTypeDef

void sdram_enter_low_power(void) {
// Enter self-refresh mode.
// In self-refresh mode the SDRAM retains data with external clocking.
// In self-refresh mode the SDRAM retains data without external clocking.
FMC_SDRAM_DEVICE->SDCMR |= (FMC_SDRAM_CMD_SELFREFRESH_MODE | // Command Mode
FMC_SDRAM_CMD_TARGET_BANK | // Command Target
(0 << 5U) | // Auto Refresh Number -1
Expand All @@ -276,6 +276,14 @@ void sdram_leave_low_power(void) {
(0 << 9U)); // Mode Register Definition
}

void sdram_enter_power_down(void) {
// Enter power-down mode.
FMC_SDRAM_DEVICE->SDCMR |= (FMC_SDRAM_CMD_POWERDOWN_MODE | // Command Mode
FMC_SDRAM_CMD_TARGET_BANK | // Command Target
(0 << 5U) | // Auto Refresh Number -1
(0 << 9U)); // Mode Register Definition
}

#if __GNUC__ >= 11
// Prevent array bounds warnings when accessing SDRAM_START_ADDRESS as a memory pointer.
#pragma GCC diagnostic push
Expand Down
1 change: 1 addition & 0 deletions ports/stm32/sdram.h
Expand Up @@ -13,5 +13,6 @@ void *sdram_start(void);
void *sdram_end(void);
void sdram_enter_low_power(void);
void sdram_leave_low_power(void);
void sdram_enter_power_down(void);
bool sdram_test(bool exhaustive);
#endif // __SDRAM_H__

0 comments on commit 2a19c3c

Please sign in to comment.