Keil MDK编程出现错误:
HardWareDriver\PWM_Output\PWM_Output.c(307): error: At end of source: #67: expected a "}"
解决方法参考了,博客 realview MDK C/C++ 混合编程问题
http://blog.csdn.net/jianxiang54321/article/details/5025752
试探性的,在代码结尾多加了一个“}” ,结果编译通过,不再提示error,可是“{” “}”的个数并不是一边多,我还没有搞懂是怎么回事
void PWM_Write_Motors(void) { #if (Remote_Config_Enable == 1) //条件编译,Remote_Config_Enable的定义见fly_config.h, //是否使用遥控器来做参数配置 1 使用, 0 为不使用/ //注意,当使用这个功能后,起飞前需要解锁油门才能进行飞行。 // if(Quadrotor_Mode == Quad_ESC_Cal)return; //正在校准电调,别添乱了 if(THROTTLE_LOCKed) { //油门锁定中,输出PWM不让电机启动,以免伤人。 LED_Blink_Routine(); //LED长亮,指示电机锁定状态 PWM_Output_Set_default(); return; } #endif // PWM_PID_Smooth(); //平滑输出 // // //保护措施,当油门低时,不启动电机。 // if(THROTTLE < (int16_t)(MINTHROTTLE+(MAXTHROTTLE-MINTHROTTLE)/20)) { // PID_ROLL = 0; //油门量小于 5% 不启动电机 // PID_PITCH = 0; //所有的控制量清零,以防电机启动 // PID_YAW = 0; // } switch(Fly_Mode) { case QUADP : //十字型的四轴飞行器 motor[0] = Math_Constrain(PIDMIX( 0,+1,-1),Min_PWM_Out,Max_PWM_Out); //REAR 后尾电机 motor[1] = Math_Constrain(PIDMIX(-1, 0,+1),Min_PWM_Out,Max_PWM_Out); //RIGHT 右边电机 motor[2] = Math_Constrain(PIDMIX(+1, 0,+1),Min_PWM_Out,Max_PWM_Out); //LEFT 左边电机 motor[3] = Math_Constrain(PIDMIX( 0,-1,-1),Min_PWM_Out,Max_PWM_Out); //FRONT 前面电机 Set_PWMOuput_CH1(motor[0]); Set_PWMOuput_CH2(motor[1]); Set_PWMOuput_CH3(motor[2]); Set_PWMOuput_CH4(motor[3]); break; case QUADX : //X 型的四轴飞行器 motor[0] = Math_Constrain(PIDMIX(-1,+1,-1),Min_PWM_Out,Max_PWM_Out); //REAR_R 后右电机 motor[1] = Math_Constrain(PIDMIX(-1,-1,+1),Min_PWM_Out,Max_PWM_Out); //FRONT_R 前右电机 motor[2] = Math_Constrain(PIDMIX(+1,+1,+1),Min_PWM_Out,Max_PWM_Out); //REAR_L 后左电机 motor[3] = Math_Constrain(PIDMIX(+1,-1,-1),Min_PWM_Out,Max_PWM_Out); //FRONT_L 前左电机 Set_PWMOuput_CH1(motor[0]); Set_PWMOuput_CH2(motor[1]); Set_PWMOuput_CH3(motor[2]); Set_PWMOuput_CH4(motor[3]); break; case Y4 : motor[0] = Math_Constrain(PIDMIX(+0,+1,-1),Min_PWM_Out,Max_PWM_Out); //REAR_1 CW motor[1] = Math_Constrain(PIDMIX(-1,-1, 0),Min_PWM_Out,Max_PWM_Out); //FRONT_R CCW motor[2] = Math_Constrain(PIDMIX(+0,+1,+1),Min_PWM_Out,Max_PWM_Out); //REAR_2 CCW motor[3] = Math_Constrain(PIDMIX(+1,-1, 0),Min_PWM_Out,Max_PWM_Out); //FRONT_L CW Set_PWMOuput_CH1(motor[0]); Set_PWMOuput_CH2(motor[1]); Set_PWMOuput_CH3(motor[2]); Set_PWMOuput_CH4(motor[3]); break; case Y6 : motor[0] = Math_Constrain(PIDMIX(+0,+4/3,+1),Min_PWM_Out,Max_PWM_Out); //REAR motor[1] = Math_Constrain(PIDMIX(-1,-2/3,-1),Min_PWM_Out,Max_PWM_Out); //RIGHT motor[2] = Math_Constrain(PIDMIX(+1,-2/3,-1),Min_PWM_Out,Max_PWM_Out); //LEFT motor[3] = Math_Constrain(PIDMIX(+0,+4/3,-1),Min_PWM_Out,Max_PWM_Out); //UNDER_REAR motor[4] = Math_Constrain(PIDMIX(-1,-2/3,+1),Min_PWM_Out,Max_PWM_Out); //UNDER_RIGHT motor[5] = Math_Constrain(PIDMIX(+1,-2/3,+1),Min_PWM_Out,Max_PWM_Out); //UNDER_LEFT Set_PWMOuput_CH1(motor[0]); Set_PWMOuput_CH2(motor[1]); Set_PWMOuput_CH3(motor[2]); Set_PWMOuput_CH4(motor[3]); Set_PWMOuput_CH5(motor[4]); Set_PWMOuput_CH6(motor[5]); break; case HEX6 : motor[0] = Math_Constrain(PIDMIX(-7/8,+1/2,+1),Min_PWM_Out,Max_PWM_Out); //REAR_R motor[1] = Math_Constrain(PIDMIX(-7/8,-1/2,-1),Min_PWM_Out,Max_PWM_Out); //FRONT_R motor[2] = Math_Constrain(PIDMIX(+7/8,+1/2,+1),Min_PWM_Out,Max_PWM_Out); //REAR_L motor[3] = Math_Constrain(PIDMIX(+7/8,-1/2,-1),Min_PWM_Out,Max_PWM_Out); //FRONT_L motor[4] = Math_Constrain(PIDMIX(+0 ,-1 ,+1),Min_PWM_Out,Max_PWM_Out); //FRONT motor[5] = Math_Constrain(PIDMIX(+0 ,+1 ,-1),Min_PWM_Out,Max_PWM_Out); //REAR Set_PWMOuput_CH1(motor[0]); Set_PWMOuput_CH2(motor[1]); Set_PWMOuput_CH3(motor[2]); Set_PWMOuput_CH4(motor[3]); Set_PWMOuput_CH5(motor[4]); Set_PWMOuput_CH6(motor[5]); break; case HEX6X : motor[0] = Math_Constrain(PIDMIX(-1/2,+7/8,+1),Min_PWM_Out,Max_PWM_Out); //REAR_R motor[1] = Math_Constrain(PIDMIX(-1/2,-7/8,+1),Min_PWM_Out,Max_PWM_Out); //FRONT_R motor[2] = Math_Constrain(PIDMIX(+1/2,+7/8,-1),Min_PWM_Out,Max_PWM_Out); //REAR_L motor[3] = Math_Constrain(PIDMIX(+1/2,-7/8,-1),Min_PWM_Out,Max_PWM_Out); //FRONT_L motor[4] = Math_Constrain(PIDMIX(-1 ,+0 ,-1),Min_PWM_Out,Max_PWM_Out); //RIGHT motor[5] = Math_Constrain(PIDMIX(+1 ,+0 ,+1),Min_PWM_Out,Max_PWM_Out); //LEFT Set_PWMOuput_CH1(motor[0]); Set_PWMOuput_CH2(motor[1]); Set_PWMOuput_CH3(motor[2]); Set_PWMOuput_CH4(motor[3]); Set_PWMOuput_CH5(motor[4]); Set_PWMOuput_CH6(motor[5]); break; } } //这里多加的“}”,编译后解决问题 }