forked from SZV10X_Software/SZV103_FM33A0xxEV_SiZhu

jinlicong
2024-06-05 cf4d12fd8322cbb350dd3bc5af8c748e8790ac64
Function/UPPER_COMPUTER/upper_com.c
@@ -73,8 +73,11 @@
      return ;
   
   dma_recv_cnt = dma_mar_reg_read - (uint32)up_comm_recv_buff;
   if(dma_recv_cnt)
   if( (dma_recv_cnt>0)&&(dma_recv_cnt <= UP_COMM_RECV_BUFF_LEN_MAX))
   {
      if((dma_recv_cnt >= UP_COMM_RECV_BUFF_LEN_MAX) || (dma_recv_cnt >= UC_RECV_LEN_MAX) )
         return;
      uc_recv_para_p->uc_recv_length = dma_recv_cnt;
      arrayA_2_arrayB(up_comm_recv_buff , uc_recv_para_p->uc_recv_buf_union.uc_recv_buf, dma_recv_cnt, LITTLE_ENDIAN) ;
      uc_recv_para_p->uc_recv_flag = SET;//½ÓÊÕÍê³É
@@ -146,7 +149,9 @@
   uc_respond_data_p->uc_recv_buf[crc_len] = send_crc_check >> 8; //¸ßλ
   uc_respond_data_p->uc_recv_buf[crc_len + 1] = send_crc_check &0xff; 
   
   UP_COMM_RE_SEND_EN;
   UC_SEND_NORMAL((uint8_t *)uc_respond_data_p,crc_len + 2);
   UP_COMM_RE_RECV_EN;
}
@@ -241,7 +246,9 @@
void upperComPro(void)
{
   //½ÓÊÕÊý¾ÝÅжÏ
   up_comm_RX_DMA_check(&uc_recv_para_g);
   if(__SYS_STATUS_BYTES_GET(power_state) == SET){
         up_comm_RX_DMA_check(&uc_recv_para_g); //Í⹩µçϲŴ¦Àí½ÓÊÕ
   }
   
   /*Ö¡¸ñʽ½âÎöÅжϣ¬´Ë´¦¼æÈÝmodbusЭÒ飬µÚÒ»¸ö×Ö½ÚÈç¹ûÊÇ0x68´ú±íÉÏλ»úЭÒ飬·Ç0x68ÔÙ½øÈëmodbus´¦Àí*/
   if ((uc_recv_para_g.uc_recv_flag ==SET)&&(uc_recv_para_g.uc_recv_length > UC_PROTOCOL_HEAD_LENGTH )&&(uc_recv_para_g.uc_recv_buf_union.uc_protocol_head_s.frame_start_code == UC_FRAME_HEAD_CODE))
@@ -277,7 +284,7 @@
               if (uc_login_state_g == UC_OK && local_random_code_g == uc_recv_para_g.uc_recv_buf_union.uc_protocol_head_s.random_number)
               {
                  Upper_ComputerReadWriteHandler(&uc_recv_para_g.uc_recv_buf_union,&uc_respond_data_g);
                  Upper_ComputerLoginRespond(&uc_respond_data_g);
                  Upper_ComputerRespond(&uc_respond_data_g);
                  __SYS_DELAY_SEC_TIME_SET_(UC_active_time,UC_ACTIVE_TIME);//ÉèÖü¤»îʱ¼ä//ÖØÖü¤»îʱ¼ä
               }
               break;
@@ -285,7 +292,7 @@
               if (uc_login_state_g == UC_OK && local_random_code_g == uc_recv_para_g.uc_recv_buf_union.uc_protocol_head_s.random_number)
               {
                  Upper_ComputerReadWriteHandler(&uc_recv_para_g.uc_recv_buf_union,&uc_respond_data_g);
                  Upper_ComputerLoginRespond(&uc_respond_data_g);
                  Upper_ComputerRespond(&uc_respond_data_g);
                  __SYS_DELAY_SEC_TIME_SET_(UC_active_time,UC_ACTIVE_TIME);//ÉèÖü¤»îʱ¼ä//ÖØÖü¤»îʱ¼ä
               }
               break;
@@ -308,10 +315,14 @@
               break;
      }
         
      }   
   }
   //ÉÏλ»ú³¬Ê±´¦Àí£¬µ±³¤Ê±¼äûÓн»»¥Ê±£¬Ëæ»úÂëʧЧ£¬ÐèÒªÖØÐµÇÈë²ÅÄܼÌÐøÊ¹ÓÃ
   if(__SYS_DELAY_SEC_FLAG_GET(UC_active_time) == SET){
      __SYS_DELAY_SEC_FLAG_CLEAR_(UC_active_time);
      local_random_code_g = 0;
   }
   
   
@@ -332,5 +343,8 @@
      
   }
   
}