Subversion Repositories FlightCtrl

Rev

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

Rev 935 Rev 936
Line 96... Line 96...
96
 
96
 
97
        // get board release
97
        // get board release
98
    DDRB  = 0x00;
98
    DDRB  = 0x00;
99
    PORTB = 0x00;
99
    PORTB = 0x00;
-
 
100
    for(timer = 0; timer < 1000; timer++); // make some delay
-
 
101
    if(PINB & (1<<PINB0))
100
    for(timer = 0; timer < 1000; timer++); // make some delay
102
    {
-
 
103
                if(PINB & (1<<PINB1)) BoardRelease = 13;
-
 
104
                else BoardRelease = 11;
101
    if(PINB & (1<<PINB0)) BoardRelease = 11;
105
        }
Line 102... Line 106...
102
    else BoardRelease = 10;
106
    else BoardRelease = 10;
103
 
107
 
104
        // set LED ports as output
108
        // set LED ports as output
105
        DDRB |= (1<<DDB1)|(1<<DDB0);
109
        DDRB |= (1<<DDB1)|(1<<DDB0);
Line 106... Line 110...
106
        ROT_ON;
110
        RED_ON;
107
        GRN_OFF;
111
        GRN_OFF;
108
 
112
 
Line 116... Line 120...
116
        PPM_in[CH_GAS] = 0;
120
        PPM_in[CH_GAS] = 0;
117
        StickYaw = 0;
121
        StickYaw = 0;
118
        StickRoll = 0;
122
        StickRoll = 0;
119
        StickNick = 0;
123
        StickNick = 0;
Line 120... Line 124...
120
 
124
 
Line 121... Line 125...
121
    ROT_OFF;
125
    RED_OFF;
122
 
126
 
123
        // initalize modules
127
        // initalize modules
124
        LED_Init();
128
        //LED_Init(); Is done within ParamSet_Init() below
125
    TIMER0_Init();
129
    TIMER0_Init();
Line 126... Line 130...
126
    TIMER2_Init();
130
    TIMER2_Init();
Line 150... Line 154...
150
        sei();
154
        sei();
Line 151... Line 155...
151
 
155
 
152
    VersionInfo.Major = VERSION_MAJOR;
156
    VersionInfo.Major = VERSION_MAJOR;
153
    VersionInfo.Minor = VERSION_MINOR;
157
    VersionInfo.Minor = VERSION_MINOR;
-
 
158
    VersionInfo.PCCompatible = VERSION_COMPATIBLE;
Line 154... Line 159...
154
    VersionInfo.PCCompatible = VERSION_COMPATIBLE;
159
    VersionInfo.Hardware = 1; // Flight Control
155
 
160
 
156
        printf("\n\rFlightControl\n\rHardware:%d.%d\n\rSoftware:V%d.%d%c ",BoardRelease/10,BoardRelease%10, VERSION_MAJOR, VERSION_MINOR,VERSION_INDEX + 'a');
161
        printf("\n\rFlightControl\n\rHardware:%d.%d\n\rSoftware:V%d.%d%c ",BoardRelease/10,BoardRelease%10, VERSION_MAJOR, VERSION_MINOR,VERSION_INDEX + 'a');
Line 209... Line 214...
209
 
214
 
Line 210... Line 215...
210
 
215
 
Line 211... Line 216...
211
 
216
 
212
        SetNeutral();
217
        SetNeutral();
Line 229... Line 234...
229
 
234
 
230
        while (1)
235
        while (1)
231
        {
236
        {
232
        if(UpdateMotor)      // control interval
237
        if(UpdateMotor)      // control interval
233
        {
238
        {
234
                        UpdateMotor=0; // reset Flag, is enabled every 2 ms by isr of timer0
239
                        UpdateMotor = 0; // reset Flag, is enabled every 2 ms by isr of timer0
235
                        //PORTD |= (1<<PORTD4);
240
                        //PORTD |= (1<<PORTD4);
236
            MotorControl();
241
            MotorControl();
Line 237... Line 242...
237
                        //PORTD &= ~(1<<PORTD4);
242
                        //PORTD &= ~(1<<PORTD4);
Line 238... Line 243...
238
 
243
 
Line 239... Line 244...
239
                        SendMotorData();
244
                        SendMotorData();
240
 
245
 
241
            ROT_OFF;
246
            RED_OFF;
242
 
247
 
Line 253... Line 258...
253
 
258
 
254
            if(!I2CTimeout)
259
            if(!I2CTimeout)
255
            {
260
            {
256
                                I2CTimeout = 5;
261
                                I2CTimeout = 5;
257
                                I2C_Reset();
262
                                I2C_Reset();
258
                                if((BeepModulation == 0xFFFF) && MotorsOn)
263
                                if((BeepModulation == 0xFFFF) && (MKFlags & MKFLAG_MOTOR_RUN) )
259
                                {
264
                                {
260
                                        BeepTime = 10000; // 1 second
265
                                        BeepTime = 10000; // 1 second
261
                                        BeepModulation = 0x0080;
266
                                        BeepModulation = 0x0080;
262
                                }
267
                                }
263
                        }
268
                        }
264
                        else
269
                        else
265
                        {
270
                        {
266
                                I2CTimeout--;
271
                                I2CTimeout--;
267
                                ROT_OFF;
272
                                RED_OFF;
Line 268... Line 273...
268
                        }
273
                        }
269
 
274
 
270
                        if(SIO_DEBUG && (!UpdateMotor || !MotorsOn))
275
                        if(SIO_DEBUG && (!UpdateMotor || !(MKFlags & MKFLAG_MOTOR_RUN) ))
271
                        {
276
                        {
272
                                USART0_TransmitTxData();
277
                                USART0_TransmitTxData();
273
                                USART0_ProcessRxData();
278
                                USART0_ProcessRxData();
Line 288... Line 293...
288
                                SPI_StartTransmitPacket();
293
                                SPI_StartTransmitPacket();
289
                                SendSPI = 4;
294
                                SendSPI = 4;
290
                                #endif
295
                                #endif
291
                                timer = SetDelay(20); // every 20 ms
296
                                timer = SetDelay(20); // every 20 ms
292
            }
297
            }
-
 
298
 
-
 
299
            LED_Update();
293
                }
300
                }
Line 294... Line 301...
294
 
301
 
295
                #ifdef USE_NAVICTRL
302
                #ifdef USE_NAVICTRL
296
                if(!SendSPI)
303
                if(!SendSPI)