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

54 lines
2.3 KiB
C
Raw Normal View History

2021-09-13 21:04:42 +08:00
/******************************************************************************************************************************************
2021-05-06 10:10:29 +08:00
* : SWM320_sram.c
2021-09-13 21:04:42 +08:00
* : SWM320单片机的SRAM驱动程序
* : http://www.synwit.com.cn/e/tool/gbook/?bid=1
2021-05-06 10:10:29 +08:00
* :
2021-09-13 21:04:42 +08:00
* : V1.1.0 20171025
* :
2021-02-18 13:29:12 +08:00
*
*
*******************************************************************************************************************************************
* @attention
*
2021-09-13 21:04:42 +08:00
* 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
2021-02-18 13:29:12 +08:00
* OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONN-
* -ECTION WITH THEIR PRODUCTS.
*
2021-09-13 21:04:42 +08:00
* COPYRIGHT 2012 Synwit Technology
2021-02-18 13:29:12 +08:00
*******************************************************************************************************************************************/
#include "SWM320.h"
#include "SWM320_sram.h"
2021-09-13 21:04:42 +08:00
/******************************************************************************************************************************************
* : SRAM_Init()
* : SRAM控制器初始化
2021-05-06 10:10:29 +08:00
* : SRAM_InitStructure * initStruct SRAM
* :
* :
2021-02-18 13:29:12 +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);
2021-05-06 10:42:41 +08:00
while(SDRAMC->REFDONE == 0);
2021-05-06 10:42:41 +08:00
SDRAMC->REFRESH &= ~(1 << SDRAMC_REFRESH_EN_Pos);
for(i = 0; i < 1000; i++) __NOP();
2021-05-06 10:42:41 +08:00
SYS->CLKEN &= ~(1 << SYS_CLKEN_SDRAM_Pos);
} while(0);
2021-05-06 10:42:41 +08:00
SYS->CLKEN |= (1 << SYS_CLKEN_RAMC_Pos);
for(i = 0; i < 10; i++) __NOP();
2021-05-06 10:42:41 +08:00
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
}