一道考试题,大侠帮忙看看!
What does this code do, and is there anything wrong with it?unsigned char somebody_elses_function(void)
{
static unsigned int max_fast_vrect = 0;
static unsigned int min_fast_vrect = 0;
static unsigned int last_fast_vrect = 0;
static signed char slope = 0;
unsigned int fast_vrect = get_adc( VRECT_FAST );
if(slope > 0)
{
if(fast_vrect <= last_fast_vrect)
{
if(slope++ > VRECT_SLOPE_DEBOUNCE)
{
slope = -1;
max_fast_vrect = last_fast_vrect;
}
}
else
{
last_fast_vrect = fast_vrect;
}
}
else if(slope < 0)
{
if(fast_vrect >= last_fast_vrect)
{
if(slope-- < -VRECT_SLOPE_DEBOUNCE)
{
slope = 1;
min_fast_vrect = last_fast_vrect;
}
}
else
{
last_fast_vrect = fast_vrect;
}
}
else
{
slope = 1;
}
if((min_fast_vrect >= max_fast_vrect) ||
(max_fast_vrect < MIN_V_RECT) ||
((max_fast_vrect - min_fast_vrect) <= (max_fast_vrect + min_fast_vrect) >> (1+2))
)
{
return TRUE;
}
return FALSE;