Kengo Kinoshita
|
May I ask how to write a interrupt handlers.
|
Kengo Kinoshita
08/17/2010 9:00 AM
post63217
|
May I ask how to write a interrupt handlers.
Dear Eric and Boudreau:
May I ask how to write a interrupt handlers.
Now I wrote the following codes.
But did not work interrupt sequence regarding isr_handler1 and isr_handler2.
It is not use signal and event only use return value of ISR(interrupt service routine).
Please teach me where points of existing bugs.
Regards,
Kengo Kinoshita
#include <sys/siginfo.h>
const struct sigevent *isr_handler1( void *arg, int id)
{
InterruptMask( TIM0 , id);
event_.sigev_code = _TM0;
return( &event_);
// procmgr_event_notify()
}
const struct sigevent *isr_handler2( void *arg, int id)
{
InterruptMask(TIM0-1 , id);
event_.sigev_code = _TM1;
return( &event_);
// procmgr_event_notify()
}
main()
pthread_attr_t attr;
int breakFlg;
pthread_attr_init( &attr );
SIGEV_INTR_INIT (&event_);
memset( ¶m, 0x0, sizeof(param) );
memset( &idle_param, 0x0, sizeof(idle_param) );
interruptID1 = InterruptAttach (
TIM0,
isr_handler1,
NULL,
0,
0);
interruptID2 = InterruptAttach (
TIM0-1,
isr_handler2,
NULL,
0,
0);
for(i=0;i<evaluateCycle;){
while(1){
printf( "Wait interrupt\n");
InterruptWait(NULL, NULL);
printf( “Exit interrupt\n");
switch( event_.sigev_code ){
case _TM1:
// breakFlg=1;
event_.sigev_code=0;
InterruptUnmask(irq+ InterruptT0-1, interruptID2 );
break;
case _TM0:
event_.sigev_code=0;
breakFlg=1;
InterruptUnmask(irq+ Interru
ptT0 , interruptID1 );
break;
}
if (breakFlg==1) {
breakFlg=0;
break;
}
}
}
|
|
|