📄 irq_ser.c
字号:
/*******************************************************************************
*
* ARM Strategic Support Group
*
*******************************************************************************/
/*******************************************************************************
*
* Module : irq_ser.c
* Description : Setups 77790 IRQ registers and serives the IRQ's (timer and
* button interrupt requests)
* Status : complete
* Platform : AEB-1
* History : 980416 ASloss
*
* - added button interrupt service
* - added header information
*
* Notes : Refer to the Sharp 77790 documentation
*
*******************************************************************************/
/*******************************************************************************
* IMPORT
*******************************************************************************/
#include "traffic.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_inittimer1 ----------------------------------------------------------
*
* Description : Initialises the counter timer (most work done by
* irq_auxctstart)
*
* Parameters : none...
* Return : none...
* Notes : none...
*
*/
static void irq_inittimer1 (void)
{
}
// new code ...................
/*
* Update the register on the target which masks the irq passed to the IC.
* This routine is target-specific. Turn the interrupt source on.
*/
void uHALir_UnmaskIrq(unsigned irq)
{
*(volatile int*)INTMSK &= ~((1 << INT_GLOBAL) | (1 << irq)); /* Force global disable OFF */
}
/* -- irq_initbutton ---------------------------------------------------------
*
* Description : Initialises the button interrupt
*
* Parameters : none...
* Return : none...
* Notes : none...
*
*/
static void irq_initbutton (void)
{
// Bitwise OR incase an existing set of Interrupts have been .....
// set by Angel Debug Monitor ....................................
*(volatile int*)INTMSK &= ~((1 << INT_GLOBAL) | (1 <<10) | (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
}
// end of new code..........
/******************************************************************************
* IRQHandler *
* *
* This IRQ handler only services two interrupt source - the Counter Timer 1 *
* source and the button interrupt. When this is sensed the handler resets *
* the counter interrupt - and increments the AuxCT_repetitions global *
* variable... *
* *
* THIS PORTION OF CODE MUST BE COMPILED USING THE ARM STATE COMPILER ARMCC *
* EVEN WHEN USED IN A THUMB STATE ENVIRONMENT. FAILURE TO DO THIS WOULD RESULT*
* IN UNPREDICTABLE RETURNS FROM THE IRQ HANDLER. *
* *
*******************************************************************************/
/* -- irq_auxtimer ------------------------------------------------------------
*
* Description : handles the aux timer interrupt.
*
* Parameters : none...
* Return : none...
* Notes : Other interrupt sources are handled by angel. See
* ang_irq_ven.s
*
*
*/
/* -- irq_buttonpress -----------------------------------------------------------
*
* Description : handles the button press interrupt...
*
* Parameters : none...
* Return : none...
* Notes : none...
*
*/
void irq_buttonpress (void)
{
/* Read in the Interrupt source .................................. */
traffic_interrupt (); // Call traffic sequencer .......
*(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_inittimer1 ();
irq_initbutton ();
irq_installhandler ((unsigned)handler_irq, IRQVector);
}
/*******************************************************************************
* END OF irq.c
*******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -