From a268b9fa1c215ae353de26fb137665232381debe Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期四, 20 九月 2018 21:16:18 +0800 Subject: [PATCH] 上海调试完成,可通讯,可设ID --- 源码/核心板/Src/main.c | 60 ++++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 34 insertions(+), 26 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 1b51d04..53a6841 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,28 +6,36 @@ #include "beep.h" #include "dw_driver.h" #include "dw_app.h" -#include "filters.h" #include "stm32f10x_it.h" +#include "serial_at_cmd_app.h" +#include "global_param.h" //#define WORK_MODE_TAG #define WORK_MODE_ANCHOR -#define START_ALARM_DIST_CM 500 -#define BEEM_ON_TIME_MS 200 - -float dis_after_filter = 0; 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) +{ + Usart1ParseDataCallback = UsartParseDataHandler; + parameter_init(); } /*! ------------------------------------------------------------------------------------------------------------------ @@ -39,36 +47,36 @@ * * @return none */ + int main(void) { - LPFilter_Frac* p_Dis_Filter; - - Device_Init(); - Dw1000_Init(); - p_Dis_Filter = New_LP_Frac(0.9); + Device_Init(); + Program_Init(); + Dw1000_Init(); + +#ifdef WORK_MODE_TAG + tag_sleep_configuraion(); +#endif + g_com_map[DEV_ID]=1; + 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之外的其他代码... - dis_after_filter = LP_Frac_Update(p_Dis_Filter, dist_cm); - - if(dis_after_filter <= START_ALARM_DIST_CM) - { - g_beep_off_time = (uint32_t)dis_after_filter * 10 - 1000; - g_beep_on_time = BEEM_ON_TIME_MS; - } - else - { - g_beep_on_time = 0; - g_beep_off_time = 0; - } - + } } -- Gitblit v1.9.3