Vladimir N. Shilov пре 3 месеци
родитељ
комит
c02a06d485
2 измењених фајлова са 22 додато и 20 уклоњено
  1. 10 9
      inc/board.h
  2. 12 11
      src/main.c

+ 10 - 9
inc/board.h

@@ -16,7 +16,8 @@
 /* PWM Timers for 50 Hz */
 #define TIM1_PSC            (24 - 1)
 #define TIM1_ARR            (20000 - 1)
-#define SERVO_INIT_VAL      2000
+#define SERVO_INIT_VAL      0
+//2000
 #define SERVO_OPEN_VAL      1000
 
 #define TIM3_PSC            (24000 - 1)
@@ -31,20 +32,20 @@
   #define Servo_1_Pin   GPIO_PIN_3
   #define Servo_1_Port  GPIOB
   #define Servo_1_CHNL  TIM1->CCR2
-  #define Servo_1_ON    {}
-  //GPIO_SetPinMode(Servo_1_Port, Servo_1_Pin, GPIO_MODE_AFF)
-  #define Servo_1_OFF   {}
-  //GPIO_SetPinMode(Servo_1_Port, Servo_1_Pin, GPIO_MODE_IN)
+//  #define Servo_1_ON    TIM1->CCER |= (TIM_CCER_CC2E | TIM_CCER_CC2P)
+//  #define Servo_1_OFF   TIM1->CCER &= ~(TIM_CCER_CC2E | TIM_CCER_CC2P)
 #endif
 #ifdef USE_SERVO_2
   #define Servo_2_Pin   GPIO_PIN_8
   #define Servo_2_Port  GPIOA
   #define Servo_2_CHNL  TIM1->CCR1
-  #define Servo_2_ON    {}
-  //GPIO_SetPinMode(Servo_2_Port, Servo_2_Pin, GPIO_MODE_AFF)
-  #define Servo_2_OFF   {}
-  //GPIO_SetPinMode(Servo_2_Port, Servo_2_Pin, GPIO_MODE_IN)
+//  #define Servo_2_ON    TIM1->CCER |= (TIM_CCER_CC1E | TIM_CCER_CC1P)
+//  #define Servo_2_OFF   TIM1->CCER &= ~(TIM_CCER_CC1E | TIM_CCER_CC1P)
 #endif
+#define Servo_1_ON
+#define Servo_1_OFF
+#define Servo_2_ON
+#define Servo_2_OFF
 
 /* Variables */
 

+ 12 - 11
src/main.c

@@ -48,14 +48,14 @@ int main(void)
   Board_Init();
 
 #ifdef USE_SERVO_1
-  Servo_1_ON;
-  Servo_1_CHNL = SERVO_INIT_VAL;
+//  Servo_1_ON;
+//  Servo_1_CHNL = SERVO_INIT_VAL;
   Servo_1_OFF;
 #endif
 
 #ifdef USE_SERVO_2
-  Servo_2_ON;
-  Servo_2_CHNL = SERVO_INIT_VAL;
+//  Servo_2_ON;
+//  Servo_2_CHNL = SERVO_INIT_VAL;
   Servo_2_OFF;
 #endif
 /*
@@ -91,9 +91,9 @@ int main(void)
       __WFI();
     }
     /* close servo 1 */
-    Servo_1_ON;
+//    Servo_1_ON;
     Servo_1_CHNL = SERVO_INIT_VAL;
-    Servo_1_OFF;
+//    Servo_1_OFF;
 #endif
     
 #ifdef USE_SERVO_2
@@ -111,15 +111,16 @@ int main(void)
       __WFI();
     }
     /* close servo 2 */
-    Servo_2_ON;
+//    Servo_2_ON;
     Servo_2_CHNL = SERVO_INIT_VAL;
-    Servo_2_OFF;
+//    Servo_2_OFF;
 #endif
 
     /* end of life */
-    //while (1) {
-    //  __WFI();
-    //}
+    while (1) {
+      __disable_irq();
+      __WFI();
+    }
   }
 } /* End of mine() */