|
#include "Rcc_Nvic_Systick.h"
|
#include "Usart.h"
|
#include "Spi.h"
|
#include "led.h"
|
#include "beep.h"
|
#include "dw_driver.h"
|
#include "dw_app.h"
|
#include "filters.h"
|
#include "stm32f10x_it.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;
|
|
void Device_Init(void)
|
{
|
// Rcc_Init();
|
SystemInit();
|
Nvic_Init();
|
Systick_Init();
|
Led_Init();
|
Beep_Init();
|
DW_GPIO_Init();
|
Usart_Init();
|
Spi_Init();
|
|
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
|
}
|
|
uint8_t aa;
|
/*! ------------------------------------------------------------------------------------------------------------------
|
* @fn main()
|
*
|
* @brief Application entry point.
|
*
|
* @param none
|
*
|
* @return none
|
*/
|
int main(void)
|
{
|
LPFilter_Frac* p_Dis_Filter;
|
|
Device_Init();
|
Dw1000_Init();
|
p_Dis_Filter = New_LP_Frac(0.9);
|
|
/* Loop forever initiating ranging exchanges. */
|
while(1)
|
{
|
#ifdef WORK_MODE_TAG
|
Tag_App();
|
#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;
|
}
|
|
}
|
}
|