Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
886 killagreg 1
#include <inttypes.h>
2
#include "led.h"
3
#include "fc.h"
4
 
5
uint16_t LED1_Time = 0;
6
uint16_t LED2_Time = 0;
7
 
8
 
9
// initializes the LED control outputs J16, J17
10
void LED_Init(void)
11
{
12
    // set PC2 & PC3 as output (control of J16 & J17)
13
        DDRC |= (1<<DDC2)|(1<<DDC3);
14
        J16_OFF;
15
        J17_OFF;
16
}
17
 
18
 
19
// called in UpdateMotors() every 2ms
20
void LED_Update(void)
21
{
22
        static uint16_t J16_blinkcount = 0;
23
        static uint16_t J17_blinkcount = 0;
24
 
25
        if (LED1_Time < 20) J16_ON;
26
        else if(LED1_Time < 220)
27
        {
28
                if((2 * J16_blinkcount) < LED1_Time) J16_ON;
29
                else J16_OFF;
30
                if(J16_blinkcount++ >= LED1_Time) J16_blinkcount = 0;
31
        }
32
        else J16_ON;
33
 
906 killagreg 34
        if (LED2_Time < 20) J17_ON;
886 killagreg 35
        else if(LED2_Time < 220)
36
        {
37
                if((2 * J17_blinkcount) < LED2_Time) J17_ON;
38
                else J17_OFF;
39
                if(J17_blinkcount++ >= LED2_Time) J17_blinkcount = 0;
40
        }
906 killagreg 41
        else J17_ON;
886 killagreg 42
}