Page 369 - MDP2022-2
P. 369

/*  MCU  Configuration--------------------------------------------------------*/


                /*  Reset  of  all  peripherals,  Initializes  the  Flash  interface  and  the  Systick.  */
                HAL_Init();


                /*  USER  CODE  BEGIN  Init  */


                /*  USER  CODE  END  Init  */


                /*  Configure  the  system  clock  */
                SystemClock_Config();


                /*  USER  CODE  BEGIN  SysInit  */


                /*  USER  CODE  END  SysInit  */


                /*  Initialize  all  configured  peripherals  */
                MX_GPIO_Init();
                MX_TIM2_Init();
                /*  USER  CODE  BEGIN  2  */


                /*  USER  CODE  END  2  */


                /*  Infinite  loop  */
                /*  USER  CODE  BEGIN  WHILE  */
                while  (1)
                {
                      //dir  D13  12  11  E10  //step  E12  14  15  13  //con  F3  15  11  E0


                  status1  =  HAL_GPIO_ReadPin(GPIOF,  up);
                  status2  =  HAL_GPIO_ReadPin(GPIOF,  down);
                  status3  =  HAL_GPIO_ReadPin(GPIOF,  left);
                  status4  =  HAL_GPIO_ReadPin(GPIOE,  right);


                      if(status1  &&  !(status3  ||  status4)){
                            if(height  <  1340){
                                  HAL_GPIO_WritePin(GPIOD,  dir1,  GPIO_PIN_RESET);
                                      HAL_GPIO_WritePin(GPIOE,  step1,  GPIO_PIN_SET);
                                      HAL_Delay(1);
                                      HAL_GPIO_WritePin(GPIOE,  step1,  GPIO_PIN_RESET);
                                      height++;
                            }
                      }
                      else  if(status2  &&  !(status3  ||  status4)){
                            if(height  >  0){
   364   365   366   367   368   369   370   371   372   373   374