Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 271 → Rev 273

/FollowMe/main.c
62,7 → 62,12
#include "led.h"
#include "menu.h"
#include "printf_P.h"
#include "analog.h"
 
#ifdef USE_FOLLOWME
int16_t UBat = 120;
#endif
 
int main (void)
{
// disable interrupts global
75,11 → 80,11
 
// initalize modules
LED_Init();
 
LEDRED_ON;
TIMER0_Init();
USART0_Init();
USART1_Init();
ADC_Init();
// enable interrupts global
sei();
LEDRED_OFF;
121,6 → 126,30
{
USART0_ProcessRxData();
USART0_TransmitTxData();
// restart ADConversion if ready
if(ADReady)
{
DebugOut.Analog[0] = Adc0;
DebugOut.Analog[1] = Adc1;
DebugOut.Analog[2] = Adc2;
DebugOut.Analog[3] = Adc3;
DebugOut.Analog[4] = Adc4;
DebugOut.Analog[5] = Adc5;
DebugOut.Analog[6] = Adc6;
DebugOut.Analog[7] = Adc7;
 
#ifdef USE_FOLLOWME
// AVcc = 5V --> 5V = 1024 counts
// the voltage at the voltage divider reference point is 0.8V less that the UBat
// because of the silicon diode inbetween.
// voltage divider R2=10K, R3=1K
// UAdc4 = R3/(R3+R2)*(UBat-0.8V) = 1k/(1k+10k)*(UBat-0.8V) = (UBat-0.8V)/11
UBat = (3 * UBat + (69 * Adc4) / 128 + 8) / 4;
DebugOut.Analog[8] = UBat;
#endif
ADReady = 0;
ADC_Enable();
}
}
return (1);
}