board.c 1.8 KB
Newer Older
z13955633063's avatar
z13955633063 已提交
1 2
#include <interrupt.h>
#include <rthw.h>
3
#include <platform.h>
z13955633063's avatar
z13955633063 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16
#if 0
static struct mem_desc hw_mem_desc[] =
{
    { 0x00000000, 0xFFFFFFFF, 0x00000000, RW_NCNB },/* None cached for 4G memory */
//  visual start, visual end, phy start , props
    { 0x00000000, 0x000FFFFF, 0x20000000, RW_CB },  /* ISR Vector table */
    { 0x00200000, 0x00001FFF, 0x40000000, RW_CB },  /* 8K cached SRAM 0/1 */
    { 0x20000000, 0x21FFFFFF, 0x20000000, RW_CB },  /* 32M cached SDRAM */
    { 0x90000000, 0x90001FFF, 0x40000000, RW_NCNB },/* 4K SRAM0 + 4k SRAM1 */
    { 0xA0000000, 0xA1FFFFFF, 0x20000000, RW_NCNB },/* 32M none-cached SDRAM */
};
#endif

17
#include <encoding.h>
z13955633063's avatar
z13955633063 已提交
18 19
static void rt_hw_timer_init(void)
{
20 21 22 23
	GPIO_REG(GPIO_INPUT_EN)    &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
	GPIO_REG(GPIO_OUTPUT_EN)   |=  ((0x1<< RED_LED_OFFSET)| (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
	GPIO_REG(GPIO_OUTPUT_VAL)  |=   (0x1 << BLUE_LED_OFFSET) ;
	GPIO_REG(GPIO_OUTPUT_VAL)  &=  ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET)) ;
24 25 26
	
/*	enable timer interrupt*/
 	set_csr(mie, MIP_MTIP);	
z13955633063's avatar
z13955633063 已提交
27
	volatile uint64_t * mtimecmp    = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIMECMP);
28 29
	CLINT_REG(CLINT_MTIME) = 0x0;
/*	CLINT_REG(CLINT_MTIMECMP) = 0x10000;*/
z13955633063's avatar
z13955633063 已提交
30
	*mtimecmp = 0x20000;
z13955633063's avatar
z13955633063 已提交
31 32 33 34 35 36 37 38 39 40 41
	return;
}
void rt_hw_board_init(void)
{
	/* initialize mmu */
/*	rt_hw_mmu_init(hw_mem_desc, sizeof(hw_mem_desc)/sizeof(hw_mem_desc[0]));*/
	/* initialize hardware interrupt */
	rt_hw_interrupt_init();

	/* initialize the system clock */
	//rt_hw_clock_init(); //set each pll etc.
z13955633063's avatar
z13955633063 已提交
42

z13955633063's avatar
z13955633063 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
	/* initialize uart */
	rt_hw_uart_init();
	rt_console_set_device(RT_CONSOLE_DEVICE_NAME);

	/* initialize timer0 */
	rt_hw_timer_init();

#ifdef RT_USING_COMPONENTS_INIT
	rt_components_board_init();
#endif

/*	HW_ICOLL_CTRL_SET(BM_ICOLL_CTRL_IRQ_FINAL_ENABLE);*/
	return;
}