From bbb68fd93739963f866d0c95246191962b6a7f72 Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期二, 29 十月 2019 09:49:50 +0800
Subject: [PATCH] 增加基站时间同步,等待systick换成基础定时器

---
 源码/核心板/Src/main.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 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 e07463e..3ed18c7 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"
@@ -16,6 +16,7 @@
 {
 	RCC_Configuration();
 	//SystemInit();
+	NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x5000);
 	Nvic_Init();
 	Systick_Init();
 	Led_Init();
@@ -82,9 +83,11 @@
 { 
 UART_PushFrame(hbsend,16);
 }
-u16 heartbeat_timer,poll_timer;
+extern u8 g_start_sync_flag;
+u16 heartbeat_timer,poll_timer,sync_timer;
 void IdleTask(void)
 {
+	g_start_sync_flag=0;
 			UART_CheckReceive();
 		UART_CheckSend();
 	if(heartbeat_timer>1000)
@@ -100,7 +103,7 @@
 		{
 			if(g_com_map[DEV_ROLE]==0)
 			{int8_t correction_time;
-				correction_time=tag_timer-(GROUP_TAG_NUM+1)*3;
+				correction_time=tag_timer-g_com_map[DEV_ID]*3;
 				tag_delaytime=correction_time;
 							if(tag_delaytime>g_com_map[COM_INTERVAL]/2)
 							{
@@ -110,6 +113,20 @@
 		g_start_send_flag=1;
 		}
 		
+	}
+	if(g_com_map[CNT_UPDATE]==1)
+	{
+	uint32_t result = 0;
+		u16 tmp = 0xAAAA;
+	__disable_irq();
+	result = FLASH_Prepare(0x8004A38, 2);
+	if(result)
+		result = FLASH_Write(0x8004A38, (const uint8_t*)&tmp, 2); 
+	__enable_irq();
+		printf("进入升级模式\r\n");
+		//	STMFLASH_Write_NoCheck(0x8004A38,0xAAAA);
+		//	Delay_ms(100);
+			SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader   
 	}
 
 	}
@@ -130,8 +147,7 @@
 		IdleTask();		
 	if(g_start_send_flag)
 	{
-		g_start_send_flag = 0;
-		
+		g_start_send_flag = 0;		
 		Tag_App();
 	}
 	

--
Gitblit v1.9.3