2010-07-14 17:50:58 +08:00
|
|
|
/*
|
|
|
|
* File : board.c
|
|
|
|
* This file is part of RT-Thread RTOS
|
|
|
|
* COPYRIGHT (C) 2006, RT-Thread Develop Team
|
|
|
|
*
|
|
|
|
* The license and distribution terms for this file may be
|
|
|
|
* found in the file LICENSE in this distribution or at
|
|
|
|
* http://www.rt-thread.org/license/LICENSE
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2010-06-25 Bernard first version
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include <rthw.h>
|
|
|
|
|
|
|
|
#include "board.h"
|
|
|
|
#include "uart.h"
|
2010-09-13 07:35:14 +08:00
|
|
|
#include <jz4755.h>
|
2010-07-14 17:50:58 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup JZ47xx
|
|
|
|
*/
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the timer interrupt service routine.
|
|
|
|
*/
|
2013-03-26 09:08:25 +08:00
|
|
|
void rt_hw_timer_handler(int vector, void* param)
|
2010-07-14 17:50:58 +08:00
|
|
|
{
|
2010-09-13 07:35:14 +08:00
|
|
|
/* increase a OS tick */
|
2010-07-14 17:50:58 +08:00
|
|
|
rt_tick_increase();
|
|
|
|
|
2010-09-13 07:35:14 +08:00
|
|
|
/* clear flag */
|
|
|
|
TCU_TFCR = TCU_TFCR_OSTFLAG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function will initial OS timer
|
|
|
|
*/
|
2013-03-23 17:34:52 +08:00
|
|
|
void rt_hw_timer_init(void)
|
2010-09-13 07:35:14 +08:00
|
|
|
{
|
|
|
|
rt_uint32_t val;
|
|
|
|
|
|
|
|
/* disable TCU clock */
|
|
|
|
CPM_CLKGR &= ~CPM_CLKGR_TCU;
|
|
|
|
TCU_TECR = TCU_TECR_OSTCL;
|
|
|
|
|
|
|
|
/* set */
|
|
|
|
OST_DR = RT_TICK_PER_SECOND * 0xcffff;
|
|
|
|
/* clear counter */
|
|
|
|
OST_CNT = 0;
|
|
|
|
|
|
|
|
#ifdef RTC_SRC_EXTAL
|
|
|
|
OST_CSR = (val | OST_TCSR_EXT_EN);
|
|
|
|
#else
|
|
|
|
OST_CSR = (val | OST_TCSR_PCLK_EN);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
TCU_TFCR = TCU_TFCR_OSTFLAG;
|
|
|
|
TCU_TMCR = TCU_TMCR_OSTMCL;
|
|
|
|
TCU_TESR = TCU_TESR_OSTST;
|
|
|
|
|
2013-03-26 09:08:25 +08:00
|
|
|
rt_hw_interrupt_install(IRQ_TCU0, rt_hw_timer_handler, RT_NULL, "tick");
|
2010-09-13 07:35:14 +08:00
|
|
|
rt_hw_interrupt_umask (IRQ_TCU0);
|
2010-07-14 17:50:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function will initial sam7s64 board.
|
|
|
|
*/
|
|
|
|
void rt_hw_board_init()
|
|
|
|
{
|
|
|
|
#ifdef RT_USING_UART
|
|
|
|
/* init hardware UART device */
|
|
|
|
rt_hw_uart_init();
|
|
|
|
#endif
|
2010-09-05 13:16:10 +08:00
|
|
|
|
2010-07-14 17:50:58 +08:00
|
|
|
#ifdef RT_USING_CONSOLE
|
|
|
|
/* set console device */
|
|
|
|
rt_console_set_device("uart");
|
|
|
|
#endif
|
2010-09-13 07:35:14 +08:00
|
|
|
|
|
|
|
/* init operating system timer */
|
|
|
|
rt_hw_timer_init();
|
2010-07-14 17:50:58 +08:00
|
|
|
}
|
|
|
|
/*@}*/
|