| | |
| | | #define NSH1 0x0001 |
| | | #define GP 0x0002 |
| | | #define FLASH_HARDWARE_VERSION_MAP (uint32_t)0x08004F00 //硬件版本号和批次信息位置 |
| | | //#define DEBUG_MODE |
| | | #define DEBUG_MODE |
| | | /* USER CODE END Includes */ |
| | | |
| | | /* Private typedef -----------------------------------------------------------*/ |
| | |
| | | __HAL_LPTIM_COMPARE_SET(&hlptim1, lpcount); |
| | | |
| | | } |
| | | |
| | | u8 active_flag,nomovesleeptime; |
| | | void Program_Init(void) |
| | | { float temp; |
| | |
| | | hardware_type = STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+4); |
| | | //deca_sleep(1000); |
| | | g_com_map[VERSION] = (1<<8)|0; |
| | | testprogram(); |
| | | // g_com_map[DEV_ID]=0x6777; |
| | | #ifdef DEBUG_MODE |
| | | // g_com_map[GROUP_ID]=21; |
| | |
| | | { |
| | | Error_Handler(); |
| | | } |
| | | HAL_Delay(2000); |
| | | HAL_Delay(1500); |
| | | |
| | | Lora_Init(); |
| | | |
| | |
| | | memcpy(&TX_Buffer+3,&tx_num,1); |
| | | // printf("Lora发送%d",tx_num); |
| | | HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_SET); |
| | | poll_startcount=HAL_LPTIM_ReadCounter(&hlptim1); |
| | | poll_startcount=poll_startcount+557;//557代表17ms |
| | | if(poll_startcount>=32768) |
| | | { |
| | | poll_startcount -=32768; |
| | | } |
| | | // poll_startcount=HAL_LPTIM_ReadCounter(&hlptim1); |
| | | // poll_startcount=poll_startcount+557;//557代表17ms |
| | | // if(poll_startcount>=32768) |
| | | // { |
| | | // poll_startcount -=32768; |
| | | // } |
| | | Radio.Send( &TX_Buffer, 4); |
| | | |
| | | tx_num++; |
| | | delay_ms(3); |
| | | |
| | | |
| | | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET); |
| | | UWB_Wkup(); |
| | | delay_us(700); |
| | | if(bat_percent>15) |
| | | { |
| | | LED_TB_ON; |
| | |
| | | freqlost_count+=1/(float)tag_frequency; |
| | | range_lost_time +=1/(float)tag_frequency; |
| | | // g_start_send_flag=1; |
| | | if(freqlost_count>FREQ_LOST_TIME) |
| | | if(0)//freqlost_count>FREQ_LOST_TIME) |
| | | { |
| | | tag_frequency = NOTAG_FREQ; |
| | | if(lost_jumpcount++>=10) //无测距情况下,每5秒发一次; |