Moved target specific code out of initialisation.c

This commit is contained in:
blckmn 2016-06-15 06:20:03 +10:00 committed by blckmn
parent e39ff27b95
commit 251b3d7e3c
6 changed files with 59 additions and 41 deletions

View File

@ -8,7 +8,7 @@
// IO pin identification // IO pin identification
// make sure that ioTag_t can't be assigned into IO_t without warning // 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 typedef void* IO_t; // type specifying IO pin. Currently ioRec_t pointer, but this may change
// NONE initializer for IO_t variable // NONE initializer for IO_t variable

View File

@ -90,45 +90,10 @@ const extiConfig_t *selectMPUIntExtiConfig(void)
return &mpuIntExtiConfig; return &mpuIntExtiConfig;
#endif #endif
#ifdef NAZE #ifdef USE_HARDWARE_REVISION_DETECTION
// MPU_INT output on rev4 PB13 return selectMPUIntExtiConfigByHardwareRevision();
static const extiConfig_t nazeRev4MPUIntExtiConfig = { #else return NULL;
.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
#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_FAKE_GYRO #ifdef USE_FAKE_GYRO

View File

@ -24,7 +24,7 @@
#include "drivers/system.h" #include "drivers/system.h"
#include "drivers/io.h" #include "drivers/io.h"
#include "drivers/exti.h"
#include "hardware_revision.h" #include "hardware_revision.h"
static const char * const hardwareRevisionNames[] = { static const char * const hardwareRevisionNames[] = {
@ -56,3 +56,22 @@ void detectHardwareRevision(void)
void updateHardwareRevision(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;
}
}

View File

@ -14,6 +14,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>. * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once
#include "drivers/exti.h"
typedef enum awf3HardwareRevision_t { typedef enum awf3HardwareRevision_t {
UNKNOWN = 0, UNKNOWN = 0,
@ -25,3 +28,5 @@ extern uint8_t hardwareRevision;
void updateHardwareRevision(void); void updateHardwareRevision(void);
void detectHardwareRevision(void); void detectHardwareRevision(void);
const extiConfig_t *selectMPUIntExtiConfigByHardwareRevision(void);

View File

@ -26,6 +26,7 @@
#include "drivers/system.h" #include "drivers/system.h"
#include "drivers/bus_spi.h" #include "drivers/bus_spi.h"
#include "drivers/sensor.h" #include "drivers/sensor.h"
#include "drivers/io.h"
#include "drivers/exti.h" #include "drivers/exti.h"
#include "drivers/accgyro.h" #include "drivers/accgyro.h"
#include "drivers/accgyro_mpu.h" #include "drivers/accgyro_mpu.h"
@ -109,3 +110,26 @@ void updateHardwareRevision(void)
hardwareRevision = NAZE32_SP; hardwareRevision = NAZE32_SP;
#endif #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
}

View File

@ -14,6 +14,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>. * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once
#include "drivers/exti.h"
typedef enum nazeHardwareRevision_t { typedef enum nazeHardwareRevision_t {
UNKNOWN = 0, UNKNOWN = 0,
@ -28,3 +31,5 @@ void updateHardwareRevision(void);
void detectHardwareRevision(void); void detectHardwareRevision(void);
void spiBusInit(void); void spiBusInit(void);
const extiConfig_t *selectMPUIntExtiConfigByHardwareRevision(void);