rt-thread/bsp/swm320/drivers/drv_sram.c

51 lines
1.3 KiB
C
Raw Normal View History

2021-02-18 13:29:12 +08:00
/*
* Copyright (c) 2006-2018, Synwit Technology Co.,Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-05-31 ZYH first version
* 2018-12-10 Zohar_Lee format file
* 2020-07-10 lik rewrite
*/
#include "drv_sram.h"
#ifdef BSP_USING_EXT_SRAM
#define DRV_DEBUG
#define LOG_TAG "drv.ext_sram"
#include <drv_log.h>
#ifdef RT_USING_MEMHEAP_AS_HEAP
static struct rt_memheap system_heap;
#endif
static int rt_hw_sram_init(void)
{
SRAM_InitStructure SRAM_InitStruct;
PORT->PORTP_SEL0 = 0xAAAAAAAA; //PP0-23 => ADDR0-23
PORT->PORTP_SEL1 = 0xAAAA;
PORT->PORTM_SEL0 = 0xAAAAAAAA; //PM0-15 => DATA15-0
PORT->PORTM_INEN = 0xFFFF;
PORT->PORTM_SEL1 = 0xAAA; //PM16 => OEN,PM17 => WEN,PM18 => NORFL_CSN,PM19 => SDRAM_CSN,PM20 => SRAM_CSN,PM21 => SDRAM_CKE
SRAM_InitStruct.ClkDiv = SRAM_CLKDIV_8;
SRAM_InitStruct.DataWidth = SRAM_DATAWIDTH_16;
SRAM_Init(&SRAM_InitStruct);
#ifdef RT_USING_MEMHEAP_AS_HEAP
/* If RT_USING_MEMHEAP_AS_HEAP is enabled, SRAM is initialized to the heap */
rt_memheap_init(&system_heap, "sram", (void *)EXT_SRAM_BEGIN, EXT_SRAM_SIZE);
#endif
return 0;
}
INIT_BOARD_EXPORT(rt_hw_sram_init);
#endif /* BSP_USING_EXT_SRAM */