| | |
| | | #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 200 |
| | | #define BEEM_ON_TIME_MS 200 |
| | | |
| | | float dis_after_filter = 0; |
| | | #define WORK_MODE_TAG |
| | | //#define WORK_MODE_ANCHOR |
| | | |
| | | void Device_Init(void) |
| | | { |
| | |
| | | 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); |
| | | } |
| | | |
| | | uint8_t aa; |
| | | |
| | | void Program_Init(void) |
| | | {uint16_t i; |
| | | Usart1ParseDataCallback = UsartParseDataHandler; |
| | | parameter_init(); |
| | | for(i=0;i<255;i++) |
| | | { |
| | | g_Tagdist[i]=0xffff; |
| | | } |
| | | } |
| | | |
| | | /*! ------------------------------------------------------------------------------------------------------------------ |
| | | * @fn main() |
| | | * |
| | |
| | | * |
| | | * @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 |
| | | 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 |
| | | if(USART_GetFlagStatus(EXT_USART, USART_FLAG_RXNE) != RESET) |
| | | { |
| | | aa = USART_ReceiveData(EXT_USART); |
| | | USART_SendData(EXT_USART, 0x66);//å串å£1åéæ°æ® |
| | | |
| | | while(USART_GetFlagStatus(EXT_USART, USART_FLAG_TC)!=SET);//çå¾
åéç»æ |
| | | |
| | | aa = 0; |
| | | } |
| | | |
| | | //é¤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; |
| | | // if(g_beep_off_time <= 0) |
| | | // g_beep_off_time = 0; |
| | | // g_beep_on_time = BEEM_ON_TIME_MS; |
| | | OUT2_ON; |
| | | |
| | | } |
| | | else |
| | | { |
| | | // g_beep_on_time = 0; |
| | | // g_beep_off_time = 0; |
| | | OUT2_OFF; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |