Rev 136 | Rev 141 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 136 | Rev 139 | ||
---|---|---|---|
Line 66... | Line 66... | ||
66 | #include "i2c.h" |
66 | #include "i2c.h" |
67 | #include "uart0.h" |
67 | #include "uart0.h" |
68 | #include "uart1.h" |
68 | #include "uart1.h" |
69 | #include "uart2.h" |
69 | #include "uart2.h" |
70 | #include "timer1.h" |
70 | #include "timer1.h" |
- | 71 | #include "timer2.h" |
|
- | 72 | #include "analog.h" |
|
71 | #include "main.h" |
73 | #include "main.h" |
72 | #include "waypoints.h" |
74 | #include "waypoints.h" |
73 | #include "mkprotocol.h" |
75 | #include "mkprotocol.h" |
Line 74... | Line 76... | ||
74 | 76 | ||
Line 204... | Line 206... | ||
204 | UART_InitStructure.UART_BaudRate = UART1_BAUD_RATE; |
206 | UART_InitStructure.UART_BaudRate = UART1_BAUD_RATE; |
205 | UART_InitStructure. UART_HardwareFlowControl = UART_HardwareFlowControl_None; |
207 | UART_InitStructure. UART_HardwareFlowControl = UART_HardwareFlowControl_None; |
206 | UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx; |
208 | UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx; |
207 | UART_InitStructure.UART_FIFO = UART_FIFO_Enable; |
209 | UART_InitStructure.UART_FIFO = UART_FIFO_Enable; |
208 | UART_InitStructure.UART_TxFIFOLevel = UART_FIFOLevel_1_2; |
210 | UART_InitStructure.UART_TxFIFOLevel = UART_FIFOLevel_1_2; |
209 | UART_InitStructure.UART_RxFIFOLevel = UART_FIFOLevel_1_8; |
211 | UART_InitStructure.UART_RxFIFOLevel = UART_FIFOLevel_1_2; |
Line 210... | Line 212... | ||
210 | 212 | ||
211 | UART_DeInit(UART1); // reset uart 1 to default |
213 | UART_DeInit(UART1); // reset uart 1 to default |
212 | UART_Init(UART1, &UART_InitStructure); // initialize uart 1 |
214 | UART_Init(UART1, &UART_InitStructure); // initialize uart 1 |
213 | // enable uart 1 interrupts selective |
215 | // enable uart 1 interrupts selective |
Line 262... | Line 264... | ||
262 | c = UART_ReceiveData(UART1); |
264 | c = UART_ReceiveData(UART1); |
Line 263... | Line 265... | ||
263 | 265 | ||
264 | // check for abort condition (ESC ESC 0x55 0xAA 0x00) |
266 | // check for abort condition (ESC ESC 0x55 0xAA 0x00) |
265 | switch (abortState) |
267 | switch (abortState) |
- | 268 | { |
|
266 | { |
269 | case 0: |
267 | case 0: if (c == 27) abortState++; |
270 | if (c == 27) abortState++; |
- | 271 | break; |
|
268 | break; |
272 | case 1: |
- | 273 | if (c == 27) abortState++; |
|
269 | case 1: if (c == 27) abortState++; else abortState = 0; |
274 | else abortState = 0; |
- | 275 | break; |
|
270 | break; |
276 | case 2: |
- | 277 | if (c == 0x55) abortState++; |
|
271 | case 2: if (c == 0x55) abortState++; else abortState = 0; |
278 | else abortState = 0; |
272 | break; |
- | |
273 | case 3: if (c == 0xAA) abortState++; else abortState = 0; |
279 | break; |
274 | break; |
280 | case 3: |
275 | case 4: if (c == 0x00) |
- | |
276 | { |
- | |
277 | DebugUART = UART1; |
- | |
278 | UART0_Connect_to_MKGPS(); |
- | |
279 | } |
281 | if (c == 0xAA) abortState++; |
280 | abortState = 0; |
282 | else abortState = 0; |
- | 283 | break; |
|
- | 284 | case 4: |
|
- | 285 | if (c == 0x00) |
|
- | 286 | { |
|
- | 287 | if(DebugUART == UART0) |
|
- | 288 | { |
|
- | 289 | UART0_Connect_to_MKGPS(); |
|
- | 290 | TIMER2_Init(); |
|
- | 291 | Analog_Init(); |
|
- | 292 | } |
|
281 | break; |
293 | DebugUART = UART1; |
- | 294 | } |
|
- | 295 | abortState = 0; |
|
- | 296 | break; |
|
282 | } |
297 | } // end switch abort state |
283 | // if the Debug uart is not UART1, redirect input to the Debug UART |
298 | // if the Debug uart is not UART1, redirect input to the Debug UART |
284 | if (DebugUART != UART1) |
299 | if (DebugUART != UART1) |
285 | { |
300 | { |
286 | // wait for space in the tx buffer of the DebugUART |
301 | // wait for space in the tx buffer of the DebugUART |
Line 352... | Line 367... | ||
352 | GPSData.Status = INVALID; |
367 | GPSData.Status = INVALID; |
353 | DebugUART = UART0; |
368 | DebugUART = UART0; |
354 | break; |
369 | break; |
355 | case UART_MKGPS: |
370 | case UART_MKGPS: |
356 | if(FC.MKFlags & MKFLAG_MOTOR_RUN) break; // not if the motors are running |
371 | if(FC.MKFlags & MKFLAG_MOTOR_RUN) break; // not if the motors are running |
- | 372 | TIMER2_Deinit(); |
|
- | 373 | Analog_Deinit(); |
|
357 | UART0_Connect_to_MKGPS(); // connect UART0 to MKGPS pins |
374 | UART0_Connect_to_MKGPS(); // connect UART0 to MKGPS pins |
358 | GPSData.Status = INVALID; |
375 | GPSData.Status = INVALID; |
359 | DebugUART = UART0; |
376 | DebugUART = UART0; |
360 | break; |
377 | break; |
361 | } |
378 | } |