diff --git a/src/main/drivers/io.h b/src/main/drivers/io.h
index dfc13aebb..debc78d95 100644
--- a/src/main/drivers/io.h
+++ b/src/main/drivers/io.h
@@ -8,7 +8,7 @@
// IO pin identification
// make sure that ioTag_t can't be assigned into IO_t without warning
-typedef uint8_t ioTag_t; // packet tag to specify IO pin
+typedef uint8_t ioTag_t; // packet tag to specify IO pin
typedef void* IO_t; // type specifying IO pin. Currently ioRec_t pointer, but this may change
// NONE initializer for IO_t variable
diff --git a/src/main/sensors/initialisation.c b/src/main/sensors/initialisation.c
index 637ded62b..25627eb63 100755
--- a/src/main/sensors/initialisation.c
+++ b/src/main/sensors/initialisation.c
@@ -90,45 +90,10 @@ const extiConfig_t *selectMPUIntExtiConfig(void)
return &mpuIntExtiConfig;
#endif
-#ifdef NAZE
- // MPU_INT output on rev4 PB13
- static const extiConfig_t nazeRev4MPUIntExtiConfig = {
- .io = IO_TAG(PB13)
- };
- // MPU_INT output on rev5 hardware PC13
- static const extiConfig_t nazeRev5MPUIntExtiConfig = {
- .io = IO_TAG(PC13)
- };
-
-#ifdef AFROMINI
- return &nazeRev5MPUIntExtiConfig;
-#else
- if (hardwareRevision < NAZE32_REV5) {
- return &nazeRev4MPUIntExtiConfig;
- }
- else {
- return &nazeRev5MPUIntExtiConfig;
- }
-#endif
-#endif
-
-#ifdef ALIENFLIGHTF3
- // MPU_INT output on V1 PA15
- static const extiConfig_t alienFlightF3V1MPUIntExtiConfig = {
- .io = IO_TAG(PA15)
- };
- // MPU_INT output on V2 PB13
- static const extiConfig_t alienFlightF3V2MPUIntExtiConfig = {
- .io = IO_TAG(PB13)
- };
- if (hardwareRevision == AFF3_REV_1) {
- return &alienFlightF3V1MPUIntExtiConfig;
- }
- else {
- return &alienFlightF3V2MPUIntExtiConfig;
- }
-#endif
- return NULL;
+#ifdef USE_HARDWARE_REVISION_DETECTION
+ return selectMPUIntExtiConfigByHardwareRevision();
+#else
return NULL;
+#endif
}
#ifdef USE_FAKE_GYRO
diff --git a/src/main/target/ALIENFLIGHTF3/hardware_revision.c b/src/main/target/ALIENFLIGHTF3/hardware_revision.c
index 16a9de5b2..0905b449c 100644
--- a/src/main/target/ALIENFLIGHTF3/hardware_revision.c
+++ b/src/main/target/ALIENFLIGHTF3/hardware_revision.c
@@ -24,7 +24,7 @@
#include "drivers/system.h"
#include "drivers/io.h"
-
+#include "drivers/exti.h"
#include "hardware_revision.h"
static const char * const hardwareRevisionNames[] = {
@@ -56,3 +56,22 @@ void detectHardwareRevision(void)
void updateHardwareRevision(void)
{
}
+
+const extiConfig_t *selectMPUIntExtiConfigByHardwareRevision(void)
+{
+ // MPU_INT output on V1 PA15
+ static const extiConfig_t alienFlightF3V1MPUIntExtiConfig = {
+ .io = IO_TAG(PA15)
+ };
+ // MPU_INT output on V2 PB13
+ static const extiConfig_t alienFlightF3V2MPUIntExtiConfig = {
+ .io = IO_TAG(PB13)
+ };
+
+ if (hardwareRevision == AFF3_REV_1) {
+ return &alienFlightF3V1MPUIntExtiConfig;
+ }
+ else {
+ return &alienFlightF3V2MPUIntExtiConfig;
+ }
+}
\ No newline at end of file
diff --git a/src/main/target/ALIENFLIGHTF3/hardware_revision.h b/src/main/target/ALIENFLIGHTF3/hardware_revision.h
index f4c0e9095..7e60ddc55 100644
--- a/src/main/target/ALIENFLIGHTF3/hardware_revision.h
+++ b/src/main/target/ALIENFLIGHTF3/hardware_revision.h
@@ -14,6 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see .
*/
+#pragma once
+
+#include "drivers/exti.h"
typedef enum awf3HardwareRevision_t {
UNKNOWN = 0,
@@ -25,3 +28,5 @@ extern uint8_t hardwareRevision;
void updateHardwareRevision(void);
void detectHardwareRevision(void);
+
+const extiConfig_t *selectMPUIntExtiConfigByHardwareRevision(void);
\ No newline at end of file
diff --git a/src/main/target/ALIENFLIGHTF3/target.mk b/src/main/target/ALIENFLIGHTF3/target.mk
index fc9d28c28..04ba9c48f 100644
--- a/src/main/target/ALIENFLIGHTF3/target.mk
+++ b/src/main/target/ALIENFLIGHTF3/target.mk
@@ -8,6 +8,5 @@ TARGET_SRC = \
drivers/accgyro_mpu6500.c \
drivers/accgyro_spi_mpu6500.c \
drivers/compass_ak8963.c \
- hardware_revision.c \
drivers/sonar_hcsr04.c
diff --git a/src/main/target/NAZE/hardware_revision.c b/src/main/target/NAZE/hardware_revision.c
index dae369844..d9f540eb9 100755
--- a/src/main/target/NAZE/hardware_revision.c
+++ b/src/main/target/NAZE/hardware_revision.c
@@ -26,6 +26,7 @@
#include "drivers/system.h"
#include "drivers/bus_spi.h"
#include "drivers/sensor.h"
+#include "drivers/io.h"
#include "drivers/exti.h"
#include "drivers/accgyro.h"
#include "drivers/accgyro_mpu.h"
@@ -109,3 +110,26 @@ void updateHardwareRevision(void)
hardwareRevision = NAZE32_SP;
#endif
}
+
+const extiConfig_t *selectMPUIntExtiConfigByHardwareRevision(void)
+{
+ // MPU_INT output on rev4 PB13
+ static const extiConfig_t nazeRev4MPUIntExtiConfig = {
+ .io = IO_TAG(PB13)
+ };
+ // MPU_INT output on rev5 hardware PC13
+ static const extiConfig_t nazeRev5MPUIntExtiConfig = {
+ .io = IO_TAG(PC13)
+ };
+
+#ifdef AFROMINI
+ return &nazeRev5MPUIntExtiConfig;
+#else
+ if (hardwareRevision < NAZE32_REV5) {
+ return &nazeRev4MPUIntExtiConfig;
+ }
+ else {
+ return &nazeRev5MPUIntExtiConfig;
+ }
+#endif
+}
diff --git a/src/main/target/NAZE/hardware_revision.h b/src/main/target/NAZE/hardware_revision.h
index 9f663bb6c..08895620f 100755
--- a/src/main/target/NAZE/hardware_revision.h
+++ b/src/main/target/NAZE/hardware_revision.h
@@ -14,6 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see .
*/
+#pragma once
+
+#include "drivers/exti.h"
typedef enum nazeHardwareRevision_t {
UNKNOWN = 0,
@@ -28,3 +31,5 @@ void updateHardwareRevision(void);
void detectHardwareRevision(void);
void spiBusInit(void);
+
+const extiConfig_t *selectMPUIntExtiConfigByHardwareRevision(void);
diff --git a/src/main/target/NAZE/target.mk b/src/main/target/NAZE/target.mk
index 45d87e4b7..07d81cf44 100644
--- a/src/main/target/NAZE/target.mk
+++ b/src/main/target/NAZE/target.mk
@@ -17,5 +17,4 @@ TARGET_SRC = \
drivers/compass_hmc5883l.c \
drivers/light_ws2811strip.c \
drivers/light_ws2811strip_stm32f10x.c \
- drivers/sonar_hcsr04.c \
- hardware_revision.c
+ drivers/sonar_hcsr04.c