请ti人帮忙解释一下这段代码,我自己有很多疑惑,十分感谢
#define QEP_MACRO(m,v) \
\
/* Check the rotational direction */ \
v.DirectionQep = (*eQEP[m]).QEPSTS.bit.QDF; \
\
/* Check the position counter for EQEP1 */ \
v.RawTheta = (*eQEP[m]).QPOSCNT + v.CalibratedAngle; \
\
if (v.RawTheta < 0) \
v.RawTheta = v.RawTheta + (*eQEP[m]).QPOSMAX; \
else if (v.RawTheta > (*eQEP[m]).QPOSMAX) \
v.RawTheta = v.RawTheta – (*eQEP[m]).QPOSMAX; \
\
/* Compute the mechanical angle */ \
v.MechTheta= v.MechScaler*v.RawTheta; \
/* Compute the electrical angle */ \
v.ElecTheta = (v.PolePairs*v.MechTheta) -floor(v.PolePairs*v.MechTheta); /* Q24 = Q0*Q24 */ \
\
/* Check an index occurrence*/ \
if ((*eQEP[m]).QFLG.bit.IEL == 1) \
{ \
v.IndexSyncFlag = 0x00F0; \
v.QepCountIndex = (*eQEP[m]).QPOSILAT; \
(*eQEP[m]).QCLR.bit.IEL = 1; /* Clear interrupt flag */ \
} \
\
/* Check unit Time out-event for speed calculation: */ \
/* Unit Timer is configured for 100Hz in INIT function*/ \
if((*eQEP[m]).QFLG.bit.UTO == 1) \
{ \
/***** Low Speed Calculation ****/ \
if(((*eQEP[m]).QEPSTS.bit.COEF || (*eQEP[m]).QEPSTS.bit.CDEF)) \
{ /* Capture Counter overflowed, hence do no compute speed*/ \
(*eQEP[m]).QEPSTS.all = 0x000C; \
} \
else if((*eQEP[m]).QCPRDLAT!=0xffff) \
/* Compute lowspeed using capture counter value*/ \
v.QepPeriod = (*eQEP[m]).QCPRDLAT; \
}
#endif // __F2833X_QEP_H__