P
enum state_t {STOPPED = 0, ONE_SHOT, ONE_SHOT_OVF, RUN, RUN_OVF};
static state_t state = STOPPED;
switch (state)
{
case STOPPED:
state = ONE_SHOT;
break;
case ONE_SHOT:
res = ICR5_now - ICR5_last;
state = RUN;
break;
case ONE_SHOT_OVF:
if(ICR5_now < ICR5_last)
{
res = ICR5_now - ICR5_last;
state = RUN;
}
state = ONE_SHOT;
break;
case RUN:
res = ICR5_now - ICR5_last;
break;
case RUN_OVF:
if(ICR5_now < ICR5_last)
{
res = ICR5_now - ICR5_last;
state = RUN;
}
state = ONE_SHOT;
break;
}
например
так можно