From b39a40b0191e0a8b155db74e885ff66e17b91896 Mon Sep 17 00:00:00 2001
From: jinlicong <493886250@qq.com>
Date: Thu, 06 Jun 2024 19:25:15 +0800
Subject: [PATCH] 继续完善
---
Function/WirelessRemoteComm/wireless_remote_comm.c | 34 ++++++++++++++++++++++++----------
1 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/Function/WirelessRemoteComm/wireless_remote_comm.c b/Function/WirelessRemoteComm/wireless_remote_comm.c
index b6e57bd..e5530d2 100644
--- a/Function/WirelessRemoteComm/wireless_remote_comm.c
+++ b/Function/WirelessRemoteComm/wireless_remote_comm.c
@@ -15,6 +15,9 @@
{
OutputIO(WRC_PWR_PORT,WRC_PWR_PIN,OUT_PUSHPULL);
OutputIO(PWR_3V8_O_PORT,PWR_3V8_O_PIN,OUT_PUSHPULL);
+ CloseIO(PWR_3V8_EN_PORT,PWR_3V8_EN_PIN);
+ PWR_3V8_OFF;
+ WRC_PWR_OFF;
}
@@ -38,6 +41,9 @@
dma_recv_cnt = dma_mar_reg_read - (uint32)WRC_recv_buff;
if(dma_recv_cnt)
{
+ if((dma_recv_cnt >= WRC_REC_BUF_LENGTH) || (dma_recv_cnt >= WRC_RECV_BUFF_LEN_MAX) )
+ return;
+
wrc_ctrl_para_p->recv_length = dma_recv_cnt;
arrayA_2_arrayB(WRC_recv_buff , wrc_ctrl_para_p->recv_buf, dma_recv_cnt, LITTLE_ENDIAN) ;
wrc_ctrl_para_p->recv_flag = SET;//�������
@@ -96,6 +102,7 @@
}
buffer[204] = 0x16;
+
WRC_UART_SEND(buffer,205);
}
@@ -120,6 +127,9 @@
check_sum += *(buf_p + count_i);
if(*(buf_p + 89) == check_sum){
+
+ WRC_RX_DMA_CH3_reload(); //����У��ͨ��������Ϊ������Ҫ���յ������Ѿ���ɣ���Ҫ����DMA����,
+
if(*(buf_p + 2) == 1){
return_flag = LINK_OK;
if((*(buf_p+3) != 1)&&(*(buf_p+3) <0x39)){
@@ -157,7 +167,7 @@
if(buf_p != NULL){
buf_next_p = strstr(buf_p , ",");
if(buf_next_p != NULL){
- __SYS_DELAY_SEC_TIME_SET_(wrc_timeout_para,wrc_ctrl_para_g.time_out_time_sec);//��ʱ���ڽ��յ�+R�ͳ�ֵ��ʱʱ�䣬�������Ӧ�÷���Э��֡��ʽ�жϳɹ�����Ӧ����֮��
+
return SizhuV4ProtocolDataAnalysis((uint8_t *)buf_next_p,ack_buf,ack_buf_length);
}
@@ -181,7 +191,7 @@
//?��Ҫ��ͨѶ������ʼ�����Է�������
SizhuV4SendParaInit();
- return WRC_SEND_DATA;
+ return WRC_CREATE_LINK;
}
WRC_STATUS WrcCreateLinkPro(void)
@@ -189,7 +199,8 @@
//��������
WRC_uart_Init(115200,NONE,OneBit);
-
+ WRC_RX_DMA_CH3_Init();
+ uart_ctrl_para_g.WRC_rxto_flag = RESET;
//?��������ʹģ�����������������
WrcSendCreateLinkCmd();
@@ -210,7 +221,7 @@
// wrc_ctrl_para_g.time_out_cnt = wrc_ctrl_para_g.time_out_time_sec;
send_buf[0] = WRC_MODULE_CMD_DATA_UP;
- send_buf[1] = send_length &0x0f;
+ send_buf[1] = send_length &0xff;
send_buf[2] = send_length >>8;
if(send_length > sizeof(send_buf)){
@@ -219,7 +230,7 @@
return WRC_OFF;
}
- WRC_UART_SEND(send_buf,send_length);
+ WRC_UART_SEND(send_buf,send_length + 3);
__SYS_DELAY_SEC_TIME_SET_(wrc_timeout_para,wrc_ctrl_para_g.time_out_time_sec);
@@ -233,7 +244,10 @@
uint16_t send_length = 0;
//����buf����
- WRC_RX_DMA_check(&wrc_uart_para_g);
+ if(uart_ctrl_para_g.WRC_rxto_flag ==SET){
+ uart_ctrl_para_g.WRC_rxto_flag = RESET;
+ WRC_RX_DMA_check(&wrc_uart_para_g);
+ }
//���������ж�
if(wrc_uart_para_g.recv_flag == SET){
@@ -249,9 +263,9 @@
if((send_length > 0)&&(send_length < sizeof(send_buf))){ //����Ӧ������Ҫ����
send_buf[0] = WRC_MODULE_CMD_DATA_UP;
- send_buf[1] = send_length &0x0f;
+ send_buf[1] = send_length &0xff;
send_buf[2] = send_length >>8;
- WRC_UART_SEND(send_buf,send_length);
+ WRC_UART_SEND(send_buf,send_length + 3);
__SYS_DELAY_SEC_TIME_SET_(wrc_timeout_para,wrc_ctrl_para_g.time_out_time_sec);
}
memset(wrc_uart_para_g.recv_buf,0,sizeof(wrc_uart_para_g.recv_buf));
@@ -298,7 +312,7 @@
PWR_3V8_OFF;
return WRC_OFF;
- }else if(wrc_ctrl_para_g.wrc_OFF_cnt == 8){
+ }else if(wrc_ctrl_para_g.wrc_OFF_cnt >= 8){
//�ӳ��˳�ͨѶ���̣���ʱ��Դ�Ѿ��رգ��൱�ڸ�����һ��ʱ����
WRC_PWR_OFF;
PWR_3V8_OFF;
@@ -317,7 +331,7 @@
return WRC_IDLE; //�ػ���ϣ�����WRC_IDLE��������ͨѶ����
}
- return WRC_IDLE;
+ return WRC_OFF;
}
--
Gitblit v1.9.3