00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <vxSIS3610InterruptService.hxx>
00019
00020
00021 using namespace std;
00022 using namespace codaObject;
00023
00024
00025
00026
00027
00028
00029 namespace codaObject {
00031 static int dispatcher(int ptr) {
00032 return ((vxSIS3610InterruptService*)ptr)->dispatchInterrupt();
00033 }
00034 }
00035
00036
00037
00038
00039
00040
00044 vxSIS3610InterruptService::vxSIS3610InterruptService(uint32_t base_addr, uint32_t intMask, int dispatchPriority,
00045 uint16_t interruptLevel, uint16_t interruptVector)
00046 : mySemId(NULL), myBaseAddr(base_addr), myDispatchPriority(dispatchPriority), myIntMask(intMask),
00047 myInterruptLevel(interruptLevel), myInterruptVector(interruptVector) {
00048 }
00049
00050
00051
00052
00053
00058 void vxSIS3610InterruptService::ISR(int sem) {
00059 semGive((SEM_ID)sem);
00060 }
00061
00062
00063
00064
00065
00069 int vxSIS3610InterruptService::dispatchInterrupt(void) {
00070
00071
00072 while(true) {
00073
00074
00075 semTake((SEM_ID)mySemId,WAIT_FOREVER);
00076
00077
00078 if(myIntObj!=NULL)myIntObj->interrupt(myIntMask);
00079
00080
00081 s3610IntAck(myIntMask);
00082 }
00083 }
00084
00085
00086
00087
00088
00092 bool vxSIS3610InterruptService::setupInterrupt(void) {
00093
00094 int status;
00095
00096
00097
00098 status = s3610Init(myBaseAddr, 0, 0);
00099 if(status!=0) {
00100 cerr << "?vxSIS3610InterruptService::setupInterrupt...error return from s3610Init: " << status << endl;
00101 return(false);
00102 }
00103
00104
00105
00106 mySemId = semBCreate(SEM_Q_FIFO,SEM_EMPTY);
00107
00108
00109
00110
00111 status = s3610IntConnect(0, NULL, (int)mySemId, myInterruptLevel, myInterruptVector);
00112 if(status!=0) {
00113 cerr << "?vxSIS3610InterruptService::setupInterrupt...error return from s3610IntConnect: " << status << endl;
00114 return(false);
00115 }
00116
00117
00118
00119 myInterruptTaskId = taskSpawn("interruptHandler",myDispatchPriority,0,20000,(int(*)(...))&dispatcher,
00120 (int)this,0,0,0,0, 0,0,0,0,0);
00121
00122 return(true);
00123 }
00124
00125
00126
00127
00128
00132 bool vxSIS3610InterruptService::enableInterrupt(void) {
00133
00134 s3610IntEnable(myIntMask);
00135 return(true);
00136 }
00137
00138
00139
00140
00141
00145 bool vxSIS3610InterruptService::deleteInterrupt(void) {
00146
00147
00148 s3610IntDisable(myIntMask);
00149
00150
00151 taskDelete(myInterruptTaskId);
00152
00153
00154 if(mySemId!=NULL)semDelete(mySemId);
00155
00156 return(true);
00157 }
00158
00159
00160