Rev 1654 | Rev 1662 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1654 | Rev 1657 | ||
---|---|---|---|
Line 20... | Line 20... | ||
20 | #define BL_CTRL_ADDRESS 5 |
20 | #define BL_CTRL_ADDRESS 5 |
Line 21... | Line 21... | ||
21 | 21 | ||
22 | #define ABO_TIMEOUT 4000 // disable abo after 4 seconds |
22 | #define ABO_TIMEOUT 4000 // disable abo after 4 seconds |
23 | #define MAX_SENDE_BUFF 160 |
23 | #define MAX_SENDE_BUFF 160 |
- | 24 | #define MAX_EMPFANGS_BUFF 160 |
|
- | 25 | ||
- | 26 | ||
- | 27 | #define BLPARAM_REVISION 1 |
|
- | 28 | #define MASK_SET_PWM_SCALING 0x01 |
|
- | 29 | #define MASK_SET_CURRENT_LIMIT 0x02 |
|
- | 30 | #define MASK_SET_TEMP_LIMIT 0x04 |
|
- | 31 | #define MASK_SET_CURRENT_SCALING 0x08 |
|
- | 32 | #define MASK_SET_BITCONFIG 0x10 |
|
- | 33 | #define MASK_RESET_CAPCOUNTER 0x20 |
|
- | 34 | #define MASK_SET_DEFAULT_PARAMS 0x40 |
|
- | 35 | #define MASK_SET_SAVE_EEPROM 0x80 |
|
- | 36 | ||
- | 37 | typedef struct |
|
- | 38 | { |
|
- | 39 | unsigned char Revision; // revision of parameter structure |
|
- | 40 | unsigned char Address; // target address |
|
- | 41 | unsigned char PwmScaling; // maximum value of pwm setpoint |
|
- | 42 | unsigned char CurrentLimit; // current limit in 1A steps |
|
- | 43 | unsigned char TemperatureLimit; // in °C |
|
- | 44 | unsigned char CurrentScaling; // scaling factor for current measurement |
|
- | 45 | unsigned char BitConfig; // see defines above |
|
- | 46 | unsigned char SetMask; // filter for active paramters |
|
- | 47 | unsigned char Checksum; // checksum for parameter sturcture |
|
- | 48 | } __attribute__((packed)) BLParameter_t; |
|
- | 49 | ||
24 | #define MAX_EMPFANGS_BUFF 160 |
50 | |
25 | unsigned char GetExternalControl = 0,DebugDisplayAnforderung1 = 0, DebugDisplayAnforderung = 0,DebugDataAnforderung = 0,GetVersionAnforderung = 0, GetPPMChannelAnforderung = 0; |
51 | unsigned char GetExternalControl = 0,DebugDisplayAnforderung1 = 0, DebugDisplayAnforderung = 0,DebugDataAnforderung = 0,GetVersionAnforderung = 0, GetPPMChannelAnforderung = 0; |
26 | unsigned char DisplayLine = 0; |
52 | unsigned char DisplayLine = 0; |
27 | unsigned volatile char SioTmp = 0; |
53 | unsigned volatile char SioTmp = 0; |
28 | unsigned volatile char NeuerDatensatzEmpfangen = 0; |
54 | unsigned volatile char NeuerDatensatzEmpfangen = 0; |
Line 471... | Line 497... | ||
471 | break; |
497 | break; |
Line 472... | Line 498... | ||
472 | 498 | ||
473 | case 'g':// |
499 | case 'g':// |
474 | GetExternalControl = 1; |
500 | GetExternalControl = 1; |
- | 501 | break; |
|
- | 502 | ||
- | 503 | case 'u': // request BL parameter |
|
- | 504 | tempchar1 = pRxData[0]; |
|
- | 505 | Debug("Reading BL-Parameter %d", tempchar1); |
|
- | 506 | if( (tempchar1 > 0) && (tempchar1 <= MAX_MOTORS) ) |
|
- | 507 | { |
|
- | 508 | BLParameter_t BLParam; |
|
- | 509 | tempchar1--; |
|
- | 510 | BLParam.Revision = BLPARAM_REVISION; |
|
- | 511 | BLParam.Address = tempchar1+1; |
|
- | 512 | BLParam.PwmScaling = BLConfig[tempchar1].PwmScaling; |
|
- | 513 | BLParam.CurrentLimit = BLConfig[tempchar1].CurrentLimit; |
|
- | 514 | BLParam.TemperatureLimit = BLConfig[tempchar1].TempLimit; |
|
- | 515 | BLParam.CurrentScaling = BLConfig[tempchar1].CurrentScaling; |
|
- | 516 | BLParam.BitConfig = BLConfig[tempchar1].BitConfig; |
|
- | 517 | BLParam.SetMask = 0; |
|
- | 518 | BLParam.Checksum = RAM_Checksum((uint8_t*)&(BLConfig[tempchar1]), sizeof(BLParam)-1); |
|
- | 519 | while(!UebertragungAbgeschlossen); |
|
- | 520 | SendOutData('U', FC_ADDRESS, 1, &BLParam, sizeof(BLParam)); |
|
- | 521 | } |
|
- | 522 | break; |
|
- | 523 | ||
- | 524 | case 'w': // write BL parameter |
|
- | 525 | tempchar1 = 0; |
|
- | 526 | if(!(FCFlags & FCFLAG_MOTOR_RUN)) // save parameter only if motors are off |
|
- | 527 | { |
|
- | 528 | BLParameter_t *pBLParam = (BLParameter_t*)pRxData; |
|
- | 529 | // version and address check |
|
- | 530 | if( (pBLParam->Revision == BLPARAM_REVISION) && (pBLParam->Address <= MAX_MOTORS) ) |
|
- | 531 | { |
|
- | 532 | uint8_t i, start, end; |
|
- | 533 | if(pBLParam->Address == 0) |
|
- | 534 | { // all BLs |
|
- | 535 | start = 0; |
|
- | 536 | end = MAX_MOTORS - 1; |
|
- | 537 | } |
|
- | 538 | else |
|
- | 539 | { // only one specific |
|
- | 540 | start = pBLParam->Address - 1; |
|
- | 541 | end = start; |
|
- | 542 | } |
|
- | 543 | for(i = start; i <= end; i++) |
|
- | 544 | { |
|
- | 545 | if(pBLParam->SetMask & MASK_SET_DEFAULT_PARAMS) BLConfig_SetDefault(i); |
|
- | 546 | else |
|
- | 547 | { |
|
- | 548 | if(pBLParam->SetMask & MASK_SET_PWM_SCALING) BLConfig[i].PwmScaling = pBLParam->PwmScaling; |
|
- | 549 | if(pBLParam->SetMask & MASK_SET_CURRENT_LIMIT) BLConfig[i].CurrentLimit = pBLParam->CurrentLimit; |
|
- | 550 | if(pBLParam->SetMask & MASK_SET_TEMP_LIMIT) BLConfig[i].TempLimit = pBLParam->TemperatureLimit; |
|
- | 551 | if(pBLParam->SetMask & MASK_SET_CURRENT_SCALING) BLConfig[i].CurrentScaling = pBLParam->CurrentScaling; |
|
- | 552 | if(pBLParam->SetMask & MASK_SET_BITCONFIG) BLConfig[i].BitConfig = pBLParam->BitConfig; |
|
- | 553 | BLConfig[i].crc = RAM_Checksum((uint8_t*)&(BLConfig[i]), sizeof(BLConfig_t)-1); // update crc |
|
- | 554 | ||
- | 555 | } |
|
- | 556 | if(pBLParam->SetMask & MASK_SET_SAVE_EEPROM) BLConfig_WriteToEEProm(i); |
|
- | 557 | } |
|
- | 558 | I2C_SendBLConfig(); |
|
- | 559 | tempchar1 = 1; |
|
- | 560 | } |
|
- | 561 | } |
|
- | 562 | while(!UebertragungAbgeschlossen); |
|
- | 563 | SendOutData('W', FC_ADDRESS,1, &tempchar1, sizeof(tempchar1)); |
|
- | 564 | break; |
|
- | 565 | ||
- | 566 | default: |
|
- | 567 | //unsupported command received |
|
475 | break; |
568 | break; |
476 | } |
569 | } |
477 | break; // default: |
570 | break; // default: |
478 | } |
571 | } |
479 | NeuerDatensatzEmpfangen = 0; |
572 | NeuerDatensatzEmpfangen = 0; |