📄 irq_ser.c
字号:
/*******************************************************************************
*
* ARM Strategic Support Group
*
*******************************************************************************/
/*******************************************************************************
*
* Module : irq_ser.c
* Description : Setups Samsung KS32C50100 IRQ registers and services the
* IRQ (button interrupt requests)
* Too Chain : ARM Developer Suite v1.0
* Platform : Evaluator7T
* History :
*
* 980416 ASloss
* - added button interrupt service
* - added header information
*
* 980625 ASloss
* - irq_installhandler alter to be Load PC compatible
*
* 2000-04-04 Andrew N. Sloss
* - port to the Evaluator7T
*
* Notes : Refer to the Samsung KS32C50100 documentation
*
*******************************************************************************/
/*******************************************************************************
* IMPORT
*******************************************************************************/
#include <stdio.h>
#include "switch.h"
/*******************************************************************************
* MACRO'S
*******************************************************************************/
// -- Samsung KS32C50100.............
#define SYSCFG 0x03FF0000
#define IOPMOD (SYSCFG + 0x5000)
#define IOPCON (SYSCFG + 0x5004)
#define IOPDATA (SYSCFG + 0x5008)
#define INTPND (SYSCFG + 0x4004)
#define INTMSK (SYSCFG + 0x4008)
#define INT_GLOBAL (21)
#define INT_SW3_MASK (1)
#define IO_ENABLE_INT0 (1<<4)
#define IO_ACTIVE_HIGH_INT0 (1<<3)
#define IO_RISING_EDGE_INT0 (1)
// -- Standard Macros...............
#define IRQVector (unsigned *) 0x18
#define PIPE_OFFSET 0x08
#define WORD_OFFSET 0x02
#define CHECK_24_BIT 0xff000000
#define BRANCH_OP_CODE 0xea000000
#define MAX_CT_LOAD 0x0000ffff
#define LOWER_16_MASK 0x0000ffff
/*****************************************************************************
* EXTERN's
*****************************************************************************/
extern void handler_irq(void);
extern void SetupSVC(void);
extern int Angel_IRQ_Address;
/*****************************************************************************
* STATICS
*****************************************************************************/
// none...
/*****************************************************************************
* 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_initbutton ---------------------------------------------------------
*
* Description : Initialises the button interrupt
*
* Parameters : none...
* Return : none...
* Notes : none...
*
*/
static void irq_initbutton (void)
{
// unmask the switch interrupt ...........
*(volatile int*)INTMSK &= ~((1<<INT_GLOBAL) | (1<<0));
*(unsigned *)IOPCON |= IO_ENABLE_INT0; // enable int0
*(unsigned *)IOPCON |= IO_ACTIVE_HIGH_INT0; // set as active high
*(unsigned *)IOPCON |= IO_RISING_EDGE_INT0; // allow for RISING EDGE
}
/* -- irq_buttonpress -----------------------------------------------------------
*
* Description : handles the button press interrupt...
*
* Parameters : none...
* Return : none...
* Notes : none...
*
*/
void irq_buttonpress (void)
{
/* Read in the Interrupt source .................................. */
switch_interrupt();
*(unsigned *) INTPND |= INT_SW3_MASK;
}
/* -- irq_init ----------------------------------------------------------------
*
* Description : This module is where all system setup would be placed - in
* this case it is only Counter/Timer that we are initialising
* so we only have a routine to initialise this. Also called
* from here is the Interrupt Handler install routine and
* initialize button interrupt
*
* Parameters : none...
* Return : none...
* Notes : none...
*
*/
void irq_init (void)
{
SetupSVC(); /* This is necessary if Angel is not running
* on the target (as when running semi-hosted
* from E-Ice) otherwise, let Angel handle it */
irq_initbutton ();
irq_installhandler ((unsigned)handler_irq, IRQVector);
}
/*******************************************************************************
* END OF irq_ser.c
*******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -