1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-12 19:10:32 +03:00

fixed mag calibration stuff as reported by multiwii dudes

added (untested) support for additional PWM output channels incase of PPM input - 4 more, so total of 10 outputs in this mode.
added (mostly untested) support for throttle calibration - short out PPM input connector with a bind plug and power up.

git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@122 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
timecop 2012-03-23 03:59:15 +00:00
parent c526d2f3b9
commit 8318331f27
8 changed files with 2892 additions and 2466 deletions

View file

@ -104,7 +104,7 @@
<sRfunc>1</sRfunc> <sRfunc>1</sRfunc>
<sRbox>1</sRbox> <sRbox>1</sRbox>
<tLdApp>1</tLdApp> <tLdApp>1</tLdApp>
<tGomain>0</tGomain> <tGomain>1</tGomain>
<tRbreak>1</tRbreak> <tRbreak>1</tRbreak>
<tRwatch>1</tRwatch> <tRwatch>1</tRwatch>
<tRmem>1</tRmem> <tRmem>1</tRmem>
@ -112,7 +112,7 @@
<tRbox>1</tRbox> <tRbox>1</tRbox>
<sRunDeb>0</sRunDeb> <sRunDeb>0</sRunDeb>
<sLrtime>0</sLrtime> <sLrtime>0</sLrtime>
<nTsel>7</nTsel> <nTsel>1</nTsel>
<sDll></sDll> <sDll></sDll>
<sDllPa></sDllPa> <sDllPa></sDllPa>
<sDlgDll></sDlgDll> <sDlgDll></sDlgDll>
@ -123,7 +123,7 @@
<tDlgDll></tDlgDll> <tDlgDll></tDlgDll>
<tDlgPa></tDlgPa> <tDlgPa></tDlgPa>
<tIfile></tIfile> <tIfile></tIfile>
<pMon>Segger\JL2CM3.dll</pMon> <pMon>BIN\UL2CM3.DLL</pMon>
</DebugOpt> </DebugOpt>
<TargetDriverDllRegistry> <TargetDriverDllRegistry>
<SetRegEntry> <SetRegEntry>
@ -134,7 +134,7 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>DLGTARM</Key> <Key>DLGTARM</Key>
<Name>(1010=333,106,699,649,0)(1007=-1,-1,-1,-1,0)(1008=90,117,456,339,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=-1,-1,-1,-1,0)(121=-1,-1,-1,-1,0)(122=-1,-1,-1,-1,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=582,118,1166,798,0)(131=549,135,1133,815,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=791,309,1258,816,0)(230=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name> <Name>(1010=333,106,699,649,0)(1007=-1,-1,-1,-1,0)(1008=90,117,456,339,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=-1,-1,-1,-1,0)(121=-1,-1,-1,-1,0)(122=-1,-1,-1,-1,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=582,118,1166,798,0)(131=549,135,1133,815,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=791,309,1258,816,0)(230=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=570,175,1163,795,0)(151=-1,-1,-1,-1,0)</Name>
</SetRegEntry> </SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
@ -144,7 +144,7 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>DLGUARM</Key> <Key>DLGUARM</Key>
<Name>(106=-1,-1,-1,-1,0)(107=-1,-1,-1,-1,0)</Name> <Name>(105=-1,-1,-1,-1,0)(106=-1,-1,-1,-1,0)(107=-1,-1,-1,-1,0)</Name>
</SetRegEntry> </SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
@ -154,56 +154,9 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>UL2CM3</Key> <Key>UL2CM3</Key>
<Name>-UV0168AVR -O238 -S8 -C0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128 -FS08000000 -FL010000</Name> <Name>-UV0168AVR -O206 -S8 -C0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC72000000 -TP21 -TDS803D -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO11 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128 -FS08000000 -FL010000</Name>
</SetRegEntry> </SetRegEntry>
</TargetDriverDllRegistry> </TargetDriverDllRegistry>
<Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>29</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134222936</Address>
<ByteObject>0</ByteObject>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename></Filename>
<ExecCommand></ExecCommand>
<Expression>\\baseflight\src/main.c\29</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>58</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134243320</Address>
<ByteObject>0</ByteObject>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename></Filename>
<ExecCommand></ExecCommand>
<Expression>\\baseflight\src/drv_mpu6050.c\58</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>66</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134232692</Address>
<ByteObject>0</ByteObject>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename></Filename>
<ExecCommand></ExecCommand>
<Expression>\\baseflight\src/sensors.c\66</Expression>
</Bp>
</Breakpoint>
<WatchWindow1> <WatchWindow1>
<Ww> <Ww>
<count>0</count> <count>0</count>
@ -227,12 +180,17 @@
<ItemText>buf <ItemText>buf
</ItemText> </ItemText>
</Ww> </Ww>
<Ww>
<count>4</count>
<WinNumber>1</WinNumber>
<ItemText>cycleTime,0x0A</ItemText>
</Ww>
</WatchWindow1> </WatchWindow1>
<MemoryWindow1> <MemoryWindow1>
<Mm> <Mm>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<SubType>0</SubType> <SubType>0</SubType>
<ItemText>eqptr</ItemText> <ItemText>20000000</ItemText>
</Mm> </Mm>
</MemoryWindow1> </MemoryWindow1>
<MemoryWindow2> <MemoryWindow2>
@ -535,10 +493,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>22</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>60</TopLine> <TopLine>61</TopLine>
<CurrentLine>78</CurrentLine> <CurrentLine>90</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\cli.c</PathWithFileName> <PathWithFileName>.\src\cli.c</PathWithFileName>
<FilenameWithoutPath>cli.c</FilenameWithoutPath> <FilenameWithoutPath>cli.c</FilenameWithoutPath>
@ -549,10 +507,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>19</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>7</TopLine> <TopLine>85</TopLine>
<CurrentLine>20</CurrentLine> <CurrentLine>115</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\config.c</PathWithFileName> <PathWithFileName>.\src\config.c</PathWithFileName>
<FilenameWithoutPath>config.c</FilenameWithoutPath> <FilenameWithoutPath>config.c</FilenameWithoutPath>
@ -565,8 +523,8 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine> <TopLine>182</TopLine>
<CurrentLine>0</CurrentLine> <CurrentLine>191</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\imu.c</PathWithFileName> <PathWithFileName>.\src\imu.c</PathWithFileName>
<FilenameWithoutPath>imu.c</FilenameWithoutPath> <FilenameWithoutPath>imu.c</FilenameWithoutPath>
@ -579,8 +537,8 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>40</TopLine> <TopLine>31</TopLine>
<CurrentLine>53</CurrentLine> <CurrentLine>51</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\main.c</PathWithFileName> <PathWithFileName>.\src\main.c</PathWithFileName>
<FilenameWithoutPath>main.c</FilenameWithoutPath> <FilenameWithoutPath>main.c</FilenameWithoutPath>
@ -593,7 +551,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>271</TopLine> <TopLine>284</TopLine>
<CurrentLine>302</CurrentLine> <CurrentLine>302</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\mixer.c</PathWithFileName> <PathWithFileName>.\src\mixer.c</PathWithFileName>
@ -607,8 +565,8 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>9</ColumnNumber> <ColumnNumber>9</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>9</TopLine> <TopLine>571</TopLine>
<CurrentLine>21</CurrentLine> <CurrentLine>583</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\mw.c</PathWithFileName> <PathWithFileName>.\src\mw.c</PathWithFileName>
<FilenameWithoutPath>mw.c</FilenameWithoutPath> <FilenameWithoutPath>mw.c</FilenameWithoutPath>
@ -619,10 +577,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>25</ColumnNumber> <ColumnNumber>31</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>1</TopLine> <TopLine>281</TopLine>
<CurrentLine>9</CurrentLine> <CurrentLine>299</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\sensors.c</PathWithFileName> <PathWithFileName>.\src\sensors.c</PathWithFileName>
<FilenameWithoutPath>sensors.c</FilenameWithoutPath> <FilenameWithoutPath>sensors.c</FilenameWithoutPath>
@ -633,10 +591,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>18</ColumnNumber> <ColumnNumber>20</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>56</TopLine> <TopLine>1</TopLine>
<CurrentLine>74</CurrentLine> <CurrentLine>1</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\serial.c</PathWithFileName> <PathWithFileName>.\src\serial.c</PathWithFileName>
<FilenameWithoutPath>serial.c</FilenameWithoutPath> <FilenameWithoutPath>serial.c</FilenameWithoutPath>
@ -647,10 +605,10 @@
<FileType>5</FileType> <FileType>5</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>14</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>54</TopLine> <TopLine>1</TopLine>
<CurrentLine>72</CurrentLine> <CurrentLine>18</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\board.h</PathWithFileName> <PathWithFileName>.\src\board.h</PathWithFileName>
<FilenameWithoutPath>board.h</FilenameWithoutPath> <FilenameWithoutPath>board.h</FilenameWithoutPath>
@ -663,8 +621,8 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>37</TopLine> <TopLine>204</TopLine>
<CurrentLine>37</CurrentLine> <CurrentLine>204</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\mw.h</PathWithFileName> <PathWithFileName>.\src\mw.h</PathWithFileName>
<FilenameWithoutPath>mw.h</FilenameWithoutPath> <FilenameWithoutPath>mw.h</FilenameWithoutPath>
@ -684,8 +642,8 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>22</ColumnNumber> <ColumnNumber>22</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>33</TopLine> <TopLine>1</TopLine>
<CurrentLine>51</CurrentLine> <CurrentLine>1</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\drv_adc.c</PathWithFileName> <PathWithFileName>.\src\drv_adc.c</PathWithFileName>
<FilenameWithoutPath>drv_adc.c</FilenameWithoutPath> <FilenameWithoutPath>drv_adc.c</FilenameWithoutPath>
@ -726,7 +684,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>42</ColumnNumber> <ColumnNumber>42</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>13</TopLine> <TopLine>1</TopLine>
<CurrentLine>29</CurrentLine> <CurrentLine>29</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\drv_hmc5883l.c</PathWithFileName> <PathWithFileName>.\src\drv_hmc5883l.c</PathWithFileName>
@ -738,10 +696,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>18</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>1</TopLine> <TopLine>134</TopLine>
<CurrentLine>1</CurrentLine> <CurrentLine>143</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\drv_i2c.c</PathWithFileName> <PathWithFileName>.\src\drv_i2c.c</PathWithFileName>
<FilenameWithoutPath>drv_i2c.c</FilenameWithoutPath> <FilenameWithoutPath>drv_i2c.c</FilenameWithoutPath>
@ -764,12 +722,12 @@
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>17</FileNumber> <FileNumber>17</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>26</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>66</TopLine> <TopLine>329</TopLine>
<CurrentLine>84</CurrentLine> <CurrentLine>364</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\drv_pwm.c</PathWithFileName> <PathWithFileName>.\src\drv_pwm.c</PathWithFileName>
<FilenameWithoutPath>drv_pwm.c</FilenameWithoutPath> <FilenameWithoutPath>drv_pwm.c</FilenameWithoutPath>
@ -782,8 +740,8 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>115</TopLine> <TopLine>124</TopLine>
<CurrentLine>115</CurrentLine> <CurrentLine>150</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\drv_system.c</PathWithFileName> <PathWithFileName>.\src\drv_system.c</PathWithFileName>
<FilenameWithoutPath>drv_system.c</FilenameWithoutPath> <FilenameWithoutPath>drv_system.c</FilenameWithoutPath>
@ -983,10 +941,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>32</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine> <TopLine>269</TopLine>
<CurrentLine>0</CurrentLine> <CurrentLine>291</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\lib\STM32F10x_StdPeriph_Driver\src\stm32f10x_gpio.c</PathWithFileName> <PathWithFileName>.\lib\STM32F10x_StdPeriph_Driver\src\stm32f10x_gpio.c</PathWithFileName>
<FilenameWithoutPath>stm32f10x_gpio.c</FilenameWithoutPath> <FilenameWithoutPath>stm32f10x_gpio.c</FilenameWithoutPath>
@ -1011,10 +969,10 @@
<FileType>2</FileType> <FileType>2</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>26</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>116</TopLine> <TopLine>116</TopLine>
<CurrentLine>124</CurrentLine> <CurrentLine>133</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\src\baseflight_startups\startup_stm32f10x_md.s</PathWithFileName> <PathWithFileName>.\src\baseflight_startups\startup_stm32f10x_md.s</PathWithFileName>
<FilenameWithoutPath>startup_stm32f10x_md.s</FilenameWithoutPath> <FilenameWithoutPath>startup_stm32f10x_md.s</FilenameWithoutPath>

View file

@ -128,7 +128,7 @@
<Target> <Target>
<UseTarget>1</UseTarget> <UseTarget>1</UseTarget>
<LoadApplicationAtStartup>1</LoadApplicationAtStartup> <LoadApplicationAtStartup>1</LoadApplicationAtStartup>
<RunToMain>0</RunToMain> <RunToMain>1</RunToMain>
<RestoreBreakpoints>1</RestoreBreakpoints> <RestoreBreakpoints>1</RestoreBreakpoints>
<RestoreWatchpoints>1</RestoreWatchpoints> <RestoreWatchpoints>1</RestoreWatchpoints>
<RestoreMemoryDisplay>1</RestoreMemoryDisplay> <RestoreMemoryDisplay>1</RestoreMemoryDisplay>
@ -136,7 +136,7 @@
<RestoreToolbox>1</RestoreToolbox> <RestoreToolbox>1</RestoreToolbox>
</Target> </Target>
<RunDebugAfterBuild>0</RunDebugAfterBuild> <RunDebugAfterBuild>0</RunDebugAfterBuild>
<TargetSelection>7</TargetSelection> <TargetSelection>1</TargetSelection>
<SimDlls> <SimDlls>
<CpuDll></CpuDll> <CpuDll></CpuDll>
<CpuDllArguments></CpuDllArguments> <CpuDllArguments></CpuDllArguments>
@ -150,7 +150,7 @@
<PeripheralDll></PeripheralDll> <PeripheralDll></PeripheralDll>
<PeripheralDllArguments></PeripheralDllArguments> <PeripheralDllArguments></PeripheralDllArguments>
<InitializationFile></InitializationFile> <InitializationFile></InitializationFile>
<Driver>Segger\JL2CM3.dll</Driver> <Driver>BIN\UL2CM3.DLL</Driver>
</TargetDlls> </TargetDlls>
</DebugOption> </DebugOption>
<Utilities> <Utilities>
@ -160,9 +160,9 @@
<RunIndependent>0</RunIndependent> <RunIndependent>0</RunIndependent>
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging> <UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
<Capability>1</Capability> <Capability>1</Capability>
<DriverSelection>4099</DriverSelection> <DriverSelection>4096</DriverSelection>
</Flash1> </Flash1>
<Flash2>Segger\JL2CM3.dll</Flash2> <Flash2>BIN\UL2CM3.DLL</Flash2>
<Flash3>"" ()</Flash3> <Flash3>"" ()</Flash3>
<Flash4></Flash4> <Flash4></Flash4>
</Utilities> </Utilities>

File diff suppressed because it is too large Load diff

View file

@ -32,6 +32,10 @@ static volatile uint16_t *OutputChannels[] = {
&(TIM4->CCR2), &(TIM4->CCR2),
&(TIM4->CCR3), &(TIM4->CCR3),
&(TIM4->CCR4), &(TIM4->CCR4),
&(TIM3->CCR1),
&(TIM3->CCR2),
&(TIM3->CCR3),
&(TIM3->CCR4),
}; };
static struct PWM_State { static struct PWM_State {
@ -43,6 +47,7 @@ static struct PWM_State {
static TIM_ICInitTypeDef TIM_ICInitStructure = { 0, }; static TIM_ICInitTypeDef TIM_ICInitStructure = { 0, };
static bool usePPMFlag = false; static bool usePPMFlag = false;
static uint8_t numOutputChannels = 0;
void TIM2_IRQHandler(void) void TIM2_IRQHandler(void)
{ {
@ -95,7 +100,7 @@ static void pwmIRQHandler(TIM_TypeDef *tim)
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
struct TIM_Channel channel = Channels[i]; struct TIM_Channel channel = Channels[i];
struct PWM_State *state = &Inputs[i]; struct PWM_State *state = &Inputs[i];
if (channel.tim == tim && (TIM_GetITStatus(tim, channel.cc) == SET)) { if (channel.tim == tim && (TIM_GetITStatus(tim, channel.cc) == SET)) {
TIM_ClearITPendingBit(channel.tim, channel.cc); TIM_ClearITPendingBit(channel.tim, channel.cc);
@ -113,16 +118,16 @@ static void pwmIRQHandler(TIM_TypeDef *tim)
val = TIM_GetCapture4(channel.tim); val = TIM_GetCapture4(channel.tim);
break; break;
} }
if (state->state == 0) if (state->state == 0)
state->rise = val; state->rise = val;
else else
state->fall = val; state->fall = val;
if (state->state == 0) { if (state->state == 0) {
// switch states // switch states
state->state = 1; state->state = 1;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Falling; TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Falling;
TIM_ICInitStructure.TIM_Channel = channel.channel; TIM_ICInitStructure.TIM_Channel = channel.channel;
TIM_ICInit(channel.tim, &TIM_ICInitStructure); TIM_ICInit(channel.tim, &TIM_ICInitStructure);
@ -132,10 +137,10 @@ static void pwmIRQHandler(TIM_TypeDef *tim)
state->capture = (state->fall - state->rise); state->capture = (state->fall - state->rise);
else else
state->capture = ((0xffff - state->rise) + state->fall); state->capture = ((0xffff - state->rise) + state->fall);
// switch state // switch state
state->state = 0; state->state = 0;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising; TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInitStructure.TIM_Channel = channel.channel; TIM_ICInitStructure.TIM_Channel = channel.channel;
TIM_ICInit(channel.tim, &TIM_ICInitStructure); TIM_ICInit(channel.tim, &TIM_ICInitStructure);
@ -144,32 +149,49 @@ static void pwmIRQHandler(TIM_TypeDef *tim)
} }
} }
void pwmInit(bool usePPM, bool useServos, bool useDigitalServos) bool pwmInit(bool usePPM, bool useServos, bool useDigitalServos)
{ {
uint8_t i; uint8_t i, val;
GPIO_InitTypeDef GPIO_InitStructure = { 0, }; uint16_t c;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure = { 0, }; bool throttleCal = true;
TIM_OCInitTypeDef TIM_OCInitStructure = { 0, }; GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure = { 0, }; TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
// Inputs // Inputs
// RX1 TIM2_CH1 PA0 [also PPM] // RX1 TIM2_CH1 PA0 [also PPM] [also used for throttle calibration]
// RX2 TIM2_CH2 PA1 // RX2 TIM2_CH2 PA1
// RX3 TIM2_CH3 PA2 // RX3 TIM2_CH3 PA2 [also UART2_TX]
// RX4 TIM2_CH4 PA3 // RX4 TIM2_CH4 PA3 [also UART2_RX]
// RX5 TIM3_CH1 PA6 // RX5 TIM3_CH1 PA6 [also ADC_IN6]
// RX6 TIM3_CH2 PA7 // RX6 TIM3_CH2 PA7 [also ADC_IN7]
// RX7 TIM3_CH3 PB0 // RX7 TIM3_CH3 PB0 [also ADC_IN8]
// RX8 TIM3_CH4 PB1 // RX8 TIM3_CH4 PB1 [also ADC_IN9]
// Outputs // Outputs
// PWM1 TIM1_CH1 PA8 // PWM1 TIM1_CH1 PA8
// PWM2 TIM1_CH4 PA11 // PWM2 TIM1_CH4 PA11
// PWM3 TIM4_CH1 PB6 // PWM3 TIM4_CH1 PB6 [also I2C1_SCL]
// PWM4 TIM4_CH2 PB7 // PWM4 TIM4_CH2 PB7 [also I2C1_SDA]
// PWM5 TIM4_CH3 PB8 // PWM5 TIM4_CH3 PB8
// PWM6 TIM4_CH4 PB9 // PWM6 TIM4_CH4 PB9
// automatic throttle calibration detection: PA0 to ground via bindplug
// Configure TIM2_CH1 for input
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
for (c = 0; c < 10000; c++) {
val = GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0);
if (val) {
throttleCal = false;
break;
}
}
// use PPM or PWM input // use PPM or PWM input
usePPMFlag = usePPM; usePPMFlag = usePPM;
@ -185,7 +207,7 @@ void pwmInit(bool usePPM, bool useServos, bool useDigitalServos)
if (usePPM) { if (usePPM) {
// Configure TIM2_CH1 for PPM input // Configure TIM2_CH1 for PPM input
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_Init(GPIOA, &GPIO_InitStructure);
@ -215,6 +237,8 @@ void pwmInit(bool usePPM, bool useServos, bool useDigitalServos)
TIM_ITConfig(TIM2, TIM_IT_CC1, ENABLE); TIM_ITConfig(TIM2, TIM_IT_CC1, ENABLE);
TIM_Cmd(TIM2, ENABLE); TIM_Cmd(TIM2, ENABLE);
// configure number of PWM outputs, in PPM mode, we use bottom 4 channels more more motors
numOutputChannels = 10;
} else { } else {
// Configure TIM2, TIM3 all 4 channels // Configure TIM2, TIM3 all 4 channels
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_6 | GPIO_Pin_7; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_6 | GPIO_Pin_7;
@ -256,6 +280,9 @@ void pwmInit(bool usePPM, bool useServos, bool useDigitalServos)
TIM_ITConfig(TIM3, TIM_IT_CC1 | TIM_IT_CC2 | TIM_IT_CC3 | TIM_IT_CC4, ENABLE); TIM_ITConfig(TIM3, TIM_IT_CC1 | TIM_IT_CC2 | TIM_IT_CC3 | TIM_IT_CC4, ENABLE);
TIM_Cmd(TIM2, ENABLE); TIM_Cmd(TIM2, ENABLE);
TIM_Cmd(TIM3, ENABLE); TIM_Cmd(TIM3, ENABLE);
// In PWM input mode, all 8 channels are wasted
numOutputChannels = 6;
} }
// Output pins // Output pins
@ -302,14 +329,43 @@ void pwmInit(bool usePPM, bool useServos, bool useDigitalServos)
TIM_Cmd(TIM4, ENABLE); TIM_Cmd(TIM4, ENABLE);
TIM_CtrlPWMOutputs(TIM1, ENABLE); TIM_CtrlPWMOutputs(TIM1, ENABLE);
TIM_CtrlPWMOutputs(TIM4, ENABLE); TIM_CtrlPWMOutputs(TIM4, ENABLE);
if (usePPM) {
// PWM 7,8,9,10
TIM_TimeBaseStructure.TIM_Period = PULSE_PERIOD - 1;
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Disable;
TIM_OCInitStructure.TIM_Pulse = PULSE_1MS;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;
TIM_OC1Init(TIM3, &TIM_OCInitStructure);
TIM_OC2Init(TIM3, &TIM_OCInitStructure);
TIM_OC3Init(TIM3, &TIM_OCInitStructure);
TIM_OC4Init(TIM3, &TIM_OCInitStructure);
TIM_Cmd(TIM3, ENABLE);
TIM_CtrlPWMOutputs(TIM3, ENABLE);
}
return throttleCal;
} }
void pwmWrite(uint8_t channel, uint16_t value) void pwmWrite(uint8_t channel, uint16_t value)
{ {
*OutputChannels[channel] = value; if (channel < numOutputChannels)
*OutputChannels[channel] = value;
} }
uint16_t pwmRead(uint8_t channel) uint16_t pwmRead(uint8_t channel)
{ {
return Inputs[channel].capture; return Inputs[channel].capture;
} }
uint8_t pwmGetNumOutputChannels(void)
{
return numOutputChannels;
}

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
void pwmInit(bool usePPM, bool useServos, bool useDigitalServos); bool pwmInit(bool usePPM, bool useServos, bool useDigitalServos); // returns whether driver is asking to calibrate throttle or not
void pwmWrite(uint8_t channel, uint16_t value); void pwmWrite(uint8_t channel, uint16_t value);
uint16_t pwmRead(uint8_t channel); uint16_t pwmRead(uint8_t channel);
uint8_t pwmGetNumOutputChannels(void);

View file

@ -147,7 +147,7 @@ void failureMode(uint8_t mode)
while (1) { while (1) {
LED1_TOGGLE; LED1_TOGGLE;
LED0_TOGGLE; LED0_TOGGLE;
delay(475); delay(475 * mode - 2);
BEEP_ON BEEP_ON
delay(25); delay(25);
BEEP_OFF; BEEP_OFF;

View file

@ -3,6 +3,26 @@
extern uint8_t useServo; extern uint8_t useServo;
void throttleCalibration(void)
{
uint8_t offset = useServo ? 2 : 0;
uint8_t len = pwmGetNumOutputChannels() - offset;
uint8_t i;
LED1_ON;
for (i = offset; i < len; i++)
pwmWrite(i, cfg.maxthrottle);
delay(3000); // 3s delay on high
for (i = offset; i < len; i++)
pwmWrite(i, cfg.minthrottle);
// blink leds to show we're calibrated and time to remove bind plug
failureMode(4);
}
int main(void) int main(void)
{ {
uint8_t i; uint8_t i;
@ -25,7 +45,9 @@ int main(void)
sensorsSet(SENSOR_ACC | SENSOR_BARO | SENSOR_MAG); sensorsSet(SENSOR_ACC | SENSOR_BARO | SENSOR_MAG);
mixerInit(); // this will set useServo var depending on mixer type mixerInit(); // this will set useServo var depending on mixer type
pwmInit(feature(FEATURE_PPM), useServo, feature(FEATURE_DIGITAL_SERVO)); // pwmInit returns true if throttle calibration is requested. if so, do it here. throttleCalibration() does NOT return - for safety.
if (pwmInit(feature(FEATURE_PPM), useServo, feature(FEATURE_DIGITAL_SERVO)))
throttleCalibration(); // noreturn
LED1_ON; LED1_ON;
LED0_OFF; LED0_OFF;

View file

@ -294,9 +294,9 @@ void Mag_init(void)
Mag_getRawADC(); Mag_getRawADC();
delay(10); delay(10);
magCal[ROLL] = 1000.0 / abs(magADC[ROLL]); magCal[ROLL] = 1160.0f / abs(magADC[ROLL]);
magCal[PITCH] = 1000.0 / abs(magADC[PITCH]); magCal[PITCH] = 1160.0f / abs(magADC[PITCH]);
magCal[YAW] = 1000.0 / abs(magADC[YAW]); magCal[YAW] = 1080.0f / abs(magADC[YAW]);
hmc5883lFinishCal(); hmc5883lFinishCal();
magInit = 1; magInit = 1;