unsigned short wr_map[8] = {0x0000,0x0000,0x0000,0x00000,0x00000,0x0000,0x0000,0x0000};unsigned short rr_map[8] = {0x0000,0x0000,0x0000,0x00000,0x00000,0x0000,0x0000,0x0000};
void Encoder_Init(Encoder_InitTypeDef Encoder_InitStruct){ wr_map[R2] &= 0xf1ff; wr_map[R2] |= (Encoder_InitStruct.Pulse_Mode << 8) |(Encoder_InitStruct.Pulse_Mul); Reg_Write(R2, wr_map[R2]);}
typedef enum{ DOUBLE_PULSE, DIR_PULSE } PULSE_MODE;
typedef enum{ MUL_1 = 0x0000, MUL_2 = 0x0400, MUL_4 = 0x0800 } ENCODER_MUL;
typedef struct{ PULSE_MODE Pulse_Mode; ENCODER_MUL Pulse_Mul; } Encoder_InitTypeDef;
int main(void){Encoder_InitTypeDef Encoder_InitStruct;Encoder_InitStruct-> Pulse_Mode = DOUBLE_PULSE; Encoder_InitStruct-> Pulse_Mul = MUL_4; Encoder_Init(&Encoder_InitStruct);}这是程序的一部分Regwrite()函数在这之前已经声明过了,问题在main()中队结构变量Encoder_InitStruct的赋值。
ibeautiful