辜渝傧

13037102709

027-87870986

教学实训

您当前的位置:首页 > 教学资源 > 实训方案 >

RFID实训|125K读卡之电路搭建

发布者:唯众    布时间:2020-12-02 15:15:37    点击量:

电路搭建

125k读卡之电路搭建
125k读卡之电路搭建

 

程序实现

int main(void)
{
     u32 count=0;
     u32 temp8=0;
//1.各项硬件初始化
  Stm32_Clock_Init(9);       
     delay_init(72);         
     fg_BuzzerInit();       
     fg_OledInit();           
     fg_BuzzerOn(200);
     clear_screen();        
     if(CheckResetMode()==1){                 //软件复位
              disp_string_8x16_16x16(1,1,(u8*)"User Reset!");
     }else{                                    
              disp_string_8x16_16x16(1,1,(u8*)"Power on!");
     }                
#if(ESP8266_IS_STA==0)     
     Boot_A();
     disp_string_8x16_16x16(1,1,(const u8*)"武汉唯众智创科技");
     disp_string_8x16_16x16(3,1,(const u8*)"有限公司");
     fg_SetKeyReset();                      
     memset((char*)&NodeTemp,0,sizeof(NodeData));
     STMFLASH_Read(FLASH_SAVE_ADDR,(u16*)&NodeTemp,sizeof(NodeData));
     clear_screen();
     disp_string_8x16_16x16(1,1,(const u8*)"A: 0");
     sprintf((char*)Str2,"%2d",NodeTemp.server[0]);            
     disp_string_8x16_16x16(1,18,(const u8*)Str2);
     uart1_init(72,115200);
     uart2_init(36,9600);
     while(1)
     {
                       u8 i;
                       delay_ms(10);
                       sprintf((char*)Str2,"Received: %2d",temp8);         
                       disp_string_8x16_16x16(3,1,(const u8*)Str2);
                       IWDG_Feed();
                       if(flag_rev1_finish )
                       {       
                                 IWDG_Feed();
                                 temp8++;
                                 if(USART1_RX_BUF[0]=='@'&&USART1_RX_BUF[39]=='$')
                                 {       
                                          for(i=0;i<16;i++)
                                          {
                                                             if(NodeTemp.ip[i]==USART1_RX_BUF[9])
                                                             {
                                                                      break;
                                                             }                                                                        
                                          }
                                          if(NodeTemp.server[0]==USART1_RX_BUF[1] && (i<15))
                                          {
                                                   Send_Buf[0]='@';
                                                   Send_Buf[11]=USART1_RX_BUF[11];
                                                   Send_Buf[13]='O';
                                                   Send_Buf[14]='K';
                                                   Send_Buf[39]='$';             
                                                   IWDG_Feed();
                                                   USART1->CR1 &= ~(1<<5);
                                                   uart1_send_bytes(40,Send_Buf);
                                                  
                                          }
                                          else
                                          {
                                                   for(i=0;i<16;i++)
                                                   {
                                                             if(NodeTemp.ip[i]==0)
                                                             {
                                                                      break;
                                                             }                                                                        
                                                   }
                                                    NodeTemp.ip[i]=i*3+USART1_RX_BUF[11]+13;                                           
                                                   Send_Buf[0]='@';
                                                   Send_Buf[11]=USART1_RX_BUF[11];
                                                   Send_Buf[13]='S';
                                                   Send_Buf[14]='E';
                                                   Send_Buf[1]=NodeTemp.server[0];
                                                   Send_Buf[9]=NodeTemp.ip[i];
                                                   Send_Buf[39]='$';                                        
                                                   STMFLASH_Write(FLASH_SAVE_ADDR,(u16*)&NodeTemp,sizeof(NodeData));    
                                                   IWDG_Feed();
                                                   USART1->CR1 &= ~(1<<5);
                                                   uart1_send_bytes(40,Send_Buf);             
                                                  
                                          }
                                         
                                 }
                                 else if(USART1_RX_BUF[0]=='#' && USART1_RX_BUF[39]=='$' && USART1_RX_BUF[1]==NodeTemp.server[0])
                                 {
                                                             u2_send_data(USART1_RX_BUF,40);
                                 }
                                 USART1->CR1 |= 1<<5;
                                 flag_rev1_finish=0;
                       }
                       if(flag_rev2_finish)
                       {
                                 uart1_send_bytes(40,USART2_RX_BUF);
                                 flag_rev2_finish=0;
                       }
              }
 
#else
              uart1_init(72,115200);
              uart2_init(36,9600);
              clear_screen();
              disp_string_8x16_16x16(1,1,(const u8*)"武汉唯众智创科技");
              disp_string_8x16_16x16(3,1,(const u8*)"有限公司");
              fg_SetKeyReset();             
              IWDG_Feed();
             
              Sensor.Id = 12;
              while(BOOT_B());
              clear_screen();
              sprintf((char*)Str2,"%2d: %2d: SID:%2d",NodeTemp.server[0],NodeTemp.ip[0],Sensor.Id);                  
              disp_string_8x16_16x16(1,1,(const u8*)Str2);
              SetBR433Pack();
              while(1)
              {
                      
                       IWDG_Feed();
                       if(flag_rev2_finish)
                       {
                                 uart2_recv(2);
                                 BR433_TX.Pack.Sid[0]=12;
                                 BR433_TX.Pack.Len = 4;
                                 BR433_TX.Pack.Data[0]=Uart2Data[0];
                                 BR433_TX.Pack.Data[1]=Uart2Data[1];
                                 BR433_TX.Pack.Data[2]=Uart2Data[2];
                                 BR433_TX.Pack.Data[3]=Uart2Data[3];
                                           sprintf((char*)Str2,"%2x %2x %2x %2x",Uart2Data[0],Uart2Data[1],Uart2Data[2],Uart2Data[3]);       
                                 disp_string_8x16_16x16(3,1,(const u8*)Str2);
                                 uart1_send_bytes(40,BR433_TX.Buf);
                                 fg_BuzzerOn(200);
                                 flag_rev2_finish=0;
                       }
              }
#endif
}


上一篇:RFID实训|125K读卡之技术介绍

下一篇:RFID实训|13.56M读卡之技术介绍