Subversion Repositories Projects

Rev

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

Rev 273 Rev 274
Line 61... Line 61...
61
#include "fat16.h"
61
#include "fat16.h"
62
#include "led.h"
62
#include "led.h"
63
#include "menu.h"
63
#include "menu.h"
64
#include "printf_P.h"
64
#include "printf_P.h"
65
#include "analog.h"
65
#include "analog.h"
-
 
66
#include "ubx.h"
Line 66... Line 67...
66
 
67
 
67
#ifdef USE_FOLLOWME
68
#ifdef USE_FOLLOWME
68
int16_t UBat = 120;
69
int16_t UBat = 120;
Line -... Line 70...
-
 
70
#endif
-
 
71
 
-
 
72
#define GPS_RX_TIMEOUT  0x0001
69
#endif
73
 
70
 
74
 
-
 
75
int main (void)
-
 
76
{
-
 
77
        static uint16_t GPS_Timer = 0;
71
int main (void)
78
        static uint16_t Error = 0;
72
{
79
 
Line 73... Line 80...
73
        // disable interrupts global
80
        // disable interrupts global
74
        cli();
81
        cli();
Line 81... Line 88...
81
        // initalize modules
88
        // initalize modules
82
        LED_Init();
89
        LED_Init();
83
        LEDRED_ON;
90
        LEDRED_ON;
84
    TIMER0_Init();
91
    TIMER0_Init();
85
        USART0_Init();
92
        USART0_Init();
-
 
93
        UBX_Init();
86
        USART1_Init();
94
        USART1_Init();
87
        ADC_Init();
95
        ADC_Init();
88
        // enable interrupts global
96
        // enable interrupts global
89
        sei();
97
        sei();
90
        LEDRED_OFF;
98
        LEDRED_OFF;
Line 120... Line 128...
120
        BeepTime = 2000;
128
        BeepTime = 2000;
121
        #endif
129
        #endif
Line 122... Line 130...
122
 
130
 
Line -... Line 131...
-
 
131
    LCD_Clear();
123
    LCD_Clear();
132
 
124
 
133
        GPS_Timer = SetDelay(1000);
125
        while (1)
-
 
126
        {
-
 
127
                USART0_ProcessRxData();
134
        while (1)
128
                USART0_TransmitTxData();
135
        {
129
                // restart ADConversion if ready
136
                // restart ADConversion if ready
130
                if(ADReady)
137
                if(ADReady)
131
                {
138
                {
Line 146... Line 153...
146
                        // UAdc4 = R3/(R3+R2)*(UBat-0.8V) = 1k/(1k+10k)*(UBat-0.8V) = (UBat-0.8V)/11
153
                        // UAdc4 = R3/(R3+R2)*(UBat-0.8V) = 1k/(1k+10k)*(UBat-0.8V) = (UBat-0.8V)/11
147
                        UBat = (3 * UBat + (69 * Adc4) / 128 + 8) / 4;
154
                        UBat = (3 * UBat + (69 * Adc4) / 128 + 8) / 4;
148
                        DebugOut.Analog[8] = UBat;
155
                        DebugOut.Analog[8] = UBat;
149
                        #endif
156
                        #endif
150
                        ADReady = 0;
157
                        ADReady = 0;
-
 
158
                        ADC_Enable(); // restart ad conversion sequence
-
 
159
                }
-
 
160
 
-
 
161
 
-
 
162
                if(GPSData.Status == NEWDATA)
-
 
163
                {
-
 
164
                        Error &= ~GPS_RX_TIMEOUT;       // clear possible error
-
 
165
                        GPS_Timer = SetDelay(1000); // reset timeout
-
 
166
                        if(CheckGPSOkay >= 5)
-
 
167
                        {
-
 
168
                                // trigger transmission of FollowMe message here.
-
 
169
 
151
                        ADC_Enable();
170
                                CheckGPSOkay = 0;
-
 
171
                        }
-
 
172
                        GPSData.Status = PROCESSED;
-
 
173
                }
-
 
174
                else // invalid or already processed
-
 
175
                {
-
 
176
                        if(CheckDelay(GPS_Timer))
-
 
177
                        {
-
 
178
                                Error |= GPS_RX_TIMEOUT;
-
 
179
                        }
152
                }
180
                }
-
 
181
 
-
 
182
                USART0_ProcessRxData();
-
 
183
                USART0_TransmitTxData();
153
    }
184
    }
154
        return (1);
185
        return (1);
155
}
186
}