| | |
| | | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET); |
| | | while(GetFlagLoraWaitSync()) |
| | | { |
| | | // current_count=HAL_LPTIM_ReadCounter(&hlptim1); |
| | | // if(current_count>=end_count&¤t_count<end_count+15000) |
| | | // { |
| | | // break; |
| | | // } |
| | | |
| | | } |
| | | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); |
| | | if(flag_sync_success) //同步成功 |
| | | { uint16_t wangguanid,checksum1; |
| | | printf("同步成功\r\n"); |
| | | // printf("同步成功\r\n"); |
| | | lora_recbuffer_len = GetLoraBufferAndLen(lora_recbuffer,&rec_sync_count);//获取LORA收到的数据和长度 |
| | | checksum1=Checksum_u16(lora_recbuffer,lora_recbuffer_len-2); |
| | | if(!memcmp(&checksum1,&lora_recbuffer[lora_recbuffer_len-2],2)) //CRC16校验是否通过 |
| | |
| | | } |
| | | }else{ |
| | | // LED_LR_ON; |
| | | printf("同步失败\r\n"); |
| | | // printf("同步失败\r\n"); |
| | | if(sync_lost_count++>SYNCLOST_THRES) |
| | | { |
| | | sync_state = Sync_Lost; |
| | |
| | | } |
| | | void testprogram(void) |
| | | { |
| | | // taglist_total_num = 30; |
| | | // taglist_id[0] = 7; |
| | | // for(uint8_t i=0;i<30;i++) |
| | | // { |
| | | // taglist_keeptime[i] = 100; |
| | | // } |
| | | |
| | | } |
| | | void TagListUpdate(void) |
| | | { |
| | |
| | | while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR)))//不断查询芯片状态直到成功接收或者发生错误 |
| | | { |
| | | if(Anchor_Vcc_Flag) |
| | | { |
| | | |
| | | // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_SET); |
| | | adc_val1 = Get_ADC_Value(); |
| | | { |
| | | adc_val1 = Get_ADC_Value(); |
| | | AD_value[ti++] = adc_val1; |
| | | if(ti>=500) |
| | | ti = 400; |
| | | // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET); |
| | | if(adc_val1<adc_val_min) |
| | | { |
| | | adc_val_min= adc_val1; |
| | | } |
| | | if(adc_val1<adc_val_min) |
| | | { |
| | | adc_val_min= adc_val1; |
| | | } |
| | | } |
| | | current_count=HAL_LPTIM_ReadCounter(&hlptim1); |
| | | if(current_count>=end_count&¤t_count<end_count+15000) |
| | |
| | | if(taglist_current_index>=taglist_total_num||taglist_total_num<=25) //如果标签当前index大于总index,或者总基站数量小于等于25,则从0开始index。 |
| | | taglist_current_index = 0; |
| | | if(Anchor_Vcc_Flag) |
| | | { |
| | | HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET); |
| | | Anchor_Vcc_Flag=0; |
| | | MX_ADC_DeInit(); |
| | | bat_volt = 3*(float)verfint_cal/AD_value[21]-0.1; |
| | | bat_percent=bat_volt*100-200; |
| | | } |
| | | { |
| | | HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET); |
| | | Anchor_Vcc_Flag=0; |
| | | MX_ADC_DeInit(); |
| | | bat_volt = 3*(float)verfint_cal/AD_value[21]-0.1; |
| | | bat_percent=bat_volt*100-200; |
| | | } |
| | | #ifdef _USE_BAR_ |
| | | //if(taglist_total_num>0) |
| | | { |