| | |
| | | //SystemInit(); |
| | | NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x5000); |
| | | Nvic_Init(); |
| | | Systick_Init(); |
| | | // Systick_Init(); |
| | | TIM3_Int_Init(); |
| | | Led_Init(); |
| | | Beep_Init(); |
| | | DW_GPIO_Init(); |
| | |
| | | checksum = Checksum_u16(&hbsend[2],12); |
| | | memcpy(&hbsend[14],&checksum,2); |
| | | } |
| | | u16 tyncpoll_time; |
| | | void Program_Init(void) |
| | | {uint16_t i; |
| | | Usart1ParseDataCallback = UsartParseDataHandler; |
| | |
| | | //deca_sleep(1000); |
| | | HeartBeatInit(); |
| | | dev_id = g_com_map[DEV_ID]; |
| | | // g_com_map[DEV_ROLE]=1; |
| | | // g_com_map[DEV_ID]=1; |
| | | // g_com_map[COM_INTERVAL]=10; |
| | | if(g_com_map[DEV_ROLE]) |
| | | { |
| | | tyncpoll_time=g_com_map[DEV_ID]*g_com_map[MAX_REPORT_ANC_NUM]*4/3; |
| | | 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{ |
| | | |
| | | 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); |
| | |
| | | if(g_com_map[HEARTBEAT]&&g_com_map[DEV_ROLE]==0) |
| | | HeatBeat(); |
| | | } |
| | | if(poll_timer>=g_com_map[COM_INTERVAL]-tag_delaytime) |
| | | { |
| | | poll_timer=0; |
| | | if(g_com_map[ANC_POLL]||g_com_map[DEV_ROLE]) |
| | | { |
| | | if(g_com_map[DEV_ROLE]==0) |
| | | {int8_t correction_time; |
| | | correction_time=tag_timer-g_com_map[DEV_ID]*3; |
| | | tag_delaytime=correction_time; |
| | | if(tag_delaytime>g_com_map[COM_INTERVAL]/2) |
| | | { |
| | | tag_delaytime=tag_delaytime-g_com_map[COM_INTERVAL]; |
| | | } |
| | | } |
| | | g_start_send_flag=1; |
| | | } |
| | | |
| | | } |
| | | if(g_com_map[CNT_UPDATE]==1) |
| | | { |
| | | uint32_t result = 0; |
| | |
| | | |
| | | Device_Init(); |
| | | Program_Init(); |
| | | Dw1000_Init(); |
| | | //Dw1000_Init(); |
| | | delay_ms(10); |
| | | Dw1000_App_Init(); |
| | | /* Loop forever initiating ranging exchanges. */ |
| | | RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); |
| | | usart_send[0]=0x55; |
| | | usart_send[1]=0xAA; |
| | | UART_PushFrame(hbsend,16); |
| | | while(1) |
| | | { |
| | | IdleTask(); |