From 1ebb084c4d5216f4e5e3e61a63c88f568caf779e Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期五, 28 九月 2018 11:27:10 +0800 Subject: [PATCH] 增加多标签测距功能,标签有bug,长时间会死机 --- 源码/核心板/Src/main.c | 48 +++++++++++++++++++++++++++++++++++------------- 1 files changed, 35 insertions(+), 13 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 366cc6f..4d5adbc 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" @@ -6,22 +6,40 @@ #include "beep.h" #include "dw_driver.h" #include "dw_app.h" +#include "stm32f10x_it.h" +#include "serial_at_cmd_app.h" +#include "global_param.h" //#define WORK_MODE_TAG #define WORK_MODE_ANCHOR void Device_Init(void) { - Rcc_Init(); +// Rcc_Init(); + SystemInit(); Nvic_Init(); Systick_Init(); +#ifdef WORK_MODE_TAG + RTC_Configuration(); +#endif Led_Init(); Beep_Init(); DW_GPIO_Init(); - Usart_Init(); + Uart1_Init(); Spi_Init(); + GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); +} + +void Program_Init(void) +{uint16_t i; + Usart1ParseDataCallback = UsartParseDataHandler; + parameter_init(); + for(i=0;i<255;i++) + { + g_Tagdist[i]=0xffff; + } } /*! ------------------------------------------------------------------------------------------------------------------ @@ -33,30 +51,34 @@ * * @return none */ + int main(void) { - + Device_Init(); + Program_Init(); Dw1000_Init(); +#ifdef WORK_MODE_TAG + tag_sleep_configuraion(); +#endif + Dw1000_App_Init(); /* Loop forever initiating ranging exchanges. */ while(1) { #ifdef WORK_MODE_TAG + if(g_start_send_flag) + { + g_start_send_flag = 0; Tag_App(); + } +// UART_CheckReceive(); + RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); + PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI); #else Anchor_App(); #endif - //除UWB之外的其他代码... - if(dist_cm<=100) - { - BEEP_ON; - } - else - { - BEEP_OFF; - } - + } } -- Gitblit v1.9.3