From 4864dd7a1bf69e16045c18bc19220b3ce9f55c72 Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期三, 17 六月 2020 23:49:37 +0800 Subject: [PATCH] V1.18华星测试基站防撞版本 --- 源码/核心板/Src/main.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 42 insertions(+), 5 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 327263c..b48ded5 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,6 +46,7 @@ } u16 tyncpoll_time; u16 slottime,max_slotpos; +extern u8 module_power; void Program_Init(void) { float temp; u16 temp2; @@ -65,12 +66,16 @@ save_com_map_to_flash(); #endif OUT485_ENABLE; - g_com_map[VERSION] = 0x010e; + g_com_map[VERSION] = 0x0112; dev_id = g_com_map[DEV_ID]; slottime=ceil((double)g_com_map[MAX_REPORT_ANC_NUM]/4)+4; max_slotpos=g_com_map[COM_INTERVAL]/slottime; tyncpoll_time=(g_com_map[DEV_ID]%max_slotpos)*slottime; - + module_power = g_com_map[POWER]; + if(module_power>67) + { + module_power=67; + } if(g_com_map[DEV_ROLE]) { @@ -109,10 +114,14 @@ UART_PushFrame(hbsend,16); } extern u8 g_start_sync_flag,usart_send_flag,anc_report_num; -u16 heartbeat_timer,poll_timer,sync_timer; +u16 heartbeat_timer,poll_timer; +int16_t sync_timer; +extern u8 flag_newsecond, tagpos_rec[50], tagpos_send[50],ancidlist_num; +uint32_t tagpos_binary; +extern u16 ancidlist_rec[20],ancidlist_send[20]; void IdleTask(void) { - main_logic(); + UART_CheckReceive(); UART_CheckSend(); if(heartbeat_timer>1000) @@ -120,6 +129,19 @@ heartbeat_timer=0; if(g_com_map[HEARTBEAT]&&g_com_map[DEV_ROLE]==0) HeatBeat(); + } + if(flag_newsecond) + { + flag_newsecond=0; + tagpos_binary=0; + memcpy(ancidlist_send,ancidlist_rec,ancidlist_num*2); + ancidlist_num=0; + for(u8 i=0;i<max_slotpos;i++) + { + if(tagpos_rec[i]) + tagpos_binary|=1<<i; + tagpos_rec[i] = 0; + } } if(g_com_map[DEV_ROLE]==0&&usart_send_flag) @@ -149,6 +171,21 @@ // Delay_ms(100); SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader } + if(g_com_map[CNT_REBOOT]==1) + { + g_com_map[CNT_REBOOT]=0; + g_com_map[MAP_SIGN_INDEX]=0; + save_com_map_to_flash(); + delay_ms(100); + SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader + } + if(g_com_map[CNT_RESTART]==1) + { + g_com_map[CNT_RESTART]=0; + save_com_map_to_flash(); + delay_ms(100); + SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader + } } int main(void) @@ -165,7 +202,7 @@ usart_send[1]=0xAA; usart_send_anc[0]=0x55; usart_send_anc[1]=0xAA; - + while(1) { g_start_sync_flag=0; -- Gitblit v1.9.3