فهرست منبع

Fix for real life N3.

Vladimir N. Shilov 3 ماه پیش
والد
کامیت
1ac99a2627
2فایلهای تغییر یافته به همراه7 افزوده شده و 85 حذف شده
  1. 2 2
      inc/board.h
  2. 5 83
      src/main.c

+ 2 - 2
inc/board.h

@@ -17,8 +17,8 @@
 #define TIM1_PSC            (24 - 1)
 #define TIM1_ARR            (20000 - 1)
 #define SERVO_INIT_VAL      0
-//2000
-#define SERVO_OPEN_VAL      1000
+#define SERVO1_OPEN_VAL      1000
+#define SERVO2_OPEN_VAL      2000
 
 #define TIM3_PSC            (24000 - 1)
 #define TIM3_ARR            (100 - 1)

+ 5 - 83
src/main.c

@@ -22,8 +22,8 @@
 /* Private includes ----------------------------------------------------------*/
 /* Private typedef -----------------------------------------------------------*/
 /* Private define ------------------------------------------------------------*/
-#define PHOTO_LEVEL_ON  (100)
-#define PHOTO_LEVEL_OFF (1000)
+#define PHOTO_LEVEL_ON  (200)
+#define PHOTO_LEVEL_OFF (800)
 
 /* Private macro -------------------------------------------------------------*/
 /* Private variables ---------------------------------------------------------*/
@@ -47,24 +47,6 @@ int main(void)
   /* Initialize onBoard Hardware */
   Board_Init();
 
-#ifdef USE_SERVO_1
-//  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_OFF;
-#endif
-/*
-  if ((Select_Port->IDR & Select_Pin) == 0) {
-    Flag.ONE_CHANNEL = 1;
-  } else {
-    Flag.ONE_CHANNEL = 0;
-  }
-*/
   /* if light is on, wait for off */
   while (photo_Value <= PHOTO_LEVEL_OFF) {
     //IWDG->KR = 0xAAAA;
@@ -72,8 +54,7 @@ int main(void)
   }
 
   /* Infinite loop */
-  while (1)
-  {
+  while (1) {
 #ifdef USE_SERVO_1
     /* wait for light on */
     while (photo_Value > PHOTO_LEVEL_ON) {
@@ -81,9 +62,7 @@ int main(void)
       __WFI();
     }
     /* open servo 1 */
-    Servo_1_ON;
-    Servo_1_CHNL = SERVO_OPEN_VAL;
-    Servo_1_OFF;
+    Servo_1_CHNL = SERVO1_OPEN_VAL;
 
     /* wait for light off */
     while (photo_Value <= PHOTO_LEVEL_OFF) {
@@ -91,9 +70,7 @@ int main(void)
       __WFI();
     }
     /* close servo 1 */
-//    Servo_1_ON;
     Servo_1_CHNL = SERVO_INIT_VAL;
-//    Servo_1_OFF;
 #endif
     
 #ifdef USE_SERVO_2
@@ -102,73 +79,18 @@ int main(void)
       //IWDG->KR = 0xAAAA;
       __WFI();
     }
-    Servo_2_ON;
-    Servo_2_CHNL = SERVO_OPEN_VAL;
-    Servo_2_OFF;
+    Servo_2_CHNL = SERVO2_OPEN_VAL;
     /* wait for light off */
     while (photo_Value <= PHOTO_LEVEL_OFF) {
       //IWDG->KR = 0xAAAA;
       __WFI();
     }
     /* close servo 2 */
-//    Servo_2_ON;
     Servo_2_CHNL = SERVO_INIT_VAL;
-//    Servo_2_OFF;
 #endif
-
-    /* end of life */
-    while (1) {
-      __disable_irq();
-      __WFI();
-    }
   }
 } /* End of mine() */
 
-/*
-static void servo_open(void) {
-  int i;
-  for (i=SERVO_INIT_VAL; i <= SERVO_OPEN_VAL; i+=50) {
-    Servo_1_CHNL = i;
-    Servo_2_CHNL = i;
-    delay_ms(40);
-  }
-}
-
-static void servo_close(void) {
-  int i;
-  for (i=SERVO_OPEN_VAL; i >= SERVO_INIT_VAL; i-=50) {
-    Servo_1_CHNL = i;
-    Servo_2_CHNL = i;
-    delay_ms(40);
-  }
-}
-*/
-
-/*
-static void uart_init(uint32_t baud)
-{
-  GPIO_SetPinMode(GPIOB, GPIO_PIN_6, GPIO_MODE_AFF);
-
-  RCC->APBENR2 |= RCC_APBENR2_USART1EN;
-
-  USART1->CR1 = USART_CR1_RE | USART_CR1_TE | USART_CR1_FIFOEN;
-  USART1->BRR = (SystemCoreClock / baud);
-  USART1->CR1 |= USART_CR1_UE;
-}
-
-static void uart_putc(char c)
-{
-  while (0 == (USART1->ISR & USART_ISR_TXE_TXFNF));
-  USART1->TDR = c;
-}
-
-static void uart_puts(char *s)
-{
-  while (*s)
-    uart_putc(*s++);
-}
-*/
-
 /**
   * @brief  This function is executed in case of error occurrence.
   * @retval None