Rev 2316 | Rev 2342 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2316 | Rev 2340 | ||
---|---|---|---|
Line 62... | Line 62... | ||
62 | #define NC_ADDRESS 2 |
62 | #define NC_ADDRESS 2 |
63 | #define MK3MAG_ADDRESS 3 |
63 | #define MK3MAG_ADDRESS 3 |
64 | #define BL_CTRL_ADDRESS 5 |
64 | #define BL_CTRL_ADDRESS 5 |
Line 65... | Line 65... | ||
65 | 65 | ||
66 | #define ABO_TIMEOUT 4000 // disable abo after 4 seconds |
66 | #define ABO_TIMEOUT 4000 // disable abo after 4 seconds |
67 | #define MAX_SENDE_BUFF 175 |
67 | #define MAX_SENDE_BUFF 220 |
Line 68... | Line 68... | ||
68 | #define MAX_EMPFANGS_BUFF 175 |
68 | #define MAX_EMPFANGS_BUFF 220 |
69 | 69 | ||
70 | #define BLPARAM_REVISION 1 |
70 | #define BLPARAM_REVISION 1 |
71 | #define MASK_SET_PWM_SCALING 0x01 |
71 | #define MASK_SET_PWM_SCALING 0x01 |
Line 204... | Line 204... | ||
204 | { |
204 | { |
205 | LcdClear(); |
205 | LcdClear(); |
206 | wdt_enable(WDTO_250MS); // Reset-Commando |
206 | wdt_enable(WDTO_250MS); // Reset-Commando |
207 | ServoActive = 0; |
207 | ServoActive = 0; |
208 | } |
208 | } |
209 | - | ||
210 | } |
209 | } |
211 | } |
210 | } |
212 | else |
211 | else |
213 | switch(UartState) |
212 | switch(UartState) |
214 | { |
213 | { |
Line 242... | Line 241... | ||
242 | unsigned int tmpCRC = 0,i; |
241 | unsigned int tmpCRC = 0,i; |
243 | for(i = 0; i < wieviele;i++) |
242 | for(i = 0; i < wieviele;i++) |
244 | { |
243 | { |
245 | tmpCRC += TxdBuffer[i]; |
244 | tmpCRC += TxdBuffer[i]; |
246 | } |
245 | } |
- | 246 | // if(i > MAX_SENDE_BUFF - 3) tmpCRC += 11; |
|
247 | tmpCRC %= 4096; |
247 | tmpCRC %= 4096; |
248 | TxdBuffer[i++] = '=' + tmpCRC / 64; |
248 | TxdBuffer[i++] = '=' + tmpCRC / 64; |
249 | TxdBuffer[i++] = '=' + tmpCRC % 64; |
249 | TxdBuffer[i++] = '=' + tmpCRC % 64; |
250 | TxdBuffer[i++] = '\r'; |
250 | TxdBuffer[i++] = '\r'; |
251 | UebertragungAbgeschlossen = 0; |
251 | UebertragungAbgeschlossen = 0; |
252 | UDR0 = TxdBuffer[0]; |
252 | UDR0 = TxdBuffer[0]; |
- | 253 | //if(DebugOut.Analog[] < i) DebugOut.Analog[] = i; |
|
253 | } |
254 | } |
Line 254... | Line -... | ||
254 | - | ||
255 | 255 | ||
256 | 256 | ||
257 | // -------------------------------------------------------------------------- |
257 | // -------------------------------------------------------------------------- |
258 | void SendOutData(unsigned char cmd,unsigned char address, unsigned char BufferAnzahl, ...) //unsigned char *snd, unsigned char len) |
258 | void SendOutData(unsigned char cmd,unsigned char address, unsigned char BufferAnzahl, ...) //unsigned char *snd, unsigned char len) |
259 | { |
259 | { |
Line 408... | Line 408... | ||
408 | PcZugriff = 255; |
408 | PcZugriff = 255; |
409 | break; |
409 | break; |
Line 410... | Line 410... | ||
410 | 410 | ||
411 | case 'q':// "Get"-Anforderung für Settings |
411 | case 'q':// "Get"-Anforderung für Settings |
- | 412 | // Bei Get werden die vom PC einstellbaren Werte vom PC zurückgelesen |
|
412 | // Bei Get werden die vom PC einstellbaren Werte vom PC zurückgelesen |
413 | if(MotorenEin) break; |
413 | if((10 <= pRxData[0]) && (pRxData[0] < 20)) |
414 | if((10 <= pRxData[0]) && (pRxData[0] < 20)) |
414 | { |
415 | { |
415 | tempchar1 = pRxData[0] - 10; |
416 | tempchar1 = pRxData[0] - 10; |
416 | if(tempchar1< 1) tempchar1 = 1; // limit to 1 |
417 | if(tempchar1< 1) tempchar1 = 1; // limit to 1 |
Line 437... | Line 438... | ||
437 | ParamSet_ReadFromEEProm(tempchar1); |
438 | ParamSet_ReadFromEEProm(tempchar1); |
438 | } |
439 | } |
439 | while(!UebertragungAbgeschlossen); |
440 | while(!UebertragungAbgeschlossen); |
440 | SendOutData('Q', FC_ADDRESS, 2, &tempchar1, sizeof(tempchar1), (unsigned char *) &EE_Parameter, sizeof(EE_Parameter) - 1); |
441 | SendOutData('Q', FC_ADDRESS, 2, &tempchar1, sizeof(tempchar1), (unsigned char *) &EE_Parameter, sizeof(EE_Parameter) - 1); |
441 | Debug("Lese Setting %d", tempchar1); |
442 | Debug("Lese Setting %d", tempchar1); |
442 | - | ||
443 | break; |
443 | break; |
Line 444... | Line 444... | ||
444 | 444 | ||
445 | case 's': // Parametersatz speichern |
445 | case 's': // Parametersatz speichern |
446 | if((1 <= pRxData[0]) && (pRxData[0] <= 5) && (pRxData[1] == EEPARAM_REVISION) && MotorenEin == 0) // check for setting to be in range |
446 | if((1 <= pRxData[0]) && (pRxData[0] <= 5) && (pRxData[1] == EEPARAM_REVISION) && MotorenEin == 0) // check for setting to be in range |
Line 460... | Line 460... | ||
460 | if(!MotorenEin) Piep(tempchar1,110); |
460 | if(!MotorenEin) Piep(tempchar1,110); |
461 | LipoDetection(0); |
461 | LipoDetection(0); |
462 | LIBFC_ReceiverInit(EE_Parameter.Receiver); |
462 | LIBFC_ReceiverInit(EE_Parameter.Receiver); |
463 | break; |
463 | break; |
464 | case 'f': // auf anderen Parametersatz umschalten |
464 | case 'f': // auf anderen Parametersatz umschalten |
- | 465 | if(MotorenEin) break; |
|
465 | if((1 <= pRxData[0]) && (pRxData[0] <= 5)) ParamSet_ReadFromEEProm(pRxData[0]); |
466 | if((1 <= pRxData[0]) && (pRxData[0] <= 5)) ParamSet_ReadFromEEProm(pRxData[0]); |
466 | tempchar1 = GetActiveParamSet(); |
467 | tempchar1 = GetActiveParamSet(); |
467 | while(!UebertragungAbgeschlossen); |
468 | while(!UebertragungAbgeschlossen); |
468 | SendOutData('F', FC_ADDRESS, 1, &tempchar1, sizeof(tempchar1)); |
469 | SendOutData('F', FC_ADDRESS, 1, &tempchar1, sizeof(tempchar1)); |
469 | if(!MotorenEin) Piep(tempchar1,110); |
470 | Piep(tempchar1,110); |
470 | LipoDetection(0); |
471 | LipoDetection(0); |
471 | LIBFC_ReceiverInit(EE_Parameter.Receiver); |
472 | LIBFC_ReceiverInit(EE_Parameter.Receiver); |
472 | break; |
473 | break; |
473 | case 'y':// serial Potis |
474 | case 'y':// serial Potis |
474 | PPM_in[13] = (signed char) pRxData[0]; PPM_in[14] = (signed char) pRxData[1]; PPM_in[15] = (signed char) pRxData[2]; PPM_in[16] = (signed char) pRxData[3]; |
475 | for(tempchar1 = 0; tempchar1 < 12; tempchar1++) PPM_in[SERIAL_POTI_START + tempchar1] = (signed char) pRxData[tempchar1]; |
475 | PPM_in[17] = (signed char) pRxData[4]; PPM_in[18] = (signed char) pRxData[5]; PPM_in[19] = (signed char) pRxData[6]; PPM_in[20] = (signed char) pRxData[7]; |
- | |
476 | PPM_in[21] = (signed char) pRxData[8]; PPM_in[22] = (signed char) pRxData[9]; PPM_in[23] = (signed char) pRxData[10]; PPM_in[24] = (signed char) pRxData[11]; |
- | |
477 | break; |
476 | break; |
478 | - | ||
479 | case 'u': // request BL parameter |
477 | case 'u': // request BL parameter |
480 | Debug("Reading BL %d", pRxData[0]); |
478 | Debug("Reading BL %d", pRxData[0]); |
481 | // try to read BL configuration |
479 | // try to read BL configuration |
482 | tempchar2 = I2C_ReadBLConfig(pRxData[0]); |
480 | tempchar2 = I2C_ReadBLConfig(pRxData[0]); |
483 | if(tempchar2 == BLCONFIG_SUCCESS) tempchar1 = 1; |
481 | if(tempchar2 == BLCONFIG_SUCCESS) tempchar1 = 1; |
484 | else tempchar1 = 0; |
482 | else tempchar1 = 0; |
485 | while(!UebertragungAbgeschlossen); // wait for previous frame to be sent |
483 | while(!UebertragungAbgeschlossen); // wait for previous frame to be sent |
486 | SendOutData('U', FC_ADDRESS, 4, &tempchar1, sizeof(tempchar1), &tempchar2, sizeof(tempchar2), &pRxData[0], 1, &BLConfig, sizeof(BLConfig_t)); |
484 | SendOutData('U', FC_ADDRESS, 4, &tempchar1, sizeof(tempchar1), &tempchar2, sizeof(tempchar2), &pRxData[0], 1, &BLConfig, sizeof(BLConfig_t)); |
487 | break; |
485 | break; |
488 | - | ||
489 | case 'w': // write BL parameter |
486 | case 'w': // write BL parameter |
490 | Debug("Writing BL %d", pRxData[0]); |
487 | Debug("Writing BL %d", pRxData[0]); |
491 | if(RxDataLen >= 1+sizeof(BLConfig_t)) |
488 | if(RxDataLen >= 1+sizeof(BLConfig_t)) |
492 | { |
489 | { |
493 | memcpy(&BLConfig, (uint8_t*)(&pRxData[1]), sizeof(BLConfig_t)); |
490 | memcpy(&BLConfig, (uint8_t*)(&pRxData[1]), sizeof(BLConfig_t)); |