📄 irq.c
字号:
/*******************************************************************************
*
* ARM Strategic Support Group
*
*******************************************************************************/
/*******************************************************************************
*
* Module : irq.c
* Description : Installs an IRQ handler and initializes the timer and button
* interrupts on the Samsung KS32C50100
* Tool Chain : ARM Developer Suite v1.0
* Platform : Evaluator7T
* History :
*
* 980416 Andrew N. Sloss
* - added button interrupt service
* - added header information
*
* 990930 Andrew N. Sloss
* - abstracted the timer and button handling routines
*
* 2000-04-3 Andrew N. Sloss
* - Ported to Evaluator7T
*
* Notes : none...
*
*******************************************************************************/
/*******************************************************************************
* IMPORT
*******************************************************************************/
#include "led.h"
#include "button.h"
#include "timer.h"
#include "macros.h"
/*******************************************************************************
* MACRO'S
*******************************************************************************/
// none...
/*****************************************************************************
* EXTERN's
*****************************************************************************/
extern void handler_irq(void);
extern void SetupSVC(void);
extern int Angel_IRQ_Address;
/*****************************************************************************
* GLOBALS
*****************************************************************************/
/*****************************************************************************
* ROUTINES
*****************************************************************************/
/* -- irq_installhandler ------------------------------------------------------
*
* Description : Places a branch instruction for the routine into the defined
* 'vector' location - this function returns the original
* contents of the 'vector
*
* Parameters : unsigned routine - IRQ handler
* : unsigned *vector - IRQ vector
* Return :
* Notes : 'routine' MUST BE WITHIN A RANGE OF 32Mbytes FROM 'vector'
*
*/
static void irq_installhandler (unsigned routine, unsigned *vector)
{
unsigned old_vector_value = 0;
unsigned *absolute;
old_vector_value = 0;
/************************************************************************
* Now the inverse must be done on the original vector to retrieve the *
* Angel IRQ Handler routine . *
************************************************************************/
old_vector_value = *vector; // Get old vector contents ....................
old_vector_value ^= 0xe59ff000; // Mask off the instruction to get the offset
// ** calculate absolute address
absolute = (unsigned *) (0x18 + old_vector_value+0x8);
// IRQ Address
Angel_IRQ_Address = *absolute; // chain Angel Interrupt Handler
*absolute = routine; // IRQ handler
}
/* -- irq_init ----------------------------------------------------------------
*
* Description : Initializes all the IRQ interrupt and installs an IRQ handler.
*
* Parameters : none...
* Return : none...
* Notes : none...
*
*/
void irq_init (void)
{
/* This is necessary if Angel is not running
* on the target (as when running semi-hosted
* from Multi-ICE) otherwise, let Angel handle
* it */
SetupSVC();
//
// initializes button and timer
//
timer_init ();
button_init ();
//
// install handler
//
irq_installhandler ((unsigned)handler_irq, (unsigned *)IRQVector);
}
/*******************************************************************************
* END OF irq.c
*******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -