|
@@ -87,11 +87,13 @@ void SystemClock_Config(void)
|
|
|
static void GPIO_Init(void)
|
|
|
{
|
|
|
/* Servo_1_Pin, Servo_2_Pin - Servos control, Alt PP out, middle speed */
|
|
|
+#ifdef USE_SERVO_1
|
|
|
GPIO_SetAFPin_0_7(Servo_1_Port, Servo_1_Pin, GPIO_AF_1);
|
|
|
GPIO_SetPinOutputType(Servo_1_Port, Servo_1_Pin, GPIO_OTYPE_PP);
|
|
|
GPIO_SetPinPull(Servo_1_Port, Servo_1_Pin, GPIO_PUPDR_NO);
|
|
|
GPIO_SetPinSpeed(Servo_1_Port, Servo_1_Pin, GPIO_OSPEED_LW);
|
|
|
GPIO_SetPinMode(Servo_1_Port, Servo_1_Pin, GPIO_MODE_AFF);
|
|
|
+#endif
|
|
|
#ifdef USE_SERVO_2
|
|
|
GPIO_SetAFPin_8_15(Servo_2_Port, Servo_2_Pin, GPIO_AF_2);
|
|
|
GPIO_SetPinOutputType(Servo_2_Port, Servo_2_Pin, GPIO_OTYPE_PP);
|
|
@@ -174,7 +176,9 @@ static void TIM1_Init(void)
|
|
|
TIM1->CCR2 = SERVO_INIT_VAL;
|
|
|
TIM1->CCR4 = SERVO_INIT_VAL;
|
|
|
// pwm mode 1 for chanels
|
|
|
+#ifdef USE_SERVO_1
|
|
|
TIM1->CCMR1 = (TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2M_2 | TIM_CCMR1_OC2PE);
|
|
|
+#endif
|
|
|
#ifdef USE_SERVO_2
|
|
|
TIM1->CCMR1 |= (TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1PE);
|
|
|
#endif
|
|
@@ -182,7 +186,9 @@ static void TIM1_Init(void)
|
|
|
TIM1->BDTR = TIM_BDTR_MOE; // enable main output
|
|
|
TIM1->EGR = TIM_EGR_UG; // force timer update
|
|
|
/* TIM1 CC_EnableChannel */
|
|
|
+#ifdef USE_SERVO_1
|
|
|
TIM1->CCER = (TIM_CCER_CC2E | TIM_CCER_CC2P);
|
|
|
+#endif
|
|
|
#ifdef USE_SERVO_2
|
|
|
TIM1->CCER |= (TIM_CCER_CC1E | TIM_CCER_CC1P);
|
|
|
#endif
|