我无法理解此代码的某些行,请描述一下这些代码的作用:此代码在 atmelstudio 中编写,是 ATMEL 的 AVR443 应用说明的示例代码
unsigned char *pTemp;
fastTemp.word = ((PIN_HALL & hallMask)>>1);
pTemp = pDrvPattern + fastTemp.word;
PORT_MC = *(pTemp);
因为 *pDrvPattern 定义如下:
__regvar __no_init unsigned char *pDrvPattern
pDrvPattern = drvPatternsCW;
unsigned char drvPatternsCW[] = {
0, //Stop
// MC_PORT drive config
PDP2_CW, //Phase2
PDP6_CW, //Phase6
PDP1_CW, //Phase1
PDP4_CW, //Phase4
PDP3_CW, //Phase3
PDP5_CW, //Phase5
// Configuration of Output Compare operation for timer 0
COM0P2_CW, //Phase2
COM0P6_CW, //Phase6
COM0P1_CW, //Phase1
COM0P4_CW, //Phase4
COM0P3_CW, //Phase3
COM0P5_CW, //Phase5
// Configuration of Output Compare operation for timer 2
COM2P2_CW, //Phase2
COM2P6_CW, //Phase6
COM2P1_CW, //Phase1
COM2P4_CW, //Phase4
COM2P3_CW, //Phase3
COM2P5_CW //Phase5
};
__regvar __no_init union _fastTemp{
unsigned int word;
struct{
unsigned char LByte;
unsigned char HByte; //Hbyte = Zero
};
} fastTemp @12;
#define PDP1_CW ((0<<UL)|(0<<VL)|(1<<WL)|(0<<UH)|(1<<VH)|(0<<WH))
#define PDP2_CW ((0<<UL)|(0<<VL)|(1<<WL)|(1<<UH)|(0<<VH)|(0<<WH))
#define PDP3_CW ((0<<UL)|(1<<VL)|(0<<WL)|(1<<UH)|(0<<VH)|(0<<WH))
#define PDP4_CW ((0<<UL)|(1<<VL)|(0<<WL)|(0<<UH)|(0<<VH)|(1<<WH))
#define PDP5_CW ((1<<UL)|(0<<VL)|(0<<WL)|(0<<UH)|(0<<VH)|(1<<WH))
#define PDP6_CW ((1<<UL)|(0<<VL)|(0<<WL)|(0<<UH)|(1<<VH)|(0<<WH))
#define HALL1 PB1
#define HALL2 PB2
#define HALL3 PB3
#define HALL_MASK ((1<<HALL1)|(1<<HALL2)|(1<<HALL3))
#define PORT_MC PORTD