board.c 1.0 KB
Newer Older
1
/*
2
 * Copyright (c) 2006-2018, RT-Thread Development Team
3
 *
4
 * SPDX-License-Identifier: Apache-2.0
5 6 7 8 9 10 11 12 13 14 15 16
 *
 * Change Logs:
 * Date           Author       Notes
 * 2008-12-11     xuxinming    first version
 */

#include <rtthread.h>
#include <rthw.h>

#include <LPC24xx.h>
#include "board.h"

M
Ming, Bai 已提交
17
#define DATA_COUNT 14400000/RT_TICK_PER_SECOND	/* T0MR0 = delayInMs * (Fpclk / 1000); */
18

B
bernard.xiong 已提交
19
extern void rt_hw_serial_init(void);
20 21 22 23 24 25

/**
 * @addtogroup LPC2478
 */
/*@{*/

B
Bernard Xiong 已提交
26
void rt_timer_handler(int vector, void* param)
27 28 29 30
{
	T0IR |= 0x01;			/* clear interrupt flag */
	rt_tick_increase();
	VICVectAddr = 0;		/* Acknowledge Interrupt */
B
bernard.xiong 已提交
31 32
}

33 34 35
/**
 * This function will init LPC2478 board
 */
36
void rt_hw_board_init(void)
B
bernard.xiong 已提交
37
{
M
Ming, Bai 已提交
38 39 40 41 42
#if defined(RT_USING_DEVICE) && defined(RT_USING_UART1)
	rt_hw_serial_init();
	rt_console_set_device("uart1");
#endif

43 44 45
	T0IR 	= 0xff; 
	T0TC 	= 0;
	T0MCR 	= 0x03; 
B
bernard.xiong 已提交
46
	T0MR0 	= (DATA_COUNT);
47

B
Bernard Xiong 已提交
48
	rt_hw_interrupt_install(TIMER0_INT, rt_timer_handler, RT_NULL, "tick");	
B
bernard.xiong 已提交
49
	rt_hw_interrupt_umask(TIMER0_INT);
50 51 52 53 54

	T0TCR = 0x01; //enable timer0 counter
}

/*@}*/