WPILib 2012
WPILibRoboticsLibraryforFRC
|
00001 // Class for handling interrupts. 00002 // Copyright (c) National Instruments 2008. All Rights Reserved. 00003 00004 #ifndef __tInterruptManager_h__ 00005 #define __tInterruptManager_h__ 00006 00007 #include "NiRio.h" 00008 #include "tSystem.h" 00009 #include <semLib.h> 00010 00011 namespace nFPGA 00012 { 00013 00014 typedef void (*tInterruptHandler)(uint32_t interruptAssertedMask, void *param); 00015 00016 class tInterruptManager : public tSystem 00017 { 00018 public: 00019 tInterruptManager(uint32_t interruptMask, bool watcher, tRioStatusCode *status); 00020 ~tInterruptManager(); 00021 void registerHandler(tInterruptHandler handler, void *param, tRioStatusCode *status); 00022 uint32_t watch(int32_t timeoutInMs, tRioStatusCode *status); 00023 void enable(tRioStatusCode *status); 00024 void disable(tRioStatusCode *status); 00025 bool isEnabled(tRioStatusCode *status); 00026 private: 00027 void handler(); 00028 static int handlerWrapper(tInterruptManager *pInterrupt); 00029 00030 void acknowledge(tRioStatusCode *status); 00031 void reserve(tRioStatusCode *status); 00032 void unreserve(tRioStatusCode *status); 00033 tInterruptHandler _handler; 00034 uint32_t _interruptMask; 00035 int32_t _taskId; 00036 NiFpga_IrqContext _rioContext; 00037 bool _watcher; 00038 bool _enabled; 00039 void *_userParam; 00040 00041 // maintain the interrupts that are already dealt with. 00042 static uint32_t _globalInterruptMask; 00043 static SEM_ID _globalInterruptMaskSemaphore; 00044 }; 00045 00046 } 00047 00048 00049 #endif // __tInterruptManager_h__ 00050