rt-thread-official/bsp/swm320/libraries/SWM320_StdPeriph_Driver/SWM320_sram.c

57 lines
2.3 KiB
C
Raw Normal View History

2021-02-18 13:29:12 +08:00
/******************************************************************************************************************************************
2021-05-06 10:10:29 +08:00
* : SWM320_sram.c
* : SWM320单片机的SRAM驱动程序
* : http://www.synwit.com.cn/e/tool/gbook/?bid=1
* :
* : V1.1.0 20171025
* :
2021-02-18 13:29:12 +08:00
*
*
*******************************************************************************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION
* REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, SYNWIT SHALL NOT BE HELD LIABLE
* FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
* OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONN-
* -ECTION WITH THEIR PRODUCTS.
*
* COPYRIGHT 2012 Synwit Technology
*******************************************************************************************************************************************/
#include "SWM320.h"
#include "SWM320_sram.h"
/******************************************************************************************************************************************
2021-05-06 10:10:29 +08:00
* : SRAM_Init()
* : SRAM控制器初始化
* : SRAM_InitStructure * initStruct SRAM
* :
* :
2021-02-18 13:29:12 +08:00
******************************************************************************************************************************************/
2021-05-06 10:42:41 +08:00
void SRAM_Init(SRAM_InitStructure *initStruct)
2021-02-18 13:29:12 +08:00
{
2021-05-06 10:42:41 +08:00
uint32_t i;
// 配置SRAM前需要刷新下SDRAM控制器
do
{
SYS->CLKEN |= (1 << SYS_CLKEN_SDRAM_Pos);
while (SDRAMC->REFDONE == 0)
;
SDRAMC->REFRESH &= ~(1 << SDRAMC_REFRESH_EN_Pos);
for (i = 0; i < 1000; i++)
__NOP();
SYS->CLKEN &= ~(1 << SYS_CLKEN_SDRAM_Pos);
} while (0);
SYS->CLKEN |= (1 << SYS_CLKEN_RAMC_Pos);
for (i = 0; i < 10; i++)
__NOP();
SRAMC->CR = (initStruct->ClkDiv << SRAMC_CR_RWTIME_Pos) |
(initStruct->DataWidth << SRAMC_CR_BYTEIF_Pos) |
(0 << SRAMC_CR_HBLBDIS_Pos); // 使能字节、半字访问
2021-02-18 13:29:12 +08:00
}