stm32/sdram: Add SDRAM enter/leave self-refresh mode functions.
These functions enable SDRAM data retention in stop mode. Example usage, in mpconfigboard.h: #define MICROPY_BOARD_ENTER_STOP sdram_enter_low_power(); #define MICROPY_BOARD_LEAVE_STOP sdram_leave_low_power();
This commit is contained in:
parent
32d76e5de6
commit
b603066bc2
@ -49,8 +49,7 @@
|
||||
|
||||
#ifdef FMC_SDRAM_BANK
|
||||
|
||||
static void sdram_init_seq(SDRAM_HandleTypeDef
|
||||
*hsdram, FMC_SDRAM_CommandTypeDef *command);
|
||||
static void sdram_init_seq(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *command);
|
||||
extern void __fatal_error(const char *msg);
|
||||
|
||||
bool sdram_init(void) {
|
||||
@ -254,6 +253,25 @@ static void sdram_init_seq(SDRAM_HandleTypeDef
|
||||
#endif
|
||||
}
|
||||
|
||||
void sdram_enter_low_power(void) {
|
||||
// Enter self-refresh mode.
|
||||
// In self-refresh mode the SDRAM retains data with 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
|
||||
(0 << 9U)); // Mode Register Definition
|
||||
}
|
||||
|
||||
void sdram_leave_low_power(void) {
|
||||
// Exit self-refresh mode.
|
||||
// Self-refresh mode is exited when the device is accessed or the mode bits are
|
||||
// set to Normal mode, so technically it's not necessary to call this functions.
|
||||
FMC_SDRAM_DEVICE->SDCMR |= (FMC_SDRAM_CMD_NORMAL_MODE | // Command Mode
|
||||
FMC_SDRAM_CMD_TARGET_BANK | // Command Target
|
||||
(0 << 5U) | // Auto Refresh Number - 1
|
||||
(0 << 9U)); // Mode Register Definition
|
||||
}
|
||||
|
||||
bool sdram_test(bool fast) {
|
||||
uint8_t const pattern = 0xaa;
|
||||
uint8_t const antipattern = 0x55;
|
||||
|
@ -11,5 +11,7 @@
|
||||
bool sdram_init(void);
|
||||
void *sdram_start(void);
|
||||
void *sdram_end(void);
|
||||
void sdram_enter_low_power(void);
|
||||
void sdram_leave_low_power(void);
|
||||
bool sdram_test(bool fast);
|
||||
#endif // __SDRAM_H__
|
||||
|
Loading…
Reference in New Issue
Block a user