|
@@ -22,8 +22,8 @@
|
|
/* Private includes ----------------------------------------------------------*/
|
|
/* Private includes ----------------------------------------------------------*/
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
/* Private define ------------------------------------------------------------*/
|
|
/* 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 macro -------------------------------------------------------------*/
|
|
/* Private variables ---------------------------------------------------------*/
|
|
/* Private variables ---------------------------------------------------------*/
|
|
@@ -47,24 +47,6 @@ int main(void)
|
|
/* Initialize onBoard Hardware */
|
|
/* Initialize onBoard Hardware */
|
|
Board_Init();
|
|
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 */
|
|
/* if light is on, wait for off */
|
|
while (photo_Value <= PHOTO_LEVEL_OFF) {
|
|
while (photo_Value <= PHOTO_LEVEL_OFF) {
|
|
//IWDG->KR = 0xAAAA;
|
|
//IWDG->KR = 0xAAAA;
|
|
@@ -72,8 +54,7 @@ int main(void)
|
|
}
|
|
}
|
|
|
|
|
|
/* Infinite loop */
|
|
/* Infinite loop */
|
|
- while (1)
|
|
|
|
- {
|
|
|
|
|
|
+ while (1) {
|
|
#ifdef USE_SERVO_1
|
|
#ifdef USE_SERVO_1
|
|
/* wait for light on */
|
|
/* wait for light on */
|
|
while (photo_Value > PHOTO_LEVEL_ON) {
|
|
while (photo_Value > PHOTO_LEVEL_ON) {
|
|
@@ -81,9 +62,7 @@ int main(void)
|
|
__WFI();
|
|
__WFI();
|
|
}
|
|
}
|
|
/* open servo 1 */
|
|
/* 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 */
|
|
/* wait for light off */
|
|
while (photo_Value <= PHOTO_LEVEL_OFF) {
|
|
while (photo_Value <= PHOTO_LEVEL_OFF) {
|
|
@@ -91,9 +70,7 @@ int main(void)
|
|
__WFI();
|
|
__WFI();
|
|
}
|
|
}
|
|
/* close servo 1 */
|
|
/* close servo 1 */
|
|
-// Servo_1_ON;
|
|
|
|
Servo_1_CHNL = SERVO_INIT_VAL;
|
|
Servo_1_CHNL = SERVO_INIT_VAL;
|
|
-// Servo_1_OFF;
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#ifdef USE_SERVO_2
|
|
#ifdef USE_SERVO_2
|
|
@@ -102,73 +79,18 @@ int main(void)
|
|
//IWDG->KR = 0xAAAA;
|
|
//IWDG->KR = 0xAAAA;
|
|
__WFI();
|
|
__WFI();
|
|
}
|
|
}
|
|
- Servo_2_ON;
|
|
|
|
- Servo_2_CHNL = SERVO_OPEN_VAL;
|
|
|
|
- Servo_2_OFF;
|
|
|
|
|
|
+ Servo_2_CHNL = SERVO2_OPEN_VAL;
|
|
/* wait for light off */
|
|
/* wait for light off */
|
|
while (photo_Value <= PHOTO_LEVEL_OFF) {
|
|
while (photo_Value <= PHOTO_LEVEL_OFF) {
|
|
//IWDG->KR = 0xAAAA;
|
|
//IWDG->KR = 0xAAAA;
|
|
__WFI();
|
|
__WFI();
|
|
}
|
|
}
|
|
/* close servo 2 */
|
|
/* close servo 2 */
|
|
-// Servo_2_ON;
|
|
|
|
Servo_2_CHNL = SERVO_INIT_VAL;
|
|
Servo_2_CHNL = SERVO_INIT_VAL;
|
|
-// Servo_2_OFF;
|
|
|
|
#endif
|
|
#endif
|
|
-
|
|
|
|
- /* end of life */
|
|
|
|
- while (1) {
|
|
|
|
- __disable_irq();
|
|
|
|
- __WFI();
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
} /* End of mine() */
|
|
} /* 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.
|
|
* @brief This function is executed in case of error occurrence.
|
|
* @retval None
|
|
* @retval None
|