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

51 lines
1.3 KiB
C
Raw Normal View History

2018-12-24 17:17:27 +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
2021-09-30 17:55:16 +08:00
* 2020-07-10 lik rewrite
2018-12-24 17:17:27 +08:00
*/
2021-09-30 17:55:16 +08:00
#include "drv_sram.h"
2018-12-24 17:17:27 +08:00
2021-09-30 17:55:16 +08:00
#ifdef BSP_USING_EXT_SRAM
2018-12-24 17:17:27 +08:00
2021-09-30 17:55:16 +08:00
#define DRV_DEBUG
#define LOG_TAG "drv.ext_sram"
#include <drv_log.h>
2018-12-24 17:17:27 +08:00
2021-09-30 17:55:16 +08:00
#ifdef RT_USING_MEMHEAP_AS_HEAP
static struct rt_memheap system_heap;
#endif
2018-12-24 17:17:27 +08:00
2021-09-30 17:55:16 +08:00
static int rt_hw_sram_init(void)
{
SRAM_InitStructure SRAM_InitStruct;
2018-12-24 17:17:27 +08:00
2021-09-30 17:55:16 +08:00
PORT->PORTP_SEL0 = 0xAAAAAAAA; //PP0-23 => ADDR0-23
PORT->PORTP_SEL1 = 0xAAAA;
2018-12-24 17:17:27 +08:00
2021-09-30 17:55:16 +08:00
PORT->PORTM_SEL0 = 0xAAAAAAAA; //PM0-15 => DATA15-0
PORT->PORTM_INEN = 0xFFFF;
2018-12-24 17:17:27 +08:00
2021-09-30 17:55:16 +08:00
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
2018-12-24 17:17:27 +08:00
return 0;
}
2021-09-30 17:55:16 +08:00
INIT_BOARD_EXPORT(rt_hw_sram_init);
#endif /* BSP_USING_EXT_SRAM */