From ae0ac687e1b68ed3c067deb67dffaea9582f329c Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期四, 23 十一月 2023 16:55:35 +0800
Subject: [PATCH] V1.2 修改继电器报警错误

---
 源码/核心板/Src/main.c |   59 +++++++++++++++++++++++++----------------------------------
 1 files changed, 25 insertions(+), 34 deletions(-)

diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c"
index 2220961..c262583 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c"
@@ -46,7 +46,7 @@
 	RCC_Configuration();
 	//SystemInit();
 	NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x5000);
-	
+	Nvic_Init();
 //	Systick_Init();
 	TIM3_Int_Init();
 	Led_Init();
@@ -55,9 +55,8 @@
 	Uart1_Init();
 	Spi_Init();
 	ADC_Configuration();
-	//IWDG_Config(IWDG_Prescaler_128 ,4095);   //10s
-	Nvic_Init();
-  IWDG_Feed();
+	IWDG_Config(IWDG_Prescaler_128 ,4095);   //10s
+    IWDG_Feed();
 	GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
 }
 u8 anchor_type;
@@ -95,12 +94,7 @@
 	{
 	  g_com_map[COM_INTERVAL]=100;
 	}
-    if(dist_threshold<300)
-		{dist_threshold = 300;}
-		if(dist_threshold>15000)
-		{dist_threshold = 15000;}
 }
-extern u8 needanchorrx;  
 u16 JDQ_time;
 int16_t g_commap_antdelay;
 void Program_Init(void)
@@ -148,35 +142,37 @@
         
 	OUT485_ENABLE;
 	ComMapCheck();	
-	g_com_map[VERSION] = 1<<8|62;
+	g_com_map[VERSION] = 1<<8|2;
     FLASH_Read(FLASH_HARDWARE_FLAG, (uint8_t*)&g_com_map[HARDWAREFLAG_INDEX], 16);
     dist_threshold = (g_com_map[SPEEDFILTER_THRES]*10)/(1000/g_com_map[COM_INTERVAL]);
+     if(dist_threshold<300)
+		{dist_threshold = 300;}
+		if(dist_threshold>15000)
+		{dist_threshold = 15000;}
     g_commap_antdelay = g_com_map[ANT_LENGTH];
     JDQ_time = g_com_map[WAR_JDQ_TIME]*10;
 	g_com_map[SW_TYPE] = 	SW_FANGZHUANG;
 	dev_id = g_com_map[DEV_ID];
-        group_id=g_com_map[GROUP_ID];
+    group_id=g_com_map[GROUP_ID];
 	slottime=ceil((double)g_com_map[MAX_REPORT_ANC_NUM]*SLOT_SCALE)+3;
 	max_slotpos=g_com_map[COM_INTERVAL]/slottime;
 	tyncpoll_time=(g_com_map[DEV_ID]%max_slotpos)*slottime;	
 	module_power = g_com_map[POWER];
 	total_slotnum = 1000/g_com_map[COM_INTERVAL];
-			vel_factor=g_com_map[FILTER_COEFFICIENT];
-		pos_factor=g_com_map[FILTER_COEFFICIENT];
-
-		if(module_power>67)
-		{
-			module_power=67;
-		}
+    vel_factor=g_com_map[FILTER_COEFFICIENT];
+	pos_factor=g_com_map[FILTER_COEFFICIENT];
+    if(module_power>67)
+    {
+        module_power=67;
+    }
 	
 	if(g_com_map[DEV_ROLE])
 	{
-		needanchorrx = 0;
 	printf("标签ID: %d .\r\n",dev_id);
 	printf("通讯间隔: %d ms.\r\n",g_com_map[COM_INTERVAL]);
 	printf("单次通讯基站数量: %d个.\r\n",g_com_map[MAX_REPORT_ANC_NUM]);
 	}else{
-	needanchorrx = 1;
+	
 	anchor_type = dev_id%g_com_map[MAX_REPORT_ANC_NUM];
 	printf("基站ID: %x .\r\n",dev_id);
 	printf("基站类型: %c .\r\n",anchor_type+0x41);
@@ -228,7 +224,7 @@
 {
 		
 			UART_CheckReceive();
-	//	UART_CheckSend();
+		UART_CheckSend();
 	
 	if(heartbeat_timer>1000)
 	{
@@ -307,12 +303,11 @@
 		{
 				SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader   
 		}
-		
-		g_com_map[RELAY1_STATE_INDEX] = READ_RELAY1;
+        g_com_map[RELAY1_STATE_INDEX] = READ_RELAY1;
 		g_com_map[RELAY2_STATE_INDEX] = READ_RELAY2;
 
 	}
-
+    
 int main(void)
 {
  
@@ -320,7 +315,7 @@
 	//StartUpTest();
 	Program_Init();
 	Dw1000_Init();
-  delay_ms(10);	
+    delay_ms(10);	
 	Dw1000_App_Init();
     /* Loop forever initiating ranging exchanges. */
 	RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
@@ -328,23 +323,19 @@
 	usart_send[1]=0xAA;
 	usart_send_anc[0]=0x55;
 	usart_send_anc[1]=0xAA;
-	dwt_setrxtimeout(0);//设定接收超时时间,0位没有超时时间
-	dwt_rxenable(0);//打开接收
+
 	while(1)
 	{
-//	g_start_sync_flag=0;
+	g_start_sync_flag=0;
 	if(g_start_send_flag)
 	{
 		g_start_send_flag = 0;		
 		Tag_App();
-		//needanchorrx = 1;
 	}
 		IdleTask();		
-//if(g_com_map[DEV_ROLE]==0)
-//    {needanchorrx = 0;
-//			Anchor_App();
-//       // Anchor_Start();
-//    }
+if(g_com_map[DEV_ROLE]==0)
+		Anchor_App();
+
 	}
 }
 

--
Gitblit v1.9.3