| | |
| | | Radio.Send(lora_sendbuffer,data_length+11); |
| | | // Delay_Ms(100); |
| | | } |
| | | extern u8 lora_jianting_flag; |
| | | static uint16_t delaytime = 1050; |
| | | static uint16_t source_id; |
| | | uint8_t rec_index; |
| | | uint16_t rec_value,rec_delaytime,rx_count; |
| | | int16_t target_count; |
| | | int32_t target_count; |
| | | extern uint16_t motor_keeptime; |
| | | void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) |
| | | { |
| | | BufferSize = size; |
| | |
| | | wg_report_freq = RX_Buffer[POLL_FREQ_IDX]+400; |
| | | memcpy(&rec_delaytime,&RX_Buffer[NEXTPOLL_TIME_IDX],2); |
| | | target_count = current_count + rec_delaytime*3.2768 - delaytime; |
| | | if(target_count>=32768) |
| | | while(target_count>=32768) |
| | | target_count-=32768; |
| | | __HAL_LPTIM_COMPARE_SET(&hlptim1, target_count); |
| | | rx_count = HAL_LPTIM_ReadCounter(&hlptim1); |
| | |
| | | break; |
| | | case WGRSP_RWTAG_WRITE: |
| | | rec_index = RX_Buffer[PWTAG_WRITE_IDX_IDX]; |
| | | if(rec_index==0xDD) |
| | | { |
| | | // if(usart5_state==1) |
| | | // { |
| | | // Usart5Init(); |
| | | // usart5_state=0; |
| | | // } |
| | | // HAL_GPIO_WritePin(GPIOC, GPIO_PIN_7, GPIO_PIN_SET); |
| | | // HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_SET); |
| | | // memcpy(&xiafayuyin_data,&RX_Buffer[9],RX_Buffer[8]); |
| | | // yuyin_sendflag=1; |
| | | // yuyinzidongguan_time=0; |
| | | // yuyin_no_sleep_flag=1; |
| | | }else{ |
| | | switch(rec_index) |
| | | { |
| | | case 0xdd: //语音下发 |
| | | break; |
| | | case 0x20: //蜂鸣 |
| | | memcpy(&rec_value,&RX_Buffer[PWTAG_WRITE_VALUE_IDX],2); |
| | | motor_keeptime = rec_value; |
| | | break; |
| | | default : |
| | | memcpy(&rec_value,&RX_Buffer[PWTAG_WRITE_VALUE_IDX],2); |
| | | g_com_map[rec_index/2] = rec_value; |
| | | save_com_map_to_flash(); |
| | | LoraRspWriteCommap(SUBMSG_WRITE_ANCPARA); |
| | | flag_writepara_needreset = 1; |
| | | no_rx_flag = 1; |
| | | } |
| | | no_rx_flag = 1; |
| | | } |
| | | |
| | | break; |
| | | } |
| | | } |
| | |
| | | } |
| | | if(!no_rx_flag) |
| | | { |
| | | SwitchLoraSettings(UWB_CHANNEL_FRQ+g_com_map[GROUP_ID],UWB_CHANNEL_SF,0); |
| | | Radio.Rx(0); |
| | | if(lora_jianting_flag) |
| | | { |
| | | SwitchLoraSettings(UWB_CHANNEL_FRQ+g_com_map[GROUP_ID],UWB_CHANNEL_SF,0); |
| | | Radio.Rx(0); |
| | | } |
| | | } |
| | | } |
| | | |
| | | void OnTxTimeout( void ) |
| | | { |
| | | Radio.Standby(); |
| | | if(lora_jianting_flag) |
| | | SwitchLoraSettings(UWB_CHANNEL_FRQ+g_com_map[GROUP_ID],UWB_CHANNEL_SF,0); |
| | | } |
| | | uint8_t tm; |
| | |
| | | Radio.Standby(); |
| | | current_count = HAL_LPTIM_ReadCounter(&hlptim1); |
| | | target_count-=current_count%3276; |
| | | if(target_count<0) |
| | | while(target_count<0) |
| | | target_count+=32768; |
| | | __HAL_LPTIM_COMPARE_SET(&hlptim1, target_count); |
| | | SwitchLoraSettings(UWB_CHANNEL_FRQ+g_com_map[GROUP_ID],UWB_CHANNEL_SF,0); |
| | | Radio.Rx(0); |
| | | if(lora_jianting_flag) |
| | | { |
| | | SwitchLoraSettings(UWB_CHANNEL_FRQ+g_com_map[GROUP_ID],UWB_CHANNEL_SF,0); |
| | | Radio.Rx(0); |
| | | } |
| | | } |
| | | |
| | | void OnRxError( void ) |
| | | { |
| | | |
| | | Radio.Standby(); |
| | | if(lora_jianting_flag) |
| | | SwitchLoraSettings(UWB_CHANNEL_FRQ+g_com_map[GROUP_ID],UWB_CHANNEL_SF,0); |
| | | } |
| | | |