fixed InterruptBridge (I think I've done this before though...)
git-svn-id: https://robotics.mvla.net/svn/frc971/2013/trunk/src@4175 f308d9b7-e957-4cde-b6ac-9a88185e7312
diff --git a/aos/crio/motor_server/CRIOControlLoopRunner.cpp b/aos/crio/motor_server/CRIOControlLoopRunner.cpp
index 9d6cd52..1971dc1 100644
--- a/aos/crio/motor_server/CRIOControlLoopRunner.cpp
+++ b/aos/crio/motor_server/CRIOControlLoopRunner.cpp
@@ -3,6 +3,7 @@
#include "aos/aos_core.h"
#include "aos/crio/shared_libs/interrupt_bridge.h"
#include "aos/crio/motor_server/MotorOutput.h"
+#include "aos/crio/motor_server/MotorServer.h"
using ::aos::control_loops::SerializableControlLoop;
diff --git a/aos/crio/shared_libs/interrupt_bridge-tmpl.h b/aos/crio/shared_libs/interrupt_bridge-tmpl.h
index 3adba38..cc00ab8 100644
--- a/aos/crio/shared_libs/interrupt_bridge-tmpl.h
+++ b/aos/crio/shared_libs/interrupt_bridge-tmpl.h
@@ -4,8 +4,7 @@
#include "WPILib/Task.h"
-#include "aos/aos_core.h"
-#include "aos/crio/motor_server/MotorServer.h"
+#include "aos/common/logging/logging.h"
#include "aos/common/time.h"
extern "C" {
@@ -208,7 +207,6 @@
// cmpwi
// bne
// li
-// NOTE: This macro is used in interrupt_notifier-tmpl.h too.
#define ASM_COMMENT(str) __asm__("# " str)
template<typename T>
void WDInterruptNotifier<T>::StaticNotify(void *self_in) {
diff --git a/aos/crio/shared_libs/interrupt_notifier-tmpl.h b/aos/crio/shared_libs/interrupt_notifier-tmpl.h
index 78e7ca8..819e552 100644
--- a/aos/crio/shared_libs/interrupt_notifier-tmpl.h
+++ b/aos/crio/shared_libs/interrupt_notifier-tmpl.h
@@ -6,9 +6,9 @@
template<typename T>
InterruptNotifier<T>::InterruptNotifier(
- typename InterruptBridge<T>::Handler handler,
- InterruptableSensorBase *sensor, T *param, int priority)
- : InterruptBridge<T>(handler, param, priority), sensor_(sensor) {
+ Handler handler,
+ InterruptableSensorBase *sensor, T *param)
+ : handler_(handler), param_(param), sensor_(sensor) {
sensor_->RequestInterrupts(StaticNotify, this);
}
@@ -19,7 +19,6 @@
template<typename T>
void InterruptNotifier<T>::Start() {
- this->StartTask();
sensor_->EnableInterrupts();
}
@@ -28,20 +27,17 @@
sensor_->DisableInterrupts();
}
-// WARNING: This IS called from an ISR. Don't use floating point. Look in
-// interrupt_bridge-tmpl.h for details.
template<typename T>
void InterruptNotifier<T>::StaticNotify(uint32_t, void *self_in) {
- ASM_COMMENT("beginning of InterruptNotifier::StaticNotify");
- if (!intContext()) { // if we're not in an actual ISR
- logMsg(const_cast<char *>("WPILib is not calling callbacks"
- " in actual ISRs any more!!\n"),
+ if (intContext()) { // if we are in an actual ISR
+ logMsg(const_cast<char *>("WPILib is calling callbacks"
+ " in actual ISRs now!!\n"),
0, 0, 0, 0, 0, 0);
+ return;
}
InterruptNotifier<T> *const self =
static_cast<InterruptNotifier<T> *>(self_in);
- self->Notify();
- ASM_COMMENT("end of InterruptNotifier::StaticNotify");
+ self->handler_(self->param_);
}
} // namespace crio
diff --git a/aos/crio/shared_libs/interrupt_notifier.h b/aos/crio/shared_libs/interrupt_notifier.h
index 87aa4a3..8334f86 100644
--- a/aos/crio/shared_libs/interrupt_notifier.h
+++ b/aos/crio/shared_libs/interrupt_notifier.h
@@ -3,16 +3,18 @@
#include "WPILib/InterruptableSensorBase.h"
-#include "aos/crio/shared_libs/interrupt_bridge.h"
-
namespace aos {
namespace crio {
// An InterruptBridge that notifies based on interrupts from a WPILib
// InterruptableSensorBase object (which DigitalInput is an example of).
+// Not actually a subclass because WPILib appears to not really use actual
+// interrupts.
template<typename T>
-class InterruptNotifier : public InterruptBridge<T> {
+class InterruptNotifier {
public:
+ typedef void (*Handler)(T *param);
+
// This object will hold a reference to sensor, but will not free it. This
// object will take ownership of everything related to interrupts for sensor
// (ie this constructor will call sensor->RequestInterrupts).
@@ -20,10 +22,9 @@
// constructed in) when this constructor is called.
// Any setup of sensor that is required should happen before Start() is
// called, but after this constructor (ie SetUpSourceEdge).
- InterruptNotifier(typename InterruptBridge<T>::Handler handler,
+ InterruptNotifier(Handler handler,
InterruptableSensorBase *sensor,
- T *param = NULL,
- int priority = InterruptBridge<T>::kDefaultPriority);
+ T *param = NULL);
virtual ~InterruptNotifier();
// Starts calling the handler whenever the interrupt triggers.
@@ -31,12 +32,15 @@
private:
// The only docs that seem to exist on the first arg is that it's named
- // interruptAssertedMask in WPILib/ChipObject/tInterruptManager.h
+ // interruptAssertedMask in WPILib/ChipObject/tInterruptManager.h.
// The second arg is the general callback parameter which will be a pointer to
// an instance. This function calls Notify() on that instance.
static void StaticNotify(uint32_t, void *self_in);
virtual void StopNotifications();
+ const Handler handler_;
+ T *const param_;
+
InterruptableSensorBase *const sensor_;
DISALLOW_COPY_AND_ASSIGN(InterruptNotifier<T>);
};