Browse Source

temporarily removed throttle calibration. broken until further notice.

implemented channel order selection (map in cli). example "map AETR1234" -> ail, ele, throttle, rudder, aux1234. thanks simon for all the halp on this one. truly a mindfuck.

git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@126 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
master
timecop 13 years ago
parent
commit
0534444b2d
  1. 59
      baseflight.uvopt
  2. 5125
      obj/baseflight.hex
  3. 1
      src/board.h
  4. 41
      src/cli.c
  5. 14
      src/config.c
  6. 18
      src/drv_pwm.c
  7. 5
      src/mw.c
  8. 2
      src/mw.h

59
baseflight.uvopt

@ -161,29 +161,24 @@
<Ww>
<count>0</count>
<WinNumber>1</WinNumber>
<ItemText>tri_yaw_middle</ItemText>
<ItemText>cycleTime,0x0A</ItemText>
</Ww>
<Ww>
<count>1</count>
<WinNumber>1</WinNumber>
<ItemText>enabledFeatures
<ItemText>Inputs
</ItemText>
</Ww>
<Ww>
<count>2</count>
<WinNumber>1</WinNumber>
<ItemText>cmdline</ItemText>
</Ww>
<Ww>
<count>3</count>
<WinNumber>1</WinNumber>
<ItemText>buf
<ItemText>Inputs
</ItemText>
</Ww>
<Ww>
<count>4</count>
<count>3</count>
<WinNumber>1</WinNumber>
<ItemText>cycleTime,0x0A</ItemText>
<ItemText>rcData,0x0A</ItemText>
</Ww>
</WatchWindow1>
<MemoryWindow1>
@ -493,10 +488,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>22</ColumnNumber>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>61</TopLine>
<CurrentLine>90</CurrentLine>
<TopLine>1</TopLine>
<CurrentLine>1</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\src\cli.c</PathWithFileName>
<FilenameWithoutPath>cli.c</FilenameWithoutPath>
@ -507,10 +502,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>19</ColumnNumber>
<ColumnNumber>56</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>85</TopLine>
<CurrentLine>115</CurrentLine>
<TopLine>1</TopLine>
<CurrentLine>21</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\src\config.c</PathWithFileName>
<FilenameWithoutPath>config.c</FilenameWithoutPath>
@ -523,8 +518,8 @@
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>182</TopLine>
<CurrentLine>191</CurrentLine>
<TopLine>50</TopLine>
<CurrentLine>56</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\src\imu.c</PathWithFileName>
<FilenameWithoutPath>imu.c</FilenameWithoutPath>
@ -535,10 +530,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<ColumnNumber>25</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>31</TopLine>
<CurrentLine>51</CurrentLine>
<TopLine>34</TopLine>
<CurrentLine>44</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\src\main.c</PathWithFileName>
<FilenameWithoutPath>main.c</FilenameWithoutPath>
@ -563,10 +558,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>9</ColumnNumber>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>571</TopLine>
<CurrentLine>583</CurrentLine>
<TopLine>39</TopLine>
<CurrentLine>46</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\src\mw.c</PathWithFileName>
<FilenameWithoutPath>mw.c</FilenameWithoutPath>
@ -621,8 +616,8 @@
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>204</TopLine>
<CurrentLine>204</CurrentLine>
<TopLine>242</TopLine>
<CurrentLine>269</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\src\mw.h</PathWithFileName>
<FilenameWithoutPath>mw.h</FilenameWithoutPath>
@ -698,7 +693,7 @@
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>134</TopLine>
<TopLine>137</TopLine>
<CurrentLine>143</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\src\drv_i2c.c</PathWithFileName>
@ -724,10 +719,10 @@
<FileType>1</FileType>
<tvExp>1</tvExp>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<ColumnNumber>1</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>329</TopLine>
<CurrentLine>364</CurrentLine>
<TopLine>77</TopLine>
<CurrentLine>99</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\src\drv_pwm.c</PathWithFileName>
<FilenameWithoutPath>drv_pwm.c</FilenameWithoutPath>
@ -740,8 +735,8 @@
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>124</TopLine>
<CurrentLine>150</CurrentLine>
<TopLine>42</TopLine>
<CurrentLine>43</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\src\drv_system.c</PathWithFileName>
<FilenameWithoutPath>drv_system.c</FilenameWithoutPath>

5125
obj/baseflight.hex
File diff suppressed because it is too large
View File

1
src/board.h

@ -4,6 +4,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>

41
src/cli.c

