Page 318 - MDP2020-1
P. 318

|    인천전자마이스터고등학교  ·············································································································
            312

                  HAL_GPIO_WritePin(DHT11_GPIO_Port,  DHT11_Pin,  GPIO_PIN_SET);
                  Delay_microsec(20);


                  while(HAL_GPIO_ReadPin(DHT11_GPIO_Port,DHT11_Pin)  ==  0){

                        Delay_microsec(1);
                        cnt++;
                        if(cnt  >  100)
                              return  0;

                  }
                  cnt  =  0;
                  while(HAL_GPIO_ReadPin(DHT11_GPIO_Port,DHT11_Pin)  ==  1){
                        Delay_microsec(1);
                        cnt++;
                        if(cnt  >  100)

                              return  0;
                  }


                  for(i=0;i<40;i++)

                  {
                        cnt  =  0;
                        while(HAL_GPIO_ReadPin(DHT11_GPIO_Port,DHT11_Pin)  ==  0){}
                        while(HAL_GPIO_ReadPin(DHT11_GPIO_Port,DHT11_Pin)  ==  1){
                              Delay_microsec(1);
                              cnt++;

                        }


                        data[i/8]<<=1;
                        data[i/8]|=(cnt>52);
                  }



                  return  data[0]&&(data[4]==data[0]+data[1]+data[2]+data[3]);
            }


            void  HAL_UART_RxCpltCallback(UART_HandleTypeDef  *huart)

            {


                  HAL_UART_Receive_IT(&huart2,receive_data,2);
            }
            /*  USER  CODE  END  0  */



            /**
   313   314   315   316   317   318   319   320   321   322   323