?? board.c
字號:
/* * 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>#include "board.h"#define DATA_COUNT 0x147 /* calc by slow crystal *//** * @addtogroup AT9200 *//*@{*/static void rt_hw_led_init(void){ REG_OUT32(AT9200_PIOC_PER , 0x00, HW_LED_PORT); REG_OUT32(AT9200_PIOC_OER , 0x00, HW_LED_PORT); REG_OUT32(AT9200_PIOC_IFER , 0x00, HW_LED_PORT); REG_OUT32(AT9200_PIOC_IDR , 0x00, HW_LED_PORT); REG_OUT32(AT9200_PIOC_PPUER, 0x00, HW_LED_PORT); REG_OUT32(AT9200_PIOC_OWER , 0x00, HW_LED_PORT); REG_OUT32(AT9200_PIOC_SODR , 0x00, HW_LED_PORT);}void rt_timer_handler(int vector){ volatile rt_uint32_t dummy; dummy = REG_IN32(AT9200_TC0_SR, 0); rt_tick_increase();}#ifdef RT_USING_FINSHextern void finsh_notify(void);/*************************************************** Implemented : Triseel** Func Name : rt_sysint_handler** Comments : handle 9200 sys multi ints** Notes : coz 9200 timer tick int shared with other int** Input Args :** argVec : sys int vec num** Output Args :** none** Rtn Val :** none*************************************************/void rt_sysint_handler(int argVec){ /* dbg UART */ if (BMP_ISSET(REG_IN32(AT9200_BASE_DBGU, AT9200_UART_CSR_OFF), AT9200_US_RXRDY_BIT)) { finsh_notify(); }}#endif/** * This function will initialize AT9200 development board. */void rt_hw_board_init(){ register rt_uint32_t RdVal; /* init time counter */ RdVal = REG_IN32(AT9200_TC0_SR, 0); /* read and clear status register */ REG_OUT32(AT9200_TC0_CCR, 0, (1 << 1)); /* disable timer */ REG_OUT32(AT9200_PMC_PCER, 0, (1 << TC0_VEC)); /* enable peripheral clock in pmc for tc0 */ REG_OUT32(AT9200_TC0_CMR, 0, 0x4004); /* compare trigger enable and timer clock2 */ REG_OUT32(AT9200_TC0_RC, 0, DATA_COUNT); /* 100 ticks per second */ // REG_OUT32(AT9200_TC0_RC, 0, 0x1998); /* 100 ticks per second */ REG_OUT32(AT9200_TC0_IER, 0, (1 << 4)); /* enable RC compare interrupt */ REG_OUT32(AT9200_TC0_CCR, 0, 0x05); /* enable clock counter and software trigger */ /* timer counter interrupt init */ REG_OUT32(AT9200_AIC_SMR, TC0_VEC*4, 0x02); /* interrupt trigger mode & priority */ REG_OUT32(AT9200_AIC_ICCR, 0, (1 << TC0_VEC)); /* clear the TC0 interrupt */ REG_OUT32(AT9200_AIC_IECR, 0, (1 << TC0_VEC)); /* enable the TC0 interrupt */ /* install int handler & unmask immediately*/ rt_hw_interrupt_install(TC0_VEC, rt_timer_handler, RT_NULL); rt_hw_interrupt_umask(TC0_VEC);#ifdef RT_USING_FINSH /* dbgu interrupt init */ REG_OUT32(AT9200_AIC_SMR , SYS_VEC*4, 0x27); /* interrupt trigger mode & priority */ REG_OUT32(AT9200_AIC_ICCR, 0, 1<<SYS_VEC); /* clear AIC int */ REG_OUT32(AT9200_AIC_IECR, 0, 1<<SYS_VEC); /* enable AIC int */ /* install int handler & unmask immediately*/ rt_hw_interrupt_install(SYS_VEC, rt_sysint_handler, RT_NULL); rt_hw_interrupt_umask(SYS_VEC);#endif /* init hardware serial */ UARTPort_T UARTDbgPort; rt_memset(&UARTDbgPort, 0, sizeof(UARTDbgPort)); UARTDbgPort.Port=UART_DBG; UARTDbgPort.bInited =0; UARTDbgPort.DataBits=DataBits_8; UARTDbgPort.Parity =Parity_None; UARTDbgPort.StopBits=StopBits_1; UARTDbgPort.BaudRate=115200; rt_serial_init(&UARTDbgPort); rt_hw_led_init();}/** * This function will set AT9200 development board led. * @param led not zero to set led on otherwise off */void rt_hw_led_set(rt_uint32_t led){ if (led)/*on*/ REG_OUT32(AT9200_PIOC_CODR, 0x00, HW_LED_PORT); /* clear to let LED on */ else /*off*/ REG_OUT32(AT9200_PIOC_SODR, 0x00, HW_LED_PORT);}void rt_hw_led_flash(void){ rt_uint32_t 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_FINSHvoid 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 */}#endif/*@}*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -