?? interrupt.c
字號:
/*
* File : trap.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development 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 "AT9200.h"
#define MAX_HANDLERS 32
extern rt_uint32_t rt_interrupt_nest;
/* exception and interrupt handler table */
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrput_flag;
/**
* @addtogroup AT91RM9200
*/
/*@{*/
/* default int handler func*/
void rt_hw_interrupt_handle(int vector)
{
rt_kprintf("interrupt: %d happen but not handled\n", vector);
}
void rt_hw_spu_handle(int vector)
{
/* indicate interrupt handle end */
REG_OUT32(AT9200_AIC_EOICR, 0, vector);
}
/**
* This function will initialize hardware interrupt
*/
void rt_hw_interrupt_init(void)
{
register int i;
REG_OUT32(AT9200_AIC_IDCR, 0, 0xFFFFFFFF); /* disable all interrupts */
REG_OUT32(AT9200_AIC_ICCR, 0, 0xFFFFFFFF); /* clear all pending interrupts */
/* circlr 32 times to init all int trigger mode & prio & default int handler func */
for (i = 0; i < MAX_HANDLERS; i++)
{
/* config the default int handler func*/
REG_OUT32(AT9200_AIC_SVR, i*4, rt_hw_interrupt_handle);
/* config trigger mode & priority(edge trigger, lowest priority) */
REG_OUT32(AT9200_AIC_SMR, i*4, 0x20);
}
REG_OUT32(AT9200_AIC_SPU, 0, rt_hw_spu_handle); /* config spurious int vec reg*/
REG_OUT32(AT9200_AIC_DCR, 0, 0x0 ); /* Protection Mode disabled, nIRQ and nFIQ lines are normally controlled by the AIC. */
/*clear AIC_EOICR 8 times*/
for (i=0;i<8;i++)
{
REG_OUT32(AT9200_AIC_EOICR, 0, 0x0);
}
/* init interrupt nest, and context in thread sp */
rt_interrupt_nest = 0;
rt_interrupt_from_thread = 0;
rt_interrupt_to_thread = 0;
rt_thread_switch_interrput_flag = 0;
}
/**
* This function will mask a interrupt.
* @param vector the interrupt number
*/
void rt_hw_interrupt_mask(int vector)
{
if (vector < MAX_HANDLERS)
{
REG_OUT32(AT9200_AIC_IDCR, 0x00, 1<<vector);
}
}
/**
* This function will un-mask a interrupt.
* @param vector the interrupt number
*/
void rt_hw_interrupt_umask(int vector)
{
if (vector < MAX_HANDLERS)
{
REG_OUT32(AT9200_AIC_IECR, 0x00, 1<<vector);
}
}
/**
* This function will install a interrupt service routine to a interrupt.
* @param vector the interrupt number
* @param new_handler the interrupt service routine to be installed
* @param old_handler the old interrupt service routine
*/
void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
{
if (vector < MAX_HANDLERS)
{
if (old_handler!=RT_NULL) *old_handler=(rt_isr_handler_t)REG_IN32(AT9200_AIC_SVR, vector*4);
if (new_handler != RT_NULL)
REG_OUT32(AT9200_AIC_SVR , vector*4, new_handler); /* interrupt vector */
else
REG_OUT32(AT9200_AIC_SVR , vector*4, rt_hw_interrupt_handle); /* default interrupt vector */
}
}
/*@}*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -