added driver for MMA8452QT accelerometer
added mag_declination set option to cli - oops status in cli now prints which ACC hardware is used. work in proress to show difference between hardware with MPU6050 and MPU3050 git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@157 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
parent
b929f79b54
commit
59ccf93dd3
163
baseflight.uvopt
163
baseflight.uvopt
|
@ -73,7 +73,7 @@
|
|||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>0</IsCurrentTarget>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>255</CpuCode>
|
||||
<Books>
|
||||
|
@ -166,61 +166,18 @@
|
|||
<Ww>
|
||||
<count>1</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>Inputs
|
||||
</ItemText>
|
||||
<ItemText>smallAngle25</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>2</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>Inputs
|
||||
</ItemText>
|
||||
<ItemText>accSmooth,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>3</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>rcData,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>4</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>incoming</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>5</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>dmpdata
|
||||
</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>6</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>dmpdata</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>7</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>dmp_fifoCountL</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>8</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>smallAngle25</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>9</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>accSmooth,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>10</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>accADC,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>11</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>acc_samples</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<MemoryWindow1>
|
||||
<Mm>
|
||||
|
@ -320,7 +277,7 @@
|
|||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
<IsCurrentTarget>0</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>255</CpuCode>
|
||||
<Books>
|
||||
|
@ -768,10 +725,10 @@
|
|||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>36</ColumnNumber>
|
||||
<ColumnNumber>15</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>415</TopLine>
|
||||
<CurrentLine>428</CurrentLine>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\cli.c</PathWithFileName>
|
||||
<FilenameWithoutPath>cli.c</FilenameWithoutPath>
|
||||
|
@ -784,8 +741,8 @@
|
|||
<Focus>0</Focus>
|
||||
<ColumnNumber>18</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>1</TopLine>
|
||||
<CurrentLine>1</CurrentLine>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\config.c</PathWithFileName>
|
||||
<FilenameWithoutPath>config.c</FilenameWithoutPath>
|
||||
|
@ -796,10 +753,10 @@
|
|||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>12</ColumnNumber>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>13</TopLine>
|
||||
<CurrentLine>24</CurrentLine>
|
||||
<TopLine>48</TopLine>
|
||||
<CurrentLine>58</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\imu.c</PathWithFileName>
|
||||
<FilenameWithoutPath>imu.c</FilenameWithoutPath>
|
||||
|
@ -812,8 +769,8 @@
|
|||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>106</TopLine>
|
||||
<CurrentLine>127</CurrentLine>
|
||||
<TopLine>16</TopLine>
|
||||
<CurrentLine>34</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\main.c</PathWithFileName>
|
||||
<FilenameWithoutPath>main.c</FilenameWithoutPath>
|
||||
|
@ -826,8 +783,8 @@
|
|||
<Focus>0</Focus>
|
||||
<ColumnNumber>120</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>110</TopLine>
|
||||
<CurrentLine>123</CurrentLine>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\mixer.c</PathWithFileName>
|
||||
<FilenameWithoutPath>mixer.c</FilenameWithoutPath>
|
||||
|
@ -838,10 +795,10 @@
|
|||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>8</ColumnNumber>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>239</TopLine>
|
||||
<CurrentLine>252</CurrentLine>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\mw.c</PathWithFileName>
|
||||
<FilenameWithoutPath>mw.c</FilenameWithoutPath>
|
||||
|
@ -852,10 +809,10 @@
|
|||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<ColumnNumber>5</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>351</TopLine>
|
||||
<CurrentLine>351</CurrentLine>
|
||||
<TopLine>49</TopLine>
|
||||
<CurrentLine>68</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\sensors.c</PathWithFileName>
|
||||
<FilenameWithoutPath>sensors.c</FilenameWithoutPath>
|
||||
|
@ -866,10 +823,10 @@
|
|||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<ColumnNumber>9</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>337</TopLine>
|
||||
<CurrentLine>355</CurrentLine>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\serial.c</PathWithFileName>
|
||||
<FilenameWithoutPath>serial.c</FilenameWithoutPath>
|
||||
|
@ -882,8 +839,8 @@
|
|||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>33</TopLine>
|
||||
<CurrentLine>47</CurrentLine>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\board.h</PathWithFileName>
|
||||
<FilenameWithoutPath>board.h</FilenameWithoutPath>
|
||||
|
@ -896,8 +853,8 @@
|
|||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>252</TopLine>
|
||||
<CurrentLine>252</CurrentLine>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\mw.h</PathWithFileName>
|
||||
<FilenameWithoutPath>mw.h</FilenameWithoutPath>
|
||||
|
@ -910,8 +867,8 @@
|
|||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>188</TopLine>
|
||||
<CurrentLine>209</CurrentLine>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\gps.c</PathWithFileName>
|
||||
<FilenameWithoutPath>gps.c</FilenameWithoutPath>
|
||||
|
@ -924,8 +881,8 @@
|
|||
<Focus>0</Focus>
|
||||
<ColumnNumber>36</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>1</TopLine>
|
||||
<CurrentLine>10</CurrentLine>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\spektrum.c</PathWithFileName>
|
||||
<FilenameWithoutPath>spektrum.c</FilenameWithoutPath>
|
||||
|
@ -938,8 +895,8 @@
|
|||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>7</TopLine>
|
||||
<CurrentLine>28</CurrentLine>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\buzzer.c</PathWithFileName>
|
||||
<FilenameWithoutPath>buzzer.c</FilenameWithoutPath>
|
||||
|
@ -959,8 +916,8 @@
|
|||
<Focus>0</Focus>
|
||||
<ColumnNumber>35</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>5</TopLine>
|
||||
<CurrentLine>26</CurrentLine>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\drv_adc.c</PathWithFileName>
|
||||
<FilenameWithoutPath>drv_adc.c</FilenameWithoutPath>
|
||||
|
@ -971,10 +928,10 @@
|
|||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<ColumnNumber>17</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>52</TopLine>
|
||||
<CurrentLine>73</CurrentLine>
|
||||
<TopLine>59</TopLine>
|
||||
<CurrentLine>71</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\drv_adxl345.c</PathWithFileName>
|
||||
<FilenameWithoutPath>drv_adxl345.c</FilenameWithoutPath>
|
||||
|
@ -1013,10 +970,10 @@
|
|||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<ColumnNumber>34</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>310</TopLine>
|
||||
<CurrentLine>331</CurrentLine>
|
||||
<TopLine>133</TopLine>
|
||||
<CurrentLine>158</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\drv_i2c.c</PathWithFileName>
|
||||
<FilenameWithoutPath>drv_i2c.c</FilenameWithoutPath>
|
||||
|
@ -1029,8 +986,8 @@
|
|||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>7</TopLine>
|
||||
<CurrentLine>27</CurrentLine>
|
||||
<TopLine>73</TopLine>
|
||||
<CurrentLine>98</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\drv_mpu3050.c</PathWithFileName>
|
||||
<FilenameWithoutPath>drv_mpu3050.c</FilenameWithoutPath>
|
||||
|
@ -1043,8 +1000,8 @@
|
|||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>1</TopLine>
|
||||
<CurrentLine>12</CurrentLine>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\drv_pwm.c</PathWithFileName>
|
||||
<FilenameWithoutPath>drv_pwm.c</FilenameWithoutPath>
|
||||
|
@ -1057,8 +1014,8 @@
|
|||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>25</TopLine>
|
||||
<CurrentLine>39</CurrentLine>
|
||||
<TopLine>36</TopLine>
|
||||
<CurrentLine>46</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\drv_system.c</PathWithFileName>
|
||||
<FilenameWithoutPath>drv_system.c</FilenameWithoutPath>
|
||||
|
@ -1099,8 +1056,8 @@
|
|||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<TopLine>149</TopLine>
|
||||
<CurrentLine>163</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\drv_mpu6050.c</PathWithFileName>
|
||||
<FilenameWithoutPath>drv_mpu6050.c</FilenameWithoutPath>
|
||||
|
@ -1133,6 +1090,20 @@
|
|||
<PathWithFileName>.\src\drv_pwm_fy90q.c</PathWithFileName>
|
||||
<FilenameWithoutPath>drv_pwm_fy90q.c</FilenameWithoutPath>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>0</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>57</TopLine>
|
||||
<CurrentLine>80</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\drv_mma845x.c</PathWithFileName>
|
||||
<FilenameWithoutPath>drv_mma845x.c</FilenameWithoutPath>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
|
@ -1316,8 +1287,8 @@
|
|||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<TopLine>133</TopLine>
|
||||
<CurrentLine>133</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>.\src\baseflight_startups\startup_stm32f10x_md.s</PathWithFileName>
|
||||
<FilenameWithoutPath>startup_stm32f10x_md.s</FilenameWithoutPath>
|
||||
|
|
|
@ -599,6 +599,11 @@
|
|||
</FileArmAds>
|
||||
</FileOption>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>drv_mma845x.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\src\drv_mma845x.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -1359,6 +1364,11 @@
|
|||
</FileArmAds>
|
||||
</FileOption>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>drv_mma845x.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\src\drv_mma845x.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -2299,6 +2309,11 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>.\src\drv_pwm_fy90q.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>drv_mma845x.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\src\drv_mma845x.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
|
5229
obj/baseflight.hex
5229
obj/baseflight.hex
File diff suppressed because it is too large
Load Diff
|
@ -123,6 +123,7 @@ typedef struct sensor_t
|
|||
#include "drv_hmc5883l.h"
|
||||
#include "drv_i2c.h"
|
||||
#include "drv_ledring.h"
|
||||
#include "drv_mma845x.h"
|
||||
#include "drv_mpu3050.h"
|
||||
#include "drv_mpu6050.h"
|
||||
#include "drv_pwm.h"
|
||||
|
|
11
src/cli.c
11
src/cli.c
|
@ -16,6 +16,7 @@ static void cliVersion(char *cmdline);
|
|||
|
||||
// from sensors.c
|
||||
extern uint8_t batteryCellCount;
|
||||
extern uint8_t accHardware;
|
||||
|
||||
// from config.c RC Channel mapping
|
||||
extern const char rcChannelLetters[];
|
||||
|
@ -45,6 +46,11 @@ const char *sensorNames[] = {
|
|||
"ACC", "BARO", "MAG", "SONAR", "GPS", NULL
|
||||
};
|
||||
|
||||
//
|
||||
const char *accNames[] = {
|
||||
"ADXL345", "MPU6050", "MMA845x", NULL
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
char *param;
|
||||
|
@ -117,6 +123,7 @@ const clivalue_t valueTable[] = {
|
|||
{ "gimbal_roll_mid", VAR_UINT16, &cfg.gimbal_roll_mid, 100, 3000 },
|
||||
{ "acc_lpf_factor", VAR_UINT8, &cfg.acc_lpf_factor, 0, 250 },
|
||||
{ "gyro_lpf", VAR_UINT16, &cfg.gyro_lpf, 0, 256 },
|
||||
{ "mag_declination", VAR_INT16, &cfg.mag_declination, -18000, 18000 },
|
||||
{ "gps_baudrate", VAR_UINT32, &cfg.gps_baudrate, 1200, 115200 },
|
||||
{ "serial_baudrate", VAR_UINT32, &cfg.serial_baudrate, 1200, 115200 },
|
||||
{ "p_pitch", VAR_UINT8, &cfg.P8[PITCH], 0, 200},
|
||||
|
@ -476,6 +483,10 @@ static void cliStatus(char *cmdline)
|
|||
uartPrint((char *)sensorNames[i]);
|
||||
uartWrite(' ');
|
||||
}
|
||||
if (sensors(SENSOR_ACC)) {
|
||||
uartPrint("ACCHW: ");
|
||||
uartPrint((char *)accNames[accHardware]);
|
||||
}
|
||||
uartPrint("\r\n");
|
||||
|
||||
uartPrint("Cycle Time: ");
|
||||
|
|
|
@ -13,7 +13,7 @@ config_t cfg;
|
|||
const char rcChannelLetters[] = "AERT1234";
|
||||
|
||||
static uint32_t enabledSensors = 0;
|
||||
uint8_t checkNewConf = 16;
|
||||
uint8_t checkNewConf = 17;
|
||||
|
||||
void parseRcChannels(const char *input)
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ void checkFirstTime(bool reset)
|
|||
cfg.accZero[0] = 0;
|
||||
cfg.accZero[1] = 0;
|
||||
cfg.accZero[2] = 0;
|
||||
cfg.magDeclination = 0; // For example, -6deg 37min, = -637 Japan, format is [sign]dddmm (degreesminutes) default is zero.
|
||||
cfg.mag_declination = 0; // For example, -6deg 37min, = -637 Japan, format is [sign]dddmm (degreesminutes) default is zero.
|
||||
cfg.acc_lpf_factor = 100;
|
||||
cfg.gyro_lpf = 42;
|
||||
cfg.gyro_smoothing_factor = 0x00141403; // default factors of 20, 20, 3 for R/P/Y
|
||||
|
|
9
src/mw.h
9
src/mw.h
|
@ -53,6 +53,13 @@ typedef enum GimbalFlags {
|
|||
GIMBAL_DISABLEAUX34 = 1 << 2,
|
||||
} GimbalFlags;
|
||||
|
||||
// Type of accelerometer used
|
||||
typedef enum AccelSensors {
|
||||
ADXL345,
|
||||
MPU6050,
|
||||
MMA845x
|
||||
} AccelSensors;
|
||||
|
||||
/*********** RC alias *****************/
|
||||
#define ROLL 0
|
||||
#define PITCH 1
|
||||
|
@ -109,7 +116,7 @@ typedef struct config_t {
|
|||
uint8_t dynThrPID;
|
||||
int16_t accZero[3];
|
||||
int16_t magZero[3];
|
||||
int16_t magDeclination; // Get your magnetic decliniation from here : http://magnetic-declination.com/
|
||||
int16_t mag_declination; // Get your magnetic decliniation from here : http://magnetic-declination.com/
|
||||
int16_t accTrim[2];
|
||||
|
||||
// sensor-related stuff
|
||||
|
|
|
@ -19,6 +19,7 @@ extern float magneticDeclination;
|
|||
|
||||
sensor_t acc; // acc access functions
|
||||
sensor_t gyro; // gyro access functions
|
||||
uint8_t accHardware = 0; // which accel chip is used.
|
||||
|
||||
#ifdef FY90Q
|
||||
// FY90Q analog gyro/acc
|
||||
|
@ -47,8 +48,10 @@ void sensorsAutodetect(void)
|
|||
sensorsClear(SENSOR_MAG);
|
||||
|
||||
// Init sensors
|
||||
if (sensors(SENSOR_ACC))
|
||||
if (sensors(SENSOR_ACC)) {
|
||||
acc.init();
|
||||
accHardware = ADXL345;
|
||||
}
|
||||
if (sensors(SENSOR_BARO))
|
||||
bmp085Init();
|
||||
|
||||
|
@ -56,18 +59,27 @@ void sensorsAutodetect(void)
|
|||
if (mpu6050Detect(&acc, &gyro)) { // first, try MPU6050, and re-enable acc (if ADXL345 is missing) since this chip has it built in
|
||||
sensorsSet(SENSOR_ACC);
|
||||
acc.init();
|
||||
accHardware = MPU6050;
|
||||
} else if (!mpu3050Detect(&gyro)) {
|
||||
// if this fails, we get a beep + blink pattern. we're doomed, no gyro or i2c error.
|
||||
failureMode(3);
|
||||
}
|
||||
|
||||
// Try to init MMA8452
|
||||
if (mma8452Detect(&acc)) {
|
||||
sensorsSet(SENSOR_ACC);
|
||||
acc.init();
|
||||
accHardware = MMA845x;
|
||||
}
|
||||
|
||||
// this is safe because either mpu6050 or mpu3050 sets it, and in case of fail, none do.
|
||||
gyro.init();
|
||||
// todo: this is driver specific :(
|
||||
mpu3050Config(cfg.gyro_lpf);
|
||||
|
||||
// calculate magnetic declination
|
||||
deg = cfg.magDeclination / 100;
|
||||
min = cfg.magDeclination % 100;
|
||||
deg = cfg.mag_declination / 100;
|
||||
min = cfg.mag_declination % 100;
|
||||
magneticDeclination = deg + ((float)min * (1.0f / 60.0f));
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue