Subversion Repositories FlightCtrl

Rev

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

Rev 1635 Rev 1645
Line 84... Line 84...
84
uint8_t Request_Display                 = FALSE;
84
uint8_t Request_Display                 = FALSE;
85
uint8_t Request_Display1                = FALSE;
85
uint8_t Request_Display1                = FALSE;
86
uint8_t Request_DebugData               = FALSE;
86
uint8_t Request_DebugData               = FALSE;
87
uint8_t Request_Data3D                  = FALSE;
87
uint8_t Request_Data3D                  = FALSE;
88
uint8_t Request_DebugLabel              = 255;
88
uint8_t Request_DebugLabel              = 255;
89
uint8_t Request_PPMChannels             = FALSE;
89
uint8_t Request_PPMChannels     = FALSE;
90
uint8_t Request_MotorTest               = FALSE;
90
uint8_t Request_MotorTest               = FALSE;
91
uint8_t DisplayLine = 0;
91
uint8_t DisplayLine = 0;
Line 92... Line 92...
92
 
92
 
93
volatile uint8_t txd_buffer[TXD_BUFFER_LEN];
93
volatile uint8_t txd_buffer[TXD_BUFFER_LEN];
Line 123... Line 123...
123
const prog_uint8_t ANALOG_LABEL[32][16] = {
123
const prog_uint8_t ANALOG_LABEL[32][16] = {
124
    //1234567890123456
124
    //1234567890123456
125
    "AnglePitch      ", //0
125
    "AnglePitch      ", //0
126
    "AngleRoll       ",
126
    "AngleRoll       ",
127
    "AngleYaw        ",
127
    "AngleYaw        ",
128
    "GyroPitch       ",
128
    "GyroPitch(AC)   ",
129
    "GyroRoll        ",
129
    "GyroRoll(AC)    ",
130
    "GyroYaw         ", //5
130
    "GyroYaw(AC)     ", //5
131
    "ControlPitch    ",
131
    "Pitch_Raw       ",
132
    "ControlRoll     ",
132
    "HiResPitch_PID  ",
133
    "ControlYaw      ",
133
    "PitchGyroOffset ",
134
    "SetPointYaw     ",
134
    "Roll_Raw        ",
135
    "YawRateIFactor  ", //10
135
    "HiResRoll_PID   ", //10
136
    "Gyro I Factor   ",
136
    "rollGyroOffset  ",
137
    "                ",
137
    "Pressure range  ",
138
    "                ",
138
    "Pressure A/D    ",
139
    "R/C Var 4       ",
139
    "Pressure Value  ",
140
    "User Param 4    ", //15
140
    "Press. rangewidz", //15
141
    "RCQuality       ",
141
    "Press. init A/D ",
142
    "Ext. Quality    ",
142
    "Ext. Quality    ",
143
    "Looping         ",
143
    "Looping         ",
144
    "throttleTerm    ",
144
    "throttleTerm    ",
145
    "pitchTerm       ", //20
145
    "pitchTerm       ", //20
146
    "rollTerm        ",
146
    "rollTerm        ",
Line 157... Line 157...
157
  };
157
  };
Line 158... Line 158...
158
 
158
 
159
/****************************************************************/
159
/****************************************************************/
160
/*              Initialization of the USART0                    */
160
/*              Initialization of the USART0                    */
161
/****************************************************************/
161
/****************************************************************/
162
void USART0_Init (void) {
162
void usart0_Init (void) {
163
  uint8_t sreg = SREG;
163
  uint8_t sreg = SREG;
Line 164... Line 164...
164
  uint16_t ubrr = (uint16_t) ((uint32_t) SYSCLK/(8 * USART0_BAUD) - 1);
164
  uint16_t ubrr = (uint16_t) ((uint32_t) SYSCLK/(8 * USART0_BAUD) - 1);
165
 
165
 
Line 423... Line 423...
423
  pRxData = &rxd_buffer[3];
423
  pRxData = &rxd_buffer[3];
424
  RxDataLen = ptrOut - 3;
424
  RxDataLen = ptrOut - 3;
425
}
425
}
Line 426... Line 426...
426
 
426
 
427
// --------------------------------------------------------------------------
427
// --------------------------------------------------------------------------
428
void USART0_ProcessRxData(void) {
428
void usart0_ProcessRxData(void) {
429
  // if data in the rxd buffer are not locked immediately return
429
  // if data in the rxd buffer are not locked immediately return
Line 430... Line 430...
430
  if(!rxd_buffer_locked) return;
430
  if(!rxd_buffer_locked) return;
Line 583... Line 583...
583
  pRxData = 0;
583
  pRxData = 0;
584
  RxDataLen = 0;
584
  RxDataLen = 0;
585
  rxd_buffer_locked = FALSE;
585
  rxd_buffer_locked = FALSE;
586
}
586
}
Line 587... Line 587...
587
 
587
 
588
//############################################################################
588
/************************************************************************/
589
//Routine für die Serielle Ausgabe
589
/* Routine für die Serielle Ausgabe                                     */
590
//############################################################################
590
/************************************************************************/
591
int16_t uart_putchar (int8_t c) {
591
int16_t uart_putchar (int8_t c) {
592
  if (c == '\n')
592
  if (c == '\n')
593
    uart_putchar('\r');
593
    uart_putchar('\r');
594
  // wait until previous character was send
594
  // wait until previous character was send
Line 597... Line 597...
597
  UDR0 = c;
597
  UDR0 = c;
598
  return (0);
598
  return (0);
599
}
599
}
Line 600... Line 600...
600
 
600
 
601
//---------------------------------------------------------------------------------------------
601
//---------------------------------------------------------------------------------------------
602
void USART0_TransmitTxData(void) {
602
void usart0_TransmitTxData(void) {
Line 603... Line 603...
603
  if(!txd_complete) return;
603
  if(!txd_complete) return;
604
 
604
 
605
  if(Request_VerInfo && txd_complete) {
605
  if(Request_VerInfo && txd_complete) {
Line 619... Line 619...
619
    LCD_PrintMenu();
619
    LCD_PrintMenu();
620
    SendOutData('L', FC_ADDRESS, 3, &MenuItem, sizeof(MenuItem), &MaxMenuItem, sizeof(MaxMenuItem), DisplayBuff, sizeof(DisplayBuff));
620
    SendOutData('L', FC_ADDRESS, 3, &MenuItem, sizeof(MenuItem), &MaxMenuItem, sizeof(MaxMenuItem), DisplayBuff, sizeof(DisplayBuff));
621
    Request_Display1 = FALSE;
621
    Request_Display1 = FALSE;
622
  }
622
  }
Line 623... Line 623...
623
 
623
 
624
  if(Request_DebugLabel != 0xFF) { // Texte für die Analogdaten
624
  if(Request_DebugLabel != 0xFF) { // Texte für die Analogdaten
625
    uint8_t label[16]; // local sram buffer
625
    uint8_t label[16]; // local sram buffer
626
    memcpy_P(label, ANALOG_LABEL[Request_DebugLabel], 16); // read lable from flash to sram buffer
626
    memcpy_P(label, ANALOG_LABEL[Request_DebugLabel], 16); // read lable from flash to sram buffer
627
    SendOutData('A', FC_ADDRESS, 2, (uint8_t *) &Request_DebugLabel, sizeof(Request_DebugLabel), label, 16);
627
    SendOutData('A', FC_ADDRESS, 2, (uint8_t *) &Request_DebugLabel, sizeof(Request_DebugLabel), label, 16);
628
    Request_DebugLabel = 0xFF;
628
    Request_DebugLabel = 0xFF;
Line 629... Line 629...
629
  }
629
  }
630
 
630
 
631
  if(ConfirmFrame && txd_complete) {   // Datensatz ohne CRC bestätigen
631
  if(ConfirmFrame && txd_complete) {   // Datensatz ohne CRC bestätigen
632
    SendOutData('B', FC_ADDRESS, 1, (uint8_t*)&ConfirmFrame, sizeof(ConfirmFrame));
632
    SendOutData('B', FC_ADDRESS, 1, (uint8_t*)&ConfirmFrame, sizeof(ConfirmFrame));
Line 633... Line 633...
633
    ConfirmFrame = 0;
633
    ConfirmFrame = 0;
Line 639... Line 639...
639
    Request_DebugData = FALSE;
639
    Request_DebugData = FALSE;
640
  }
640
  }
Line 641... Line 641...
641
 
641
 
642
  if( ((Data3D_Interval && CheckDelay(Data3D_Timer)) || Request_Data3D) && txd_complete) {
642
  if( ((Data3D_Interval && CheckDelay(Data3D_Timer)) || Request_Data3D) && txd_complete) {
643
    SendOutData('C', FC_ADDRESS, 1,(uint8_t *) &Data3D, sizeof(Data3D));
643
    SendOutData('C', FC_ADDRESS, 1,(uint8_t *) &Data3D, sizeof(Data3D));
644
    Data3D.AngleNick = (int16_t)((10 * pitchAngle) / GYRO_DEG_FACTOR_PITCHROLL); // convert to multiple of 0.1°
644
    Data3D.AngleNick = (int16_t)((10 * angle[PITCH]) / GYRO_DEG_FACTOR_PITCHROLL); // convert to multiple of 0.1°
645
    Data3D.AngleRoll = (int16_t)((10 * rollAngle) / GYRO_DEG_FACTOR_PITCHROLL); // convert to multiple of 0.1°
645
    Data3D.AngleRoll = (int16_t)((10 * angle[ROLL]) / GYRO_DEG_FACTOR_PITCHROLL); // convert to multiple of 0.1°
646
    Data3D.Heading   = (int16_t)((10 * yawGyroHeading)   / GYRO_DEG_FACTOR_YAW); // convert to multiple of 0.1°
646
    Data3D.Heading   = (int16_t)((10 * yawGyroHeading)   / GYRO_DEG_FACTOR_YAW); // convert to multiple of 0.1°
647
    Data3D_Timer = SetDelay(Data3D_Interval);
647
    Data3D_Timer = SetDelay(Data3D_Interval);
648
    Request_Data3D = FALSE;
648
    Request_Data3D = FALSE;
Line 653... Line 653...
653
    Request_ExternalControl = FALSE;
653
    Request_ExternalControl = FALSE;
654
  }
654
  }
Line 655... Line 655...
655
 
655
 
656
#ifdef USE_MK3MAG
656
#ifdef USE_MK3MAG
657
  if((CheckDelay(Compass_Timer)) && txd_complete) {
657
  if((CheckDelay(Compass_Timer)) && txd_complete) {
658
    ToMk3Mag.Attitude[0] = (int16_t)((10 * pitchAngle) / GYRO_DEG_FACTOR_PITCH_ROLL);  // approx. 0.1 deg
658
    ToMk3Mag.Attitude[0] = (int16_t)((10 * angle[PITCH]) / GYRO_DEG_FACTOR_PITCH_ROLL);  // approx. 0.1 deg
659
    ToMk3Mag.Attitude[1] = (int16_t)((10 * rollAngle) / GYRO_DEG_FACTOR_PITCH_ROLL);  // approx. 0.1 deg
659
    ToMk3Mag.Attitude[1] = (int16_t)((10 * angle[ROLL]) / GYRO_DEG_FACTOR_PITCH_ROLL);  // approx. 0.1 deg
660
    ToMk3Mag.UserParam[0] = dynamicParams.UserParams[0];
660
    ToMk3Mag.UserParam[0] = dynamicParams.UserParams[0];
661
    ToMk3Mag.UserParam[1] = dynamicParams.UserParams[1];
661
    ToMk3Mag.UserParam[1] = dynamicParams.UserParams[1];
662
    ToMk3Mag.CalState = CompassCalState;
662
    ToMk3Mag.CalState = CompassCalState;
663
    SendOutData('w', MK3MAG_ADDRESS, 1,(uint8_t *) &ToMk3Mag,sizeof(ToMk3Mag));
663
    SendOutData('w', MK3MAG_ADDRESS, 1,(uint8_t *) &ToMk3Mag,sizeof(ToMk3Mag));