Subversion Repositories FlightCtrl

Rev

Rev 1657 | Rev 1665 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1657 Rev 1662
Line 425... Line 425...
425
                                        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];
425
                                        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];
426
                                        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];
426
                                        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];
427
                                        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];
427
                                        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];
428
                                        break;
428
                                        break;
Line -... Line 429...
-
 
429
 
-
 
430
                        case 'u': // request BL parameter
-
 
431
                                Debug("Reading BL %d", pRxData[0]);
-
 
432
                                // try to read BL configuration
-
 
433
                                tempchar1 = I2C_ReadBLConfig(pRxData[0]);
-
 
434
                                if(tempchar1)
-
 
435
                                {
-
 
436
                                        while(!UebertragungAbgeschlossen); // wait for previous frame to be sent
-
 
437
                                        SendOutData('U', FC_ADDRESS, 2, tempchar1, 1, &BLConfig, sizeof(BLConfig_t));
-
 
438
                                }
-
 
439
                                break;
-
 
440
 
-
 
441
                        case 'w': // write BL parameter
-
 
442
                                Debug("Writing BL %d", pRxData[0]);
-
 
443
                                if(RxDataLen >= 1+sizeof(BLConfig_t))
-
 
444
                                {
-
 
445
                                        memcpy(&BLConfig, (uint8_t*)(&pRxData[1]), sizeof(BLConfig_t));
-
 
446
                                        // tbd. in MK-Tool
-
 
447
                                        BLConfig.crc = RAM_Checksum((uint8_t*)&BLConfig, sizeof(BLConfig_t) - 1); // update crc
-
 
448
                                        tempchar1 = I2C_WriteBLConfig(pRxData[0]);
-
 
449
                                        while(!UebertragungAbgeschlossen); // wait for previous frame to be sent
-
 
450
                                        SendOutData('W', FC_ADDRESS,1, &tempchar1, sizeof(tempchar1));
-
 
451
                                }
-
 
452
                                break;
429
 
453
 
Line 430... Line 454...
430
                } // case FC_ADDRESS:
454
                } // case FC_ADDRESS:
Line 431... Line 455...
431
 
455
 
432
                default: // any Slave Address
456
                default: // any Slave Address
433
 
457
 
434
                switch(RxdBuffer[2])
458
                switch(RxdBuffer[2])
435
                {
459
                {
436
                        // 't' comand placed here only for compatibility to BL
460
                        // 't' comand placed here only for compatibility to BL
437
                        case 't':// Motortest
461
                        case 't':// Motortest
438
                                if(AnzahlEmpfangsBytes > 10) memcpy(&MotorTest[0], (unsigned char *)pRxData, sizeof(MotorTest));
462
                                if(AnzahlEmpfangsBytes >= sizeof(MotorTest)) memcpy(&MotorTest[0], (unsigned char *)pRxData, sizeof(MotorTest));
439
                                else memcpy(&MotorTest[0], (unsigned char *)pRxData, 4);
463
                                else memcpy(&MotorTest[0], (unsigned char *)pRxData, 4);
440
                                        while(!UebertragungAbgeschlossen);
464
                                        while(!UebertragungAbgeschlossen);
Line 498... Line 522...
498
 
522
 
499
                        case 'g'://
523
                        case 'g'://
500
                                        GetExternalControl = 1;
524
                                        GetExternalControl = 1;
Line 501... Line -...
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;
525
                                        break;
565
 
526
 
566
                        default:
527
                        default:
567
                                //unsupported command received
528
                                //unsupported command received
568
                                break;
529
                                break;