Rev 23 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 23 | Rev 171 | ||
---|---|---|---|
1 | /*#######################################################################################*/ |
1 | /*#######################################################################################*/ |
2 | /* !!! THIS IS NOT FREE SOFTWARE !!! */ |
2 | /* !!! THIS IS NOT FREE SOFTWARE !!! */ |
3 | /*#######################################################################################*/ |
3 | /*#######################################################################################*/ |
4 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
4 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
5 | // + Copyright (c) 2008 Ingo Busker, Holger Buss |
5 | // + Copyright (c) 2008 Ingo Busker, Holger Buss |
6 | // + Nur für den privaten Gebrauch |
6 | // + Nur für den privaten Gebrauch / NON-COMMERCIAL USE ONLY |
7 | // + FOR NON COMMERCIAL USE ONLY |
7 | // + FOR NON COMMERCIAL USE ONLY |
8 | // + www.MikroKopter.com |
8 | // + www.MikroKopter.com |
9 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
9 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
10 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
10 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
11 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist. |
11 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist. |
12 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
12 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
13 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
13 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
14 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
14 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
15 | // + Verkauf von Luftbildaufnahmen, usw. |
15 | // + Verkauf von Luftbildaufnahmen, usw. |
16 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
16 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
17 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
17 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
18 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
18 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
19 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
19 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
20 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
20 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
21 | // + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
21 | // + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
22 | // + eindeutig als Ursprung verlinkt werden |
22 | // + eindeutig als Ursprung verlinkt werden |
23 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
23 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
24 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
24 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
25 | // + Benutzung auf eigene Gefahr |
25 | // + Benutzung auf eigene Gefahr |
26 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
26 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
27 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
27 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
28 | // + Die PORTIERUNG der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
28 | // + Die Portierung oder Nutzung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
29 | // + mit unserer Zustimmung zulässig |
29 | // + mit unserer Zustimmung zulässig |
30 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
30 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
31 | // + Teile, die nicht eindeutig mit unserer Lizenzvereinbarung gekennzeichnet sind, unterliegen u.U. eigenen Vereinbarungen: |
31 | // + Teile, die nicht eindeutig mit unserer Lizenzvereinbarung gekennzeichnet sind, unterliegen u.U. eigenen Vereinbarungen: |
32 | // + z.B. Die Funktion printf_P() unterliegt ihrer eigenen Lizenz |
32 | // + z.B. Die Funktion printf_P() unterliegt ihrer eigenen Lizenz |
33 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
33 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
34 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
34 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
35 | // + this list of conditions and the following disclaimer. |
35 | // + this list of conditions and the following disclaimer. |
36 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
36 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
37 | // + from this software without specific prior written permission. |
37 | // + from this software without specific prior written permission. |
38 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permitted |
38 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permitted |
39 | // + for non-commercial use (directly or indirectly) |
39 | // + for non-commercial use (directly or indirectly) |
40 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
40 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
41 | // + with our written permission |
41 | // + with our written permission |
42 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
42 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
43 | // + clearly linked as origin |
43 | // + clearly linked as origin |
44 | // + * PORTING this software (or part of it) to systems (other than hardware from www.mikrokopter.de) is NOT allowed |
44 | // + * porting the sources to other systems or using the software on other systems (except hardware from www.mikrokopter.de) is not allowed |
45 | // |
45 | // |
46 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
46 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
47 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
47 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
48 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
48 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
49 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
49 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
50 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
50 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
51 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
51 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
52 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
52 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
53 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
53 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
54 | // + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
54 | // + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
55 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
55 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
56 | // + POSSIBILITY OF SUCH DAMAGE. |
56 | // + POSSIBILITY OF SUCH DAMAGE. |
57 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
57 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
58 | const unsigned long _Main_Crystal = 25000; |
58 | const unsigned long _Main_Crystal = 25000; |
59 | 59 | ||
60 | #include "main.h" |
60 | #include "main.h" |
61 | 61 | ||
62 | u32 TimerCompassUpdate; |
62 | u32 TimerCompassUpdate; |
63 | u32 TimerI2CReadDelay; |
63 | u32 TimerI2CReadDelay; |
64 | u32 TimerDebugDataDelay; |
64 | u32 TimerDebugDataDelay; |
65 | 65 | ||
66 | u8 BeepTime; |
66 | u8 BeepTime; |
67 | void Init_Undef(void); |
67 | void Init_Undef(void); |
68 | u8 Parameter_UserParam1; |
68 | u8 Parameter_UserParam1; |
69 | u8 Parameter_UserParam2; |
69 | u8 Parameter_UserParam2; |
70 | u8 Parameter_UserParam3; |
70 | u8 Parameter_UserParam3; |
71 | u8 Parameter_UserParam4; |
71 | u8 Parameter_UserParam4; |
72 | u8 Parameter_UserParam5; |
72 | u8 Parameter_UserParam5; |
73 | u8 Parameter_UserParam6; |
73 | u8 Parameter_UserParam6; |
74 | u8 Parameter_UserParam7; |
74 | u8 Parameter_UserParam7; |
75 | u8 Parameter_UserParam8; |
75 | u8 Parameter_UserParam8; |
76 | s32 FC_StickNick; |
76 | s32 FC_StickNick; |
77 | s32 FC_StickRoll; |
77 | s32 FC_StickRoll; |
78 | s32 FC_StickGier; |
78 | s32 FC_StickGier; |
79 | s32 FC_StickGas; |
79 | s32 FC_StickGas; |
80 | s32 FC_Poti1; |
80 | s32 FC_Poti1; |
81 | s32 FC_Poti2; |
81 | s32 FC_Poti2; |
82 | s32 FC_Poti3; |
82 | s32 FC_Poti3; |
83 | s32 FC_Poti4; |
83 | s32 FC_Poti4; |
84 | s32 SenderOkay = 0; |
84 | s32 SenderOkay = 0; |
85 | u8 text[20]; |
85 | u8 text[20]; |
86 | 86 | ||
87 | //---------------------------------------------------------------------------------------------------- |
87 | //---------------------------------------------------------------------------------------------------- |
88 | void Leds_Init(void) |
88 | void Leds_Init(void) |
89 | { |
89 | { |
90 | GPIO_InitTypeDef GPIO_InitStructure; |
90 | GPIO_InitTypeDef GPIO_InitStructure; |
91 | 91 | ||
92 | SCU_APBPeriphClockConfig(__GPIO6, ENABLE); |
92 | SCU_APBPeriphClockConfig(__GPIO6, ENABLE); |
93 | SCU_APBPeriphClockConfig(__GPIO5, ENABLE); |
93 | SCU_APBPeriphClockConfig(__GPIO5, ENABLE); |
94 | 94 | ||
95 | //GPIO_DeInit(GPIO5); |
95 | //GPIO_DeInit(GPIO5); |
96 | GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; |
96 | GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; |
97 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; |
97 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; |
98 | GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
98 | GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
99 | GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1 ; |
99 | GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1 ; |
100 | GPIO_Init(GPIO5, &GPIO_InitStructure); |
100 | GPIO_Init(GPIO5, &GPIO_InitStructure); |
101 | 101 | ||
102 | GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; |
102 | GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; |
103 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; |
103 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; |
104 | GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; |
104 | GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; |
105 | GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; |
105 | GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; |
106 | GPIO_Init(GPIO5, &GPIO_InitStructure); |
106 | GPIO_Init(GPIO5, &GPIO_InitStructure); |
107 | 107 | ||
108 | 108 | ||
109 | } |
109 | } |
110 | // |
110 | // |
111 | void OutputStartupData(void) |
111 | void OutputStartupData(void) |
112 | { |
112 | { |
113 | 113 | ||
114 | char text[20]; |
114 | char text[20]; |
115 | SerialPutString("\n\r--------------\n\r"); |
115 | SerialPutString("\n\r--------------\n\r"); |
116 | 116 | ||
117 | sprintf(text,"NaviCtrl V%d.%d\n\r", VersionInfo.Hauptversion, VersionInfo.Nebenversion); SerialPutString(text); |
117 | sprintf(text,"NaviCtrl V%d.%d\n\r", VersionInfo.Hauptversion, VersionInfo.Nebenversion); SerialPutString(text); |
118 | 118 | ||
119 | 119 | ||
120 | } |
120 | } |
121 | 121 | ||
122 | //---------------------------------------------------------------------------------------------------- |
122 | //---------------------------------------------------------------------------------------------------- |
123 | int main(void) |
123 | int main(void) |
124 | { |
124 | { |
125 | static u8 oldCompassCalState = 0; |
125 | static u8 oldCompassCalState = 0; |
126 | 126 | ||
127 | // SCU_MCLKSourceConfig(SCU_MCLK_OSC); |
127 | // SCU_MCLKSourceConfig(SCU_MCLK_OSC); |
128 | // SCU_PCLKDivisorConfig(SCU_PCLK_Div2); |
128 | // SCU_PCLKDivisorConfig(SCU_PCLK_Div2); |
129 | // SCU_MCLKSourceConfig(SCU_MCLK_PLL); |
129 | // SCU_MCLKSourceConfig(SCU_MCLK_PLL); |
130 | 130 | ||
131 | 131 | ||
132 | SCU_MCLKSourceConfig(SCU_MCLK_OSC); |
132 | SCU_MCLKSourceConfig(SCU_MCLK_OSC); |
133 | SCU_PLLCmd(DISABLE); // PLL aus |
133 | SCU_PLLCmd(DISABLE); // PLL aus |
134 | SCU_RCLKDivisorConfig(SCU_RCLK_Div1); |
134 | SCU_RCLKDivisorConfig(SCU_RCLK_Div1); |
135 | SCU_HCLKDivisorConfig(SCU_HCLK_Div1); |
135 | SCU_HCLKDivisorConfig(SCU_HCLK_Div1); |
136 | SCU_PCLKDivisorConfig(SCU_PCLK_Div2); |
136 | SCU_PCLKDivisorConfig(SCU_PCLK_Div2); |
137 | // SCU_FMICLKDivisorConfig(SCU_FMICLK_Div1); |
137 | // SCU_FMICLKDivisorConfig(SCU_FMICLK_Div1); |
138 | // FMI_Config(FMI_READ_WAIT_STATE_3,FMI_WRITE_WAIT_STATE_0, FMI_PWD_ENABLE, FMI_LVD_ENABLE,FMI_FREQ_HIGH); |
138 | // FMI_Config(FMI_READ_WAIT_STATE_3,FMI_WRITE_WAIT_STATE_0, FMI_PWD_ENABLE, FMI_LVD_ENABLE,FMI_FREQ_HIGH); |
139 | SCU_PLLFactorsConfig(192,25,3); // PLL = 48 MHz |
139 | SCU_PLLFactorsConfig(192,25,3); // PLL = 48 MHz |
140 | 140 | ||
141 | SCU_PLLCmd(ENABLE); // PLL Enabled |
141 | SCU_PLLCmd(ENABLE); // PLL Enabled |
142 | 142 | ||
143 | SCU_MCLKSourceConfig(SCU_MCLK_PLL); // MCLK = PLL |
143 | SCU_MCLKSourceConfig(SCU_MCLK_PLL); // MCLK = PLL |
144 | 144 | ||
145 | 145 | ||
146 | VersionInfo.Hauptversion = VERSION_HAUPTVERSION; |
146 | VersionInfo.Hauptversion = VERSION_HAUPTVERSION; |
147 | VersionInfo.Nebenversion = VERSION_NEBENVERSION; |
147 | VersionInfo.Nebenversion = VERSION_NEBENVERSION; |
148 | VersionInfo.PCKompatibel = VERSION_KOMPATIBEL; |
148 | VersionInfo.PCKompatibel = VERSION_KOMPATIBEL; |
149 | 149 | ||
150 | SCU_AHBPeriphClockConfig(__VIC,ENABLE); |
150 | SCU_AHBPeriphClockConfig(__VIC,ENABLE); |
151 | SCU_AHBPeriphReset(__VIC,DISABLE); |
151 | SCU_AHBPeriphReset(__VIC,DISABLE); |
152 | VIC_DeInit(); |
152 | VIC_DeInit(); |
153 | 153 | ||
154 | InitInterrupt(); |
154 | InitInterrupt(); |
155 | 155 | ||
156 | Leds_Init(); |
156 | Leds_Init(); |
157 | Debug_UART1_Init(); |
157 | Debug_UART1_Init(); |
158 | OutputStartupData(); |
158 | OutputStartupData(); |
159 | 159 | ||
160 | GPS_UART0_Init(); |
160 | GPS_UART0_Init(); |
161 | USB_ConfigInit(); |
161 | USB_ConfigInit(); |
162 | 162 | ||
163 | 163 | ||
164 | SPI0_Init(); |
164 | SPI0_Init(); |
165 | 165 | ||
166 | 166 | ||
167 | 167 | ||
168 | TIMER1_Init(); |
168 | TIMER1_Init(); |
169 | I2C1_Init(); |
169 | I2C1_Init(); |
170 | 170 | ||
171 | I2C_Version.Hauptversion = 0xff; |
171 | I2C_Version.Hauptversion = 0xff; |
172 | 172 | ||
173 | SendI2C_Command(I2C_CMD_VERSION); |
173 | SendI2C_Command(I2C_CMD_VERSION); |
174 | 174 | ||
175 | TimerCompassUpdate = SetDelay(50); |
175 | TimerCompassUpdate = SetDelay(50); |
176 | while (!CheckDelay(TimerCompassUpdate)); |
176 | while (!CheckDelay(TimerCompassUpdate)); |
177 | 177 | ||
178 | TimerCompassUpdate = SetDelay(5); |
178 | TimerCompassUpdate = SetDelay(5); |
179 | TimerI2CReadDelay = SetDelay(5); |
179 | TimerI2CReadDelay = SetDelay(5); |
180 | 180 | ||
181 | /* |
181 | /* |
182 | InitFat16(); |
182 | InitFat16(); |
183 | 183 | ||
184 | ReadSetting(1); |
184 | ReadSetting(1); |
185 | */ |
185 | */ |
186 | SerialPutString("Init done\n\r."); |
186 | SerialPutString("Init done\n\r."); |
187 | SerialPutString("--------------\n\n\r"); |
187 | SerialPutString("--------------\n\n\r"); |
188 | 188 | ||
189 | for (;;) |
189 | for (;;) |
190 | { |
190 | { |
191 | if(NeuerDatensatzEmpfangen) |
191 | if(NeuerDatensatzEmpfangen) |
192 | { |
192 | { |
193 | BearbeiteRxDaten(); |
193 | BearbeiteRxDaten(); |
194 | DatenUebertragung(); |
194 | DatenUebertragung(); |
195 | // if (GPIO_ReadBit(GPIO5, GPIO_Pin_3)) SerialPutString("keine SD\n\r"); else SerialPutString("SD eingesteckt!\n\r"); |
195 | // if (GPIO_ReadBit(GPIO5, GPIO_Pin_3)) SerialPutString("keine SD\n\r"); else SerialPutString("SD eingesteckt!\n\r"); |
196 | 196 | ||
197 | } |
197 | } |
198 | 198 | ||
199 | 199 | ||
200 | UpdateSPI_Buffer(); |
200 | UpdateSPI_Buffer(); |
201 | SPI_CheckSlaveSelect(); |
201 | SPI_CheckSlaveSelect(); |
202 | UART1_Transmit(); |
202 | UART1_Transmit(); |
203 | 203 | ||
204 | // ----------- I2C Timing ------------------------- |
204 | // ----------- I2C Timing ------------------------- |
205 | if (CheckDelay(TimerCompassUpdate)) |
205 | if (CheckDelay(TimerCompassUpdate)) |
206 | { |
206 | { |
207 | if(oldCompassCalState != CompassCalState) |
207 | if(oldCompassCalState != CompassCalState) |
208 | { |
208 | { |
209 | oldCompassCalState = CompassCalState; |
209 | oldCompassCalState = CompassCalState; |
210 | TimerCompassUpdate = SetDelay(25); |
210 | TimerCompassUpdate = SetDelay(25); |
211 | SendI2C_Command(I2C_CMD_WRITE_CAL); |
211 | SendI2C_Command(I2C_CMD_WRITE_CAL); |
212 | } |
212 | } |
213 | else |
213 | else |
214 | { |
214 | { |
215 | GPIO_ToggleBit(GPIO5, GPIO_Pin_6); |
215 | GPIO_ToggleBit(GPIO5, GPIO_Pin_6); |
216 | GPIO_ToggleBit(GPIO5, GPIO_Pin_7); |
216 | GPIO_ToggleBit(GPIO5, GPIO_Pin_7); |
217 | TimerCompassUpdate = SetDelay(25); |
217 | TimerCompassUpdate = SetDelay(25); |
218 | SendI2C_Command(I2C_CMD_READ_HEADING); |
218 | SendI2C_Command(I2C_CMD_READ_HEADING); |
219 | } |
219 | } |
220 | 220 | ||
221 | } |
221 | } |
222 | 222 | ||
223 | if (CheckDelay(TimerI2CReadDelay)) |
223 | if (CheckDelay(TimerI2CReadDelay)) |
224 | { |
224 | { |
225 | if (I2C_ReadRequest) |
225 | if (I2C_ReadRequest) |
226 | { |
226 | { |
227 | I2C_ReadRequest= 0; |
227 | I2C_ReadRequest= 0; |
228 | 228 | ||
229 | I2C_Direction = I2C_MODE_RECEIVER; |
229 | I2C_Direction = I2C_MODE_RECEIVER; |
230 | I2C_GenerateStart(I2C1, ENABLE); |
230 | I2C_GenerateStart(I2C1, ENABLE); |
231 | } |
231 | } |
232 | TimerI2CReadDelay = SetDelay(1000); |
232 | TimerI2CReadDelay = SetDelay(1000); |
233 | } |
233 | } |
234 | 234 | ||
235 | if (CheckDelay(TimerDebugDataDelay)) |
235 | if (CheckDelay(TimerDebugDataDelay)) |
236 | { SendGPSPosAnforderung = 1; |
236 | { SendGPSPosAnforderung = 1; |
237 | DatenUebertragung(); |
237 | DatenUebertragung(); |
238 | 238 | ||
239 | TimerDebugDataDelay = SetDelay(500); |
239 | TimerDebugDataDelay = SetDelay(500); |
240 | } |
240 | } |
241 | // ---------------------------------------------------- |
241 | // ---------------------------------------------------- |
242 | } |
242 | } |
243 | } |
243 | } |
244 | 244 | ||
245 | 245 |