Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 781 → Rev 782

/branches/V0.68d Code Redesign killagreg/cmps03.c
1,6 → 1,8
#include <avr/io.h>
#include <stdlib.h>
#include "fc.h"
#include "timer0.h"
#include "uart.h"
 
int32_t PWMHeading = -1;
uint8_t PWMTimeout = 0;
37,6 → 39,13
// This counter is incremented by a periode of 102.4us,
// i.e. the resoluton of pwm coded heading is approx. 1 deg.
PWMCount++;
// pwm overflow?
if (PWMCount > 400)
{
if(PWMTimeout ) PWMTimeout--; // decrement timeout
PWMCount = 0; // reset PWM Counter
}
 
}
else // PWM is low
{
52,14 → 61,6
}
PWMCount = 0; // reset pwm counter
}
// overflow without a low edge (nothing connected to PC4)
if (PWMCount > 400)
{
if(PWMTimeout ) PWMTimeout--;
PWMCount = 0;
}
 
 
}
 
 
69,6 → 70,9
int16_t CMPS03_Heading(void)
{
int16_t heading, w, v;
 
DebugOut.Analog[11] = PWMTimeout;
 
if(PWMTimeout)
{
w = abs(IntegralPitch / 512);
82,14 → 86,14
if (heading < 0) heading += 360;
heading = heading%360;
}
else // no date available from compass
else // compass to much tilted
{
if(!BeepTime) BeepTime = 100; // make noise to signal the compass problem
heading = -1;
}
}
else // no data from compass
{
if(!BeepTime) BeepTime = 100; // make noise to signal the compass problem
heading = -1;
}
return heading;