Hi,
I'am working with the TI's High Voltage Motor Control and PFC Developer Kit.
The code( in f2803xhall_gpio.h )below just make me so confused:
/*----------------------------------------------------------------------------------------------
HALL3_DETERMINE_STATE Macro Definition
----------------------------------------------------------------------------------------------*/
Uint32 temp;
Uint16 HallGpioBitA,HallGpioBitB,HallGpioBitC;
#define HALL3_DETERMINE_STATE_MACRO(v) \
\
/* temp.2-0 = GPIO26.GPIO25.GPIO24 */ \
temp = (GpioDataRegs.GPADAT.all>>24)&0x00000007; /* read all three GPIOs at once*/ \
\
HallGpioBitA = (temp&0x00000001); /* save GPIO24 - A*/ \
HallGpioBitB = (temp&0x00000002)>>1; /* save GPIO25 - B*/ \
HallGpioBitC = (temp&0x00000004)>>2; /* save GPIO26 - C*/ \
HallGpioBitA = HallGpioBitA; /*<<2; shift GPIO24 - A*/ \
HallGpioBitB = HallGpioBitB<<1; /* shift GPIO25 - B*/ \
HallGpioBitC = HallGpioBitC<<2; /*<<1; shift GPIO26 - C*/ \
\
v.HallGpio = HallGpioBitA + HallGpioBitB + HallGpioBitC;
My question is, why not just replace with the code below? Is there some other consideration of the code above?
temp = (GpioDataRegs.GPADAT.all>>24)&0x00000007; /* read all three GPIOs at once*/ \
v.HallGpio = temp;
Thank, Qiu