📄 board.c.svn-base
字号:
/* * 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://openlab.rt-thread.com/license/LICENSE * * Change Logs: * Date Author Notes * Triseel */#include <rtthread.h>#include <rthw.h>#include <AT9200.h>#include <Serial.h>#define DATA_COUNT 0x147 /*calc by slow crystal*//*! * @addtogroup AT9200 *//*@{*/static int SysIntKind=0; /*sys int bmp*/static void LEDInit(void){ REG_OUT32(AT9200_PIOC_PER , 0x00, LEDFLASHPORT); REG_OUT32(AT9200_PIOC_OER , 0x00, LEDFLASHPORT); REG_OUT32(AT9200_PIOC_IFER , 0x00, LEDFLASHPORT); REG_OUT32(AT9200_PIOC_IDR , 0x00, LEDFLASHPORT); REG_OUT32(AT9200_PIOC_PPUER, 0x00, LEDFLASHPORT); REG_OUT32(AT9200_PIOC_OWER , 0x00, LEDFLASHPORT); REG_OUT32(AT9200_PIOC_SODR , 0x00, LEDFLASHPORT);}void rt_timer_handler(int vector){ register rt_uint32 RdVal; /*the following part are bsp relative*/ RdVal=REG_IN32(AT9200_ST_SR, 0); /*rd & clr status reg*/ /*invoke OS func*/ rt_tick_increase();}/*************************************************** Implemented : Triseel** Func Name : rt_sysint_handler** Comments : handle 9200 sys multi ints** Notes : coz 9200 timer tick int shared with other int, so use this func replace the former rt_timer_handler** Input Args : ** argVec : sys int vec num** : ** Output Args : ** none** Rtn Val : ** none*************************************************/void rt_sysint_handler(int argVec){ register rt_uint32 RegVal; /*timer tick*/ if ( BMP_ISSET(SysIntKind, SYS_INT_ST_BIT) /*can handle this int*/ &&BMP_ISSET(REG_IN32(AT9200_ST_SR, 0), AT9200_ST_PITS_BIT) ) /*rd reg to judge really the designated int is triggered*/ { /*invoke OS func*/ rt_tick_increase(); }#ifdef RT_USING_FINSH /*dbg UART*/ if ( BMP_ISSET(SysIntKind, SYS_INT_DBGUART_BIT) &&BMP_ISSET(REG_IN32(AT9200_BASE_DBGU, AT9200_UART_CSR_OFF), AT9200_US_RXRDY_BIT) ) { REG_OUT32(AT9200_BASE_DBGU, AT9200_UART_CR_OFF, AT9200_US_RSTRX_VAL); /*rst the rx ctrl reg*/ finsh_notify(); }#endif}/*************************************************** Implemented : Triseel, Date : ** Func Name : rt_hw_board_init** Comments : This function will init Triseel9200 board** Notes : ** Input Args : ** none** Output Args : ** none** Rtn Val : ** none*************************************************/void rt_hw_board_init(){ register rt_uint32 RdVal; /*cfg timer as OS timer tick*/ RdVal=REG_IN32(AT9200_ST_SR, 0); /*rd & clr status reg*/ REG_OUT32(AT9200_ST_IDR , 0, 4); /*disable timer int*/ REG_OUT32(AT9200_ST_PIMR , 0, DATA_COUNT); /*cfg interval classical 10ms, coz calc by slow clk, so dont need assign PMC*/ REG_OUT32(AT9200_ST_RTAR , 0, 0); REG_OUT32(AT9200_ST_RTMR , 0, 1); REG_OUT32(AT9200_ST_IER , 0, 1); /*enable self int*/ REG_OUT32(AT9200_AIC_SMR , SYS_VEC*4, 0x27); /*int trigger mode & priority*/ REG_OUT32(AT9200_AIC_SVR , SYS_VEC*4, rt_sysint_handler); //--?-- REG_OUT32(AT9200_AIC_ICCR, 0 , 1<<SYS_VEC); /*clr AIC int*/ REG_OUT32(AT9200_AIC_IECR, 0 , 1<<SYS_VEC); /*enable AIC int*/ /* install int handler & unmask immediately*/ BMP_SET(SysIntKind, SYS_INT_ST_BIT); rt_hw_interrupt_install(SYS_VEC, rt_sysint_handler, RT_NULL); rt_hw_interrupt_umask(SYS_VEC); LEDInit();}void rt_hw_led_set(rt_uint32 led){ if (led) /*on*/ REG_OUT32(AT9200_PIOC_CODR, 0x00, LEDFLASHPORT); /*clr to let LED on*/ else /*off*/ REG_OUT32(AT9200_PIOC_SODR, 0x00, LEDFLASHPORT);}void rt_hw_led_flash(void){ unsigned int i, j; rt_hw_led_set(0); for (i=0;i<0xFFFF;i++) j++; rt_hw_led_set(1); for (i=0;i<0xFFFF;i++) j++;}#ifdef RT_USING_FINSHextern void finsh_notify(void);void rt_hw_finsh_init(){ /*init the cpu regs firstly*/ REG_OUT32(AT9200_BASE_DBGU, AT9200_UART_IER_OFF, AT9200_US_RXRDY_BIT); /*enable rx rdy int*/ BMP_SET(SysIntKind, SYS_INT_DBGUART_BIT);}#endif/*@}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -