If the position of the ISR is the same on different cameras ... the following maybe of interest:
The
aj_hijack_ISR() :
+) makes a copy of the current Interrupt Service Routine table (sub + parm)
+) replaces it with calls to aj_ISR() with the parameter the ISR number
Calls to
aj_ISR_info() displays counts (modulo 256), on the screen (ISR 0..15 down the left most collumn, ISR 0,16,32 top row)
Main use (other than cross-eyed screen saver) is to determine which ISRs are calls when, and an 'easy' way to hijack them / experiment with the ISR firing..
AJ
/********************************************************************
* *
* aj_ISR() - Replaces all ISRs called by DryOs *
* Increases that ISR counter -> Then calls the ISR *
* *
********************************************************************/
volatile unsigned int g_ISR[256]; // Copy of 256 ISR sub addresses
volatile unsigned int g_ISR_parm[256]; // Copy of 256 ISR sub parms
volatile unsigned int g_ISR_count[256]; // How many times ISR called?
volatile unsigned int g_isr_errors = 0;
void aj_ISR(unsigned int i) // i = isr_number
{
/*************************************
* Make sure that Parm is in range! *
*************************************/
if (i <256)
{
void (*isr_sub)(unsigned int) = (void *) g_ISR[i];
isr_sub( g_ISR_parm[i] );
g_ISR_count[i]++ ;
}
else
{
g_isr_errors ++;
}
} /* end of aj_ISR() */
/********************************************************************
* *
* aj_hijack_ISR() - Steal the ISR lookup table and replace it *
* will a call to aj_ISR() *
* *
********************************************************************/
void aj_hijack_ISR()
{
/********************************
* Only run the Hi-hack once! *
********************************/
static unsigned int first=0;
if (first != 0)
{
return;
}
first = 1;
/**********************************************************
* First time - copy all ISR_addresses, and ISR_Parms *
**********************************************************/
unsigned int i=0;
for (i=0; i<256; i++)
{
unsigned int sub_addr = 0x400006F8 + i*4;
unsigned int parm_addr = 0x40000AF8 + i*4;
g_ISR[i] = * (unsigned int *) sub_addr;
g_ISR_parm[i] = * (unsigned int *) parm_addr;
g_ISR_count[i] = 0; // initialise the number of times this ISR has been called.
}
/***************************************************************************
* OK .. this time around .. overwrite the DryOs array with the AJ_ISR() *
***************************************************************************/
for (i=0; i<256; i++)
{
unsigned int sub_addr = 0x400006F8 + i*4;
unsigned int parm_addr = 0x40000AF8 + i*4;
* (unsigned int *) sub_addr = (unsigned int) aj_ISR; // point at AJ_ISR
* (unsigned int *) parm_addr = i; // parm is now the ISR_number
g_ISR_count[i] = 0; // initialise the number of times this ISR has been called.
}
} /* end of aj_hijack_ISR() */
/********************************************************************
* *
* aj_ISR_info() - How are we doing? *
* *
********************************************************************/
void aj_ISR_info(void)
{
/*****************************************************
* Any ISR_parms passed to aj_ISR() out of range()? *
*****************************************************/
bmp_printf( FONT_MED,
0,0,
"Err=%d ", g_isr_errors) ;
/*************************************
* Make sure that Parm is in range! *
*************************************/
unsigned int i;
for(i=0; i<256; i++)
{
unsigned int x = i % 16;
unsigned int y = i / 16;
unsigned int count = g_ISR_count[i] % 256 ;
bmp_printf( FONT_MED,
x*40, y*24 + 30,
"%02X", count) ;
}
} /* end of aj_ISR() */
=====================
void aj_main(void)
{
// your main loop
aj_hijack_ISR(); // Hijacks all the ISR to point at aj_ISR()
aj_ISR_info(); // screen update of number of times each ISR called
} /* end of aj_main() */