blob: a6283fed9b1ba8c968015d0151c11746c36bb1d0 [file] [log] [blame]
jerrymf1579332013-02-07 01:56:28 +00001// Class for handling interrupts.
2// Copyright (c) National Instruments 2008. All Rights Reserved.
3
4#ifndef __tInterruptManager_h__
5#define __tInterruptManager_h__
6
7#include "NiRio.h"
8#include "tSystem.h"
9#include <semLib.h>
10
11namespace nFPGA
12{
13
14typedef void (*tInterruptHandler)(uint32_t interruptAssertedMask, void *param);
15
16class tInterruptManager : public tSystem
17{
18public:
19 tInterruptManager(uint32_t interruptMask, bool watcher, tRioStatusCode *status);
20 ~tInterruptManager();
21 void registerHandler(tInterruptHandler handler, void *param, tRioStatusCode *status);
22 uint32_t watch(int32_t timeoutInMs, tRioStatusCode *status);
23 void enable(tRioStatusCode *status);
24 void disable(tRioStatusCode *status);
25 bool isEnabled(tRioStatusCode *status);
26private:
27 void handler();
28 static int handlerWrapper(tInterruptManager *pInterrupt);
29
30 void acknowledge(tRioStatusCode *status);
31 void reserve(tRioStatusCode *status);
32 void unreserve(tRioStatusCode *status);
33 tInterruptHandler _handler;
34 uint32_t _interruptMask;
35 int32_t _taskId;
36 NiFpga_IrqContext _rioContext;
37 bool _watcher;
38 bool _enabled;
39 void *_userParam;
40
41 // maintain the interrupts that are already dealt with.
42 static uint32_t _globalInterruptMask;
43 static SEM_ID _globalInterruptMaskSemaphore;
44};
45
46}
47
48
49#endif // __tInterruptManager_h__
50