Merge pull request #512 from blckmn/development

Moved target specific code out of sensors/initialisation.c
This commit is contained in:
J Blackman 2016-06-15 08:32:01 +10:00 committed by GitHub
commit 2e7f1fabff
8 changed files with 60 additions and 44 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
}
}

View File

@ -14,6 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
*/
#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);

View File

@ -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

View File

@ -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
}

View File

@ -14,6 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
*/
#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);

View File

@ -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