@ -7,6 +7,7 @@ static void cliDefaults(char *cmdline);
static void cliExit(char *cmdline);
static void cliFeature(char *cmdline);
static void cliHelp(char *cmdline);
static void cliMap(char *cmdline);
static void cliMixer(char *cmdline);
static void cliSave(char *cmdline);
static void cliSet(char *cmdline);
@ -16,6 +17,9 @@ static void cliVersion(char *cmdline);
// from sensors.c
extern uint8_t batteryCellCount;
// from config.c RC Channel mapping
extern const char rcChannelLetters[];
// buffer
static char cliBuffer[32];
static uint8_t bufferIndex = 0;
@ -47,6 +51,7 @@ const clicmd_t cmdTable[] = {
{ "exit", "", cliExit },
{ "feature", "list or -val or val", cliFeature },
{ "help", "", cliHelp },
{ "map", "mapping of first 4 channels", cliMap },
{ "mixer", "mixer name or list", cliMixer },
{ "save", "save and reboot", cliSave },
{ "set", "name=value or blank for list", cliSet },
@ -245,6 +250,42 @@ static void cliHelp(char *cmdline)
}
}
static void cliMap(char *cmdline)
{
uint8_t len;
uint8_t i;
char out[9];
len = strlen(cmdline);
if (len == 0 || len != 8) {
uartPrint("Current assignment: ");
for (i = 0; i < 8; i++)
out[cfg.rcmap[i]] = rcChannelLetters[i];
out[i] = '\0';
uartPrint(out);
uartPrint("\r\n");
return;
} else {
bool fail = false;
// uppercase it
for (i = 0; i < 8; i++) {
cmdline[i] = toupper(cmdline[i]);
if (!strchr(rcChannelLetters, cmdline[i])) {
fail = true;
break;
}
}
if (fail)
uartPrint("Must be any order of AETR1234\r\n");
else {
parseRcChannels(cmdline);
cliMap("");
}
}
}
static void cliMixer(char *cmdline)
{
uint8_t i;

14
src/config.c

@ -6,10 +6,22 @@
#define FLASH_WRITE_ADDR (0x08000000 + (uint32_t)FLASH_PAGE_SIZE * 63) // use the last KB for storage
config_t cfg;
const char rcChannelLetters[] = "AERT1234";
static uint32_t enabledSensors = 0;
static uint8_t checkNewConf = 6;
void parseRcChannels(const char *input)
{
const char *c, *s;
for (c = input; *c; c++) {
s = strchr(rcChannelLetters, *c);
if (s)
cfg.rcmap[s - rcChannelLetters] = c - input;
}
}
void readEEPROM(void)
{
uint8_t i;
@ -107,6 +119,8 @@ void checkFirstTime(bool reset)
cfg.vbatmincellvoltage = 33;
// Radio/ESC
parseRcChannels("AETR1234");
// parseRcChannels("ATER1234");
cfg.deadband = 0;
cfg.midrc = 1500;
cfg.mincheck = 1100;

18
src/drv_pwm.c

@ -32,6 +32,7 @@ static volatile uint16_t *OutputChannels[] = {
&(TIM4->CCR2),
&(TIM4->CCR3),
&(TIM4->CCR4),
// Extended use during CPPM input
&(TIM3->CCR1),
&(TIM3->CCR2),
&(TIM3->CCR3),
@ -162,7 +163,7 @@ bool pwmInit(bool usePPM, bool useServos, bool useDigitalServos)
uint8_t i, val;
uint16_t c;
bool throttleCal = true;
bool throttleCal = false;
// Inputs
@ -189,14 +190,19 @@ bool pwmInit(bool usePPM, bool useServos, bool useDigitalServos)
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
#if 0
// wait a while
delay(100);
for (c = 0; c < 10000; c++) {
for (c = 0; c < 50000; c++) {
val = GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0);
if (val) {
throttleCal = false;
break;
}
}
}
#endif
// use PPM or PWM input
usePPMFlag = usePPM;
@ -355,12 +361,14 @@ bool pwmInit(bool usePPM, bool useServos, bool useDigitalServos)
TIM_Cmd(TIM3, ENABLE);
TIM_CtrlPWMOutputs(TIM3, ENABLE);
}
#if 0
// throttleCal check part 2: delay 50ms, check if any RC pulses have been received
delay(50);
// if rc is on, it was set, check if rc is alive. if it is, cancel.
if (rcActive)
throttleCal = false;
#endif
return throttleCal;
}
@ -379,4 +387,4 @@ uint16_t pwmRead(uint8_t channel)
uint8_t pwmGetNumOutputChannels(void)
{
return numOutputChannels;
}
}

5
src/mw.c

@ -43,7 +43,6 @@ uint8_t baroMode = 0; // if altitude hold is activated
int16_t axisPID[3];
volatile uint16_t rcValue[18] = { 1502, 1502, 1502, 1502, 1502, 1502, 1502, 1502, 1502, 1502, 1502, 1502, 1502, 1502, 1502, 1502, 1502, 1502 }; // interval [1000;2000]
uint8_t rcChannel[8] = { ROLL, PITCH, THROTTLE, YAW, AUX1, AUX2, AUX3, AUX4 };
// **********************
// GPS
@ -281,7 +280,7 @@ uint16_t readRawRC(uint8_t chan)
uint16_t data;
failsafeCnt = 0;
data = pwmRead(rcChannel[chan]);
data = pwmRead(cfg.rcmap[chan]);
if (data < 750 || data > 2250)
data = 1500;
@ -293,7 +292,7 @@ void computeRC(void)
static int16_t rcData4Values[8][4], rcDataMean[8];
static uint8_t rc4ValuesIndex = 0;
uint8_t chan, a;
#if defined(SBUS)
readSBus();
#endif

2
src/mw.h

@ -152,6 +152,7 @@ typedef struct config_t {
uint8_t vbatmincellvoltage; // minimum voltage per cell, this triggers battery out alarms, in 0.1V units, default is 33 (3.3V)
// Radio/ESC-related configuration
uint8_t rcmap[8]; // mapping of radio channels to internal RPYTA+ order
uint8_t deadband; // introduce a deadband around the stick center. Must be greater than zero
uint16_t midrc; // Some radios have not a neutral point centered on 1500. can be changed here
uint16_t mincheck; // minimum rc end
@ -262,6 +263,7 @@ void mixTable(void);
void serialCom(void);
// Config
void parseRcChannels(const char *input);
void readEEPROM(void);
void writeParams(void);
void checkFirstTime(bool reset);

Loading…
Cancel
Save